app-ph.vue 6.9 KB

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