From f7a2f588ef2c9c8d283a1392cf68110850dc8416 Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Thu, 21 Nov 2024 09:46:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=B8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/member/billDetails.vue | 4 +- pages/user/coupon.vue | 106 +++++- pagesInviteFriends/index/index.vue | 10 +- pagesOrder/components/orderInfoAfter.vue | 375 +++++++++++++-------- pagesOrder/components/orderInfoPoints.vue | 300 ----------------- pagesOrder/components/paymentMethod.vue | 39 ++- pagesOrder/components/rechargeFree.vue | 10 +- pagesOrder/confirm_order/index.vue | 200 ++++++----- pagesOrder/order_detail/index.vue | 134 ++++++-- pagesPoints/IntegralDetail/index.vue | 2 +- pagesPoints/exchangeRecordDetail/index.vue | 11 +- 11 files changed, 613 insertions(+), 578 deletions(-) delete mode 100644 pagesOrder/components/orderInfoPoints.vue diff --git a/pages/member/billDetails.vue b/pages/member/billDetails.vue index d056771..e73f2b5 100644 --- a/pages/member/billDetails.vue +++ b/pages/member/billDetails.vue @@ -22,11 +22,11 @@ - + - {{active == 1 ? item.biz_name : item.memberName}} + {{active == 1 ? item.biz_name : item.content}} {{ active == 1 ? item.type : (item.floatType == 'add'?'+':'')}} {{active == 1 ? item.amount : item.floatPoints}} diff --git a/pages/user/coupon.vue b/pages/user/coupon.vue index ae9282d..be866b8 100644 --- a/pages/user/coupon.vue +++ b/pages/user/coupon.vue @@ -68,6 +68,10 @@ + + + 暂不使用券 + @@ -133,7 +137,7 @@ userId: uni.cache.get('userInfo').id, status: this.status } - if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' ) { + if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type == 'orderInfo_coupon' || this.type == 'orderInfo_product' ) { params.orderId = -1; } if ( this.shopId ) { @@ -163,7 +167,7 @@ */ navigatorGo ( item ) { uni.cache.set('shopId',item.shopId) - if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product') { + if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type == 'orderInfo_coupon' || this.type == 'orderInfo_product' ) { if ( item.type == 1 ) { if( this.payAmount < item.fullAmount) { uni.showToast({ @@ -173,6 +177,20 @@ return; } uni.$emit('couponItem', JSON.stringify(item)) + let selectCouponData = uni.cache.get('selectCouponData') || []; + let couponList = selectCouponData.filter(v => v.type == 1); + if ( couponList.length > 0) { + couponList.map(items => { + if ( item.type == 1 ) { + for(var v in items){ + items[v] = item[v] + } + } + }) + } else { + selectCouponData.push(item) + } + uni.cache.set('selectCouponData',selectCouponData) uni.navigateBack(); } else { let productNum = 0;//商品购物车数量 @@ -208,7 +226,45 @@ }) return; } + let isNum = 0; + let isProductItem; + // 确认订单 + if ( this.type == 'confirm_order_product' ) { + product.forEach(item => { + for (let i = 0; i < item.number; i++){ + isNum++ + if ( isNum == productTicketNum+1 ) { + isProductItem = item; + } + } + }) + if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.salePrice)) { + uni.showToast({ + title: `当前金额不足商品抵扣`, + icon: "none", + }) + return; + } + } + // 订单详情 + if ( this.type == 'orderInfo_product' ) { + product.forEach(item => { + for (let i = 0; i < item.num; i++){ + isNum++ + if ( isNum == productTicketNum+1 ) { + isProductItem = item; + } + } + }) + if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.price)) { + uni.showToast({ + title: `当前金额不足商品抵扣`, + icon: "none", + }) + return; + } + } // let productNum = 0; @@ -226,6 +282,9 @@ // } uni.$emit('couponItem', JSON.stringify(item)) + let selectCouponData = uni.cache.get('selectCouponData') || []; + selectCouponData.push(item) + uni.cache.set('selectCouponData',selectCouponData) uni.navigateBack(); } @@ -237,6 +296,27 @@ } }, + + /** + * 取消使用优惠券/商品券 + */ + cancelCoupon () { + let selectCouponData = uni.cache.get('selectCouponData') + if ( this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon' ) { + let couponList = selectCouponData.filter(v => v.type == 1); + let productList = selectCouponData.filter(v => v.type == 2); + if ( couponList.length > 0 ) { + uni.cache.set('selectCouponData',productList) + } + } else if ( this.type == 'confirm_order_product' || this.type == 'orderInfo_product' ) { + let couponList = selectCouponData.filter(v => v.type == 1); + let productList = selectCouponData.filter(v => v.type == 2); + if ( productList.length > 0 ) { + uni.cache.set('selectCouponData',couponList) + } + } + uni.navigateBack(); + }, } }; @@ -311,7 +391,7 @@ height: 192rpx; background: #E3AD7F; border-radius: 18rpx 0rpx 0rpx 18rpx; - + padding: 0 20rpx; // ::before { @@ -463,7 +543,25 @@ } } - + .btnBox{ + width: 100%; + position: absolute; + bottom: 0; + left: 0; + background-color: #fff; + padding: 30rpx 30rpx 50rpx 30rpx; + .btn{ + width: 100%; + height: 90rpx; + line-height: 90rpx; + text-align: center; + font-weight: bold; + font-size: 36rpx; + color: #FFFFFF; + border-radius: 12rpx; + background: #E3AD7F; + } + } } \ No newline at end of file diff --git a/pagesInviteFriends/index/index.vue b/pagesInviteFriends/index/index.vue index f72a28d..f8f4113 100644 --- a/pagesInviteFriends/index/index.vue +++ b/pagesInviteFriends/index/index.vue @@ -40,9 +40,9 @@ - {{item.invitedName}} - {{ - isSuccess ? '邀请成功' : '未邀请成功' + {{item.invitedName||""}} + {{ + item.success ? '邀请成功' : '未邀请成功' }} {{item.createTime}} @@ -162,11 +162,11 @@ shareId : this.InviteFriendsData.id, invitedId : uni.cache.get('userInfo').id, shopId : this.shopId, - success : this.isSuccess, + success : this.tabAcitve == 1 ? true : false, } let res = await this.api.shareRecord(params) if ( res.code == 0 ) { - this.shareRecordData = res.data; + this.shareRecordData = res.data.records; this.tabList[0].num = res.data.isSuccess; this.tabList[1].num = res.data.isFail; } diff --git a/pagesOrder/components/orderInfoAfter.vue b/pagesOrder/components/orderInfoAfter.vue index c5eade1..789b3c7 100644 --- a/pagesOrder/components/orderInfoAfter.vue +++ b/pagesOrder/components/orderInfoAfter.vue @@ -53,40 +53,74 @@ {{listinfo.orderInfo.seatAmount}} - - - - - {{ item.name }} + + + + + + + {{ item.name }} + + + {{item.value}} + + + + + {{items.name}} + X{{items.num}} + -¥{{items.discountAmount || 0}} + + + + + + 使用 {{ calcUsablePointsData.pointsNum}} 积分抵扣¥{{calcUsablePointsData.pointsNum/calcUsablePointsData.equivalentPoints}} + + + {{calcUsablePointsData.unusableReason}} + + + + + + + - - {{item.value}} - + + + + + + + 优惠券 + + + -¥ + {{item.discountAmount}} + - - - {{items.name}} - X{{items.num}} - -¥{{items.discountAmount || 0}} - - - - - - 使用 {{ calcUsablePointsData.pointsNum}} 积分抵扣¥{{calcUsablePointsData.pointsNum/calcUsablePointsData.equivalentPoints}} - - - {{calcUsablePointsData.unusableReason}} - - - - - - + + + 商品券 + + + {{item.name}} + X{{item.finalUseNum}} + -¥{{item.finalDiscountAmount}} + - - + + 积分抵扣 + + + + {{listinfo.orderInfo.pointsDiscountAmount.toFixed(2)}} + + + + 总计¥ {{listinfo.payAmount}} @@ -139,13 +173,21 @@ { name: "积分抵扣", type: "points",value: "", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/points.png" } ], calcUsablePointsData: null, + isShow: false, + payAmount: 0, isPointsChecked: false, - freeCheck: false, - freeDisabled: false, userCouponInfos: [], + selectCouponData: [], } }, props:{ + rechargeFreeChecked: { + type: Boolean + }, + freeCheck: { + type: Boolean + }, + listinfo:{ type: Object }, @@ -161,59 +203,93 @@ this.$forceUpdate() } }, + rechargeFreeChecked:{ + immediate: true, + handler (newVal) { + console.log(this.isPointsChecked) + if ( newVal ) { + + // let couponList = this.userCouponInfos.filter(v => v.type == 1); + // this.listinfo.payAmount = (couponList.length > 0 ? Number(this.listinfo.payAmount) + couponList[0].discountAmount : this.listinfo.payAmount) + // let productList = this.userCouponInfos.filter(v => v.type == 2); + // productList.map(item=> { + // this.listinfo.payAmount += item.productPayAmount + // }) + this.isPointsChecked = false + + this.$emit("setPayAmount",{ + payAmount: this.listinfo.payAmount, + userCouponInfos: this.userCouponInfos, + freeCheck: this.freeCheck, + calcUsablePointsData: this.calcUsablePointsData, + isPointsChecked: this.isPointsChecked, + }) + } + + // this.userCouponInfos = [] + } + }, }, mounted() { + this.payAmount = this.listinfo.payAmount; + uni.cache.set('selectCouponData',[]) + this.isShow = true; }, methods: { childOnShow() { - console.log(222) - uni.$on('couponItem',this.changeCoupon) - this.getCalcUsablePoints() + this.getCalcUsablePoints() + if (!this.isShow ) { + return; + } + // uni.$on('couponItem',this.changeCoupon) + this.userCouponInfos = []; + this.favorable[0].value = "" + this.favorable[1].value = [] + this.listinfo.payAmount = this.payAmount + this.selectCouponData = uni.cache.get('selectCouponData') || [] + this.changeCoupon(); }, /** * 监听优惠券/商品券选择 * @param {Object} data */ changeCoupon ( data ) { - let _this = this; - // uni.$off('couponItem') - let couponData = JSON.parse(data) - console.log('监听到事件来自返回的参数:' , couponData); - if ( couponData.type == 1 ) { //满减优惠券 - let couponList = _this.userCouponInfos.filter(v => v.type == 1); + + // 优惠券数据 + let couponList = this.selectCouponData.filter(v => v.type == 1); + // 商品券列表 + let productList = this.selectCouponData.filter(v => v.type == 2); + + // 优惠券处理 + if ( couponList.length > 0 ) { + let couponData = couponList[0] //不包含优惠券的金额 - let currentPayAmount = (couponList.length > 0 ? Number(_this.listinfo.payAmount) + couponList[0].discountAmount : _this.listinfo.payAmount) + let currentPayAmount = (this.userCouponInfos.filter(v => v.type == 1).length > 0 ? Number(this.listinfo.payAmount) + couponData.discountAmount : this.listinfo.payAmount) // 判断优惠金额不能大于支付金额 if ( couponData.discountAmount < currentPayAmount) { - _this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2) - _this.favorable[0].value = ('-¥'+couponData.discountAmount) - if ( couponList.length > 0) { - _this.userCouponInfos.map(item => { - if ( item.type == 1 ) { - item.userCouponId = couponData.id - item.type = couponData.type - item.discountAmount = couponData.discountAmount - item.num = couponData.type == 1 ? 1 : couponData.num - } - }) + + if ( this.isPointsChecked ) { + this.listinfo.payAmount = (this.listinfo.payAmount-(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); } else { - _this.favorable[0].value = ('-¥'+couponData.discountAmount) - _this.userCouponInfos.push({ + this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); + } + this.listinfo.payAmount = ( currentPayAmount - couponData.discountAmount).toFixed(2) + this.favorable[0].value = ('-¥'+couponData.discountAmount) + + this.userCouponInfos.push({ userCouponId: couponData.id, type: couponData.type, discountAmount: couponData.discountAmount, num: couponData.type == 1 ? 1 : couponData.num, }) - } - console.log(currentPayAmount) - console.log(_this.listinfo.payAmount) - if ( _this.isPointsChecked ) { - _this.pointsChange() - _this.getCalcUsablePoints() + if ( this.isPointsChecked ) { + this.isPointsChecked = !this.isPointsChecked + this.getCalcUsablePoints() } this.$emit("setPayAmount",{ payAmount: this.listinfo.payAmount, userCouponInfos: this.userCouponInfos, + freeCheck: this.freeCheck, calcUsablePointsData: this.calcUsablePointsData, isPointsChecked: this.isPointsChecked, }) @@ -223,76 +299,65 @@ icon: "none", }) } - } else { //商品券 - //不包含商品券的金额 - let currentPayAmount = 0; - // 筛选选中商品券商品列表 - let couponList = _this.listinfo.details.filter(v => v.productId == couponData.proId); - //金额从小到大排序 - let minCouponList = couponList.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice)) - let productTicketList = _this.userCouponInfos.filter(v => v.productId == couponData.proId); - //商品券抵扣的数量 - let productNum = couponData.num; - // 使用数量 - let num = 0; - let productPayAmount = 0; - let productTicketNum = 0; - let productNumber = 0; - productTicketList.map((item,index) => { - console.log(item) - productTicketNum += item.num - _this.listinfo.payAmount = Number(_this.listinfo.payAmount) + item.discountAmount - }) - console.log(productTicketNum) - let productTicketNumber = 0; - minCouponList.map((item,index) => { - // productNumber += item.num - console.log("productTicketNum==",productTicketNum) - if ( productNum > 0 && productTicketNum > 0) { - productTicketNumber = productTicketNum - productTicketNum = (item.num - productTicketNum) <= 0 ? (productTicketNum - item.num) : item.num - productTicketNum - console.log("item.num - productTicketNumber===",item.num - productTicketNumber) - - } - if ( productNum > 0 && productTicketNum > 0) { - item.num = (item.num - productTicketNumber) <= 0 ? 0 : (item.num - productTicketNumber) - } - console.log("productTicketNum==",productTicketNum) - console.log("item.num===",item.num) - if ( productNum > 0 && item.num > 0) { - console.log("index===",index) - let num = productNum >= item.num ? item.num : productNum - productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0; - - productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.price)) - } - }) - if ( productPayAmount > _this.listinfo.payAmount) { - - } - _this.userCouponInfos.push({ - userCouponId: couponData.id, - type: couponData.type, - productId: couponData.proId, - discountAmount: productPayAmount, - num: productNum == 0 ? couponData.num : (couponData.num - productNum), - }) - _this.favorable[1].value.push({ - userCouponId: couponData.id, - name: couponData.name, - type: couponData.type, - productId: couponData.proId, - discountAmount: productPayAmount, - num: productNum == 0 ? couponData.num : (couponData.num - productNum), - }) - console.log(productNum) - if ( _this.isPointsChecked) { - _this.pointsChange() - } + } + + // 商品券处理 + if ( productList.length > 0 ) { + //商品券使用数量 - _this.setPayAmount() - } - uni.$off('couponItem') + // 商品数量 + let productAllNum = 0; + + productList.map((item,index)=>{ + // 筛选选中商品券商品列表 + let productDetails = this.listinfo.details.filter(v => v.productId == item.proId); + //金额从小到大排序 + let minCouponList = productDetails.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice)) + let productNum = 0; + let productPayAmount = 0; + let productDetailsNum = 0; + productDetails.map((v,indexs) => { + productDetailsNum += v.num; + }) + + minCouponList.map((v,indexs) => { + for (let i = 0; i < v.num; i++){ + if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.price) < (this.listinfo.payAmount - productPayAmount) )) { + productNum++ + productAllNum++ + productPayAmount += v.memberPrice > 0 ? v.memberPrice : v.price + } + + } + + }) + + if ( productNum > 0 ) { + this.userCouponInfos.push({ + userCouponId: item.id, + type: item.type, + productId: item.proId, + discountAmount: productPayAmount, + num: productNum , + }) + this.favorable[1].value.push({ + userCouponId: item.id, + name: item.name, + type: item.type, + productId: item.proId, + discountAmount: productPayAmount, + num: productNum, + }) + } + + }) + if ( this.isPointsChecked) { + this.isPointsChecked = !this.isPointsChecked + this.getCalcUsablePoints() + } + } + this.setPayAmount() + }, setPayAmount ( cartLists ) { let tableFee; @@ -302,11 +367,7 @@ if ( this.userCouponInfos.length > 0 ) { console.log(this.userCouponInfos) this.userCouponInfos.forEach(item => { - if ( item.type == 1 ) { - // if ( item.discountAmount && item.discountAmount > 0 ) { - // this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2) - // } - } else { + if ( item.type == 2 ) { if ( item.discountAmount && item.discountAmount > 0 ) { this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2) } @@ -320,6 +381,7 @@ this.$emit("setPayAmount",{ payAmount: this.listinfo.payAmount, userCouponInfos: this.userCouponInfos, + freeCheck: this.freeCheck, calcUsablePointsData: this.calcUsablePointsData, isPointsChecked: this.isPointsChecked, }) @@ -333,17 +395,16 @@ } this.isPointsChecked = !this.isPointsChecked if ( this.isPointsChecked ) { - this.freeDisabled = true - this.listinfo.payAmount = (this.listinfo.payAmount-(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); } else { - this.freeDisabled = false this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); } console.log(this.listinfo.payAmount) this.$emit("setPayAmount",{ payAmount: this.listinfo.payAmount, userCouponInfos: this.userCouponInfos, + freeDisabled: this.freeDisabled, + freeCheck: this.freeCheck, calcUsablePointsData: this.calcUsablePointsData, isPointsChecked: this.isPointsChecked, }) @@ -359,16 +420,17 @@ } uni.pro.navigateTo('/pages/user/coupon', { - type: "confirm_order_coupon", + type: "orderInfo_coupon", shopId: this.listinfo.shopId, payAmount: payAmount, - shoppingCart: JSON.stringify(this.listinfo.details) + shoppingCart: JSON.stringify(this.listinfo.details), + productList: JSON.stringify(couponList) }) break; case 'product': let productList = this.userCouponInfos.filter(v => v.type == 2); uni.pro.navigateTo('/pages/user/coupon', { - type: "confirm_order_product", + type: "orderInfo_product", shopId: this.listinfo.shopId, payAmount: this.listinfo.payAmount, shoppingCart: JSON.stringify(this.listinfo.details), @@ -624,6 +686,33 @@ color: #333333; } } + .val.column{ + display: flex; + flex-direction: column; + .productCoupon{ + display: flex; + align-items: flex-end; + margin: 0 0 10rpx 0; + .name{ + font-weight: 400; + font-size: 26rpx; + color: #999; + margin: 0; + } + .num{ + font-weight: 400; + font-size: 26rpx; + color: #999; + margin: 0 30rpx; + line-height: 20rpx; + } + .amount{ + font-weight: bold; + font-size: 26rpx; + color: #333; + } + } + } } .favorable{ @@ -684,7 +773,9 @@ .favorable.column{ align-items: flex-start; } - + .cell-item.column{ + align-items: flex-start; + } .total-wrap { width: 100%; display: flex; diff --git a/pagesOrder/components/orderInfoPoints.vue b/pagesOrder/components/orderInfoPoints.vue deleted file mode 100644 index d99a700..0000000 --- a/pagesOrder/components/orderInfoPoints.vue +++ /dev/null @@ -1,300 +0,0 @@ - - - - - diff --git a/pagesOrder/components/paymentMethod.vue b/pagesOrder/components/paymentMethod.vue index b53d9c7..ecb8267 100644 --- a/pagesOrder/components/paymentMethod.vue +++ b/pagesOrder/components/paymentMethod.vue @@ -64,18 +64,35 @@ }, watch: { - freeCheck(newVal,oldVal) { - if ( newVal ) { - // #ifdef MP-WEIXIN - this.radiovalue = 2 - // #endif - // #ifdef MP-ALIPAY - this.radiovalue = 3 - // #endif - let name = this.paymentMethodName[this.radiovalue-1].name; - this.$emit("groupChange",{type:this.radiovalue ,name: name }) + // freeCheck(newVal,oldVal) { + // if ( newVal ) { + // // #ifdef MP-WEIXIN + // this.radiovalue = 2 + // // #endif + // // #ifdef MP-ALIPAY + // this.radiovalue = 3 + // // #endif + // let name = this.paymentMethodName[this.radiovalue-1].name; + // console.log({type:this.radiovalue ,name: name }) + // this.$emit("groupChange",{type:this.radiovalue ,name: name }) + // } + // } + freeCheck:{ + immediate: true, + handler (newVal) { + if ( newVal ) { + // #ifdef MP-WEIXIN + this.radiovalue = 2 + // #endif + // #ifdef MP-ALIPAY + this.radiovalue = 3 + // #endif + let name = this.paymentMethodName[this.radiovalue-1].name; + console.log({type:this.radiovalue ,name: name }) + this.$emit("groupChange",{type:this.radiovalue ,name: name }) + } } - } + }, }, mounted() { console.log(this.amountVIP) diff --git a/pagesOrder/components/rechargeFree.vue b/pagesOrder/components/rechargeFree.vue index 960302a..18ffea9 100644 --- a/pagesOrder/components/rechargeFree.vue +++ b/pagesOrder/components/rechargeFree.vue @@ -4,7 +4,7 @@ 优惠 - 充值消费{{freeDingConfig.rechargeTimes}}倍(¥{{freeDingConfig.rechargeThreshold}}),本单立享免单! + 充值消费{{freeDingConfig.rechargeTimes}}倍(订单满¥{{freeDingConfig.rechargeThreshold}}远可用),本单立享免单! @@ -41,6 +41,11 @@ if ( this.payAmount < this.freeDingConfig.rechargeThreshold ) { this.freeDisabled = true } + }, + payAmount (newVal) { + if ( this.payAmount < this.freeDingConfig.rechargeThreshold ) { + this.freeDisabled = true + } } }, mounted() { @@ -69,7 +74,7 @@