From a2994454aa8152d3f660531d8f677246dd7bf303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lemon=E6=A9=AA?= <17633066053@163.com> Date: Mon, 23 Aug 2021 10:56:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=AD=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84bug,=E4=BB=A5=E5=8F=8A=E6=8B=BC=E5=9B=A2?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E8=A7=84=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/cart/coupon/myCoupon.vue | 8 ++- pages/cart/payment/popup/goods.vue | 88 ++++++++++++-------------- pages/cart/payment/shareOrderGoods.vue | 22 ++++--- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/pages/cart/coupon/myCoupon.vue b/pages/cart/coupon/myCoupon.vue index 817b9e4..fbbea77 100644 --- a/pages/cart/coupon/myCoupon.vue +++ b/pages/cart/coupon/myCoupon.vue @@ -11,6 +11,7 @@ + @@ -112,7 +113,7 @@ export default { }; }, - onLoad() { + onShow() { this.getData(); }, @@ -142,7 +143,7 @@ export default { let index = this.tabCurrentIndex; getMemberCoupons(this.navList[index].params).then((res) => { uni.stopPullDownRefresh(); - if (res.statusCode == 200) { + if (res.data.success) { let data = res.data.result.records; if (data.length == 0) { if (res.data.pageNumber == 1) { @@ -157,6 +158,7 @@ export default { this.navList[index].dataList.push(...data); } } + console.log(this.navList[index].dataList) uni.hideLoading(); }); }, @@ -220,7 +222,7 @@ $item-color: #fff; } .swiper-box { - height: calc(100% - 40px); + height: calc(100vh - 40px); } .list-scroll-content { diff --git a/pages/cart/payment/popup/goods.vue b/pages/cart/payment/popup/goods.vue index 77fe238..fe906b4 100644 --- a/pages/cart/payment/popup/goods.vue +++ b/pages/cart/payment/popup/goods.vue @@ -23,17 +23,19 @@ formatPrice(goodsDetail.price)[0] }} .{{ formatPrice(goodsDetail.price)[1] }} - + - ¥ - {{ + + ¥ + {{ formatPrice(goodsDetail.price)[0] }} - .{{ formatPrice(goodsDetail.price)[1] }} - + .{{ formatPrice(goodsDetail.price)[1] }} + + 已选 @@ -50,7 +52,7 @@ {{ spec.name }} - {{ spec_val.value }} @@ -63,7 +65,8 @@ - 加入购物车 + + 加入购物车 立即购买 @@ -98,7 +101,13 @@ export default { isClose: false, //是否可以点击遮罩关闭 }; }, - props: ["goodsDetail", "buyMask", "selectedSku", "goodsSpec", "addr"], + props: [ + "goodsDetail", //商品详情 + "buyMask", + "selectedSku", + "goodsSpec", + "addr", + ], watch: { buyType: { handler(val) { @@ -129,14 +138,12 @@ export default { /**点击规格 */ handleClickSpec(val, index, specValue) { - this.$set(this.currentSelceted, index, specValue.id); - + this.$set(this.currentSelceted, index, specValue.value); let selectedSkuId = this.goodsSpec.find((i) => { let matched = true; let specValues = i.specValues.filter((j) => j.specName !== "images"); - for (let n = 0; n < specValues.length; n++) { - if (specValues[n].specValueId !== this.currentSelceted[n]) { + if (specValues[n].specValue !== this.currentSelceted[n]) { matched = false; return; } @@ -145,7 +152,6 @@ export default { return i; } }); - this.selectSkuList = { spec: { specName: val.name, @@ -155,23 +161,9 @@ export default { }; this.selectName = specValue.value; - this.$emit("handleClickSku", selectedSkuId.skuId, this.goodsDetail.id); - }, - - /** - * 直接购买 - */ - buy(data) { - API_trade.addToCart(data).then((res) => { - if (res.data.code == 200) { - uni.navigateTo({ - url: `/pages/order/fillorder?way=${ - data.cartType - }&addr=${""}&parentOrder=${encodeURIComponent( - JSON.stringify(this.parentOrder) - )}`, - }); - } + this.$emit("handleClickSku", { + skuId: selectedSkuId.skuId, + goodsId: this.goodsDetail.goodsId, }); }, @@ -201,38 +193,39 @@ export default { this.$emit("queryCart"); this.closeMask(); - } else { - uni.showToast({ - title: res.data.message, - duration: 2000, - icon: "none", - }); - return false; } }); } else { // 判断是否拼团商品 - if (this.buyType == "PINTUAN") { + if (this.buyType) { data.cartType = "PINTUAN"; - } else if (this.buyType == "POINTS") { - data.cartType = "POINTS"; + } else if (this.goodsDetail.goodsType == "VIRTUAL_GOODS") { + data.cartType = "VIRTUAL"; } else { data.cartType = "BUY_NOW"; } - this.buy(data); + API_trade.addToCart(data).then((res) => { + if (res.data.code == 200) { + uni.navigateTo({ + url: `/pages/order/fillorder?way=${data.cartType}&addr=${ + this.addr.id || "" + }&parentOrder=${encodeURIComponent( + JSON.stringify(this.parentOrder) + )}`, + }); + } + }); } }, formatSku(list) { // 格式化数据 - if (typeof list != Array) return false; + let arr = [{}]; list.forEach((item, index) => { item.specValues.forEach((spec, specIndex) => { - let id = spec.specNameId; let name = spec.specName; let values = { - id: spec.specValueId, value: spec.specValue, quantity: item.quantity, }; @@ -244,7 +237,7 @@ export default { if ( arrItem.name == name && arrItem.values && - !arrItem.values.find((i) => i.id === values.id) + !arrItem.values.find((i) => i.value === values.value) ) { arrItem.values.push(values); } @@ -254,7 +247,6 @@ export default { }); if (!keys.includes(name)) { arr.push({ - id: id, name: name, values: [values], }); @@ -271,7 +263,7 @@ export default { item.specValues .filter((i) => i.specName !== "images") .forEach((value, _index) => { - this.currentSelceted[_index] = value.specValueId; + this.currentSelceted[_index] = value.specValue; this.selectName = value.specValue; @@ -289,6 +281,8 @@ export default { mounted() { this.formatSku(this.goodsSpec); + + console.log(this.goodsDetail); }, }; diff --git a/pages/cart/payment/shareOrderGoods.vue b/pages/cart/payment/shareOrderGoods.vue index a772302..36f03de 100644 --- a/pages/cart/payment/shareOrderGoods.vue +++ b/pages/cart/payment/shareOrderGoods.vue @@ -72,7 +72,7 @@ import popupGoods from "./popup/goods"; //购物车商品的模块 export default { data() { return { - flage:false, //判断接口是否正常请求 + flage: false, //判断接口是否正常请求 addr: { id: "", }, @@ -140,7 +140,7 @@ export default { async init(sn, sku) { let res = await getPinTuanShare(sn, sku); if (res.data.success && res.data.result.promotionGoods) { - this.flage = true + this.flage = true; this.data = res.data.result; this.selectedGoods = res.data.result.promotionGoods; let endTime = Date.parse( @@ -172,7 +172,10 @@ export default { } else { this.isMaster = false; // 获取商品详情 - this.getGoodsDetail(this.routers.sku, this.routers.goodsId); + this.getGoodsDetail({ + id: this.routers.sku, + goodsId: this.routers.goodsId, + }); } // 获取当前商品是否已经购买 @@ -183,15 +186,16 @@ export default { isBuy.length != 0 ? (this.isBuy = true) : (this.isBuy = false); } } else { - uni.showToast({ - title: '当前拼团单有误!请联系管理员重试', - duration: 2000, - icon:"none" - }); + uni.showToast({ + title: "当前拼团单有误!请联系管理员重试", + duration: 2000, + icon: "none", + }); } }, // 获取商品详情 - getGoodsDetail(id, goodsId) { + getGoodsDetail(val) { + let { id, goodsId } = val; uni.showLoading({ title: "加载中", mask: true,