From d51656a3351743711e7f09b5c882ab17cb8ab4cb Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Thu, 18 Jan 2024 11:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E6=94=AF=E6=8C=81=E5=9C=A8=E7=BA=BF=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E8=A1=A5=E9=BD=90=E5=B7=AE=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 2 +- pages/annex/vip_center/index.vue | 14 +- pages/user/index.vue | 2 +- pages/users/online_payment/exchange/index.vue | 364 ++++++++++++++++-- pages/users/online_payment/payment/index.vue | 8 +- pages/users/online_payment/site/index.vue | 67 +++- 6 files changed, 403 insertions(+), 54 deletions(-) diff --git a/pages.json b/pages.json index a04d865..3789f90 100644 --- a/pages.json +++ b/pages.json @@ -549,7 +549,7 @@ { "path": "online_payment/site/index", "style": { - "navigationBarTitleText": "兑换管理" + "navigationBarTitleText": "酒道馆管理" } }, { diff --git a/pages/annex/vip_center/index.vue b/pages/annex/vip_center/index.vue index 52c7c41..dfb889e 100644 --- a/pages/annex/vip_center/index.vue +++ b/pages/annex/vip_center/index.vue @@ -50,7 +50,7 @@ @@ -213,7 +213,7 @@ } }, watch: { - + }, computed: mapGetters(['isLogin','uid']), onLoad(options) { @@ -231,7 +231,7 @@ if(options.spread) spread(options.spread, this.isLogin) }, onShow(){ - + }, onReachBottom() { this.groomList(); @@ -260,7 +260,7 @@ if(['/pages/goods_cate/goods_cate','/pages/order_addcart/order_addcart','/pages/user/index','/pages/plant_grass/index'].indexOf(url) == -1){ uni.navigateTo({ url:url - }) + }) }else{ uni.switchTab({ url:url @@ -429,7 +429,7 @@ that.payClose(); uni.navigateTo({ url: '/pages/order_pay_back/index?keyCode='+callback_key+'&url='+jsConfig+'&type=11', - }) + }) return; break; // #ifndef MP @@ -598,7 +598,7 @@ uni.navigateTo({ url: `/pages/goods_details/index?id=${id}` }); - }, + }, groomList() { if (this.finished || this.loading) { return; @@ -613,7 +613,7 @@ this.loading = false; this.page += 1; }).catch(err => { - + }); }, }, diff --git a/pages/user/index.vue b/pages/user/index.vue index 1ab1d75..3d9aaf6 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -97,7 +97,7 @@ - + diff --git a/pages/users/online_payment/exchange/index.vue b/pages/users/online_payment/exchange/index.vue index 3df0a2f..be0b42e 100644 --- a/pages/users/online_payment/exchange/index.vue +++ b/pages/users/online_payment/exchange/index.vue @@ -20,14 +20,14 @@ - + @@ -35,7 +35,8 @@ 提货商品总价值 ¥ - + + 剩余酒卡额度 @@ -54,11 +55,40 @@ {{ pay_info.diff_money }} - 应补现金 + 实际支付差价 {{ pay_info.diff_money_pay }} + + + 支付方式 + + + + + + + + 确认兑换 确认兑换 @@ -138,6 +168,7 @@ import {mapGetters} from "vuex"; import authorize from '@/components/Authorize'; import emptyPage from '@/components/emptyPage.vue'; import spread from "@/libs/spread"; +import {getUserInfo} from "@/api/user"; const app = getApp(); export default { @@ -163,6 +194,7 @@ export default { staff_info: {}, staff_list: {}, default_staff_id: 0, + default_total_money: 0, // 消费用户 consume_info: {}, consume_list: {}, @@ -172,22 +204,69 @@ export default { }, // 提交信息 pay_info: { + // 兑换信息 total_money: 0.00, use_integral: 0.00, diff_money: 0.00, diff_money_pay: 0.00, + // 支付信息 + pay_type: 'weixin', + // #ifdef H5 + return_url: 'http://' + window.location.host + '/pages/users/order_list/index', + // #endif }, + //支付方式 + pay_list: [ + { + "name": "微信支付", + "icon": "icon-weixin2", + value: 'weixin', + title: '微信快捷支付', + payStatus: 1, + }, + { + name: "支付宝支付", + icon: "icon-icon34", + // #ifdef H5 || APP-PLUS + value: 'alipay', + // #endif + // #ifdef MP + value: 'alipayQr', + // #endif + title: '支付宝支付', + payStatus: this.$store.getters.globalData.alipay_open + }, + { + "name": "余额支付", + "icon": "icon-icon-test", + value: 'balance', + title: '可用余额:', + payStatus: this.$store.getters.globalData.yue_pay_status, + }, + { + "name": "线下支付", + "icon": "icon-yinhangqia", + value: 'offline', + title: '线下支付', + payStatus: 2, + }, + ], + now_money: 0, }; }, computed: { - ...mapGetters(['isLogin', 'userInfo', 'viewColor']) + ...mapGetters(['isLogin', 'uid', 'userInfo', 'viewColor']) }, onLoad(options) { if(options.scene){ + // console.log('转换前参数:',options.scene) + // 由于微信长度限制问题 suid=staff_id;pid=point_id;tmy=total_money var scene = this.$util.getUrlParams(decodeURIComponent(options.scene)); - this.point_search.default_point_id = scene.point_id || 0; + console.log("接收参数",scene) + this.point_search.default_point_id = scene.pid || 0; this.consume_search.default_consume_id = scene.consume_uid || 0; - this.default_staff_id = scene.staff_uid || 0; + this.default_staff_id = scene.suid || 0; + this.default_total_money = Number(scene.tmy) || 0; // 判断:如果存在消费用户 则当前登录用户为操作员 if(Number(this.consume_search.default_consume_id) > 0){ this.default_staff_id = this.userInfo.uid || 0; @@ -211,7 +290,7 @@ export default { 'pay_info.total_money': { handler(val) { let totalMoney = this.pay_info.total_money.toFixed(2); - console.log('总价值', totalMoney) + // console.log('总价值', totalMoney) // 判断酒卡额度是否足够 if(Number(totalMoney) > Number(this.pointUserInfo.available)){ this.$util.Tips({ @@ -221,6 +300,7 @@ export default { return false; } // 计算使用的相关信息 + // console.log('可用积分',Number(this.pointUserInfo.available_integral)) if(Number(totalMoney) > Number(this.pointUserInfo.available_integral)){ // 积分不足 this.pay_info.use_integral = Number(this.pointUserInfo.available_integral); @@ -261,6 +341,10 @@ export default { // 提货点选择初始化 let pointId = _this.point_info.id || 0; if(pointId <= 0) _this.showPointPopup(); + // 获取用户信息 + getUserInfo().then(res => { + _this.now_money = res.data.now_money + }); }, // 获取用户持有信息 getUserInfo(){ @@ -271,6 +355,8 @@ export default { pointUserInfo(params) .then(res => { _this.pointUserInfo = res.data || {}; + // 是否存在默认价值 + _this.pay_info.total_money = Number(_this.default_total_money) || 0; }) .catch(err => { this.$util.Tips({ @@ -354,9 +440,10 @@ export default { }, // 兑换用户选择 - 显示弹框 showConsumePopup(){ - if(Object.keys(this.consume_list).length <= 0) this.getConsumeList(); + // todo 逻辑修改,不在选择消费用户 + // if(Object.keys(this.consume_list).length <= 0) this.getConsumeList(); // 不存在默认选中 显示弹框 - if(Number(this.consume_search.default_consume_id) <= 0) this.$refs.selectedConsume.open('center'); + // if(Number(this.consume_search.default_consume_id) <= 0) this.$refs.selectedConsume.open('center'); }, // 兑换用户选择 - 隐藏弹框 consumeClosePopup(){ @@ -394,26 +481,246 @@ export default { let payInfo = Object.assign({},_this.pay_info); payInfo.point_id = this.point_info.id; payInfo.staff_uid = this.staff_info.uid; - payInfo.consume_uid = this.consume_info.uid; - + // payInfo.consume_uid = this.consume_info.uid; + // 订单支付相关内容 + console.log('支付类型',payInfo.pay_type) + if (payInfo.pay_type == 'weixin') { + // #ifdef H5 + payInfo.pay_type = _this.$wechat.isWeixin() ? 'weixin' : 'h5' + // #endif + // #ifdef MP + payInfo.pay_type = 'routine' + // #endif + // #ifdef APP-PLUS + payInfo.pay_type = 'weixin' + // #endif + } + // 发起请求 uni.showLoading({ title: '处理中...', mask: true }); - confirmExchange(payInfo) - .then(res => { - uni.hideLoading(); - this.$util.Tips({ - title: '操作成功!', - icon: 'success' - },{tab:1,url:'/pages/user/index'}); - }) - .catch(err => { - uni.hideLoading(); - this.$util.Tips({ - title: err - }); - }); + confirmExchange(payInfo).then(res => { + uni.hideLoading(); + if(payInfo.diff_money_pay > 0){ + let status = res.data.status, + orderId = res.data.result.order_id, + callback_key = res.data.result.pay_key, + jsConfig = res.data.result.config, + goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.message; + _this.orderPay = true; + uni.hideLoading(); + switch (status) { + case 'ORDER_EXIST': + case 'EXTEND_ORDER': + case 'PAY_ERROR': + case 'error': + return _this.$util.Tips({ + title: res.message + }, { + tab: 5, + url: goPages + }); + break; + case 'success': + return _this.$util.Tips({ + title: res.message, + icon: 'success' + }, { + tab: 5, + url: goPages + }); + break; + case 'alipay': + case "alipayQr": + uni.navigateTo({ + url: '/pages/order_pay_back/index?keyCode=' + callback_key + '&url=' + + jsConfig + }) + return; + break; + // #ifndef MP + case "wechat": + case "weixin": + case "weixinApp": + jsConfig.timeStamp = jsConfig.timestamp; + // #ifndef APP-PLUS + this.$wechat.pay(jsConfig).then(res => { + return _this.$util.Tips({ + title: res.message, + icon: 'success' + }, { + tab: 4, + url: goPages + }); + }).catch(res => { + if (res.errMsg == 'chooseWXPay:cancel') return _this.$util.Tips({ + title: '取消支付' + }, { + tab: 5, + url: goPages + '&status=0' + }); + }) + // #endif + // #ifdef APP-PLUS + let mp_pay_name='' + if(uni.requestOrderPayment){ + mp_pay_name='requestOrderPayment' + }else{ + mp_pay_name='requestPayment' + } + uni[mp_pay_name]({ + provider: 'wxpay', + orderInfo: jsConfig, + success: (e) => { + let url = '/pages/order_pay_status/index?order_id=' + orderId + + '&msg=支付成功'; + return _this.$util.Tips({ + title: '支付成功', + icon: 'success' + }, { + tab: 4, + url: url + }); + }, + fail: (e) => { + let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付'; + return _this.$util.Tips({ + title: '取消支付', + }, { + tab: 4, + url: url + }); + }, + complete: () => { + let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付'; + return _this.$util.Tips({ + title: '', + }, { + tab: 4, + url: url + }); + }, + }); + // #endif + break; + // #endif + // #ifdef MP + case "routine": + jsConfig.timeStamp = jsConfig.timestamp; + _this.toPay = true; + let mp_pay_name='' + if(uni.requestOrderPayment){ + mp_pay_name='requestOrderPayment' + }else{ + mp_pay_name='requestPayment' + } + uni[mp_pay_name]({ + ...jsConfig, + success: function(res) { + uni.hideLoading(); + return _this.$util.Tips({ + title: '支付成功', + icon: 'success' + }, { + tab: 5, + url: goPages + }); + }, + fail: function(e) { + let pages = '/pages/order_pay_status/index?order_id=' + + orderId + '&msg=取消支付' + return _this.$util.Tips({ + title: '取消支付' + }, { + tab: 5, + url: pages + '&status=0' + }); + }, + }) + break; + // #endif + case "balance": + //余额 + return _this.$util.Tips({ + title: res.msg + }, { + tab: 5, + url: goPages + '&status=1' + }); + break; + // #ifdef H5 + case 'h5': + let host = window.location.protocol + "//" + window.location.host; + let url = `${host}/pages/order_pay_status/index?order_id=${orderId}&msg=${res.message}` + let eUrl = encodeURIComponent(url) + let jsurl = jsConfig.mweb_url || jsConfig.h5_url + let locations = `${jsurl}&redirect_url=${eUrl}` + setTimeout(() => { + location.href = locations; + }, 100); + break; + // #endif + // #ifdef APP-PLUS + case 'alipayApp': + uni.requestPayment({ + provider: 'alipay', + orderInfo: jsConfig, + success: (e) => { + return _this.$util.Tips({ + title: '支付成功', + icon: 'success' + }, { + tab: 5, + url: goPages + }); + }, + fail: (e) => { + let pages = '/pages/order_pay_status/index?order_id=' + + orderId + '&msg=支付失败' + return _this.$util.Tips({ + title: '支付失败' + }, { + tab: 5, + url: pages + }); + }, + complete: () => { + uni.hideLoading(); + let pages = '/pages/order_pay_status/index?order_id=' + + orderId + '&msg=取消支付' + return _this.$util.Tips({ + title: '' + }, { + tab: 5, + url: pages + }); + }, + }); + break; + // #endif + default: + let pages = '/pages/order_pay_status/index?order_id=' + + orderId + '&msg=取消支付' + return _this.$util.Tips({ + title: '取消支付' + }, { + tab: 5, + url: pages + '&status=0' + }); + } + }else{ + this.$util.Tips({ + title: '操作成功!', + icon: 'success' + },{tab:1,url:'/pages/user/index'}); + } + }).catch(err => { + uni.hideLoading(); + this.$util.Tips({ + title: err + }); + }); }, // 跳转 goMenuPage(url) { @@ -426,6 +733,11 @@ export default { this.openAuto() } }, + // 修改支付方式 + changePayType(e){ + this.pay_info.pay_type = e.detail.value || e.target.value; + }, + }, // #ifdef MP // 分享给好友 diff --git a/pages/users/online_payment/payment/index.vue b/pages/users/online_payment/payment/index.vue index 69554e7..a8fa246 100644 --- a/pages/users/online_payment/payment/index.vue +++ b/pages/users/online_payment/payment/index.vue @@ -37,7 +37,7 @@ {{item.title}} - {{userInfo.now_money}} + {{now_money}} @@ -91,6 +91,7 @@ import {mapGetters} from "vuex"; import authorize from '@/components/Authorize'; import emptyPage from '@/components/emptyPage.vue'; import spread from "@/libs/spread"; +import {getUserInfo} from "@/api/user"; const app = getApp(); export default { @@ -153,6 +154,7 @@ export default { payStatus: 2, }, ], + now_money: 0, }; }, @@ -191,6 +193,10 @@ export default { // 门店选择初始化 let merId = _this.mer_info.mer_id || 0; if(merId <= 0) _this.merShowPopup(); + // 获取用户信息 + getUserInfo().then(res => { + _this.now_money = res.data.now_money + }); }, // 门店选择 - 显示弹框 merShowPopup(){ diff --git a/pages/users/online_payment/site/index.vue b/pages/users/online_payment/site/index.vue index 131d691..308c873 100644 --- a/pages/users/online_payment/site/index.vue +++ b/pages/users/online_payment/site/index.vue @@ -4,7 +4,7 @@ - 站点管理 + 酒道馆 兑换记录 @@ -14,7 +14,8 @@ {{item.title}} {{item.address}} - + 兑换码 + 已停用 @@ -42,7 +43,7 @@ - 关闭 + 关闭 @@ -138,23 +139,48 @@ export default { // 显示店铺兑换二维码 showQrCode(item){ let _this = this; - let params = { - point_id: item.id - }; - getSiteQrCode(params).then(res => { - if(res.status == 200){ - _this.qrCode = res.data.qr_code || '' - _this.$refs.qrCodePopup.open('center'); + // 点击按钮触发弹框输入框的显示 + uni.showModal({ + title: '兑换商品金额', // 弹框标题 + content: '', + editable: true,//是否显示输入框 + placeholderText: '请输入用户兑换商品的总金额',//输入框提示内容 + showCancel: true, // 是否显示取消按钮 + cancelText: '取消', // 取消按钮文字 + confirmText: '确定', // 确认按钮文字 + success: (res) => { + console.log(res) + if (res.confirm && Number(res.content) > 0) { + let inputValue = Number(res.content); + let params = { + point_id: item.id, + total_money: inputValue, + }; + getSiteQrCode(params).then(res => { + if (res.status == 200) { + _this.qrCode = res.data.qr_code || '' + _this.$refs.qrCodePopup.open('center'); + } + }).catch(err => { + this.$util.Tips({ + title: err + }); + }); + } else if (res.cancel) { + console.log('用户点击了取消'); + } } - }).catch(err => { - this.$util.Tips({ - title: err - }); - }); - - - + }) }, + // 关闭二维码 + closeQrCode(){ + this.$refs.qrCodePopup.close(); + } + + + + + } } @@ -238,6 +264,11 @@ export default { width: 120rpx; text-align: center; } + .not-btn{ + background-color: #909399!important; + border-color: #909399!important; + color: #fff!important; + } } .site-box:last-child{ border-bottom: 0!important;