From 6febd2cdbcd296a435dda85ed1fdf0a694717956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Fri, 8 Oct 2021 14:27:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=8B=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/lf-payPassword/lf-payPassword.vue | 6 +- components/smh-pwd/smh-pwd.vue | 99 ++++++++++++++++++ pages/article/details.vue | 2 +- pages/business/login/login.vue | 2 +- pages/index/index/index.vue | 8 +- pages/order/confirm/confirm.vue | 104 ++++++++++++++----- pages/point/shoppingMall/shoppingMall.vue | 6 +- pages/shop/goodsdetail.vue | 2 + pages/user/loginType/loginType.vue | 2 +- 9 files changed, 197 insertions(+), 34 deletions(-) create mode 100644 components/smh-pwd/smh-pwd.vue diff --git a/components/lf-payPassword/lf-payPassword.vue b/components/lf-payPassword/lf-payPassword.vue index da39c9b..afd7aa1 100644 --- a/components/lf-payPassword/lf-payPassword.vue +++ b/components/lf-payPassword/lf-payPassword.vue @@ -4,6 +4,7 @@ {{ title }} + @@ -28,10 +29,12 @@ + diff --git a/pages/article/details.vue b/pages/article/details.vue index 5e74e93..c846790 100644 --- a/pages/article/details.vue +++ b/pages/article/details.vue @@ -9,7 +9,7 @@ - 金城优选线上商城 + 金诚优选线上商城 2021.09.01 16:28:22 diff --git a/pages/business/login/login.vue b/pages/business/login/login.vue index 1da880a..c3a86da 100644 --- a/pages/business/login/login.vue +++ b/pages/business/login/login.vue @@ -4,7 +4,7 @@ - 欢迎来到金城优选! + 欢迎来到金诚优选! diff --git a/pages/index/index/index.vue b/pages/index/index/index.vue index 147ed2f..822ab76 100644 --- a/pages/index/index/index.vue +++ b/pages/index/index/index.vue @@ -80,8 +80,10 @@ 购物车 - {{car_num || 0}} - 99+ + + {{car_num || 0}} + 99+ + @@ -852,7 +854,7 @@ }, onShareAppMessage(){ return { - title: '欢迎使用金城优选小程序!', + title: '欢迎使用金诚优选小程序!', path: '/pages/route/index?route=home' } } diff --git a/pages/order/confirm/confirm.vue b/pages/order/confirm/confirm.vue index f38a3e6..fee04cd 100644 --- a/pages/order/confirm/confirm.vue +++ b/pages/order/confirm/confirm.vue @@ -5,8 +5,8 @@ 选择收货方式 - 邮寄 - 自提 + 邮寄 + 自提 @@ -28,7 +28,7 @@ - + 店铺地址 @@ -56,7 +56,7 @@ {{ item.item_name }} {{ item.item_meta.specs_text }} - ¥{{ item.total_yuan }}积分 + ¥{{ unitConversion(item.unit_price) }}积分 x {{ item.quantity }} @@ -77,15 +77,15 @@ 商品金额 - ¥{{ order_detail.order.items_total_yuan }}积分 + ¥{{ itemsPrice }}积分 运费 - +¥{{ order_detail.order.payable_freight_yuan }} + +¥{{ order_detail.order.payable_freight_yuan || 0 }} 优惠 - -¥{{ order_detail.order.adjustments_total_yuan }} + -¥{{ fullMinus(order_detail.discounts) }} @@ -172,7 +172,9 @@ order_detail: {coupons: []}, show_coupon: false, coupon_index: null, - goods_type: 1 + goods_type: 1, + itemsPrice: 0, // 商品金额(所有商品之和,但不包括额外费用及优惠) + totalPrice: 0 // 合计价格 } }, computed: { @@ -187,15 +189,15 @@ } } }, - totalPrice(){ - let order = this.order_detail.order; - if(!this.$isRight(order)){ - return 0; - } - if(this.mode){ - return order.total_yuan; - }else{ - return new Bigc(order.total_yuan).plus(order.payable_freight); + fullMinus(){ + return function(arr){ + if(this.$isRight(arr)){ + let price = arr[0].adjustmentTotal; + let adjustmentTotal = new Bigc(price).div(100); + return Math.abs(adjustmentTotal); + }else{ + return 0 + } } } }, @@ -232,9 +234,54 @@ let detail = res.data.data; this.order_detail = detail; this.address = res.data.data.address; + if(this.$isRight(detail.coupons)){ + this.coupon_index = 0; + } + this.calcAmount(); uni.hideLoading() }).catch(err => uni.hideLoading()) }, + // 单位转换金额 + unitConversion(price){ + let newPrice = new Bigc(price).div(100); + return Math.abs(newPrice); + }, + // 计算金额 + calcAmount(){ + let detail = this.order_detail; + let items = detail.order.items; + let itemsPrice = new Bigc(0); + // 所有商品总计 + items.map(item => { + let price = new Bigc(item.unit_price).div(100); + let itemP = price.times(item.quantity); + itemsPrice = itemsPrice.plus(itemP); + }) + this.itemsPrice = itemsPrice; + // 减去优惠券的价格 + if(this.coupon_index != null){ + let coupon = detail.coupons[this.coupon_index]; + let adjustmentTotal = new Bigc(coupon.adjustmentTotal).div(100); // 得到负数 + itemsPrice = itemsPrice.plus(adjustmentTotal); // 加一个负数等于减去的优惠 + } + // 减去满减优惠 + if(this.$isRight(detail.discounts)){ + let discount = detail.discounts[0]; + let adjustmentTotal = new Bigc(discount.adjustmentTotal).div(100); // 得到负数 + itemsPrice = itemsPrice.plus(adjustmentTotal); // 加一个负数等于减去的优惠 + } + // 如果为邮寄订单时,加上运费 + if(this.mode == 0){ + let payable_freight = new Bigc(detail.order.payable_freight).div(100); + itemsPrice = itemsPrice.plus(payable_freight); + } + this.totalPrice = itemsPrice; // 合计价格 + }, + // 切换订单是邮寄还是自提 + switchMode(mode){ + this.mode = mode; + this.calcAmount(); + }, // 获取默认地址 getDefaultAddress(){ this.$http.get({ @@ -272,15 +319,20 @@ this.$msg('请先添加收货地址!'); return } + let par = { + order_no: this.order_detail.order.order_no, + pick_self: this.mode, // 0 配送,1自提 + address_id: this.address.id, + note: this.value + } + // 是否选择了优惠券 TODO 优惠券id是否传对? + if(this.coupon_index != null){ + par.coupon_id = this.order_detail.coupons[this.coupon_index].id; + } + this.$http.post({ api: 'api/shopping/order/confirm', - data: { - order_no: this.order_detail.order.order_no, - // discount_id: 0, // 优惠券id? TODO - pick_self: this.mode, // 0 配送,1自提 - address_id: this.address.id, - note: this.value - }, + data: par, header: { Authorization: this.token } @@ -289,7 +341,7 @@ if(res.data.code == 200 || res.data.code == true){ let order = res.data.data.order; let url = '/pages/order/cashier/cashier'; - url += '?amount='+ order.total_yuan; + url += '?amount='+ this.totalPrice; url += '&order_no='+ order.order_no; this.$url(url, {type: 'redirect'}); }else{ @@ -304,6 +356,8 @@ }else{ this.coupon_index = Number(event.detail.value); } + this.show_coupon = false; + this.calcAmount(); } } } diff --git a/pages/point/shoppingMall/shoppingMall.vue b/pages/point/shoppingMall/shoppingMall.vue index de9ebdd..9ecd367 100644 --- a/pages/point/shoppingMall/shoppingMall.vue +++ b/pages/point/shoppingMall/shoppingMall.vue @@ -21,8 +21,10 @@ 购物车 - {{car_num}} - 99+ + + {{car_num}} + 99+ + diff --git a/pages/shop/goodsdetail.vue b/pages/shop/goodsdetail.vue index a8a62fb..0a3e97e 100644 --- a/pages/shop/goodsdetail.vue +++ b/pages/shop/goodsdetail.vue @@ -11,6 +11,8 @@ 距离结束还剩余 - 欢迎来到金城优选! + 欢迎来到金诚优选! From 0c6528d6c4c12ab888ede48fe2289787e85f0ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Fri, 8 Oct 2021 15:26:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A1=B5=E9=9D=A2=E6=B8=B2=E6=9F=93=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=8C=E6=9B=B4=E6=8D=A2=E5=AF=86=E7=A0=81=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=BB=84=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/lf-jpCoded/lf-jpCoded.vue | 235 ------------------- components/lf-payPassword/lf-payPassword.vue | 10 +- components/smh-pwd/smh-pwd.vue | 40 ++-- pages/order/confirm/confirm.vue | 14 +- 4 files changed, 35 insertions(+), 264 deletions(-) delete mode 100644 components/lf-jpCoded/lf-jpCoded.vue diff --git a/components/lf-jpCoded/lf-jpCoded.vue b/components/lf-jpCoded/lf-jpCoded.vue deleted file mode 100644 index 5f024e1..0000000 --- a/components/lf-jpCoded/lf-jpCoded.vue +++ /dev/null @@ -1,235 +0,0 @@ - - - - - diff --git a/components/lf-payPassword/lf-payPassword.vue b/components/lf-payPassword/lf-payPassword.vue index afd7aa1..6d6ad24 100644 --- a/components/lf-payPassword/lf-payPassword.vue +++ b/components/lf-payPassword/lf-payPassword.vue @@ -3,8 +3,7 @@ {{ title }} - - + @@ -28,13 +27,11 @@