app-normal.vue 16 KB

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