Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
meihua-island-book
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-01-17 16:36:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd454e3a05af35739642bfa940ce7e0a14edda61
cd454e3a
1 parent
abca4bca
支付金额为0时逻辑调整
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
37 deletions
src/api/index.js
src/components/payCard.vue
src/api/index.js
View file @
cd454e3
/*
* @Date: 2023-12-22 10:29:37
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 202
3-12-28 09:55:37
* @LastEditTime: 202
4-01-17 15:56:50
* @FilePath: /meihuaApp/src/api/index.js
* @Description: 文件描述
*/
...
...
@@ -20,6 +20,7 @@ const Api = {
ORDER_CANCEL
:
'/srv/?a=room_data&t=order_cancel'
,
PAY
:
'/srv/?a=pay'
,
PAY_CHECK
:
'/srv/?a=pay_check'
,
ORDER_SUCCESS
:
'/srv/?a=room_data&t=order_success'
,
}
/**
...
...
@@ -118,3 +119,10 @@ export const myOrderAPI = (params) => fn(fetch.get(Api.MY_ORDER, params));
* @returns
*/
export
const
orderCancelAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
ORDER_CANCEL
,
params
));
/**
* @description: 订单成功
* @param id
* @returns
*/
export
const
orderSuccessAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
ORDER_SUCCESS
,
params
));
...
...
src/components/payCard.vue
View file @
cd454e3
<!--
* @Date: 2023-12-20 14:11:11
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 202
3-12-29 17:59:42
* @LastEditTime: 202
4-01-17 16:00:33
* @FilePath: /meihuaApp/src/components/payCard.vue
* @Description: 文件描述
-->
...
...
@@ -22,7 +22,7 @@
import Taro from '@tarojs/taro'
import { ref, watch, onMounted, onUnmounted } from 'vue'
import { getCurrentPageUrl } from "@/utils/weapp";
import { payAPI, payCheckAPI } from '@/api/index'
import { payAPI, payCheckAPI
, orderSuccessAPI
} from '@/api/index'
/**
* 格式化时间
...
...
@@ -90,43 +90,62 @@ onUnmounted(() => {
})
const goToPay = async () => {
// 获取支付参数
const { code, data } = await payAPI({ order_id: id.value });
if (code) {
let pay = data;
// 触发微信支付操作
wx.requestPayment({
timeStamp: pay.timeStamp,
nonceStr: pay.nonceStr,
package: pay.package,
signType: pay.signType,
paySign: pay.paySign,
success: async (result) => {
emit('close'); // 关闭支付弹框
Taro.showToast({
title: '支付成功',
icon: 'success',
duration: 1000
});
// 支付成功后,调用检查接口
const pay_success = await payCheckAPI({ order_id: id.value });
if (pay_success.code) {
let current_page = getCurrentPageUrl();
if (current_page === 'pages/my/index') { // 我的页面打开
// 刷新当前页面
Taro.reLaunch({
url: '/pages/my/index?tab_index=5'
});
}
if (current_page === 'pages/detail/index') { // 订房确认页打开
// 跳转订单成功页
Taro.navigateTo({
url: '/pages/payInfo/index',
});
if (price.value > 0) { // 金额大于0
// 获取支付参数
const { code, data } = await payAPI({ order_id: id.value });
if (code) {
let pay = data;
// 触发微信支付操作
wx.requestPayment({
timeStamp: pay.timeStamp,
nonceStr: pay.nonceStr,
package: pay.package,
signType: pay.signType,
paySign: pay.paySign,
success: async (result) => {
emit('close'); // 关闭支付弹框
Taro.showToast({
title: '支付成功',
icon: 'success',
duration: 1000
});
// 支付成功后,调用检查接口
const pay_success = await payCheckAPI({ order_id: id.value });
if (pay_success.code) {
let current_page = getCurrentPageUrl();
if (current_page === 'pages/my/index') { // 我的页面打开
// 刷新当前页面
Taro.reLaunch({
url: '/pages/my/index?tab_index=5'
});
}
if (current_page === 'pages/detail/index') { // 订房确认页打开
// 跳转订单成功页
Taro.navigateTo({
url: '/pages/payInfo/index',
});
}
}
}
});
}
} else { // 金额等于0
const { code, data } = await orderSuccessAPI({ id: id.value });
if (code) {
let current_page = getCurrentPageUrl();
if (current_page === 'pages/my/index' || current_page === 'pages/confirm/index') { // 我的页面打开获取确认订单页价格为零
// 刷新当前页面
Taro.reLaunch({
url: '/pages/my/index?tab_index=5'
});
}
});
if (current_page === 'pages/detail/index') { // 订房确认页打开
// 跳转订单成功页
Taro.navigateTo({
url: '/pages/payInfo/index',
});
}
}
}
}
</script>
...
...
Please
register
or
login
to post a comment