app-hyt.vue 16 KB

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