123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641 |
- <template>
- <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">
- <img src="~/assets/theme-images/normal/pc/logo.png" />
- <span>认证通</span>
- </div>
- <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="onJumpTo(item)">
- <span class="icon" :class="item.icon"></span>
- <span class="text">{{ item.name }}</span>
- </div>
- </template>
- </div>
- <div class="user-info">
- <template v-if="accessToken">
- <div class="user-center">
- <span class="icon el-icon-user-solid"></span>
- <span class="icon el-icon-arrow-down"></span>
- <div class="drop-down">
- <ul class="nav">
- <li @click.stop="onUserCenter">个人中心</li>
- <li @click.stop="logout">退出登录</li>
- </ul>
- </div>
- </div>
- </template>
- <template v-else>
- <div class="login-btn" @click="onLogin">登录</div>
- </template>
- </div>
- <span class="collapse-icon" @click="drawer = true"></span>
- </div>
- </div>
- </div>
- <div class="content">
- <nuxt />
- </div>
- <!-- <div class="footer flex justify-center items-center" v-show="showFooter">
- - {{ supplierInfo.shopName }} | 由采美网提供技术支持 -
- </div> -->
- <SimpleLogin :type="formType" @click="onLoginClick"></SimpleLogin>
- </div>
- <template v-if="!isPc">
- <el-drawer :visible.sync="drawer" size="63%">
- <div class="nav">
- <template v-for="item in list">
- <div class="link" :key="item.id" @click="onJumpTo(item)">
- <span class="icon" :class="item.icon"></span>
- <span class="text">{{ item.name }}</span>
- </div>
- </template>
- </div>
- </el-drawer>
- </template>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- export default {
- computed: {
- ...mapGetters([
- 'userInfo',
- 'accessToken',
- 'authUserId',
- 'appId',
- 'routePrefix',
- 'themeName',
- 'isPc',
- 'showHeader',
- 'showFooter',
- 'supplierInfo',
- ]),
- themeClass() {
- return `theme-${this.themeName}`
- },
- },
- head() {
- return {
- meta: [
- {
- name: 'viewport',
- content:
- 'width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
- },
- ],
- }
- },
- data() {
- return {
- formType: 'login',
- drawer: false,
- isMounted: false,
- list: [
- {
- id: 1,
- name: '授权申请',
- path: '/form/club-register',
- icon: 'icon-register',
- },
- // {
- // id: 2,
- // name: '产品资料',
- // path: '/docs/0',
- // icon: 'icon-doc',
- // },
- {
- id: 3,
- name: '意见反馈',
- path: '/feedback',
- icon: 'icon-feedback',
- },
- ],
- }
- },
- created() {
- if (this.authUserId === 15) {
- this.list.splice(1, 0, {
- id: 2,
- name: '云资料库',
- path: '/docs/0',
- icon: 'icon-doc',
- })
- }
- },
- mounted() {
- this.responseWidth()
- this.initPageData()
- // this.checkAccountType()
- },
- beforeDestroy() {
- window.removeEventListener('resize', () => {})
- this.refreshCacheData()
- },
- methods: {
- // 跳转
- onJumpTo(item) {
- this.drawer = false
- const hasLogin = this.$store.getters.accessToken
- // 保存登录重定向路由
- this.$setStorage(
- this.routePrefix,
- 'login_redicret',
- this.routePrefix + item.path
- )
- if (item.id > 2 && !hasLogin) {
- this.$toast({ message: '请先登录', duration: 1000 })
- this.formType = 'login'
- this.$store.commit('app/SHOW_LOGIN')
- return
- }
- if (item.id === 0) {
- const url = this.routePrefix + item.path
- this.$router.push(url)
- } else {
- const url = this.routePrefix + item.path
- this.$router.push(url)
- }
- },
- // 点击登录
- onLoginClick(type) {
- this.formType = type
- },
- // 初始化数据页面公共数据
- async initPageData() {
- this.$store.commit('app/SET_PAGE_THEME', 'normal')
- // 获取用户信息
- let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
- if (userInfo && userInfo.authUserId === this.authUserId) {
- this.$store.commit('user/SET_USER_INFO', userInfo)
- const res = await this.$http.api.checkTokenResult()
- this.$store.commit('user/SET_USER_INFO', res.data)
- }
- this.isMounted = true
- },
- // 校验公众号类型
- async checkAccountType() {
- try {
- // 1订阅号,2服务号
- 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() {
- this.formType = 'login'
- this.$store.commit('app/SHOW_LOGIN')
- },
- // 注册
- onRegister() {
- this.formType = 'register'
- this.$store.commit('app/SHOW_LOGIN')
- },
- // 退出登录
- logout() {
- this.$store.dispatch('user/logout')
- this.$removeStorage(this.routePrefix, 'userInfo')
- this.backHome()
- },
- // 回到首页
- backHome() {
- // if (this.$route.path === this.routePrefix) return
- // this.$router.replace(this.routePrefix)
- window.location.href = window.location.origin + this.routePrefix
- },
- // 个人中心
- onUserCenter() {
- // const path = `${this.routePrefix}/center`
- window.location.href =
- window.location.origin + `${this.routePrefix}/center`
- },
- // 响应页面宽度变化
- responseWidth() {
- this.$store.commit('app/SET_SCREEN', window.innerWidth)
- window.addEventListener('resize', (e) => {
- this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
- })
- },
- // 数据初始化刷新浏览器
- refreshCacheData() {
- this.$removeStorage(this.routePrefix, 'club_list_data')
- },
- },
- }
- </script>
- <style scoped lang="scss">
- @keyframes slide-down {
- 0% {
- top: 48px;
- z-index: 9;
- opacity: 0;
- }
- 100% {
- top: 32px;
- opacity: 1;
- }
- }
- // PC端
- @media screen and (min-width: 768px) {
- .layout {
- padding-top: 80px;
- user-select: none;
- .header {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 999;
- width: 100%;
- height: 80px;
- box-sizing: border-box;
- background: linear-gradient(90deg, #101010 0%, #404040 100%);
- .navbar {
- width: 1200px;
- margin: 0 auto;
- height: 100%;
- }
- .logo {
- cursor: pointer;
- img {
- display: block;
- width: 44px;
- height: 44px;
- &.ross {
- width: 85px;
- height: 27px;
- margin-right: 15px;
- transform: translateY(-2px);
- }
- }
- span {
- font-size: 24px;
- color: #fff;
- }
- }
- .nav {
- .link {
- display: inline;
- margin-left: 32px;
- cursor: pointer;
- &:hover {
- .text {
- @include themify($themes) {
- color: themed('color');
- }
- }
- .icon {
- &.icon-register {
- background-image: url(~assets/theme-images/normal/pc/link-entry-register-active.png);
- }
- &.icon-doc {
- background-image: url(~assets/theme-images/normal/pc/link-entry-doc-active.png);
- }
- &.icon-feedback {
- background-image: url(~assets/theme-images/normal/pc/link-entry-feedback-active.png);
- }
- }
- }
- }
- .icon {
- width: 20px;
- height: 20px;
- display: inline-block;
- vertical-align: -4px;
- margin-right: 4px;
- background-size: 20px;
- background-repeat: no-repeat;
- background-position: center;
- &.icon-register {
- background-image: url(~assets/theme-images/normal/pc/link-entry-register.png);
- }
- &.icon-doc {
- background-image: url(~assets/theme-images/normal/pc/link-entry-doc.png);
- }
- &.icon-feedback {
- background-image: url(~assets/theme-images/normal/pc/link-entry-feedback.png);
- }
- }
- .text {
- font-size: 16px;
- color: #fff;
- }
- }
- .user-info {
- color: #fff;
- font-size: 16px;
- margin-left: 48px;
- .login-btn {
- width: 80px;
- height: 34px;
- color: #fff;
- background: rgba(255, 255, 255, 0.39);
- font-size: 14px;
- text-align: center;
- line-height: 34px;
- cursor: pointer;
- }
- .user-center {
- position: relative;
- .icon {
- width: 32px;
- height: 32px;
- text-align: center;
- line-height: 32px;
- &.el-icon-user-solid {
- font-size: 24px;
- cursor: pointer;
- }
- &.el-icon-arrow-down {
- font-size: 22px;
- transition: all 0.2s;
- }
- }
- &:hover {
- .drop-down {
- display: block;
- animation: slide-down 0.4s linear forwards;
- }
- .el-icon-arrow-down {
- transform: rotateZ(180deg);
- }
- }
- .drop-down {
- display: none;
- opacity: 0;
- // z-index: -1;
- right: 0;
- position: absolute;
- background: transparent;
- box-sizing: border-box;
- padding-top: 24px;
- .nav {
- width: 118px;
- padding: 8px 0;
- background: #fff;
- box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
- border-radius: 4px;
- li {
- font-size: 14px;
- color: #282828;
- text-align: center;
- line-height: 40px;
- transition: all 0.4s;
- cursor: pointer;
- &:hover {
- @include themify($themes) {
- color: themed('color');
- }
- }
- }
- }
- }
- }
- .login,
- .register,
- .logout {
- cursor: pointer;
- &:hover {
- @include themify($themes) {
- color: themed('color');
- }
- }
- }
- }
- }
- .content {
- // min-height: calc(100vh - 80px - 80px);
- min-height: calc(100vh - 80px);
- background-color: #f7f7f7;
- overflow: hidden;
- }
- .footer {
- height: 80px;
- background-color: #2c3038;
- color: #fff;
- font-size: 14px;
- }
- }
- }
- // 移动端
- @media screen and (max-width: 768px) {
- .layout {
- padding-top: 12.8vw;
- .header {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 999;
- width: 100%;
- padding: 0 4vw;
- height: 12.8vw;
- box-sizing: border-box;
- background: linear-gradient(90deg, #101010 0%, #404040 100%);
- .navbar {
- height: 100%;
- }
- .logo {
- img {
- display: block;
- width: 8vw;
- height: 8vw;
- &.ross {
- width: 12.2vw;
- height: 3.9vw;
- margin-right: 1.9vw;
- transform: translateY(-0.6vw);
- }
- }
- span {
- font-size: 4vw;
- color: #fff;
- }
- }
- .user-info {
- color: #fff;
- font-size: 3vw;
- .logout {
- margin: 0 1.6vw;
- }
- .login-btn {
- width: 13.4vw;
- height: 6.4vw;
- color: #fff;
- background: rgba(255, 255, 255, 0.39);
- font-size: 3.4vw;
- text-align: center;
- line-height: 6.4vw;
- margin-right: 2.4vw;
- }
- .user-center {
- position: relative;
- .icon {
- width: 5.6vw;
- height: 5.6vw;
- text-align: center;
- line-height: 5.6vw;
- margin-right: 4vw;
- &.el-icon-user-solid {
- font-size: 24px;
- cursor: pointer;
- }
- &.el-icon-arrow-down {
- display: none;
- }
- }
- &:hover {
- .drop-down {
- display: block;
- animation: slide-down 0.4s linear forwards;
- }
- .el-icon-arrow-down {
- transform: rotateZ(180deg);
- }
- }
- .drop-down {
- display: none;
- opacity: 0;
- right: 0;
- position: absolute;
- background: transparent;
- box-sizing: border-box;
- padding-top: 1.2vw;
- .nav {
- width: 26vw;
- padding: 1vw 0;
- background: #fff;
- box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
- border-radius: 0.4vw;
- li {
- font-size: 3.4vw;
- color: #282828;
- text-align: center;
- line-height: 8.6vw;
- transition: all 0.4s;
- }
- }
- }
- }
- }
- .collapse-icon {
- display: block;
- width: 5.6vw;
- height: 5.6vw;
- background: url(~assets/theme-images/common/h5-icon-collapse.png)
- no-repeat center;
- background-size: 5.6vw;
- }
- }
- .content {
- // min-height: calc(100vh - 12.8vw - 12.4vw);
- min-height: calc(100vh - 12.8vw);
- }
- .footer {
- height: 12.4vw;
- background-color: #2c3038;
- color: #fff;
- font-size: 3vw;
- }
- }
- .nav {
- width: 63vw;
- box-sizing: border-box;
- padding: 0 6.4vw;
- .link {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- border-bottom: 0.1vw solid #c2c2c2;
- padding-bottom: 3vw;
- padding-top: 6vw;
- .icon {
- width: 5.6vw;
- height: 5.6vw;
- vertical-align: -1.2vw;
- margin-right: 2.4vw;
- background-size: 5.6vw;
- background-repeat: no-repeat;
- background-position: center;
- &.icon-register {
- background-image: url(~assets/theme-images/normal/h5/link-entry-register-active.png);
- }
- &.icon-doc {
- background-image: url(~assets/theme-images/normal/h5/link-entry-doc-active.png);
- }
- &.icon-feedback {
- background-image: url(~assets/theme-images/normal/h5/link-entry-feedback-active.png);
- }
- }
- .text {
- font-size: 3.4vw;
- color: #282828;
- }
- }
- }
- }
- </style>
|