app-normal.vue 15 KB

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