完善支付逻辑
This commit is contained in:
parent
b0be4002d4
commit
0892a4771e
@ -27,10 +27,10 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import { jzGetQkExpiredTime, jzXkCancelApi } from "@/api/base/server";
|
import { jzGetQkExpiredTime, jzXkCancelApi, jzXkJfCxjApi } from "@/api/base/server";
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
import { useDataStore } from "@/store/modules/data";
|
import { useDataStore } from "@/store/modules/data";
|
||||||
const { getCurXs, getUser, initWs, setWsCallback } = useUserStore();
|
const { getCurXs, initWs, setWsCallback } = useUserStore();
|
||||||
const { getData } = useDataStore();
|
const { getData } = useDataStore();
|
||||||
|
|
||||||
const payUrl = ref("");
|
const payUrl = ref("");
|
||||||
@ -108,8 +108,6 @@ const cancelRegistration = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onLoad(async (options: any) => {
|
onLoad(async (options: any) => {
|
||||||
if (options.payUrl) {
|
if (options.payUrl) {
|
||||||
payUrl.value = decodeURIComponent(options.payUrl);
|
payUrl.value = decodeURIComponent(options.payUrl);
|
||||||
@ -120,9 +118,39 @@ onLoad(async (options: any) => {
|
|||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '缺少支付地址', icon: 'none' })
|
uni.showToast({ title: '缺少支付地址', icon: 'none' })
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
goBack();
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
const res = await jzXkJfCxjApi({
|
||||||
|
orderNumber: getData.orderNumber,
|
||||||
|
xsId: getData.xsId,
|
||||||
|
xkId: getData.xkId
|
||||||
|
});
|
||||||
|
// 订单状态,01-交易中,02-交易成功,03-交易失败,04-交易关闭
|
||||||
|
const { orderStat, respCode } = res.result;
|
||||||
|
if ("0000000000" === respCode) {
|
||||||
|
if ("02" === orderStat) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pages/base/course-selection/payment-success",
|
||||||
|
});
|
||||||
|
} else if ("03" === orderStat) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pages/base/course-selection/payment-fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: "订单查询失败",
|
||||||
|
icon: "error",
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
goBack();
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("订单查询失败", error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ import { jzGetQkExpiredTime, jzXkCancelApi, jzXkFqJfjApi } from "@/api/base/serv
|
|||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
import { useDataStore } from "@/store/modules/data";
|
import { useDataStore } from "@/store/modules/data";
|
||||||
const { getCurXs, getUser } = useUserStore();
|
const { getCurXs, getUser } = useUserStore();
|
||||||
const { getData } = useDataStore();
|
const { getData, setData } = useDataStore();
|
||||||
|
|
||||||
// 学生信息
|
// 学生信息
|
||||||
const curXs = computed(() => getCurXs);
|
const curXs = computed(() => getCurXs);
|
||||||
@ -131,8 +131,12 @@ const payNow = async () => {
|
|||||||
openId: getUser.openId,
|
openId: getUser.openId,
|
||||||
});
|
});
|
||||||
if (res.resultCode === 1 && res.result) {
|
if (res.resultCode === 1 && res.result) {
|
||||||
|
setData({
|
||||||
|
...getData,
|
||||||
|
...res.result
|
||||||
|
});
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/base/course-selection/pay-wait?payUrl=${encodeURIComponent(res.result)}`
|
url: `/pages/base/course-selection/pay-wait?payUrl=${encodeURIComponent(res.result.cashierPayHtml)}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -62,7 +62,12 @@ export const useUserStore = defineStore({
|
|||||||
this.wsCallback = callback;
|
this.wsCallback = callback;
|
||||||
},
|
},
|
||||||
initWs() {
|
initWs() {
|
||||||
if (!this.ws) {
|
if (this.ws) {
|
||||||
|
if (typeof this.ws.closeConnect === 'function') {
|
||||||
|
this.ws.closeConnect();
|
||||||
|
}
|
||||||
|
this.ws = null;
|
||||||
|
}
|
||||||
this.ws = useWebSocket(`/zhxy/webSocket/${this.userdata.userId}`, (type: string, res: any) => {
|
this.ws = useWebSocket(`/zhxy/webSocket/${this.userdata.userId}`, (type: string, res: any) => {
|
||||||
// 判断this.wsCallback是函数,调用
|
// 判断this.wsCallback是函数,调用
|
||||||
if (typeof this.wsCallback === "function") {
|
if (typeof this.wsCallback === "function") {
|
||||||
@ -70,7 +75,6 @@ export const useUserStore = defineStore({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.ws.reconnect();
|
this.ws.reconnect();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @description: 验证码登录
|
* @description: 验证码登录
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user