app-hyt.vue 16 KB

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