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
2023-12-27 17:42:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5c09c8c7d554ce84192a8fd45040eca71fe108ce
5c09c8c7
1 parent
4df1f04f
模拟支付流程代码更新
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
23 deletions
src/api/index.js
src/components/payCard.vue
src/api/index.js
View file @
5c09c8c
/*
* @Date: 2023-12-22 10:29:37
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-12-27 1
4:08:2
1
* @LastEditTime: 2023-12-27 1
7:27:3
1
* @FilePath: /meihuaApp/src/api/index.js
* @Description: 文件描述
*/
...
...
@@ -16,6 +16,8 @@ const Api = {
GET_LIST
:
'/srv/?a=room_data&t=get_list'
,
GET_ROOM
:
'/srv/?a=room_data&t=get_room'
,
ADD_ORDER
:
'/srv/?a=room_data&t=add_order'
,
PAY
:
'/srv/?a=pay'
,
PAY_CHECK
:
'/srv/?a=pay_check'
,
}
/**
...
...
@@ -84,3 +86,17 @@ export const getRoomAPI = (params) => fn(fetch.get(Api.GET_ROOM, params));
* @returns
*/
export
const
addOrderAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
ADD_ORDER
,
params
));
/**
* @description: 支付
* @param order_id 订单ID
* @returns
*/
export
const
payAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
PAY
,
params
));
/**
* @description: 检查是否支付成功
* @param order_id 订单ID
* @returns
*/
export
const
payCheckAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
PAY_CHECK
,
params
));
...
...
src/components/payCard.vue
View file @
5c09c8c
<!--
* @Date: 2023-12-20 14:11:11
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-12-27 1
1:47:33
* @LastEditTime: 2023-12-27 1
7:37:35
* @FilePath: /meihuaApp/src/components/payCard.vue
* @Description: 文件描述
-->
...
...
@@ -22,6 +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'
/**
* 格式化时间
...
...
@@ -98,8 +99,8 @@ onUnmounted(() => {
timeId && clearInterval(timeId);
})
const goToPay = () => {
// TODO:
支付成功后的操作
const goToPay =
async
() => {
// TODO:
模拟代码
emit('close'); // 关闭支付弹框
//
Taro.showToast({
...
...
@@ -122,35 +123,45 @@ const goToPay = () => {
});
}
}, 1000);
// this.$parent.sdk.post('c/app/prepay', {
// id: this.params.id
// }).then(res => {
// if (res.data.ret === 'OK') {
// let pay = res.data.content.payargs;
// TODO:实际操作代码等待接口放上去
// // 获取支付参数
// const pay = await payAPI({ order_id: id.value });
// if (pay.code) {
// let pay = pay.data.payargs;
// // 触发微信支付操作
// wx.requestPayment({
// timeStamp: pay.timeStamp,
// nonceStr: pay.nonceStr,
// package: pay.package,
// signType: pay.signType,
// paySign: pay.paySign,
// success: (result) => {
// that.$parent.sdk.post('c/order/paySuccess', {
// id: that.params.id
// }).then(pRes => {
// if (pRes.data.ret === 'OK') {
// that.Toast('success', '感谢您的捐赠', 3000)
// } else {
// that.Toast('fail', pRes.data.err, 3000);
// 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=1'
// });
// }
// if (current_page === 'pages/detail/index') { // 订房确认页打开
// // 跳转订单成功页
// Taro.navigateTo({
// url: '/pages/payInfo/index',
// });
// }
// }
// }).catch(err => {
// console.error(err)
// })
// }
// });
// } else {
// this.Toast('fail', res.data.msg, 3000);
// }
// })
}
</script>
...
...
Please
register
or
login
to post a comment