From 3acefe0832e1032e750c5087412220a3282fc4b8 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Wed, 18 Jun 2025 20:07:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0H5=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=8A=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增H5环境专属页面promotionH5.vue用于邀请好友功能 - 优化支付逻辑,区分微信小程序和H5环境的支付方式 - 重构wxPay方法返回Promise以支持async/await - 修复表单组件样式问题及地址选择逻辑 - 添加H5环境URL参数解析功能 - 优化canvas绘制逻辑和图片保存体验 --- components/couponList/couponList.vue | 5 + main.js | 19 + pages.json | 3 + pages/index/center.vue | 8 + pages_order/components/formTextarea.vue | 35 +- pages_order/mine/cooperation.vue | 764 ++++++++++++++++---------------- pages_order/mine/partner.vue | 2 +- pages_order/mine/promotion.vue | 108 ++--- pages_order/mine/promotionH5.vue | 563 +++++++++++++++++++++++ pages_order/order/createOrder.vue | 10 +- store/store.js | 5 +- utils/pay.js | 68 +-- 12 files changed, 1092 insertions(+), 498 deletions(-) create mode 100644 pages_order/mine/promotionH5.vue diff --git a/components/couponList/couponList.vue b/components/couponList/couponList.vue index 4dff115..9848fb7 100644 --- a/components/couponList/couponList.vue +++ b/components/couponList/couponList.vue @@ -53,6 +53,11 @@ this.getCouponList() } }, + // #ifndef H5 + mounted() { + this.getCouponList() + }, + // #endif methods: { select(item) { this.$emit('select', item) diff --git a/main.js b/main.js index f971a7f..6f2140e 100644 --- a/main.js +++ b/main.js @@ -25,6 +25,25 @@ import navbar from '@/components/base/navbar.vue' Vue.component('configPopup',configPopup) Vue.component('navbar',navbar) + +// #ifdef H5 +//获取url中参数的方法 +function GetQueryString(name) { + var url = window.location.href; + try { + var cs = url.split('?')[1]; //获取?之后的参数字符串 + var cs_arr = cs.split('&'); //参数字符串分割为数组 + for (var i = 0; i < cs_arr.length; i++) { //遍历数组,拿到json对象 + if (cs_arr[i].split('=')[0] == name) { + sessionStorage.setItem('vid',cs_arr[i].split('=')[1]); + } + } + }catch(e){} +} +GetQueryString('vid'); +// #endif + + const app = new Vue({ ...App, store, diff --git a/pages.json b/pages.json index 5642281..803386b 100644 --- a/pages.json +++ b/pages.json @@ -76,6 +76,9 @@ { "path": "mine/promotion" }, + { + "path": "mine/promotionH5" + }, { "path": "mine/coupon" }, diff --git a/pages/index/center.vue b/pages/index/center.vue index 3fdabd7..2116500 100644 --- a/pages/index/center.vue +++ b/pages/index/center.vue @@ -97,7 +97,15 @@ 我的团队 + + + + + + + + 邀请好友 diff --git a/pages_order/components/formTextarea.vue b/pages_order/components/formTextarea.vue index 44ace3d..97f69d5 100644 --- a/pages_order/components/formTextarea.vue +++ b/pages_order/components/formTextarea.vue @@ -1,40 +1,29 @@ \ No newline at end of file diff --git a/pages_order/mine/partner.vue b/pages_order/mine/partner.vue index 658b964..fdc82f2 100644 --- a/pages_order/mine/partner.vue +++ b/pages_order/mine/partner.vue @@ -25,7 +25,7 @@ - 直推用户{{ `(${total}人)` }} + 直推用户{{ `(${total || 0}人)` }} diff --git a/pages_order/mine/promotion.vue b/pages_order/mine/promotion.vue index e81943f..ec30224 100644 --- a/pages_order/mine/promotion.vue +++ b/pages_order/mine/promotion.vue @@ -1,14 +1,14 @@ \ No newline at end of file diff --git a/pages_order/order/createOrder.vue b/pages_order/order/createOrder.vue index dc72d95..1ebd2c7 100644 --- a/pages_order/order/createOrder.vue +++ b/pages_order/order/createOrder.vue @@ -172,7 +172,15 @@ } else { // 微信支付 console.log('--发起支付接口回调', res) + + // #ifdef MP-WEIXIN await uni.requestPaymentWxPay(res) + // #endif + + + // #ifdef H5 + await this.$wxPay(res) + // #endif } uni.showToast({ @@ -181,7 +189,7 @@ }) setTimeout(uni.redirectTo, 700, { - url: '/pages/index/order' + url: '/pages/index/order' }) } catch (err) { } diff --git a/store/store.js b/store/store.js index 9fb10a0..eb2c94c 100644 --- a/store/store.js +++ b/store/store.js @@ -126,8 +126,9 @@ const store = new Vuex.Store({ Vue.set(state, 'userInfo', res.result) if (!state.userInfo.nickName || - !state.userInfo.headImage || - !state.userInfo.phone + !state.userInfo.headImage + // || + // !state.userInfo.phone ) { uni.showModal({ title: '申请获取您的信息!', diff --git a/utils/pay.js b/utils/pay.js index a41698d..fd6fbcc 100644 --- a/utils/pay.js +++ b/utils/pay.js @@ -1,4 +1,3 @@ - // #ifdef H5 import jWeixin from './lib/jweixin-module.js' // #endif @@ -6,42 +5,43 @@ import jWeixin from './lib/jweixin-module.js' /** * 调用微信支付 * @param {Object} res - 支付参数对象,包含appId、timeStamp、nonceStr等必要信息 - * @param {Function} successCallback - 支付成功的回调函数 - * @param {Function} failCallback - 支付失败的回调函数 - * @param {Function} optionCallback - 配置失败的回调函数 + * @returns {Promise} - 返回Promise对象,resolve表示支付成功,reject表示支付失败 */ -export function wxPay(res, successCallback, failCallback, optionCallback) { - // 配置微信JSSDK - jWeixin.config({ - debug: false, - appId: res.result.appId, //必填,公众号的唯一标识 - jsApiList: ['chooseWXPay'] //必填,需要使用的JS接口列表 - }); +export function wxPay(res) { + return new Promise((resolve, reject) => { + // 配置微信JSSDK + jWeixin.config({ + debug: false, + appId: res.result.appId, //必填,公众号的唯一标识 + jsApiList: ['chooseWXPay'] //必填,需要使用的JS接口列表 + }); - // JSSDK配置成功后的回调 - jWeixin.ready(function() { - // 调用微信支付接口 - jWeixin.chooseWXPay({ - appId: res.result.appId, - timestamp: res.result.timeStamp, // 支付签名时间戳 - nonceStr: res.result.nonceStr, // 支付签名随机串 - package: res.result.packageValue, // 统一支付接口返回的prepay_id参数值 - signType: res.result.signType, // 签名类型,默认为MD5 - paySign: res.result.paySign, // 支付签名 - success: function() { - successCallback && successCallback(); - }, - fail: function(error) { - failCallback && failCallback(); - }, - cancel : function(){ - failCallback && failCallback(); - } + // JSSDK配置成功后的回调 + jWeixin.ready(function() { + // 调用微信支付接口 + jWeixin.chooseWXPay({ + appId: res.result.appId, + timestamp: res.result.timeStamp, // 支付签名时间戳 + nonceStr: res.result.nonceStr, // 支付签名随机串 + package: res.result.packageValue, // 统一支付接口返回的prepay_id参数值 + signType: res.result.signType, // 签名类型,默认为MD5 + paySign: res.result.paySign, // 支付签名 + success: function(result) { + resolve(result); + }, + fail: function(error) { + reject(error); + }, + cancel: function(error) { + reject({ type: 'cancel', ...error }); + } + }); }); - }); - // JSSDK配置失败处理 - jWeixin.error(function(res) { - optionCallback && optionCallback() + // JSSDK配置失败处理 + jWeixin.error(function(error) { + reject({ type: 'config_error', ...error }); + }); }); } +