Commit dde64c91 authored by 郭志伟's avatar 郭志伟

fix: 问题修复

parent 30f30651
......@@ -51,8 +51,8 @@ import { mapState, mapActions } from "vuex";
import Modal from "@/components/Modal";
import { loginByPhone, getCaptchaSms } from "@/api/user";
import protocol from "@/api/protocol";
import cookies from "cookies-js";
import { isPhone, isWeixinBrower } from "@/service/validation";
import localStorage from "@/service/localStorage";
export default {
name: "LoginModal",
components: {
......@@ -101,13 +101,12 @@ export default {
},
async login() {
this.formData.loginChannel = isWeixinBrower ? 1 : 2;
this.formData.openId = localStorage.getItem("openId") || null;
this.formData.openId = localStorage.get("openId") || null;
const res = await loginByPhone(this.formData);
if (res) {
this.$notify({ type: "success", message: "登录成功" });
this.setIsShowLogin(false);
localStorage.setItem("mongoToken", res.token);
cookies.set("mongoToken", res.token, { expires: "01/01/2030" });
localStorage.set("mongoToken", res.token);
// TODO 开发目前使用这个token
// localStorage.setItem("mongoToken", "6ae7da7dd4c543f1a36c702c6f419f12");
}
......
import cookies from "cookies-js";
export default {
get(key) {
let result = window.localStorage.getItem(key);
// 如果本地存储拿不到tokenn,那就去cookies拿
if (!result && key === "mongoToken") {
return cookies.get(key) || "";
}
try {
return JSON.parse(result);
} catch (e) {
......@@ -13,6 +19,10 @@ export default {
if (toString.call(value) === "[object Array]" || toString.call(value) === "[object Object]") {
value = JSON.stringify(value);
}
// token存cookies一份,做备份
if (key === "mongoToken") {
cookies.set(key, value, { expires: "01/01/2030" });
}
return window.localStorage.setItem(key, value);
},
remove(key) {
......
......@@ -271,7 +271,6 @@ export default {
"relativeName",
"relativeIdNo"
];
console.log(errorInfo);
if (!noMsgArr.includes(errors[0].name)) {
this.$notify({ type: "warning", message: errors[0].message });
}
......
......@@ -31,8 +31,11 @@ export default {
...this.subFormData
});
if (res) {
if (detailType) {
const _key = detailType === "li" ? "PolicyFormData" : detailType + "DetailFormData";
localStorage.remove(_key);
}
this.orderInfo = res;
detailType && localStorage.remove(detailType + "DetailFormData");
this.goPay();
}
},
......
......@@ -26,18 +26,16 @@ export default {
// }
this.isPayWait = true;
this.orderInfo = this.$route.query;
let thirdParams = "";
if (this.orderInfo.third) {
thirdParams = decodeURIComponent(this.orderInfo.third);
}
// 如果存在isXyqb,同时当前不是在信用钱包环境
if ((this.orderInfo.isXyqb == 1 && !isXyqb) || thirdParams.indexOf("1") === 0) {
if ((this.orderInfo.isXyqb == 1 && !isXyqb) || this.orderInfo.third.indexOf("1") === 0) {
window.location.href = "xyqb://my";
if (localStorage.get("mongoToken")) {
this.$router.replace("/policy");
} else {
this.$router.replace("/home");
}
setTimeout(() => {
if (localStorage.get("mongoToken")) {
this.$router.replace("/policy");
} else {
this.$router.replace("/home");
}
}, 1000);
return;
}
// 没有订单信息的情况
......
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