app-normal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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. padding-top: 80px;
  249. user-select: none;
  250. .header {
  251. position: fixed;
  252. top: 0;
  253. left: 0;
  254. z-index: 999;
  255. width: 100%;
  256. height: 80px;
  257. box-sizing: border-box;
  258. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  259. .navbar {
  260. width: 1200px;
  261. margin: 0 auto;
  262. height: 100%;
  263. }
  264. .logo {
  265. cursor: pointer;
  266. img {
  267. display: block;
  268. width: 44px;
  269. height: 44px;
  270. &.ross {
  271. width: 85px;
  272. height: 27px;
  273. margin-right: 15px;
  274. transform: translateY(-2px);
  275. }
  276. }
  277. span {
  278. font-size: 24px;
  279. color: #fff;
  280. }
  281. }
  282. .nav {
  283. .link {
  284. display: inline;
  285. margin-left: 32px;
  286. cursor: pointer;
  287. &:hover {
  288. .text {
  289. @include themify($themes) {
  290. color: themed('color');
  291. }
  292. }
  293. .icon {
  294. &.icon-register {
  295. background-image: url(~assets/theme-images/normal/pc/link-entry-register-active.png);
  296. }
  297. &.icon-doc {
  298. background-image: url(~assets/theme-images/normal/pc/link-entry-doc-active.png);
  299. }
  300. &.icon-feedback {
  301. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback-active.png);
  302. }
  303. }
  304. }
  305. }
  306. .icon {
  307. width: 20px;
  308. height: 20px;
  309. display: inline-block;
  310. vertical-align: -4px;
  311. margin-right: 4px;
  312. background-size: 20px;
  313. background-repeat: no-repeat;
  314. background-position: center;
  315. &.icon-register {
  316. background-image: url(~assets/theme-images/normal/pc/link-entry-register.png);
  317. }
  318. &.icon-doc {
  319. background-image: url(~assets/theme-images/normal/pc/link-entry-doc.png);
  320. }
  321. &.icon-feedback {
  322. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback.png);
  323. }
  324. }
  325. .text {
  326. font-size: 16px;
  327. color: #fff;
  328. }
  329. }
  330. .user-info {
  331. color: #fff;
  332. font-size: 16px;
  333. margin-left: 48px;
  334. .login-btn {
  335. width: 80px;
  336. height: 34px;
  337. color: #fff;
  338. background: rgba(255, 255, 255, 0.39);
  339. font-size: 14px;
  340. text-align: center;
  341. line-height: 34px;
  342. cursor: pointer;
  343. }
  344. .user-center {
  345. position: relative;
  346. .icon {
  347. width: 32px;
  348. height: 32px;
  349. text-align: center;
  350. line-height: 32px;
  351. &.el-icon-user-solid {
  352. font-size: 24px;
  353. cursor: pointer;
  354. }
  355. &.el-icon-arrow-down {
  356. font-size: 22px;
  357. transition: all 0.2s;
  358. }
  359. }
  360. &:hover {
  361. .drop-down {
  362. display: block;
  363. animation: slide-down 0.4s linear forwards;
  364. }
  365. .el-icon-arrow-down {
  366. transform: rotateZ(180deg);
  367. }
  368. }
  369. .drop-down {
  370. display: none;
  371. opacity: 0;
  372. // z-index: -1;
  373. right: 0;
  374. position: absolute;
  375. background: transparent;
  376. box-sizing: border-box;
  377. padding-top: 24px;
  378. .nav {
  379. width: 118px;
  380. padding: 8px 0;
  381. background: #fff;
  382. box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
  383. border-radius: 4px;
  384. li {
  385. font-size: 14px;
  386. color: #282828;
  387. text-align: center;
  388. line-height: 40px;
  389. transition: all 0.4s;
  390. cursor: pointer;
  391. &:hover {
  392. @include themify($themes) {
  393. color: themed('color');
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. .login,
  401. .register,
  402. .logout {
  403. cursor: pointer;
  404. &:hover {
  405. @include themify($themes) {
  406. color: themed('color');
  407. }
  408. }
  409. }
  410. }
  411. }
  412. .content {
  413. // min-height: calc(100vh - 80px - 80px);
  414. min-height: calc(100vh - 80px);
  415. background-color: #f7f7f7;
  416. overflow: hidden;
  417. }
  418. .footer {
  419. height: 80px;
  420. background-color: #2c3038;
  421. color: #fff;
  422. font-size: 14px;
  423. }
  424. }
  425. }
  426. // 移动端
  427. @media screen and (max-width: 768px) {
  428. .layout {
  429. padding-top: 12.8vw;
  430. .header {
  431. position: fixed;
  432. top: 0;
  433. left: 0;
  434. z-index: 999;
  435. width: 100%;
  436. padding: 0 4vw;
  437. height: 12.8vw;
  438. box-sizing: border-box;
  439. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  440. .navbar {
  441. height: 100%;
  442. }
  443. .logo {
  444. img {
  445. display: block;
  446. width: 8vw;
  447. height: 8vw;
  448. &.ross {
  449. width: 12.2vw;
  450. height: 3.9vw;
  451. margin-right: 1.9vw;
  452. transform: translateY(-0.6vw);
  453. }
  454. }
  455. span {
  456. font-size: 4vw;
  457. color: #fff;
  458. }
  459. }
  460. .user-info {
  461. color: #fff;
  462. font-size: 3vw;
  463. .logout {
  464. margin: 0 1.6vw;
  465. }
  466. .login-btn {
  467. width: 13.4vw;
  468. height: 6.4vw;
  469. color: #fff;
  470. background: rgba(255, 255, 255, 0.39);
  471. font-size: 3.4vw;
  472. text-align: center;
  473. line-height: 6.4vw;
  474. margin-right: 2.4vw;
  475. }
  476. .user-center {
  477. position: relative;
  478. .icon {
  479. width: 5.6vw;
  480. height: 5.6vw;
  481. text-align: center;
  482. line-height: 5.6vw;
  483. margin-right: 4vw;
  484. &.el-icon-user-solid {
  485. font-size: 24px;
  486. cursor: pointer;
  487. }
  488. &.el-icon-arrow-down {
  489. display: none;
  490. }
  491. }
  492. &:hover {
  493. .drop-down {
  494. display: block;
  495. animation: slide-down 0.4s linear forwards;
  496. }
  497. .el-icon-arrow-down {
  498. transform: rotateZ(180deg);
  499. }
  500. }
  501. .drop-down {
  502. display: none;
  503. opacity: 0;
  504. right: 0;
  505. position: absolute;
  506. background: transparent;
  507. box-sizing: border-box;
  508. padding-top: 1.2vw;
  509. .nav {
  510. width: 26vw;
  511. padding: 1vw 0;
  512. background: #fff;
  513. box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
  514. border-radius: 0.4vw;
  515. li {
  516. font-size: 3.4vw;
  517. color: #282828;
  518. text-align: center;
  519. line-height: 8.6vw;
  520. transition: all 0.4s;
  521. }
  522. }
  523. }
  524. }
  525. }
  526. .collapse-icon {
  527. display: block;
  528. width: 5.6vw;
  529. height: 5.6vw;
  530. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  531. no-repeat center;
  532. background-size: 5.6vw;
  533. }
  534. }
  535. .content {
  536. // min-height: calc(100vh - 12.8vw - 12.4vw);
  537. min-height: calc(100vh - 12.8vw);
  538. }
  539. .footer {
  540. height: 12.4vw;
  541. background-color: #2c3038;
  542. color: #fff;
  543. font-size: 3vw;
  544. }
  545. }
  546. .nav {
  547. width: 63vw;
  548. box-sizing: border-box;
  549. padding: 0 6.4vw;
  550. .link {
  551. display: flex;
  552. justify-content: flex-start;
  553. align-items: center;
  554. border-bottom: 0.1vw solid #c2c2c2;
  555. padding-bottom: 3vw;
  556. padding-top: 6vw;
  557. .icon {
  558. width: 5.6vw;
  559. height: 5.6vw;
  560. vertical-align: -1.2vw;
  561. margin-right: 2.4vw;
  562. background-size: 5.6vw;
  563. background-repeat: no-repeat;
  564. background-position: center;
  565. &.icon-register {
  566. background-image: url(~assets/theme-images/normal/h5/link-entry-register-active.png);
  567. }
  568. &.icon-doc {
  569. background-image: url(~assets/theme-images/normal/h5/link-entry-doc-active.png);
  570. }
  571. &.icon-feedback {
  572. background-image: url(~assets/theme-images/normal/h5/link-entry-feedback-active.png);
  573. }
  574. }
  575. .text {
  576. font-size: 3.4vw;
  577. color: #282828;
  578. }
  579. }
  580. }
  581. }
  582. </style>