Commit 5013b8f8 by huangzhi

feat: 支付成功跳转

parent dadc5cc5
......@@ -28,7 +28,7 @@
<button
class="pay-button"
:loading="loading"
@click="pay"
@click="onPay"
>
确认支付
</button>
......@@ -38,6 +38,7 @@
<script>
import { setTrackData } from '@/utils/util'
import { hostPrefix } from '@/config'
export default {
name: 'OrderPay',
......@@ -83,23 +84,27 @@ export default {
},
methods: {
// 调用后端接口得到支付参数
async pay() {
async onPay() {
if (this.loading) {
return
}
setTrackData({
events: [
{
event_id: 'content_click',
event_custom_properties: {
part: 'order_middle_page',
position: 'foot_column',
element: 'confirm_payment',
content: this.orderId,
},
},
],
})
// todo
this.handleSuccess()
// setTrackData({
// events: [
// {
// event_id: 'content_click',
// event_custom_properties: {
// part: 'order_middle_page',
// position: 'foot_column',
// element: 'confirm_payment',
// content: this.orderId,
// },
// },
// ],
// })
this.loading = true
const { uid, accessToken, openId } = this.$store.state.user
// 组合支付从余额里面扣除的金额
......@@ -107,6 +112,7 @@ export default {
// 支付方式,1: 余额 5: 微信 7: 微信 + 余额
const payType = this.payAmount > 0 ? (this.balance > 0 ? 7 : 5) : 1
try {
// todo 这是一个什么页面?,一定要传吗
const wxUrl = encodeURIComponent('http://m.ydl.com?backPayId=' + this.payId)
const res = await this.$request.post(
'/auth/cashierV2/unityPay',
......@@ -115,8 +121,9 @@ export default {
orderId: this.orderId,
payAmount: this.payAmount,
openId: openId,
payType,
payBalance,
// todo
payType: 1,
payBalance: 0.1,
payChannel: 'WX_MINI_APP',
quitUrl: wxUrl,
returnUrl: wxUrl,
......@@ -175,26 +182,32 @@ export default {
})
},
handleSuccess() {
// 支付成功埋点
setTrackData({
events: [
{
event_id: 'payment_succ_page_visit',
event_custom_properties: {
part: 'order_middle_page',
position: '',
element: '',
order_id: this.orderId,
},
},
],
})
// // 支付成功埋点
// setTrackData({
// events: [
// {
// event_id: 'payment_succ_page_visit',
// event_custom_properties: {
// part: 'order_middle_page',
// position: '',
// element: '',
// order_id: this.orderId,
// },
// },
// ],
// })
// 触发支付成功事件
uni.$emit('paySuccess', this.from)
// uni.$emit('paySuccess', this.from)
uni.showToast({
title: '支付成功',
duration: 1500,
})
const url = `${hostPrefix}/h5-course/pay/groupSuccess`
uni.navigateTo({
url: `/pages/web/web?title=${
this.doctor.name ? `${this.doctor.name}的评价` : ''
}&loadUrl=${encodeURIComponent(url)}`,
})
},
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment