From f1a67b1131a69f6950ea1ad27a7d43d50cd30952 Mon Sep 17 00:00:00 2001 From: Wik-T <812952667@qq.com> Date: Wed, 1 Mar 2023 18:03:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=89=AB=E7=A0=81=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=9A=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 182 +++++++++++++++++++------------------- pages/welcome/welcome.vue | 2 +- 2 files changed, 91 insertions(+), 93 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 369df2a..a7784a3 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -9,7 +9,8 @@ - + 门店优惠 @@ -67,7 +68,7 @@ - 暂无优惠券 + -¥{{deductionPrice}} - + {{discout.discountName}} @@ -145,7 +146,6 @@ 立即登录 - @@ -180,13 +180,13 @@ return { plateNumberList: [], length: 6, - discountPrice: 0, //优惠金额 + discountPrice: 0, //优惠金额 inputPrice: '', //输入金额 payPrice: 0, //支付金额 reNum: 0, // 是否重复 priceValue: [0, 0], // 可以指定默认值 discountList: '', //优惠券数据 - memDiscountId: [], //选择中的值 + memDiscountId: '', //选择中的值 numKeybordList: [ [1, 2, 3], [4, 5, 6], @@ -211,35 +211,8 @@ getCodeisWaiting: false, } }, - mounted() { - // this.openKeyBoard('number'); - }, + mounted() {}, onLoad: function() { - // var arr1 = window.location.href; - // var arr2 = arr1.split('='); - // if (arr2[1].length == 12) { - // var arr3 = arr2[1].split('#/'); - // app.globalData.snNo = arr3[0]; - // uni.setStorage({ - // key: "snNumber", - // data: arr3[0] - // }) - // this.jumpWeb(); - // } else { - // let that = this; - // var arr4 = arr2[2].split('&'); - // app.globalData.code = arr4[0]; - // uni.getStorage({ - // key: 'snNumber', - // success(e) { - // app.globalData.snNo = e.data; - // that.getQrCodeDetail(); - // } - // }) - // } - // if (app.globalData.code) { - // this.getH5AccessToken(); - // } if (app.globalData.snNo) { this.getQrCodeDetail(); } @@ -257,17 +230,16 @@ this.plateNumberList.forEach(item => { str += item.toString(); }) - parice = str - (this.priceValue[1] / 10 / 10); - if(str == 0){ - this.calculation(0); + parice = str - (this.priceValue[1] / 10 / 10); + if (str == 0) { + this.calculation(0); + } + if (str) { + this.calculation(str); } - if(str){ - this.calculation(str); - } if (parice > 0) { this.cjstu = false; } else { - // this.payPrice = 0; this.priceValue = [0, 0]; } this.inputPrice = str; @@ -375,6 +347,7 @@ }) this.$refs.popups.hide(); this.getUserAccount(); + this.queryUserDiscountList(); } else { this.showtoastdes = res.return_msg; uni.showToast({ @@ -389,6 +362,10 @@ showPopuplogin() { this.$refs.popups.show(); }, + //显示弹出 + showPopup() { + this.$refs.popup.show(); + }, //查询积分 getUserAccount() { getUserAccount().then(res => { @@ -415,23 +392,24 @@ //计算价格 calculation(item) { let storetype = ''; - let storeprice = ''; - if(this.storeList.discountActivity !='' && this.storeList.discountActivity !=null){ - if (item >= this.storeList.discountActivity.discountCondition && this.storeList.discountActivity.discountType == 1) { - storetype = this.storeList.discountActivity.discountType; - storeprice = this.storeList.discountActivity.discountPrice; - }else{ - storetype = this.storeList.discountActivity.discountType; - storeprice = this.storeList.discountActivity.discountPrice; - } + let storeprice = ''; + if (this.storeList.discountActivity != '' && this.storeList.discountActivity != null) { + if (item >= this.storeList.discountActivity.discountCondition && this.storeList.discountActivity + .discountType == 1) { + storetype = this.storeList.discountActivity.discountType; + storeprice = this.storeList.discountActivity.discountPrice; + } else { + storetype = this.storeList.discountActivity.discountType; + storeprice = this.storeList.discountActivity.discountPrice; + } } - + let datas = { transactionPrice: item, storeDiscountType: storetype, storeDiscountPrice: storeprice, - userDiscountType: '', - userDiscountPrice: '' + userDiscountType: this.memDiscountId, + userDiscountPrice: this.deductionPrice } calculation(datas).then(res => { if (res.return_code == '000000') { @@ -441,19 +419,6 @@ } }); }, - //H5 获取openId - // getH5AccessToken(item) { - // let params = { - // code: app.globalData.code - // } - // getH5AccessToken(params).then(res => { - // if (res.return_code == '000000' && res.return_data.openid) { - // app.globalData.openId = res.return_data.openid; - // } else { - // this.jumpWeb(); - // } - // }); - // }, //查询门店详情 getQrCodeDetail() { let datas = { @@ -467,13 +432,63 @@ } }) }, - //显示弹出 - showPopup() { - this.$refs.popup.show(); - }, + //选择优惠券 - radioChanges(item) { + radioChanges(item) { + // this.rechangeload(); + if (this.inputPrice == '') { + uni.showToast({ + title: '请输入正确的支付金额', + duration: 2000, + icon: 'none' + }) + this.payPrice = 0; + this.plateNumberList = []; + this.$refs.popup.hide(); + return; + } + if (this.memDiscountId == item.id) { // 如果已经选中,则取消选中 + this.memDiscountId = ''; + this.deductionPrice = '0.00'; + this.calculation(this.inputPrice); + } else { // 否则进行选中赋值 + if (item.discountType == 1) { + if (this.inputPrice >= item.discountCondition) { + this.memDiscountId = item.id; + //满减价格 + this.deductionPrice = item.discountPrice; + let oldprice = this.inputPrice - this.deductionPrice; + this.calculation(oldprice); + } else { + uni.showToast({ + title: '请满' + item.discountCondition + '使用此券', + icon: 'none', + duration: 2000 + }) + } + } + if (item.discountType == 2) { + this.memDiscountId = item.id; + //抵扣价格 + this.deductionPrice = item.discountPrice; + let oldprice = this.inputPrice - this.deductionPrice; + this.calculation(oldprice); + } + if (item.discountType == 3) { + this.memDiscountId = item.id; + // 打折 + this.deductionPrice = parseFloat(this.inputPrice - (this.inputPrice * item.discountPrice)).toFixed( + 2); + let oldprice = parseFloat(this.inputPrice * item.discountPrice).toFixed(2); + this.calculation(oldprice); + } + } + this.$refs.popup.hide(); + }, + rechangeload() { + this.isUse = false; + this.$nextTick(() => (this.isUse = true)) }, //重定向方法 jumpWeb() { @@ -488,31 +503,13 @@ //提交支付 confirm() { let lenth = this.plateNumberList.length - 1; - // if (!this.payPrice) { - // uni.showToast({ - // title: '请输入支付金额', - // duration: 2000, - // icon: 'none' - // }) - // return; - // } - if (this.plateNumberList[lenth] == '.') { - uni.showToast({ - title: '请输入正确的支付金额', - duration: 2000, - icon: 'none' - }) - this.payPrice = 0; - this.plateNumberList = []; - return; - } var n = String(this.payPrice) var t = n.charAt(0) // 必须保证第一个为数字而不是. n = n.replace(/^\./g, '') // 保证只有出现一个.而没有多个. - n = n.replace(/\.{2,}/g, '.') - if (n == 0) { + n = n.replace(/\.{2,}/g, '.') + if (n == 0 || this.plateNumberList[lenth] == '') { uni.showToast({ title: '请输入正确的支付金额', duration: 2000, @@ -641,7 +638,8 @@ }); jweixin.chooseWXPay({ appId: self.appId, - timestamp: self.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 + timestamp: self + .timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 nonceStr: self.nonceStr, // 支付签名随机串,不长于 32 位 package: self.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***) signType: self.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5' diff --git a/pages/welcome/welcome.vue b/pages/welcome/welcome.vue index 89e716d..77c1161 100644 --- a/pages/welcome/welcome.vue +++ b/pages/welcome/welcome.vue @@ -60,7 +60,7 @@ url:'../index/index' }) } else { - this.jumpcdx(); + this.jumpWeb(); } }); },