app-ross.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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="flex justify-center items-center">
  16. <div class="nav" v-if="isPc">
  17. <template v-for="item in list">
  18. <div class="link" :key="item.id" @click="onJumpTo(item)">
  19. <span class="icon" :class="item.icon"></span>
  20. <span class="text">{{ item.name }}</span>
  21. </div>
  22. </template>
  23. </div>
  24. <div class="user-info">
  25. <template v-if="accessToken">
  26. <span v-text="userInfo.mobile"></span>
  27. <span class="underline logout" @click="logout">退出登录</span>
  28. </template>
  29. <template v-else>
  30. <div class="flex justify-center">
  31. <div
  32. class="login mx-3 rounded-sm border-white md:leading-6"
  33. @click="onLogin"
  34. >
  35. 登录
  36. </div>
  37. |
  38. <div
  39. class="register mx-3 rounded-sm border-white md:leading-6"
  40. @click="onRegister"
  41. >
  42. 注册
  43. </div>
  44. </div>
  45. </template>
  46. </div>
  47. <span class="collapse-icon" @click="drawer = true"></span>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="content">
  52. <nuxt />
  53. </div>
  54. <div class="footer flex justify-center items-center" v-show="showFooter">
  55. - {{ supplierInfo.shopName }} | 由采美网提供技术支持 -
  56. </div>
  57. <SimpleLogin :type="formType" @click="onLoginClick"></SimpleLogin>
  58. </div>
  59. <template v-if="!isPc">
  60. <el-drawer :visible.sync="drawer" size="63%">
  61. <div class="nav">
  62. <template v-for="item in list">
  63. <div class="link" :key="item.id" @click="onJumpTo(item)">
  64. <span class="icon" :class="item.icon"></span>
  65. <span class="text">{{ item.name }}</span>
  66. </div>
  67. </template>
  68. </div>
  69. </el-drawer>
  70. </template>
  71. </div>
  72. </template>
  73. <script>
  74. import { mapGetters } from 'vuex'
  75. export default {
  76. computed: {
  77. ...mapGetters([
  78. 'userInfo',
  79. 'accessToken',
  80. 'authUserId',
  81. 'appId',
  82. 'routePrefix',
  83. 'themeName',
  84. 'isPc',
  85. 'showHeader',
  86. 'showFooter',
  87. 'supplierInfo',
  88. ]),
  89. themeClass() {
  90. return `theme-${this.themeName}`
  91. },
  92. },
  93. head() {
  94. return {
  95. meta: [
  96. {
  97. name: 'viewport',
  98. content:
  99. 'width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
  100. },
  101. ],
  102. }
  103. },
  104. data() {
  105. return {
  106. formType: 'login',
  107. drawer: false,
  108. isMounted: false,
  109. list: [
  110. {
  111. id: 1,
  112. name: '授权申请',
  113. path: '/form/club-register',
  114. icon: 'icon-register',
  115. },
  116. {
  117. id: 2,
  118. name: '产品资料',
  119. path: '/docs/0',
  120. icon: 'icon-doc',
  121. },
  122. {
  123. id: 3,
  124. name: '意见反馈',
  125. path: '/feedback',
  126. icon: 'icon-feedback',
  127. },
  128. ],
  129. }
  130. },
  131. mounted() {
  132. this.responseWidth()
  133. this.initPageData()
  134. // this.checkAccountType()
  135. },
  136. beforeDestroy() {
  137. window.removeEventListener('resize', () => {})
  138. this.refreshCacheData()
  139. },
  140. methods: {
  141. // 跳转
  142. onJumpTo(item) {
  143. this.drawer = false
  144. const hasLogin = this.$store.getters.accessToken
  145. // 保存登录重定向路由
  146. this.$setStorage(
  147. this.routePrefix,
  148. 'login_redicret',
  149. this.routePrefix + item.path
  150. )
  151. if (item.id > 2 && !hasLogin) {
  152. this.$toast({ message: '请先登录', duration: 1000 })
  153. this.formType = 'login'
  154. this.$store.commit('app/SHOW_LOGIN')
  155. return
  156. }
  157. if (item.id === 0) {
  158. const url = this.routePrefix + item.path
  159. this.$router.push(url)
  160. } else {
  161. const url = this.routePrefix + item.path
  162. this.$router.push(url)
  163. }
  164. },
  165. // 点击登录
  166. onLoginClick(type) {
  167. this.formType = type
  168. },
  169. // 初始化数据页面公共数据
  170. initPageData() {
  171. this.$store.commit('app/SET_PAGE_THEME', 'ross')
  172. // 获取用户信息
  173. let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
  174. if (userInfo && userInfo.authUserId === this.authUserId) {
  175. this.$store.commit('user/SET_USER_INFO', userInfo)
  176. }
  177. this.isMounted = true
  178. },
  179. // 校验公众号类型
  180. async checkAccountType() {
  181. try {
  182. // 1订阅号,2服务号
  183. if (!this.appId) return
  184. const res = await this.$http.api.checkAccountType({ appId: this.appId })
  185. this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
  186. } catch (error) {
  187. console.log(error)
  188. }
  189. },
  190. // 登录
  191. onLogin() {
  192. this.formType = 'login'
  193. this.$store.commit('app/SHOW_LOGIN')
  194. },
  195. // 注册
  196. onRegister() {
  197. this.formType = 'register'
  198. this.$store.commit('app/SHOW_LOGIN')
  199. },
  200. // 退出登录
  201. logout() {
  202. this.$store.dispatch('user/logout')
  203. this.$removeStorage(this.routePrefix, 'userInfo')
  204. this.backHome()
  205. },
  206. // 回到首页
  207. backHome() {
  208. if (this.$route.path === this.routePrefix) return
  209. this.$router.replace(this.routePrefix)
  210. },
  211. // 响应页面宽度变化
  212. responseWidth() {
  213. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  214. window.addEventListener('resize', (e) => {
  215. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  216. })
  217. },
  218. // 数据初始化刷新浏览器
  219. refreshCacheData() {
  220. this.$removeStorage(this.routePrefix, 'club_list_data')
  221. },
  222. },
  223. }
  224. </script>
  225. <style scoped lang="scss">
  226. // PC端
  227. @media screen and (min-width: 768px) {
  228. .layout {
  229. padding-top: 80px;
  230. user-select: none;
  231. .header {
  232. position: fixed;
  233. top: 0;
  234. left: 0;
  235. z-index: 999;
  236. width: 100%;
  237. height: 80px;
  238. box-sizing: border-box;
  239. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  240. .navbar {
  241. width: 1200px;
  242. margin: 0 auto;
  243. height: 100%;
  244. }
  245. .logo {
  246. cursor: pointer;
  247. img {
  248. display: block;
  249. width: 44px;
  250. height: 44px;
  251. &.ross {
  252. width: 85px;
  253. height: 27px;
  254. margin-right: 15px;
  255. transform: translateY(-2px);
  256. }
  257. }
  258. span {
  259. font-size: 24px;
  260. color: #fff;
  261. }
  262. }
  263. .nav {
  264. .link {
  265. display: inline;
  266. margin-left: 32px;
  267. cursor: pointer;
  268. &:hover {
  269. .text {
  270. @include themify($themes) {
  271. color: themed('color');
  272. }
  273. }
  274. .icon {
  275. &.icon-register {
  276. background-image: url(~assets/theme-images/ross/pc-link-entry-register-active.png);
  277. }
  278. &.icon-doc {
  279. background-image: url(~assets/theme-images/ross/pc-link-entry-doc-active.png);
  280. }
  281. &.icon-feedback {
  282. background-image: url(~assets/theme-images/ross/pc-link-entry-feedback-active.png);
  283. }
  284. }
  285. }
  286. }
  287. .icon {
  288. width: 20px;
  289. height: 20px;
  290. display: inline-block;
  291. vertical-align: -4px;
  292. margin-right: 4px;
  293. background-size: 20px;
  294. background-repeat: no-repeat;
  295. background-position: center;
  296. &.icon-register {
  297. background-image: url(~assets/theme-images/ross/pc-link-entry-register.png);
  298. }
  299. &.icon-doc {
  300. background-image: url(~assets/theme-images/ross/pc-link-entry-doc.png);
  301. }
  302. &.icon-feedback {
  303. background-image: url(~assets/theme-images/ross/pc-link-entry-feedback.png);
  304. }
  305. }
  306. .text {
  307. font-size: 16px;
  308. color: #fff;
  309. }
  310. }
  311. .user-info {
  312. color: #fff;
  313. font-size: 16px;
  314. margin-left: 48px;
  315. .login,
  316. .register,
  317. .logout {
  318. cursor: pointer;
  319. &:hover {
  320. @include themify($themes) {
  321. color: themed('color');
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .content {
  328. min-height: calc(100vh - 80px - 80px);
  329. background-color: #f7f7f7;
  330. overflow: hidden;
  331. }
  332. .footer {
  333. height: 80px;
  334. background-color: #2c3038;
  335. color: #fff;
  336. font-size: 14px;
  337. }
  338. }
  339. }
  340. // 移动端
  341. @media screen and (max-width: 768px) {
  342. .layout {
  343. padding-top: 12.8vw;
  344. .header {
  345. position: fixed;
  346. top: 0;
  347. left: 0;
  348. z-index: 999;
  349. width: 100%;
  350. padding: 0 4vw;
  351. height: 12.8vw;
  352. box-sizing: border-box;
  353. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  354. .navbar {
  355. height: 100%;
  356. }
  357. .logo {
  358. img {
  359. display: block;
  360. width: 8vw;
  361. height: 8vw;
  362. &.ross {
  363. width: 12.2vw;
  364. height: 3.9vw;
  365. margin-right: 1.9vw;
  366. transform: translateY(-0.6vw);
  367. }
  368. }
  369. span {
  370. font-size: 4vw;
  371. color: #fff;
  372. }
  373. }
  374. .user-info {
  375. color: #fff;
  376. font-size: 3vw;
  377. .logout {
  378. margin: 0 1.6vw;
  379. }
  380. }
  381. .collapse-icon {
  382. display: block;
  383. width: 5.6vw;
  384. height: 5.6vw;
  385. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  386. no-repeat center;
  387. background-size: 5.6vw;
  388. }
  389. }
  390. .content {
  391. min-height: calc(100vh - 12.8vw - 12.4vw);
  392. }
  393. .footer {
  394. height: 12.4vw;
  395. background-color: #2c3038;
  396. color: #fff;
  397. font-size: 3vw;
  398. }
  399. }
  400. .nav {
  401. width: 63vw;
  402. box-sizing: border-box;
  403. padding: 0 6.4vw;
  404. .link {
  405. display: flex;
  406. justify-content: flex-start;
  407. align-items: center;
  408. border-bottom: 0.1vw solid #c2c2c2;
  409. padding-bottom: 3vw;
  410. padding-top: 6vw;
  411. .icon {
  412. width: 5.6vw;
  413. height: 5.6vw;
  414. vertical-align: -1.2vw;
  415. margin-right: 2.4vw;
  416. background-size: 5.6vw;
  417. background-repeat: no-repeat;
  418. background-position: center;
  419. &.icon-register {
  420. background-image: url(~assets/theme-images/ross/h5-link-entry-register-active.png);
  421. }
  422. &.icon-doc {
  423. background-image: url(~assets/theme-images/ross/h5-link-entry-doc-active.png);
  424. }
  425. &.icon-feedback {
  426. background-image: url(~assets/theme-images/ross/h5-link-entry-feedback-active.png);
  427. }
  428. }
  429. .text {
  430. font-size: 3.4vw;
  431. color: #282828;
  432. }
  433. }
  434. }
  435. }
  436. </style>