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

Merge branch 'feature/fix_policy' into 'master'

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

See merge request !84
parents 36cfb01a d8e8eb1b
......@@ -57,8 +57,11 @@ async function getAuthInfo(xyqbToken) {
}
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 });
// 切换账号时清除缓存
if (localStorage.get("openId") && res.openId !== localStorage.get("openId")) {
console.log("切换账号");
localStorage.clear();
......
import { payByWay } from "@/service/pay";
import { isXyqb, isWeixinBrower } from "@/service/validation";
import { placeOrder } from "@/api/product";
import { getPolicyDetail } from "@/api/policy";
import localStorage from "@/service/localStorage";
import { mapActions } from "vuex";
......@@ -81,7 +82,7 @@ export default {
},
getPayResult() {
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) {
this.payTimer = setTimeout(() => {
this.getPayResult();
......@@ -89,13 +90,27 @@ export default {
} else {
this.setIsPayWait(false);
this.setIsLoading(false);
// 保单详情页支付需重新调用保单接口
if (this.$route.name === "PolicyDetail") {
this.getPolicy();
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 });
}
});
},
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";
import GOODS_LIST from "@/api/goodsList.mock";
export default {
data() {
return {
isFromPay: false
};
},
methods: {
getData(policy) {
const key = this.findKey(policy);
......@@ -50,12 +45,6 @@ export default {
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 {
...policy,
..._.find(GOODS_LIST, { id: policy?.productNo }),
......@@ -77,13 +66,5 @@ export default {
..._.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