Compare commits
No commits in common. "1d6831a76e961d458b1013ada5f224fb5f70d389" and "28bcacc096cfecdc7fa8e4250e4f80146d4aa976" have entirely different histories.
1d6831a76e
...
28bcacc096
@ -6,5 +6,4 @@ export const apiArr = {
|
|||||||
getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
||||||
addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
|
addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
|
||||||
deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
|
deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
|
||||||
updateCar:"/api/v2/wechat/commodity/cart/update",
|
|
||||||
}
|
}
|
||||||
@ -27,7 +27,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 规格 -->
|
<!-- 规格 -->
|
||||||
<!-- @click="changeGG2(item, index)" :class="index == currentGGIndex ? 'active' : ''"> -->
|
|
||||||
<div class="GGBox">
|
<div class="GGBox">
|
||||||
<div class="GG_left">
|
<div class="GG_left">
|
||||||
<div class="GG_Item" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
<div class="GG_Item" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||||
@ -64,8 +63,6 @@
|
|||||||
<image v-for="item in currentGG.goods_detail_pic" :src="picUrl + item" mode="widthFix"></image>
|
<image v-for="item in currentGG.goods_detail_pic" :src="picUrl + item" mode="widthFix"></image>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 底部购物车 -->
|
<!-- 底部购物车 -->
|
||||||
<div class="Car">
|
<div class="Car">
|
||||||
<div class="car_left">
|
<div class="car_left">
|
||||||
@ -83,21 +80,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="car_right"
|
<div class="car_right" v-if="!info[currentGGIndex].cart_count || info[currentGGIndex].cart_count.count == 0"
|
||||||
v-if="!info.commodity_goods_info_list[currentGGIndex].cart_count || info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0"
|
|
||||||
@click="addCar">
|
@click="addCar">
|
||||||
加入购物车
|
加入购物车
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="car_right" v-if="info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0">
|
<div class="car_right" v-if="info[currentGGIndex].cart_count.count > 0">
|
||||||
|
<u-number-box v-model="info[currentGGIndex].cart_count.count" @change="changeCar">
|
||||||
<u-number-box v-model="info.commodity_goods_info_list[currentGGIndex].cart_count.count"
|
|
||||||
@change="changeCar" min="0">
|
|
||||||
<view slot="minus" class="minus">
|
<view slot="minus" class="minus">
|
||||||
<u-icon name="minus" size="36" bold></u-icon>
|
<u-icon name="minus" size="36" bold></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<text slot="input" style="width: 200rpx;text-align: center;" class="input">
|
<text slot="input" style="width: 200rpx;text-align: center;" class="input">{{
|
||||||
{{ info.commodity_goods_info_list[currentGGIndex].cart_count.count }}</text>
|
info[currentGGIndex].cart_count.count }}</text>
|
||||||
<view slot="plus" class="plus">
|
<view slot="plus" class="plus">
|
||||||
<u-icon name="plus" color="#FFFFFF" size="36" bold></u-icon>
|
<u-icon name="plus" color="#FFFFFF" size="36" bold></u-icon>
|
||||||
</view>
|
</view>
|
||||||
@ -149,6 +143,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { info } from 'sass';
|
||||||
import {
|
import {
|
||||||
apiArr
|
apiArr
|
||||||
} from '../../../api/shop';
|
} from '../../../api/shop';
|
||||||
@ -176,8 +171,6 @@ export default {
|
|||||||
|
|
||||||
currentGG: "", //当前选中规格
|
currentGG: "", //当前选中规格
|
||||||
currentGGIndex: "", //当前规格index
|
currentGGIndex: "", //当前规格index
|
||||||
|
|
||||||
carOrderList: [],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -273,7 +266,6 @@ export default {
|
|||||||
item.commodity_pic = item.commodity_pic.split(',')
|
item.commodity_pic = item.commodity_pic.split(',')
|
||||||
});
|
});
|
||||||
this.currentGG = res.commodity_goods_info_list[0]
|
this.currentGG = res.commodity_goods_info_list[0]
|
||||||
this.currentGGIndex = 0
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -290,22 +282,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// changeGG2(item, index) {
|
|
||||||
|
|
||||||
// request(apiArr.addCar,"POST",{
|
|
||||||
// goods_id:item.id,
|
|
||||||
// count:1
|
|
||||||
// })
|
|
||||||
// },
|
|
||||||
|
|
||||||
changeGG(item, index) {
|
changeGG(item, index) {
|
||||||
this.currentGG = item
|
this.currentGG = item
|
||||||
this.currentGGIndex = index
|
this.currentGGIndex = index
|
||||||
if (this.currentGG.cart_count) {
|
this.currentGG.cart_count = { count: 0 }
|
||||||
this.currentNum = this.currentGG.cart_count.count
|
|
||||||
} else {
|
|
||||||
this.currentGG.cart_count = { count: 0 }
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
car() {
|
car() {
|
||||||
NavgateTo('../shopCar/index')
|
NavgateTo('../shopCar/index')
|
||||||
@ -319,37 +299,14 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
//离开页面的时候 判断添加了多少 删除了多少商品
|
|
||||||
getShopCarList() {
|
|
||||||
request(apiArr.getCar, 'POST', {}).then(res => {
|
|
||||||
this.carOrderList = res.commodity_cart_list
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
addCar() {
|
addCar() {
|
||||||
console.log(this.info);
|
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = 1
|
||||||
|
|
||||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {count:1}
|
|
||||||
|
|
||||||
let carNum = 0
|
|
||||||
this.info.commodity_goods_info_list.forEach(item => {
|
|
||||||
carNum += item.cart_count.count
|
|
||||||
})
|
|
||||||
this.carNum = carNum
|
|
||||||
},
|
},
|
||||||
|
|
||||||
changeCar(newValue) {
|
changeCar(newValue) {
|
||||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = newValue.value
|
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = newValue.value
|
||||||
let carNum = 0
|
|
||||||
this.info.commodity_goods_info_list.forEach(item => {
|
|
||||||
if (item.cart_count) {
|
|
||||||
carNum += item.cart_count.count
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.carNum = carNum
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
@ -359,27 +316,30 @@ export default {
|
|||||||
this.id = options.id
|
this.id = options.id
|
||||||
this.getGoodsInfo()
|
this.getGoodsInfo()
|
||||||
this.getShopCar()
|
this.getShopCar()
|
||||||
this.getShopCarList()
|
|
||||||
},
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
|
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
|
|
||||||
let goods_id_and_count = []
|
|
||||||
this.info.commodity_goods_info_list.forEach(item => {
|
|
||||||
goods_id_and_count.push({
|
|
||||||
goods_id: item.id,
|
|
||||||
count: item.cart_count.count
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
request(apiArr.updateCar, "POST", {
|
|
||||||
goods_id_and_count
|
|
||||||
})
|
|
||||||
return
|
|
||||||
},
|
},
|
||||||
|
// watch() {
|
||||||
|
// return {
|
||||||
|
// 'info.commodity_goods_info_list': {
|
||||||
|
// handler(newList) {
|
||||||
|
// // 计算购物车总数
|
||||||
|
// this.carNum = newList.reduce((total, item) => {
|
||||||
|
// if (item.cart_count && item.cart_count.count) {
|
||||||
|
// return total + item.cart_count.count;
|
||||||
|
// }
|
||||||
|
// return total;
|
||||||
|
// }, 0);
|
||||||
|
// },
|
||||||
|
// deep: true,
|
||||||
|
// immediate: true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -538,7 +538,7 @@ page {
|
|||||||
height: 140rpx;
|
height: 140rpx;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 33rpx;
|
right: 33rpx;
|
||||||
bottom: 180rpx;
|
bottom: 380rpx;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.shop_car image{
|
.shop_car image{
|
||||||
|
|||||||
@ -191,7 +191,7 @@
|
|||||||
<nav-footer :current="2" />
|
<nav-footer :current="2" />
|
||||||
|
|
||||||
<div class="shop_car" @click="shopCar">
|
<div class="shop_car" @click="shopCar">
|
||||||
<u-badge numberType="limit" type="error" max="99" :value="carNum"></u-badge>
|
<u-badge numberType="limit" type="error" max="99" :value="value"></u-badge>
|
||||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_num.png"></image>
|
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_num.png"></image>
|
||||||
<!-- <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_empty.png"></image> -->
|
<!-- <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_empty.png"></image> -->
|
||||||
</div>
|
</div>
|
||||||
@ -277,8 +277,7 @@ export default {
|
|||||||
rightCateList:[], //底部右侧分类
|
rightCateList:[], //底部右侧分类
|
||||||
currentThirdId:"",
|
currentThirdId:"",
|
||||||
|
|
||||||
tagList:[],
|
tagList:[]
|
||||||
carNum:"",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -337,13 +336,6 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getShopCarList(){
|
|
||||||
request(apiArr.getCar,"POST",).then(res=>{
|
|
||||||
console.log(res);
|
|
||||||
this.carNum = res.total
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
changeLeftCate(e){
|
changeLeftCate(e){
|
||||||
this.secondId = e
|
this.secondId = e
|
||||||
this.getGoodsList()
|
this.getGoodsList()
|
||||||
@ -355,7 +347,6 @@ export default {
|
|||||||
this.top = meun.top;
|
this.top = meun.top;
|
||||||
this.localHeight = meun.height;
|
this.localHeight = meun.height;
|
||||||
this.getCateList()
|
this.getCateList()
|
||||||
this.getShopCarList()
|
|
||||||
},
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
if (this.flag) {
|
if (this.flag) {
|
||||||
|
|||||||
@ -13,28 +13,28 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="deleteIcon" @click="deleteItem">
|
<div class="deleteIcon">
|
||||||
<u-icon name="trash" size="50rpx"></u-icon>
|
<u-icon name="trash" size="50rpx"></u-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="goodsList">
|
<div class="goodsList">
|
||||||
<div class="goodsItem" v-for="item, index in shopCarList" :key="item.id">
|
<div class="goodsItem" v-for="item, index in shopCarList" :key="item.id">
|
||||||
<div class="goodsItem_left" @click="changeChecked(item, index)">
|
<div class="goodsItem_left" @click="changeChecked(item,index)">
|
||||||
<image v-if="!item.checked" src="http://192.168.0.172:5500/7.15/shop_checked1.png"></image>
|
<image v-if="!item.checked" src="http://192.168.0.172:5500/7.15/shop_checked1.png"></image>
|
||||||
<image v-if="item.checked" src="http://192.168.0.172:5500/7.15/shop_checked2.png"></image>
|
<image v-if="item.checked" src="http://192.168.0.172:5500/7.15/shop_checked2.png"></image>
|
||||||
</div>
|
</div>
|
||||||
<div class="goodsItem_right">
|
<div class="goodsItem_right">
|
||||||
<div class="goodsItem_msg">
|
<div class="goodsItem_msg">
|
||||||
<div class="goodsItem_msg_img">
|
<div class="goodsItem_msg_img">
|
||||||
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
|
<image :src="picUrl + item.commodity_pic">
|
||||||
</image>
|
</image>
|
||||||
</div>
|
</div>
|
||||||
<div class="goodsItem_msg_right">
|
<div class="goodsItem_msg_right">
|
||||||
<div class="goodsItem_msg_right_tit">{{ item.commodity_goods_info.goods_name }}</div>
|
<div class="goodsItem_msg_right_tit">{{ item.goods_name }}</div>
|
||||||
<div class="goodsItem_msg_right_subTit">{{ item.commodity_goods_info.goods_intro }}</div>
|
<div class="goodsItem_msg_right_subTit">{{ item.goods_intro }}</div>
|
||||||
<div class="goodsItem_msg_right_msg">
|
<div class="goodsItem_msg_right_msg">
|
||||||
<div class="goodsItem_msg_right_msg_left">
|
<div class="goodsItem_msg_right_msg_left">
|
||||||
<span>¥</span>{{ item.commodity_goods_info.sales_price }} <span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
<span>¥</span>{{ item.sales_price }} <span>/{{ item.goods_unit }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="goodsItem_msg_right_msg_right">
|
<div class="goodsItem_msg_right_msg_right">
|
||||||
<u-number-box v-model="item.count">
|
<u-number-box v-model="item.count">
|
||||||
@ -114,9 +114,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
back() {
|
|
||||||
NavgateTo("1")
|
|
||||||
},
|
|
||||||
submitOrder() {
|
submitOrder() {
|
||||||
NavgateTo("../submitOrder/index")
|
NavgateTo("../submitOrder/index")
|
||||||
},
|
},
|
||||||
@ -132,7 +129,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 单个修改
|
// 单个修改
|
||||||
changeChecked(item, index) {
|
changeChecked(item, index) {
|
||||||
this.shopCarList[index].checked = !this.shopCarList[index].checked
|
this.shopCarList[index].checked = !this.shopCarList[index].checked
|
||||||
this.calcTotal()
|
this.calcTotal()
|
||||||
@ -159,40 +156,11 @@ export default {
|
|||||||
let total = 0
|
let total = 0
|
||||||
this.shopCarList.forEach(item => {
|
this.shopCarList.forEach(item => {
|
||||||
if (item.checked) {
|
if (item.checked) {
|
||||||
total += item.commodity_goods_info.sales_price * item.count
|
total += item.sales_price * item.count
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.shopMoney = total
|
this.shopMoney = total
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteItem() {
|
|
||||||
let that = this
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '确定删除所选商品吗',
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
let ids = []
|
|
||||||
that.shopCarList.forEach(item => {
|
|
||||||
if(item.checked){
|
|
||||||
ids.push(item.id)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
request(apiArr.deleteCar, "POST", {
|
|
||||||
ids
|
|
||||||
}).then(res=>{
|
|
||||||
uni.showToast({
|
|
||||||
title: '删除成功',
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
that.getShopCar()
|
|
||||||
})
|
|
||||||
} else if (res.cancel) {
|
|
||||||
console.log('用户点击取消');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user