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 da39c9b..6d6ad24 100644 --- a/components/lf-payPassword/lf-payPassword.vue +++ b/components/lf-payPassword/lf-payPassword.vue @@ -3,7 +3,7 @@ {{ title }} - + @@ -27,11 +27,11 @@ + 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..5022094 100644 --- a/pages/order/confirm/confirm.vue +++ b/pages/order/confirm/confirm.vue @@ -5,8 +5,8 @@ 选择收货方式 - 邮寄 - 自提 + 邮寄 + 自提 @@ -28,7 +28,7 @@ - + 店铺地址 @@ -44,7 +44,7 @@ 暂无收货地址,请前往添加 - + {{ order_detail.order.brand.name }} @@ -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) }} @@ -169,33 +169,39 @@ token: '', address: {}, address_id: null, - order_detail: {coupons: []}, + order_detail: {}, show_coupon: false, coupon_index: null, - goods_type: 1 + goods_type: 1, + itemsPrice: 0, // 商品金额(所有商品之和,但不包括额外费用及优惠) + totalPrice: 0 // 合计价格 } }, computed: { showCouponTitle(){ + let order_detail = this.order_detail; + if(typeof order_detail.coupons == 'undefined'){ + order_detail.coupons = []; + } if(this.coupon_index != null){ - return this.order_detail.coupons[this.coupon_index].discount.title; + return order_detail.coupons[this.coupon_index].discount.title; }else{ - if(this.order_detail.coupons.length){ + if(order_detail.coupons.length){ return '不使用优惠券'; }else{ return '暂无可用优惠券'; } } }, - 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 +238,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 +323,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 +345,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 +360,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 66766a1..ff89539 100644 --- a/pages/shop/goodsdetail.vue +++ b/pages/shop/goodsdetail.vue @@ -10,7 +10,7 @@ 距离结束还剩余 - - 欢迎来到金城优选! + 欢迎来到金诚优选!