Commit d8e8eb1b authored by 郝聪敏's avatar 郝聪敏

fix: 切换微信号清空缓存、支付成功流程bug解决

parent 36cfb01a
...@@ -57,8 +57,11 @@ async function getAuthInfo(xyqbToken) { ...@@ -57,8 +57,11 @@ async function getAuthInfo(xyqbToken) {
} }
async function getWxOpenId(code) { async function getWxOpenId(code) {
if (localStorage.get("openId")) return; // code只能用一次
if (!code || code === sessionStorage.getItem("latestCode")) return;
sessionStorage.setItem("latestCode", code);
const res = await getwxOpenId({ code, appId: cfg.wxAppId }); const res = await getwxOpenId({ code, appId: cfg.wxAppId });
// 切换账号时清除缓存
if (localStorage.get("openId") && res.openId !== localStorage.get("openId")) { if (localStorage.get("openId") && res.openId !== localStorage.get("openId")) {
console.log("切换账号"); console.log("切换账号");
localStorage.clear(); localStorage.clear();
......
import { payByWay } from "@/service/pay"; import { payByWay } from "@/service/pay";
import { isXyqb, isWeixinBrower } from "@/service/validation"; import { isXyqb, isWeixinBrower } from "@/service/validation";
import { placeOrder } from "@/api/product"; import { placeOrder } from "@/api/product";
import { getPolicyDetail } from "@/api/policy";
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
import { mapActions } from "vuex"; import { mapActions } from "vuex";
...@@ -81,7 +82,7 @@ export default { ...@@ -81,7 +82,7 @@ export default {
}, },
getPayResult() { getPayResult() {
const { payOrderNo, orderNo } = this.orderInfo; const { payOrderNo, orderNo } = this.orderInfo;
placeOrder.polling({ payOrderNo, payOrderType: 1 }).then(payRes => { placeOrder.polling({ payOrderNo, payOrderType: 1 }).then(async payRes => {
if (!payRes.result && payRes.payState === 2) { if (!payRes.result && payRes.payState === 2) {
this.payTimer = setTimeout(() => { this.payTimer = setTimeout(() => {
this.getPayResult(); this.getPayResult();
...@@ -89,13 +90,27 @@ export default { ...@@ -89,13 +90,27 @@ export default {
} else { } else {
this.setIsPayWait(false); this.setIsPayWait(false);
this.setIsLoading(false); this.setIsLoading(false);
// 保单详情页支付需重新调用保单接口
if (this.$route.name === "PolicyDetail") { if (this.$route.name === "PolicyDetail") {
this.getPolicy(); this.getPolicy();
return; return;
} }
// 根据状态跳转页面
const status = await this.getPolicyStatus(orderNo);
if (["6.2-3", "6.1-3"].includes(status)) {
this.$router.replace(`/policy/success/${orderNo}`);
return;
}
this.$router.replace({ path: "/policy/detail/" + orderNo }); this.$router.replace({ path: "/policy/detail/" + orderNo });
} }
}); });
},
async getPolicyStatus(orderNo) {
const policy = await getPolicyDetail(orderNo);
return policy?.payState
? `${policy?.policyState}-${policy?.payState}`
: String(policy?.policyState);
} }
} }
}; };
...@@ -4,11 +4,6 @@ import { parseTime } from "@/service/utils"; ...@@ -4,11 +4,6 @@ import { parseTime } from "@/service/utils";
import GOODS_LIST from "@/api/goodsList.mock"; import GOODS_LIST from "@/api/goodsList.mock";
export default { export default {
data() {
return {
isFromPay: false
};
},
methods: { methods: {
getData(policy) { getData(policy) {
const key = this.findKey(policy); const key = this.findKey(policy);
...@@ -50,12 +45,6 @@ export default { ...@@ -50,12 +45,6 @@ export default {
value.contend = `保障期限:${policyPeriod.label}`; value.contend = `保障期限:${policyPeriod.label}`;
} }
// 校验是否支付成功
const status = this.getStatus(policy);
if (["6.2-3", "6.1-3"].includes(status) && this.isFromPay) {
this.$router.replace(`/policy/success/${this.$route.params.orderNo}`);
}
return { return {
...policy, ...policy,
..._.find(GOODS_LIST, { id: policy?.productNo }), ..._.find(GOODS_LIST, { id: policy?.productNo }),
...@@ -77,13 +66,5 @@ export default { ...@@ -77,13 +66,5 @@ export default {
..._.find(GOODS_LIST, { id: policy?.productNo }) ..._.find(GOODS_LIST, { id: policy?.productNo })
}; };
} }
},
beforeRouteEnter(to, from, next) {
next(vm => {
const prePath = ["/goods/inform", "/goods/detail", "/policy/add"];
if (prePath.includes(from.path)) {
vm.isFromPay = true;
}
});
} }
}; };
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