app-normal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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/normal/pc/logo.png" />
  8. <span>认证通</span>
  9. </div>
  10. <div class="flex justify-center items-center">
  11. <div class="nav" v-if="isPc">
  12. <template v-for="item in list">
  13. <div class="link" :key="item.id" @click="onJumpTo(item)">
  14. <span class="icon" :class="item.icon"></span>
  15. <span class="text">{{ item.name }}</span>
  16. </div>
  17. </template>
  18. </div>
  19. <div class="user-info">
  20. <template v-if="accessToken">
  21. <div class="user-center">
  22. <span class="icon el-icon-user-solid"></span>
  23. <span class="icon el-icon-arrow-down"></span>
  24. <div class="drop-down">
  25. <ul class="nav">
  26. <li @click.stop="onUserCenter">个人中心</li>
  27. <li @click.stop="logout">退出登录</li>
  28. </ul>
  29. </div>
  30. </div>
  31. </template>
  32. <template v-else>
  33. <div class="login-btn" @click="onLogin">登录</div>
  34. </template>
  35. </div>
  36. <span class="collapse-icon" @click="drawer = true"></span>
  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. <template v-if="!isPc">
  49. <el-drawer :visible.sync="drawer" size="63%">
  50. <div class="nav">
  51. <template v-for="item in list">
  52. <div class="link" :key="item.id" @click="onJumpTo(item)">
  53. <span class="icon" :class="item.icon"></span>
  54. <span class="text">{{ item.name }}</span>
  55. </div>
  56. </template>
  57. </div>
  58. </el-drawer>
  59. </template>
  60. </div>
  61. </template>
  62. <script>
  63. import { mapGetters } from 'vuex'
  64. export default {
  65. computed: {
  66. ...mapGetters([
  67. 'userInfo',
  68. 'accessToken',
  69. 'authUserId',
  70. 'appId',
  71. 'routePrefix',
  72. 'themeName',
  73. 'isPc',
  74. 'showHeader',
  75. 'showFooter',
  76. 'supplierInfo',
  77. ]),
  78. themeClass() {
  79. return `theme-${this.themeName}`
  80. },
  81. },
  82. head() {
  83. return {
  84. meta: [
  85. {
  86. name: 'viewport',
  87. content:
  88. 'width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
  89. },
  90. ],
  91. }
  92. },
  93. data() {
  94. return {
  95. formType: 'login',
  96. drawer: false,
  97. isMounted: false,
  98. list: [
  99. {
  100. id: 1,
  101. name: '授权申请',
  102. path: '/form/club-register',
  103. icon: 'icon-register',
  104. },
  105. // {
  106. // id: 2,
  107. // name: '产品资料',
  108. // path: '/docs/0',
  109. // icon: 'icon-doc',
  110. // },
  111. {
  112. id: 3,
  113. name: '意见反馈',
  114. path: '/feedback',
  115. icon: 'icon-feedback',
  116. },
  117. ],
  118. }
  119. },
  120. mounted() {
  121. this.responseWidth()
  122. this.initPageData()
  123. // this.checkAccountType()
  124. },
  125. beforeDestroy() {
  126. window.removeEventListener('resize', () => {})
  127. this.refreshCacheData()
  128. },
  129. methods: {
  130. // 跳转
  131. onJumpTo(item) {
  132. this.drawer = false
  133. const hasLogin = this.$store.getters.accessToken
  134. // 保存登录重定向路由
  135. this.$setStorage(
  136. this.routePrefix,
  137. 'login_redicret',
  138. this.routePrefix + item.path
  139. )
  140. if (item.id > 2 && !hasLogin) {
  141. this.$toast({ message: '请先登录', duration: 1000 })
  142. this.formType = 'login'
  143. this.$store.commit('app/SHOW_LOGIN')
  144. return
  145. }
  146. if (item.id === 0) {
  147. const url = this.routePrefix + item.path
  148. this.$router.push(url)
  149. } else {
  150. const url = this.routePrefix + item.path
  151. this.$router.push(url)
  152. }
  153. },
  154. // 点击登录
  155. onLoginClick(type) {
  156. this.formType = type
  157. },
  158. // 初始化数据页面公共数据
  159. async initPageData() {
  160. this.$store.commit('app/SET_PAGE_THEME', 'normal')
  161. // 获取用户信息
  162. let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
  163. if (userInfo && userInfo.authUserId === this.authUserId) {
  164. this.$store.commit('user/SET_USER_INFO', userInfo)
  165. const res = await this.$http.api.checkTokenResult()
  166. this.$store.commit('user/SET_USER_INFO', res.data)
  167. }
  168. this.isMounted = true
  169. },
  170. // 校验公众号类型
  171. async checkAccountType() {
  172. try {
  173. // 1订阅号,2服务号
  174. if (!this.appId) return
  175. const res = await this.$http.api.checkAccountType({ appId: this.appId })
  176. this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
  177. } catch (error) {
  178. console.log(error)
  179. }
  180. },
  181. // 登录
  182. onLogin() {
  183. this.formType = 'login'
  184. this.$store.commit('app/SHOW_LOGIN')
  185. },
  186. // 注册
  187. onRegister() {
  188. this.formType = 'register'
  189. this.$store.commit('app/SHOW_LOGIN')
  190. },
  191. // 退出登录
  192. logout() {
  193. this.$store.dispatch('user/logout')
  194. this.$removeStorage(this.routePrefix, 'userInfo')
  195. this.backHome()
  196. },
  197. // 回到首页
  198. backHome() {
  199. // if (this.$route.path === this.routePrefix) return
  200. // this.$router.replace(this.routePrefix)
  201. window.location.href = window.location.origin + this.routePrefix
  202. },
  203. // 个人中心
  204. onUserCenter() {
  205. // const path = `${this.routePrefix}/center`
  206. window.location.href =
  207. window.location.origin + `${this.routePrefix}/center`
  208. },
  209. // 响应页面宽度变化
  210. responseWidth() {
  211. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  212. window.addEventListener('resize', (e) => {
  213. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  214. })
  215. },
  216. // 数据初始化刷新浏览器
  217. refreshCacheData() {
  218. this.$removeStorage(this.routePrefix, 'club_list_data')
  219. },
  220. },
  221. }
  222. </script>
  223. <style scoped lang="scss">
  224. @keyframes slide-down {
  225. 0% {
  226. top: 48px;
  227. z-index: 9;
  228. opacity: 0;
  229. }
  230. 100% {
  231. top: 32px;
  232. opacity: 1;
  233. }
  234. }
  235. // PC端
  236. @media screen and (min-width: 768px) {
  237. .layout {
  238. padding-top: 80px;
  239. user-select: none;
  240. .header {
  241. position: fixed;
  242. top: 0;
  243. left: 0;
  244. z-index: 999;
  245. width: 100%;
  246. height: 80px;
  247. box-sizing: border-box;
  248. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  249. .navbar {
  250. width: 1200px;
  251. margin: 0 auto;
  252. height: 100%;
  253. }
  254. .logo {
  255. cursor: pointer;
  256. img {
  257. display: block;
  258. width: 44px;
  259. height: 44px;
  260. &.ross {
  261. width: 85px;
  262. height: 27px;
  263. margin-right: 15px;
  264. transform: translateY(-2px);
  265. }
  266. }
  267. span {
  268. font-size: 24px;
  269. color: #fff;
  270. }
  271. }
  272. .nav {
  273. .link {
  274. display: inline;
  275. margin-left: 32px;
  276. cursor: pointer;
  277. &:hover {
  278. .text {
  279. @include themify($themes) {
  280. color: themed('color');
  281. }
  282. }
  283. .icon {
  284. &.icon-register {
  285. background-image: url(~assets/theme-images/normal/pc/link-entry-register-active.png);
  286. }
  287. &.icon-doc {
  288. background-image: url(~assets/theme-images/normal/pc/link-entry-doc-active.png);
  289. }
  290. &.icon-feedback {
  291. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback-active.png);
  292. }
  293. }
  294. }
  295. }
  296. .icon {
  297. width: 20px;
  298. height: 20px;
  299. display: inline-block;
  300. vertical-align: -4px;
  301. margin-right: 4px;
  302. background-size: 20px;
  303. background-repeat: no-repeat;
  304. background-position: center;
  305. &.icon-register {
  306. background-image: url(~assets/theme-images/normal/pc/link-entry-register.png);
  307. }
  308. &.icon-doc {
  309. background-image: url(~assets/theme-images/normal/pc/link-entry-doc.png);
  310. }
  311. &.icon-feedback {
  312. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback.png);
  313. }
  314. }
  315. .text {
  316. font-size: 16px;
  317. color: #fff;
  318. }
  319. }
  320. .user-info {
  321. color: #fff;
  322. font-size: 16px;
  323. margin-left: 48px;
  324. .login-btn {
  325. width: 80px;
  326. height: 34px;
  327. color: #fff;
  328. background: rgba(255, 255, 255, 0.39);
  329. font-size: 14px;
  330. text-align: center;
  331. line-height: 34px;
  332. cursor: pointer;
  333. }
  334. .user-center {
  335. position: relative;
  336. .icon {
  337. width: 32px;
  338. height: 32px;
  339. text-align: center;
  340. line-height: 32px;
  341. &.el-icon-user-solid {
  342. font-size: 24px;
  343. cursor: pointer;
  344. }
  345. &.el-icon-arrow-down {
  346. font-size: 22px;
  347. transition: all 0.2s;
  348. }
  349. }
  350. &:hover {
  351. .drop-down {
  352. display: block;
  353. animation: slide-down 0.4s linear forwards;
  354. }
  355. .el-icon-arrow-down {
  356. transform: rotateZ(180deg);
  357. }
  358. }
  359. .drop-down {
  360. display: none;
  361. opacity: 0;
  362. // z-index: -1;
  363. right: 0;
  364. position: absolute;
  365. background: transparent;
  366. box-sizing: border-box;
  367. padding-top: 24px;
  368. .nav {
  369. width: 118px;
  370. padding: 8px 0;
  371. background: #fff;
  372. box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
  373. border-radius: 4px;
  374. li {
  375. font-size: 14px;
  376. color: #282828;
  377. text-align: center;
  378. line-height: 40px;
  379. transition: all 0.4s;
  380. cursor: pointer;
  381. &:hover {
  382. @include themify($themes) {
  383. color: themed('color');
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .login,
  391. .register,
  392. .logout {
  393. cursor: pointer;
  394. &:hover {
  395. @include themify($themes) {
  396. color: themed('color');
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .content {
  403. min-height: calc(100vh - 80px - 80px);
  404. background-color: #f7f7f7;
  405. overflow: hidden;
  406. }
  407. .footer {
  408. height: 80px;
  409. background-color: #2c3038;
  410. color: #fff;
  411. font-size: 14px;
  412. }
  413. }
  414. }
  415. // 移动端
  416. @media screen and (max-width: 768px) {
  417. .layout {
  418. padding-top: 12.8vw;
  419. .header {
  420. position: fixed;
  421. top: 0;
  422. left: 0;
  423. z-index: 999;
  424. width: 100%;
  425. padding: 0 4vw;
  426. height: 12.8vw;
  427. box-sizing: border-box;
  428. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  429. .navbar {
  430. height: 100%;
  431. }
  432. .logo {
  433. img {
  434. display: block;
  435. width: 8vw;
  436. height: 8vw;
  437. &.ross {
  438. width: 12.2vw;
  439. height: 3.9vw;
  440. margin-right: 1.9vw;
  441. transform: translateY(-0.6vw);
  442. }
  443. }
  444. span {
  445. font-size: 4vw;
  446. color: #fff;
  447. }
  448. }
  449. .user-info {
  450. color: #fff;
  451. font-size: 3vw;
  452. .logout {
  453. margin: 0 1.6vw;
  454. }
  455. .login-btn {
  456. width: 13.4vw;
  457. height: 6.4vw;
  458. color: #fff;
  459. background: rgba(255, 255, 255, 0.39);
  460. font-size: 3.4vw;
  461. text-align: center;
  462. line-height: 6.4vw;
  463. margin-right: 2.4vw;
  464. }
  465. .user-center {
  466. position: relative;
  467. .icon {
  468. width: 5.6vw;
  469. height: 5.6vw;
  470. text-align: center;
  471. line-height: 5.6vw;
  472. margin-right: 4vw;
  473. &.el-icon-user-solid {
  474. font-size: 24px;
  475. cursor: pointer;
  476. }
  477. &.el-icon-arrow-down {
  478. display: none;
  479. }
  480. }
  481. &:hover {
  482. .drop-down {
  483. display: block;
  484. animation: slide-down 0.4s linear forwards;
  485. }
  486. .el-icon-arrow-down {
  487. transform: rotateZ(180deg);
  488. }
  489. }
  490. .drop-down {
  491. display: none;
  492. opacity: 0;
  493. right: 0;
  494. position: absolute;
  495. background: transparent;
  496. box-sizing: border-box;
  497. padding-top: 1.2vw;
  498. .nav {
  499. width: 26vw;
  500. padding: 1vw 0;
  501. background: #fff;
  502. box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
  503. border-radius: 0.4vw;
  504. li {
  505. font-size: 3.4vw;
  506. color: #282828;
  507. text-align: center;
  508. line-height: 8.6vw;
  509. transition: all 0.4s;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. .collapse-icon {
  516. display: block;
  517. width: 5.6vw;
  518. height: 5.6vw;
  519. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  520. no-repeat center;
  521. background-size: 5.6vw;
  522. }
  523. }
  524. .content {
  525. min-height: calc(100vh - 12.8vw - 12.4vw);
  526. }
  527. .footer {
  528. height: 12.4vw;
  529. background-color: #2c3038;
  530. color: #fff;
  531. font-size: 3vw;
  532. }
  533. }
  534. .nav {
  535. width: 63vw;
  536. box-sizing: border-box;
  537. padding: 0 6.4vw;
  538. .link {
  539. display: flex;
  540. justify-content: flex-start;
  541. align-items: center;
  542. border-bottom: 0.1vw solid #c2c2c2;
  543. padding-bottom: 3vw;
  544. padding-top: 6vw;
  545. .icon {
  546. width: 5.6vw;
  547. height: 5.6vw;
  548. vertical-align: -1.2vw;
  549. margin-right: 2.4vw;
  550. background-size: 5.6vw;
  551. background-repeat: no-repeat;
  552. background-position: center;
  553. &.icon-register {
  554. background-image: url(~assets/theme-images/normal/h5/link-entry-register-active.png);
  555. }
  556. &.icon-doc {
  557. background-image: url(~assets/theme-images/normal/h5/link-entry-doc-active.png);
  558. }
  559. &.icon-feedback {
  560. background-image: url(~assets/theme-images/normal/h5/link-entry-feedback-active.png);
  561. }
  562. }
  563. .text {
  564. font-size: 3.4vw;
  565. color: #282828;
  566. }
  567. }
  568. }
  569. }
  570. </style>