Commit ada543f6 authored by 郭志伟's avatar 郭志伟 Committed by 郝聪敏

feat: 联调

parent 1abb06c4
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
<cr-loading class="loading" size="24px">加载中...</cr-loading> <cr-loading class="loading" size="24px">加载中...</cr-loading>
</div> </div>
<login-modal /> <login-modal />
<auth-from-xyqb /> <!-- <auth-from-xyqb /> -->
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from "vuex";
import LoginModal from "@/components/LoginModal"; import LoginModal from "@/components/LoginModal";
import AuthFromXyqb from "@/components/AuthFromXyqb"; // import AuthFromXyqb from "@/components/AuthFromXyqb";
export default { export default {
components: { components: {
LoginModal, LoginModal
AuthFromXyqb // AuthFromXyqb
}, },
computed: { computed: {
...mapState(["isLoading"]) ...mapState(["isLoading"])
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from "vuex";
import localStorage from "@/service/localStorage";
import { authByxyqb } from "@/api/user";
export default { export default {
name: "AuthFromXyqb", name: "AuthFromXyqb",
data() { data() {
...@@ -24,14 +22,7 @@ export default { ...@@ -24,14 +22,7 @@ export default {
...mapState(["showAuthXyqb"]) ...mapState(["showAuthXyqb"])
}, },
methods: { methods: {
...mapActions(["setShowAuthXyqb"]), ...mapActions(["setShowAuthXyqb"])
async getAuthInfo() {
const res = await authByxyqb();
if (res) {
localStorage.set("mongoToken", res.token);
localStorage.set("xyqbUserInfo", res);
}
}
} }
}; };
</script> </script>
......
...@@ -3,6 +3,7 @@ import VueRouter from "vue-router"; ...@@ -3,6 +3,7 @@ import VueRouter from "vue-router";
import routes from "./routes"; import routes from "./routes";
import { parseSearch } from "@/service/utils"; import { parseSearch } from "@/service/utils";
import { isXyqb } from "@/service/validation"; import { isXyqb } from "@/service/validation";
// import cfg from "@/config";
import { authByxyqb } from "@/api/user"; import { authByxyqb } from "@/api/user";
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
Vue.use(VueRouter); Vue.use(VueRouter);
...@@ -23,11 +24,13 @@ const router = new VueRouter({ ...@@ -23,11 +24,13 @@ const router = new VueRouter({
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const urlParams = parseSearch(window.location.href); const urlParams = parseSearch(window.location.href);
if (isXyqb()) getAuthInfo(urlParams.token); if (isXyqb) getAuthInfo(urlParams.token);
// if (isWeixinBrower) getWxOpenId(urlParams.code);
next(); next();
}); });
async function getAuthInfo(xyqbToken) { async function getAuthInfo(xyqbToken) {
if (localStorage.get("xyqbToken")) return;
const res = await authByxyqb({ xyqbToken }); const res = await authByxyqb({ xyqbToken });
if (res) { if (res) {
localStorage.set("mongoToken", res.token); localStorage.set("mongoToken", res.token);
...@@ -35,6 +38,13 @@ async function getAuthInfo(xyqbToken) { ...@@ -35,6 +38,13 @@ async function getAuthInfo(xyqbToken) {
localStorage.set("xyqbToken", xyqbToken); localStorage.set("xyqbToken", xyqbToken);
} }
} }
// async function getWxOpenId(code) {
// if (localStorage.get("openId")) return;
// const res = await getwxOpenId({ code, appId: cfg.wxAppId });
// this.openId = res.openId;
// localStorage.set("openId", res.openId);
// }
// router.afterEach(() => {}); // router.afterEach(() => {});
export default router; export default router;
...@@ -250,12 +250,6 @@ export function isBankNumber(str) { ...@@ -250,12 +250,6 @@ export function isBankNumber(str) {
} }
// 判断微信环境 // 判断微信环境
export function isWeixinBrower() { export const isWeixinBrower = window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger";
const ua = window.navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) === "micromessenger";
}
// 判断信用钱包环境 // 判断信用钱包环境
export function isXyqb() { export const isXyqb = window.navigator.userAgent.toLowerCase().match(/xyqb/i) == "xyqb";
const ua = window.navigator.userAgent.toLowerCase();
return ua.match(/xyqb/i) === "xyqb";
}
...@@ -9,7 +9,7 @@ export default new Vuex.Store({ ...@@ -9,7 +9,7 @@ export default new Vuex.Store({
activeIdx: 0, activeIdx: 0,
isLoading: false, isLoading: false,
isShowLogin: false, isShowLogin: false,
showAuthXyqb: true showAuthXyqb: "init" // init 已获取信息未授权,pending 授权弹框
}, },
mutations: { mutations: {
setActiveIdx(state, value) { setActiveIdx(state, value) {
...@@ -21,7 +21,7 @@ export default new Vuex.Store({ ...@@ -21,7 +21,7 @@ export default new Vuex.Store({
setIsShowLogin(state, value) { setIsShowLogin(state, value) {
state.isShowLogin = value; state.isShowLogin = value;
}, },
setShowAuthXyqb(state, value) { authXyqb(state, value) {
state.showAuthXyqb = value; state.showAuthXyqb = value;
} }
}, },
...@@ -35,7 +35,7 @@ export default new Vuex.Store({ ...@@ -35,7 +35,7 @@ export default new Vuex.Store({
setIsShowLogin({ commit }, args) { setIsShowLogin({ commit }, args) {
commit("setIsShowLogin", args); commit("setIsShowLogin", args);
}, },
setShowAuthXyqb({ commit }, args) { setsuthXyqb({ commit }, args) {
commit("setShowAuthXyqb", args); commit("setShowAuthXyqb", args);
} }
}, },
......
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