app-hyt.vue 15 KB

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