app.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div :class="themeClass" v-if="isMounted">
  3. <div class="layout" :style="{ paddingTop: showHeader ? '' : 0 }">
  4. <div class="header" v-show="showHeader">
  5. <div class="navbar flex justify-between items-center">
  6. <div class="logo flex items-center" @click="backHome">
  7. <img
  8. src="~/assets/theme-images/ross/ross-logo-f.png"
  9. v-if="themeName === 'ross'"
  10. class="ross"
  11. />
  12. <img src="~/assets/theme-images/common/icon-logo.png" v-else />
  13. <span>认证通</span>
  14. </div>
  15. <div class="user-info">
  16. <template v-if="accessToken">
  17. <span v-text="userInfo.mobile"></span>
  18. <span class="underline logout" @click="logout">退出登录</span>
  19. </template>
  20. <template v-else>
  21. <div class="flex justify-center">
  22. <div
  23. class="login pr-3 pl-3 rounded-sm border-white leading-6"
  24. @click="onLogin"
  25. >
  26. 登录
  27. </div>
  28. |
  29. <div
  30. class="register pr-3 pl-3 rounded-sm border-white leading-6"
  31. @click="onRegister"
  32. >
  33. 注册
  34. </div>
  35. </div>
  36. </template>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="content">
  41. <nuxt />
  42. </div>
  43. <div class="footer flex justify-center items-center" v-show="showFooter">
  44. - {{ supplierInfo.shopName }} | 由采美网提供技术支持 -
  45. </div>
  46. <SimpleLogin :type="formType" @click="onLoginClick"></SimpleLogin>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import { mapGetters } from 'vuex'
  52. export default {
  53. computed: {
  54. ...mapGetters([
  55. 'userInfo',
  56. 'accessToken',
  57. 'authUserId',
  58. 'appId',
  59. 'routePrefix',
  60. 'themeName',
  61. 'isPc',
  62. 'showHeader',
  63. 'showFooter',
  64. 'supplierInfo',
  65. ]),
  66. themeClass() {
  67. return `theme-${this.themeName}`
  68. },
  69. },
  70. head() {
  71. return {
  72. meta: [
  73. {
  74. name: 'viewport',
  75. content:
  76. 'width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
  77. },
  78. ],
  79. }
  80. },
  81. data() {
  82. return {
  83. formType: 'login',
  84. drawer: false,
  85. isMounted: false,
  86. list: [
  87. {
  88. id: 1,
  89. name: '授权申请',
  90. path: '/form/club-register',
  91. icon: 'icon-register',
  92. },
  93. {
  94. id: 2,
  95. name: '产品资料',
  96. path: '/docs/0',
  97. icon: 'icon-doc',
  98. },
  99. {
  100. id: 3,
  101. name: '意见反馈',
  102. path: '/feedback',
  103. icon: 'icon-feedback',
  104. },
  105. ],
  106. }
  107. },
  108. mounted() {
  109. this.responseWidth()
  110. this.initPageData()
  111. // this.checkAccountType()
  112. },
  113. beforeDestroy() {
  114. window.removeEventListener('resize', () => {})
  115. this.refreshCacheData()
  116. },
  117. methods: {
  118. // 点击登录
  119. onLoginClick(type) {
  120. this.formType = type
  121. },
  122. // 初始化数据页面公共数据
  123. initPageData() {
  124. // this.$store.commit('app/SET_PAGE_THEME', 'app')
  125. // 获取用户信息
  126. let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
  127. if (userInfo && userInfo.authUserId === this.authUserId) {
  128. this.$store.commit('user/SET_USER_INFO', userInfo)
  129. }
  130. this.isMounted = true
  131. },
  132. // 校验公众号类型
  133. async checkAccountType() {
  134. try {
  135. // 1订阅号,2服务号
  136. if (!this.appId) return
  137. const res = await this.$http.api.checkAccountType({ appId: this.appId })
  138. this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
  139. } catch (error) {
  140. console.log(error)
  141. }
  142. },
  143. // 登录
  144. onLogin() {
  145. this.formType = 'login'
  146. this.$store.commit('app/SHOW_LOGIN')
  147. },
  148. // 注册
  149. onRegister() {
  150. this.formType = 'register'
  151. this.$store.commit('app/SHOW_LOGIN')
  152. },
  153. // 退出登录
  154. logout() {
  155. this.$store.dispatch('user/logout')
  156. this.$removeStorage(this.routePrefix, 'userInfo')
  157. this.backHome()
  158. },
  159. // 回到首页
  160. backHome() {
  161. if (this.$route.path === this.routePrefix) return
  162. this.$router.replace(this.routePrefix)
  163. },
  164. // 响应页面宽度变化
  165. responseWidth() {
  166. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  167. window.addEventListener('resize', (e) => {
  168. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  169. })
  170. },
  171. // 数据初始化刷新浏览器
  172. refreshCacheData() {
  173. this.$removeStorage(this.routePrefix, 'club_list_data')
  174. },
  175. },
  176. }
  177. </script>
  178. <style scoped lang="scss">
  179. // PC端
  180. @media screen and (min-width: 768px) {
  181. .layout {
  182. padding-top: 80px;
  183. user-select: none;
  184. .header {
  185. position: fixed;
  186. top: 0;
  187. left: 0;
  188. z-index: 999;
  189. width: 100%;
  190. height: 80px;
  191. box-sizing: border-box;
  192. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  193. .navbar {
  194. width: 1200px;
  195. margin: 0 auto;
  196. height: 100%;
  197. }
  198. .logo {
  199. cursor: pointer;
  200. img {
  201. display: block;
  202. width: 44px;
  203. height: 44px;
  204. &.ross {
  205. width: 85px;
  206. height: 27px;
  207. margin-right: 15px;
  208. transform: translateY(-2px);
  209. }
  210. }
  211. span {
  212. font-size: 24px;
  213. color: #fff;
  214. }
  215. }
  216. .user-info {
  217. color: #fff;
  218. font-size: 16px;
  219. .login,
  220. .register,
  221. .logout {
  222. cursor: pointer;
  223. &:hover {
  224. @include themify($themes) {
  225. color: themed('color');
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .content {
  232. min-height: calc(100vh - 80px - 80px);
  233. background-color: #f7f7f7;
  234. overflow: hidden;
  235. }
  236. .footer {
  237. height: 80px;
  238. background-color: #2c3038;
  239. color: #fff;
  240. font-size: 14px;
  241. }
  242. }
  243. }
  244. // 移动端
  245. @media screen and (max-width: 768px) {
  246. .layout {
  247. padding-top: 12.8vw;
  248. .header {
  249. position: fixed;
  250. top: 0;
  251. left: 0;
  252. z-index: 999;
  253. width: 100%;
  254. padding: 0 2.4vw;
  255. height: 12.8vw;
  256. box-sizing: border-box;
  257. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  258. .navbar {
  259. height: 100%;
  260. }
  261. .logo {
  262. img {
  263. display: block;
  264. width: 8vw;
  265. height: 8vw;
  266. &.ross {
  267. width: 12.2vw;
  268. height: 3.9vw;
  269. margin-right: 1.9vw;
  270. transform: translateY(-1vw);
  271. }
  272. }
  273. span {
  274. font-size: 4vw;
  275. color: #fff;
  276. }
  277. }
  278. .user-info {
  279. color: #fff;
  280. font-size: 3vw;
  281. }
  282. }
  283. .content {
  284. min-height: calc(100vh - 12.8vw - 12.4vw);
  285. }
  286. .footer {
  287. height: 12.4vw;
  288. background-color: #2c3038;
  289. color: #fff;
  290. font-size: 3vw;
  291. }
  292. }
  293. }
  294. </style>