|
@@ -1,10 +1,6 @@
|
|
|
<template>
|
|
|
- <div :class="themeClass">
|
|
|
- <div
|
|
|
- class="layout"
|
|
|
- v-if="isMounted"
|
|
|
- :style="{ paddingTop: showHeader ? '' : 0 }"
|
|
|
- >
|
|
|
+ <div :class="themeClass" v-if="isMounted">
|
|
|
+ <div class="layout" :style="{ paddingTop: showHeader ? '' : 0 }">
|
|
|
<div class="header" v-show="showHeader">
|
|
|
<div class="navbar flex justify-between items-center">
|
|
|
<div class="logo flex items-center" @click="backHome">
|
|
@@ -19,7 +15,7 @@
|
|
|
<div class="flex justify-center items-center">
|
|
|
<div class="nav" v-if="isPc">
|
|
|
<template v-for="item in list">
|
|
|
- <div class="link" :key="item.id" @click="toDetail(item)">
|
|
|
+ <div class="link" :key="item.id" @click="onJumpTo(item)">
|
|
|
<span class="icon" :class="item.icon"></span>
|
|
|
<span class="text">{{ item.name }}</span>
|
|
|
</div>
|
|
@@ -65,7 +61,7 @@
|
|
|
<el-drawer :visible.sync="drawer" size="63%">
|
|
|
<div class="nav">
|
|
|
<template v-for="item in list">
|
|
|
- <div class="link" :key="item.id" @click="toDetail(item)">
|
|
|
+ <div class="link" :key="item.id" @click="onJumpTo(item)">
|
|
|
<span class="icon" :class="item.icon"></span>
|
|
|
<span class="text">{{ item.name }}</span>
|
|
|
</div>
|
|
@@ -78,8 +74,6 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
-import { isWeChat } from '~/utils/validator'
|
|
|
-import { toAuthorization } from '~/utils'
|
|
|
export default {
|
|
|
computed: {
|
|
|
...mapGetters([
|
|
@@ -87,7 +81,6 @@ export default {
|
|
|
'accessToken',
|
|
|
'authUserId',
|
|
|
'appId',
|
|
|
- 'accountType',
|
|
|
'routePrefix',
|
|
|
'themeName',
|
|
|
'isPc',
|
|
@@ -112,9 +105,9 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- isMounted: false,
|
|
|
formType: 'login',
|
|
|
drawer: false,
|
|
|
+ isMounted: false,
|
|
|
list: [
|
|
|
{
|
|
|
id: 1,
|
|
@@ -138,14 +131,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.init()
|
|
|
- console.log(1)
|
|
|
+ this.responseWidth()
|
|
|
+ this.initPageData()
|
|
|
+ // this.checkAccountType()
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
window.removeEventListener('resize', () => {})
|
|
|
+ this.refreshCacheData()
|
|
|
},
|
|
|
methods: {
|
|
|
- toDetail(item) {
|
|
|
+ // 跳转
|
|
|
+ onJumpTo(item) {
|
|
|
this.drawer = false
|
|
|
const hasLogin = this.$store.getters.accessToken
|
|
|
// 保存登录重定向路由
|
|
@@ -155,14 +151,6 @@ export default {
|
|
|
this.routePrefix + item.path
|
|
|
)
|
|
|
if (item.id > 2 && !hasLogin) {
|
|
|
- // 在微信浏览器中使用微信授权登录
|
|
|
- if (isWeChat() && this.appId && this.accountType === 2) {
|
|
|
- const payload = {
|
|
|
- authUserId: this.authUserId,
|
|
|
- routePrefix: this.routePrefix,
|
|
|
- }
|
|
|
- return toAuthorization(this.appId, payload)
|
|
|
- }
|
|
|
this.$toast({ message: '请先登录', duration: 1000 })
|
|
|
this.formType = 'login'
|
|
|
this.$store.commit('app/SHOW_LOGIN')
|
|
@@ -178,94 +166,49 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 点击登录
|
|
|
onLoginClick(type) {
|
|
|
this.formType = type
|
|
|
},
|
|
|
|
|
|
- init() {
|
|
|
- this.responseWidth()
|
|
|
- this.initPageData()
|
|
|
- },
|
|
|
// 初始化数据页面公共数据
|
|
|
initPageData() {
|
|
|
- // 获取供应商id
|
|
|
- const authUserId = parseInt(this.$route.params.template)
|
|
|
- const routePrefix = `/${authUserId}/ross`
|
|
|
- // 保存页面路由前缀
|
|
|
- this.$store.commit('app/SET_ROUTE_PREFIX', routePrefix)
|
|
|
- // 保存用户AppId
|
|
|
- this.$store.commit('user/SET_AUTH_USER_ID', authUserId)
|
|
|
-
|
|
|
- // 设置页面主题12
|
|
|
- // if (authUserId === parseInt(12)) {
|
|
|
- // this.$store.commit('app/SET_PAGE_THEME', 'ross')
|
|
|
- // }
|
|
|
this.$store.commit('app/SET_PAGE_THEME', 'ross')
|
|
|
-
|
|
|
// 获取用户信息
|
|
|
- let userInfo = this.$getStorage(routePrefix, 'userInfo')
|
|
|
- if (userInfo && userInfo.authUserId === authUserId) {
|
|
|
+ let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
|
|
|
+ if (userInfo && userInfo.authUserId === this.authUserId) {
|
|
|
this.$store.commit('user/SET_USER_INFO', userInfo)
|
|
|
}
|
|
|
- // 初始化供应商信息
|
|
|
- this.fetchSupplierInfo()
|
|
|
- },
|
|
|
-
|
|
|
- // 获取供应商信息
|
|
|
- async fetchSupplierInfo() {
|
|
|
- try {
|
|
|
- const res = await this.$http.api.fetchSupplierInfo({
|
|
|
- authUserId: this.authUserId,
|
|
|
- })
|
|
|
- this.$store.commit('supplier/SET_SUPPLIER_INFO', res.data)
|
|
|
- this.$store.commit('user/SET_APPID', res.data.appId)
|
|
|
- // 如果appId存在
|
|
|
- if (res.data.appId) {
|
|
|
- this.checkAccountType(res.data.appId)
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- } finally {
|
|
|
- this.isMounted = true
|
|
|
- // 清除缓存
|
|
|
- this.refreshCacheData()
|
|
|
- }
|
|
|
+ this.isMounted = true
|
|
|
},
|
|
|
|
|
|
// 校验公众号类型
|
|
|
- async checkAccountType(appId) {
|
|
|
+ async checkAccountType() {
|
|
|
try {
|
|
|
// 1订阅号,2服务号
|
|
|
- const res = await this.$http.api.checkAccountType({ appId })
|
|
|
- this.$store.commit('user/SET_ACCOUNT_TYPE', res.data)
|
|
|
+ if (!this.appId) return
|
|
|
+ const res = await this.$http.api.checkAccountType({ appId: this.appId })
|
|
|
+ this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 登录
|
|
|
onLogin() {
|
|
|
- // 在微信浏览器中使用微信授权登录
|
|
|
- if (isWeChat() && this.appId && this.accountType === 2) {
|
|
|
- const payload = {
|
|
|
- authUserId: this.authUserId,
|
|
|
- routePrefix: this.routePrefix,
|
|
|
- }
|
|
|
- return toAuthorization(this.appId, payload)
|
|
|
- }
|
|
|
this.formType = 'login'
|
|
|
this.$store.commit('app/SHOW_LOGIN')
|
|
|
},
|
|
|
|
|
|
+ // 注册
|
|
|
onRegister() {
|
|
|
this.formType = 'register'
|
|
|
- console.log(this.formType)
|
|
|
this.$store.commit('app/SHOW_LOGIN')
|
|
|
},
|
|
|
|
|
|
// 退出登录
|
|
|
logout() {
|
|
|
this.$store.dispatch('user/logout')
|
|
|
- console.log(this.routePrefix)
|
|
|
this.$removeStorage(this.routePrefix, 'userInfo')
|
|
|
this.backHome()
|
|
|
},
|