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

fix: 问题修复

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