123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <div class="layout" v-if="isMounted">
- <div class="header"></div>
- <div class="content">
- <nuxt />
- </div>
- <div class="footer"></div>
- <ldm-login></ldm-login>
- </div>
- </template>
- <script>
- import { getCookies } from '@/utils/auth'
- import { mapGetters } from 'vuex'
- export default {
- computed: {
- ...mapGetters(['userInfo', 'type', 'accessToken', 'authUserId']),
- },
- head() {
- return {
- title: '德国WELLCOMET LDM® 官方查询系统',
- link: [{ rel: 'icon', type: 'image/x-icon', href: '/ldm.ico' }],
- }
- },
- data() {
- return {
- isMounted: false,
- }
- },
- mounted() {
- this.init()
- },
- beforeDestroy() {
- window.removeEventListener('resize', () => {})
- },
- methods: {
- init() {
- this.responseWidth()
- this.initPageData()
- },
- // 初始化数据页面公共数据
- initPageData() {
- const id = this.$route.params.template
- // 保存页面入口
- this.$store.commit('user/SET_TYPE', `${id}/app`)
- // 保存用户AppId
- this.$store.commit('user/SET_AUTHUSERID', id)
- // 获取用户信息
- const userInfo = getCookies('userInfo')
- if (userInfo && userInfo.authUserId === id) {
- this.$store.commit('user/SET_USERINFO', JSON.parse(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)
- if (res.data.appId) {
- this.checkAccountType(res.data.appId)
- }
- } catch (error) {
- console.log(error)
- } finally {
- this.isMounted = true
- }
- },
- // 校验公众号类型
- async checkAccountType(appId) {
- try {
- // 1订阅号,2服务号
- const res = this.$http.api.checkAccountType({ appId })
- this.$store.commit('user/SET_ACCOUNT_TYPE', res.data)
- } catch (error) {
- console.log(error)
- }
- },
- // 退出登录
- logout() {
- this.$store.dispatch('user/logout')
- },
- // 回到首页
- backHome() {
- const url = '/' + this.type
- if (this.$route.path === url) return
- this.$router.replace(url)
- },
- // 响应页面宽度变化
- responseWidth() {
- this.$store.commit('app/SET_SCREEN', window.innerWidth)
- window.addEventListener('resize', (e) => {
- this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
- })
- },
- },
- }
- </script>
- <style scoped lang="scss"></style>
|