hookehuyr

支付接口联调

1 <!-- 1 <!--
2 * @Date: 2023-12-20 14:11:11 2 * @Date: 2023-12-20 14:11:11
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-28 13:40:59 4 + * @LastEditTime: 2023-12-29 16:14:15
5 * @FilePath: /meihuaApp/src/components/payCard.vue 5 * @FilePath: /meihuaApp/src/components/payCard.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -98,15 +98,27 @@ onUnmounted(() => { ...@@ -98,15 +98,27 @@ onUnmounted(() => {
98 }) 98 })
99 99
100 const goToPay = async () => { 100 const goToPay = async () => {
101 - // TODO:模拟代码 101 + // 获取支付参数
102 + const { code, data } = await payAPI({ order_id: id.value });
103 + if (code) {
104 + let pay = data;
105 + // 触发微信支付操作
106 + wx.requestPayment({
107 + timeStamp: pay.timeStamp,
108 + nonceStr: pay.nonceStr,
109 + package: pay.package,
110 + signType: pay.signType,
111 + paySign: pay.paySign,
112 + success: async (result) => {
102 emit('close'); // 关闭支付弹框 113 emit('close'); // 关闭支付弹框
103 - //
104 Taro.showToast({ 114 Taro.showToast({
105 title: '支付成功', 115 title: '支付成功',
106 icon: 'success', 116 icon: 'success',
107 duration: 1000 117 duration: 1000
108 }); 118 });
109 - setTimeout(() => { 119 + // 支付成功后,调用检查接口
120 + const pay_success = await payCheckAPI({ order_id: id.value });
121 + if (pay_success.code) {
110 let current_page = getCurrentPageUrl(); 122 let current_page = getCurrentPageUrl();
111 if (current_page === 'pages/my/index') { // 我的页面打开 123 if (current_page === 'pages/my/index') { // 我的页面打开
112 // 刷新当前页面 124 // 刷新当前页面
...@@ -120,46 +132,10 @@ const goToPay = async () => { ...@@ -120,46 +132,10 @@ const goToPay = async () => {
120 url: '/pages/payInfo/index', 132 url: '/pages/payInfo/index',
121 }); 133 });
122 } 134 }
123 - }, 1000); 135 + }
124 - // TODO:实际操作代码等待接口放上去 136 + }
125 - // // 获取支付参数 137 + });
126 - // const pay = await payAPI({ order_id: id.value }); 138 + }
127 - // if (pay.code) {
128 - // let pay = pay.data.payargs;
129 - // // 触发微信支付操作
130 - // wx.requestPayment({
131 - // timeStamp: pay.timeStamp,
132 - // nonceStr: pay.nonceStr,
133 - // package: pay.package,
134 - // signType: pay.signType,
135 - // paySign: pay.paySign,
136 - // success: async (result) => {
137 - // emit('close'); // 关闭支付弹框
138 - // Taro.showToast({
139 - // title: '支付成功',
140 - // icon: 'success',
141 - // duration: 1000
142 - // });
143 - // // 支付成功后,调用检查接口
144 - // const pay_success = await payCheckAPI({ order_id: id.value });
145 - // if (pay_success.code) {
146 - // let current_page = getCurrentPageUrl();
147 - // if (current_page === 'pages/my/index') { // 我的页面打开
148 - // // 刷新当前页面
149 - // Taro.reLaunch({
150 - // url: '/pages/my/index?tab_index=5'
151 - // });
152 - // }
153 - // if (current_page === 'pages/detail/index') { // 订房确认页打开
154 - // // 跳转订单成功页
155 - // Taro.navigateTo({
156 - // url: '/pages/payInfo/index',
157 - // });
158 - // }
159 - // }
160 - // }
161 - // });
162 - // }
163 } 139 }
164 </script> 140 </script>
165 141
......