Compare commits
4 Commits
fdd5bbfb3b
...
15d42c2df1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15d42c2df1 | ||
|
|
f8c37680a4 | ||
|
|
dfbfb0440e | ||
| 53d506c084 |
@ -6,5 +6,6 @@ export const apiArr = {
|
||||
getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
||||
addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
|
||||
deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
|
||||
updateCar:"/api/v2/wechat/commodity/cart/update",//更新购物车
|
||||
updateCar:"/api/v2/wechat/commodity/cart/update",//更新购物车信息
|
||||
getUserDefAddress:"/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
|
||||
}
|
||||
@ -327,25 +327,67 @@ export default {
|
||||
},
|
||||
|
||||
addCar() {
|
||||
console.log(this.info);
|
||||
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {count:1}
|
||||
|
||||
let carNum = 0
|
||||
|
||||
let that = this
|
||||
//如果没有当前商品 直接添加一个
|
||||
let goods_id_and_count = []
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { count: 1 }
|
||||
this.info.commodity_goods_info_list.forEach(item => {
|
||||
carNum += item.cart_count.count
|
||||
console.log(item);
|
||||
|
||||
goods_id_and_count.push({
|
||||
goods_id: item.id,
|
||||
count: item.cart_count.count
|
||||
})
|
||||
})
|
||||
this.carNum = carNum
|
||||
|
||||
request(apiArr.updateCar, "POST", {
|
||||
goods_id_and_count
|
||||
}).then(res => {
|
||||
that.getShopCar()
|
||||
that.getShopCarList()
|
||||
})
|
||||
// let flag = false
|
||||
// this.carOrderList.forEach(item => {
|
||||
// if (item.goods_id == this.info.commodity_goods_info_list[this.currentGGIndex].id) {
|
||||
// flag = true
|
||||
// }
|
||||
// })
|
||||
// console.log(flag);
|
||||
|
||||
// if (flag) {
|
||||
|
||||
// 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
|
||||
// } else {
|
||||
|
||||
// }
|
||||
|
||||
},
|
||||
|
||||
changeCar(newValue) {
|
||||
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.carOrderList.forEach(item=>{
|
||||
if(item.commodity_goods_info.id == this.info.commodity_goods_info_list[this.currentGGIndex].id){
|
||||
console.log(item,'item');
|
||||
item.count = newValue.value
|
||||
}
|
||||
})
|
||||
let carNum = 0
|
||||
this.carOrderList.forEach(item=>{
|
||||
carNum += item.count
|
||||
})
|
||||
// let carNum = 0
|
||||
// this.info.commodity_goods_info_list.forEach(item => {
|
||||
// if (item.cart_count) {
|
||||
// carNum += item.cart_count.count
|
||||
// }
|
||||
// })
|
||||
this.carNum = carNum
|
||||
},
|
||||
|
||||
@ -357,12 +399,15 @@ export default {
|
||||
this.localHeight = meun.height;
|
||||
|
||||
this.id = options.id
|
||||
this.getGoodsInfo()
|
||||
this.getShopCar()
|
||||
this.getShopCarList()
|
||||
|
||||
},
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.getGoodsInfo()
|
||||
this.getShopCar()
|
||||
this.getShopCarList()
|
||||
},
|
||||
onHide() {
|
||||
|
||||
|
||||
@ -132,6 +132,10 @@ page {
|
||||
padding: 35rpx 0;
|
||||
}
|
||||
|
||||
.CateItem_active {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.CateItem .hot {
|
||||
width: 25.82rpx;
|
||||
height: 30rpx;
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
<div class="Con">
|
||||
<div class="Con_left">
|
||||
<div
|
||||
class="CateItem"
|
||||
class="CateItem" :class="item.id === currentLeftCateId ? 'CateItem_active' : ''"
|
||||
v-for="item in leftCateList"
|
||||
:key="item.id"
|
||||
@click="changeLeftCate(item.id)"
|
||||
@ -176,7 +176,7 @@
|
||||
<u-number-box
|
||||
:min="0"
|
||||
v-model="items.quantity"
|
||||
@change="handleQuantityChange(items)"
|
||||
@change="(value) => handleQuantityChange(value,items)"
|
||||
>
|
||||
<view slot="minus" class="minus">
|
||||
<u-icon name="minus" size="20"></u-icon>
|
||||
@ -244,7 +244,7 @@
|
||||
<u-number-box
|
||||
v-model="ite.quantity"
|
||||
:min="0"
|
||||
@change="handleQuantityChange(ite)"
|
||||
@change="(value) => handleQuantityChange(value,ite)"
|
||||
>
|
||||
<view slot="minus" class="minus">
|
||||
<u-icon name="minus" size="20"></u-icon>
|
||||
@ -356,6 +356,7 @@ export default {
|
||||
],
|
||||
|
||||
rightTopActive: 0,
|
||||
currentLeftCateId: null,
|
||||
topShow: false,
|
||||
|
||||
GGshow: false,
|
||||
@ -416,8 +417,14 @@ export default {
|
||||
console.log(res);
|
||||
this.CateList = res.commodity_category_list;
|
||||
this.firstId = res.commodity_category_list[0].id;
|
||||
this.leftCateList = res.commodity_category_list[0].level_two_category;
|
||||
this.secondId = res.commodity_category_list[0].level_two_category[0].id;
|
||||
this.leftCateList = res.commodity_category_list[0].level_two_category || [];
|
||||
if (this.leftCateList.length > 0) {
|
||||
this.currentLeftCateId = this.leftCateList[0].id;
|
||||
this.secondId = this.leftCateList[0].id;
|
||||
} else {
|
||||
this.currentLeftCateId = null;
|
||||
this.secondId = null;
|
||||
}
|
||||
this.getGoodsList();
|
||||
});
|
||||
},
|
||||
@ -448,13 +455,12 @@ export default {
|
||||
},
|
||||
|
||||
changeLeftCate(e) {
|
||||
this.currentLeftCateId = e;
|
||||
this.secondId = e;
|
||||
this.getGoodsList();
|
||||
},
|
||||
//商品数量变化
|
||||
handleQuantityChange(item) {
|
||||
console.log("🚀 ~ handleQuantityChange ~ value:", item);
|
||||
const goodsId = "";
|
||||
handleQuantityChange(val,item) {
|
||||
if (item.commodity_goods_info_list.length) {
|
||||
this.goodsId = item.commodity_goods_info_list[0].id;
|
||||
} else {
|
||||
@ -465,19 +471,16 @@ export default {
|
||||
goods_id_and_count: [
|
||||
{
|
||||
goods_id: this.goodsId,
|
||||
count: item.quantity ? item.quantity + 1 : 1,
|
||||
count: val.value,
|
||||
},
|
||||
],
|
||||
};
|
||||
console.log("🚀 ~ handleQuantityChange ~ params:", params);
|
||||
request(apiArr.updateCar, "POST", params).then((res) => {
|
||||
console.log(res);
|
||||
this.getShopCarList();
|
||||
uni.showToast({
|
||||
title: "操作成功!",
|
||||
success() {
|
||||
// setTimeout(() => {
|
||||
// that.getBanlance()
|
||||
// }, 1500)
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -488,6 +491,9 @@ export default {
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.getCateList();
|
||||
// this.getShopCarList();
|
||||
},
|
||||
onShow() {
|
||||
this.getShopCarList();
|
||||
},
|
||||
onReachBottom() {
|
||||
|
||||
@ -31,19 +31,21 @@
|
||||
</div>
|
||||
<div class="goodsItem_msg_right">
|
||||
<div class="goodsItem_msg_right_tit">{{ item.commodity_goods_info.goods_name }}</div>
|
||||
<div class="goodsItem_msg_right_subTit">{{ item.commodity_goods_info.goods_intro }}</div>
|
||||
<div class="goodsItem_msg_right_subTit">{{ item.commodity_goods_info.goods_intro }}
|
||||
</div>
|
||||
<div class="goodsItem_msg_right_msg">
|
||||
<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.commodity_goods_info.sales_price }} <span>/{{
|
||||
item.commodity_goods_info.goods_unit }}</span>
|
||||
</div>
|
||||
<div class="goodsItem_msg_right_msg_right">
|
||||
<u-number-box v-model="item.count">
|
||||
<view slot="minus" class="minus">
|
||||
<u-number-box v-model="item.count" :asyncChange="true" min="0">
|
||||
<view slot="minus" class="minus" @click="minus(item, index)">
|
||||
<u-icon name="minus" size="32" bold></u-icon>
|
||||
</view>
|
||||
<text slot="input" style="width: 80rpx;text-align: center;" class="input">{{
|
||||
item.count }}</text>
|
||||
<view slot="plus" class="plus">
|
||||
<view slot="plus" class="plus" @click="add(item, index)">
|
||||
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
|
||||
</view>
|
||||
</u-number-box>
|
||||
@ -118,7 +120,15 @@ export default {
|
||||
NavgateTo("1")
|
||||
},
|
||||
submitOrder() {
|
||||
NavgateTo("../submitOrder/index")
|
||||
|
||||
let arr = []
|
||||
this.shopCarList.forEach(item => {
|
||||
if (item.checked) {
|
||||
arr.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
NavgateTo(`../submitOrder/index?shopCarList=${JSON.stringify(arr)}`)
|
||||
},
|
||||
|
||||
getShopCar() {
|
||||
@ -126,7 +136,6 @@ export default {
|
||||
res.commodity_cart_list.forEach(item => {
|
||||
item.checked = false
|
||||
});
|
||||
console.log(res.commodity_cart_list);
|
||||
this.shopCarTotal = res.total
|
||||
this.shopCarList = res.commodity_cart_list
|
||||
})
|
||||
@ -156,8 +165,11 @@ export default {
|
||||
},
|
||||
// 计算金额
|
||||
calcTotal() {
|
||||
|
||||
let total = 0
|
||||
this.shopCarList.forEach(item => {
|
||||
console.log(item);
|
||||
|
||||
if (item.checked) {
|
||||
total += item.commodity_goods_info.sales_price * item.count
|
||||
}
|
||||
@ -165,6 +177,25 @@ export default {
|
||||
this.shopMoney = total
|
||||
},
|
||||
|
||||
minus(item, index) {
|
||||
let that = this
|
||||
if (item.count === 1) {
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids: [item.id]
|
||||
}).then(res => {
|
||||
that.shopCarList.splice(index, 1)
|
||||
that.calcTotal()
|
||||
})
|
||||
}
|
||||
this.shopCarList[index].count = this.shopCarList[index].count - 1
|
||||
this.calcTotal()
|
||||
},
|
||||
add(item, index) {
|
||||
this.shopCarList[index].count = this.shopCarList[index].count + 1
|
||||
this.calcTotal()
|
||||
},
|
||||
|
||||
|
||||
deleteItem() {
|
||||
let that = this
|
||||
uni.showModal({
|
||||
@ -174,18 +205,22 @@ export default {
|
||||
if (res.confirm) {
|
||||
let ids = []
|
||||
that.shopCarList.forEach(item => {
|
||||
if(item.checked){
|
||||
if (item.checked) {
|
||||
ids.push(item.id)
|
||||
item.checked = false
|
||||
}
|
||||
})
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids
|
||||
}).then(res=>{
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
duration: 2000
|
||||
});
|
||||
that.getShopCar()
|
||||
that.calcTotal()
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
|
||||
@ -176,4 +176,24 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.address_Info_btn {
|
||||
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
height: 90rpx;
|
||||
width: 600rpx;
|
||||
font-size: 36rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.noneDef{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
@ -4,42 +4,49 @@
|
||||
<div class="border">
|
||||
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
|
||||
</div>
|
||||
<div class="address_Info" @click="choseAddress">
|
||||
<div class="address_Info" @click="choseAddress" v-if="defAddress">
|
||||
<div class="address_Info_left">
|
||||
<div class="address_Info_left_tit">收货地址</div>
|
||||
<div class="address_Info_left_name">李佳 15901518415</div>
|
||||
<div class="address_Info_left_addr">北京北京市朝阳区珠江绿洲文化广场</div>
|
||||
</div>
|
||||
<div class="address_Info_right">
|
||||
<u-icon name="arrow-right" size="40rpx"></u-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="address_Info" @click="choseAddress" v-if="!defAddress">
|
||||
<div class="address_Info_left noneDef">
|
||||
<div class="address_Info_btn">添加收货地址</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="border">
|
||||
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="goodsCate" v-for="items, indexs in 2" :key="indexs">
|
||||
<div class="goodsItem" v-for="item, index in 3" :key="index">
|
||||
<div class="goodsCate" v-for="items, indexs in carList" :key="indexs">
|
||||
<div class="goodsItem">
|
||||
<div class="goodsItem_msg_img">
|
||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_MsgImg1.png">
|
||||
<image :src="picUrl + items.commodity_goods_info.commodity_pic">
|
||||
</image>
|
||||
</div>
|
||||
<div class="goodsItem_msg_right">
|
||||
<div class="goodsItem_msg_right_tit">泰国金枕榴莲</div>
|
||||
<div class="goodsItem_msg_right_subTit">商品介绍商品介绍</div>
|
||||
<div class="goodsItem_msg_right_tit">{{ items.commodity_goods_info.goods_name }}</div>
|
||||
<div class="goodsItem_msg_right_subTit">{{ items.commodity_goods_info.goods_intro }}</div>
|
||||
<div class="goodsItem_msg_right_msg">
|
||||
<div class="goodsItem_msg_right_msg_left">
|
||||
<span>¥</span>125.9 <span>/个</span>
|
||||
<span>¥</span>{{ items.commodity_goods_info.sales_price }}
|
||||
<span>/{{ items.commodity_goods_info.goods_unit }}</span>
|
||||
</div>
|
||||
<div class="goodsItem_msg_right_msg_right">
|
||||
<u-number-box v-model="value">
|
||||
<view slot="minus" class="minus">
|
||||
<view slot="minus" class="minus" @click="minus(items, indexs)">
|
||||
<u-icon name="minus" size="32" bold></u-icon>
|
||||
</view>
|
||||
<text slot="input" style="width: 80rpx;text-align: center;" class="input">{{
|
||||
value }}</text>
|
||||
<view slot="plus" class="plus">
|
||||
<text slot="input" style="width: 80rpx;text-align: center;" class="input">
|
||||
{{ items.count }}
|
||||
</text>
|
||||
<view slot="plus" class="plus" @click="add(items, indexs)">
|
||||
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
|
||||
</view>
|
||||
</u-number-box>
|
||||
@ -52,10 +59,10 @@
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="footer">
|
||||
<div class="btn">立即支付¥4500.00</div>
|
||||
<div class="btn">立即支付¥{{ totalMony }}</div>
|
||||
</div>
|
||||
|
||||
</view>
|
||||
@ -64,7 +71,7 @@
|
||||
<script>
|
||||
import {
|
||||
apiArr
|
||||
} from '../../../api/doorToDoor';
|
||||
} from '../../../api/shop';
|
||||
import {
|
||||
picUrl,
|
||||
menuButtonInfo,
|
||||
@ -74,22 +81,63 @@ import {
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
picUrl,
|
||||
top: "",
|
||||
localHeight: "",
|
||||
value: 3,
|
||||
type: "error",
|
||||
|
||||
carList: [],
|
||||
totalMony: 0,
|
||||
defAddress:{},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
choseAddress(){
|
||||
choseAddress() {
|
||||
NavgateTo('../address/index')
|
||||
},
|
||||
|
||||
calcTotal() {
|
||||
let total = 0
|
||||
this.carList.forEach(item => {
|
||||
total += item.commodity_goods_info.sales_price * item.count
|
||||
})
|
||||
this.totalMony = total
|
||||
},
|
||||
|
||||
minus(item, index) {
|
||||
let that = this
|
||||
if (item.count === 1) {
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids: [item.id]
|
||||
}).then(res => {
|
||||
that.carList.splice(index, 1)
|
||||
that.calcTotal()
|
||||
})
|
||||
}
|
||||
this.carList[index].count = this.carList[index].count - 1
|
||||
this.calcTotal()
|
||||
},
|
||||
add(item, index) {
|
||||
this.carList[index].count = this.carList[index].count + 1
|
||||
this.calcTotal()
|
||||
},
|
||||
//用户收货地址
|
||||
getUserAddress() {
|
||||
request(apiArr.getUserDefAddress, "POST", {}).then(res => {
|
||||
this.defAddress = res.default_address
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.getUserAddress()
|
||||
},
|
||||
onLoad(options) {
|
||||
const meun = menuButtonInfo();
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.carList = JSON.parse(options.shopCarList)
|
||||
this.calcTotal()
|
||||
},
|
||||
onReachBottom() {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user