Commit 5013b8f8 by huangzhi

feat: 支付成功跳转

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