Commit 5db1fe93 authored by 郭志伟's avatar 郭志伟

Merge branch 'fix/consultant_pay' into 'master'

fix: 替换cookies-js为js-cookie

See merge request !207
parents 107fbb91 6cadec98
import cookies from "js-cookie";
import Cookies from "js-cookie";
export default {
get(key) {
let result = window.localStorage.getItem(key);
// 如果本地存储拿不到tokenn,那就去cookies拿
// 如果本地存储拿不到tokenn,那就去Cookies拿
if (!result && key === "mongoToken") {
return cookies.get(key) || "";
return Cookies.get(key) || "";
}
try {
return JSON.parse(result);
......@@ -19,15 +19,16 @@ export default {
if (toString.call(value) === "[object Array]" || toString.call(value) === "[object Object]") {
value = JSON.stringify(value);
}
// token存cookies一份,做备份
// token存Cookies一份,做备份
if (key === "mongoToken") {
cookies.set(key, value, { expires: "01/01/2030" });
Cookies.set(key, value, { expires: 3650 });
}
console.log(value);
return window.localStorage.setItem(key, value);
},
remove(key) {
if (key === "mongoToken") {
cookies.remove(key);
Cookies.remove(key);
}
return window.localStorage.removeItem(key);
},
......
......@@ -262,6 +262,12 @@ export default {
},
async goPay() {
this.isPayWait = true;
function getOrderInfo() {
setTimeout(() => {
this.isPayWait = false;
this.$parent.getOrderInfo(true);
}, 1000);
}
try {
const res = await goPay({ tradeType: this.tradeType, openId: this.openId });
if (res) {
......@@ -296,23 +302,14 @@ export default {
}
payByWay(this.tradeType, payInfo)
.then(() => {
setTimeout(() => {
this.isPayWait = false;
this.$parent.getOrderInfo(true);
}, 1000);
getOrderInfo();
})
.catch(() => {
setTimeout(() => {
this.isPayWait = false;
this.$parent.getOrderInfo(true);
}, 1000);
getOrderInfo();
});
}
} catch (error) {
this.isPayWait = false;
setTimeout(() => {
this.$parent.getOrderInfo(true);
}, 1000);
getOrderInfo();
}
}
}
......
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