app-wym.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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. <span>认证通</span>
  8. </div>
  9. <!--<div class="flex justify-center items-center">
  10. <div class="nav" v-if="isPc">
  11. <template v-for="item in list">
  12. <div class="link" :key="item.id" @click="onJumpTo(item)">
  13. <span class="icon" :class="item.icon"></span>
  14. <span class="text">{{ item.name }}</span>
  15. </div>
  16. </template>
  17. </div>
  18. <div class="user-info">
  19. <template v-if="accessToken">
  20. <div class="user-center">
  21. <span class="icon el-icon-user-solid"></span>
  22. <span class="icon el-icon-arrow-down"></span>
  23. <div class="drop-down">
  24. <ul class="nav">
  25. <li @click.stop="onUserCenter">个人中心</li>
  26. <li @click.stop="logout">退出登录</li>
  27. </ul>
  28. </div>
  29. </div>
  30. </template>
  31. <template v-else>
  32. <div class="login-btn" @click="onLogin">登录</div>
  33. </template>
  34. </div>
  35. <span class="collapse-icon" @click="drawer = true"></span>
  36. </div>-->
  37. </div>
  38. </div>
  39. <div class="content">
  40. <nuxt />
  41. </div>
  42. <div class="footer flex justify-center items-center" v-show="showFooter">
  43. - 由采美网提供技术支持 -
  44. </div>
  45. <SimpleLogin :type="formType" @click="onLoginClick"></SimpleLogin>
  46. </div>
  47. <template v-if="!isPc">
  48. <el-drawer :visible.sync="drawer" size="63%">
  49. <div class="nav">
  50. <template v-for="item in list">
  51. <div class="link" :key="item.id" @click="onJumpTo(item)">
  52. <span class="icon" :class="item.icon"></span>
  53. <span class="text">{{ item.name }}</span>
  54. </div>
  55. </template>
  56. </div>
  57. </el-drawer>
  58. </template>
  59. </div>
  60. </template>
  61. <script>
  62. import { mapGetters } from 'vuex'
  63. import { EventBus } from '@/plugins/router'
  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. 'wxConfig',
  78. ]),
  79. themeClass() {
  80. return `theme-${this.themeName}`
  81. },
  82. },
  83. head() {
  84. return {
  85. meta: [
  86. {
  87. name: 'viewport',
  88. content:
  89. 'width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
  90. },
  91. ],
  92. }
  93. },
  94. data() {
  95. return {
  96. formType: 'login',
  97. drawer: false,
  98. isMounted: false,
  99. list: [
  100. // {
  101. // id: 4,
  102. // name: '挑战赛',
  103. // path: '/activity/challenge',
  104. // icon: 'icon-challenge',
  105. // auth: false,
  106. // },
  107. {
  108. id: 1,
  109. name: '授权申请',
  110. path: '/form/club-register',
  111. icon: 'icon-register',
  112. auth: false,
  113. },
  114. //{
  115. // id: 2,
  116. // name: '云资料库',
  117. // path: '/docs/0',
  118. // icon: 'icon-doc',
  119. // auth: false,
  120. //},
  121. {
  122. id: 3,
  123. name: '意见反馈',
  124. path: '/feedback',
  125. icon: 'icon-feedback',
  126. auth: true,
  127. },
  128. ],
  129. }
  130. },
  131. mounted() {
  132. this.responseWidth()
  133. this.initPageData()
  134. //this.initAppMessageShareData()
  135. //EventBus.$on('afterEach', () => {
  136. // this.initAppMessageShareData()
  137. //})
  138. },
  139. beforeDestroy() {
  140. window.removeEventListener('resize', () => {})
  141. this.refreshCacheData()
  142. EventBus.$off('afterEach')
  143. },
  144. methods: {
  145. // 全局分享事件
  146. initAppMessageShareData() {
  147. let retryCount = 1
  148. // 判断是否为微信浏览器环境
  149. // if (!isWeChat()) return
  150. const whiteList = ['template-ross-activity-challenge']
  151. if (whiteList.indexOf(this.$route.name) > -1) return
  152. // 网站主机地址
  153. const HOST = process.env.LOCALHOSE
  154. this.$wxReady((wx) => {
  155. //需在用户可能点击分享按钮前就先调用
  156. wx.updateAppMessageShareData({
  157. title: '认证通', // 分享标题
  158. desc: '一款专业的正品认证软件系统', // 分享描述
  159. link: HOST + this.routePrefix, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
  160. imgUrl: HOST + '/share-icon.png', // 分享图标
  161. fail: () => {
  162. if (retryCount === 0) return
  163. this.initAppMessageShareData()
  164. retryCount--
  165. },
  166. })
  167. })
  168. },
  169. // 跳转
  170. onJumpTo(item) {
  171. this.drawer = false
  172. const hasLogin = this.$store.getters.accessToken
  173. // 保存登录重定向路由
  174. this.$setStorage(
  175. this.routePrefix,
  176. 'login_redicret',
  177. this.routePrefix + item.path
  178. )
  179. if (item.auth && !hasLogin) {
  180. this.$toast({ message: '请先登录', duration: 1000 })
  181. this.formType = 'login'
  182. this.$store.commit('app/SHOW_LOGIN')
  183. return
  184. }
  185. const url = this.routePrefix + item.path
  186. this.$router.push(url)
  187. },
  188. // 点击登录
  189. onLoginClick(type) {
  190. this.formType = type
  191. },
  192. // 初始化数据页面公共数据
  193. async initPageData() {
  194. this.$store.commit('app/SET_PAGE_THEME', 'wym')
  195. // 获取用户信息
  196. let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
  197. if (userInfo && userInfo.authUserId === this.authUserId) {
  198. this.$store.commit('user/SET_USER_INFO', userInfo)
  199. const res = await this.$http.api.checkTokenResult()
  200. this.$store.commit('user/SET_USER_INFO', res.data)
  201. }
  202. this.isMounted = true
  203. },
  204. // 校验公众号类型
  205. async checkAccountType() {
  206. try {
  207. // 1订阅号,2服务号
  208. if (!this.appId) return
  209. const res = await this.$http.api.checkAccountType({ appId: this.appId })
  210. this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
  211. } catch (error) {
  212. console.log(error)
  213. }
  214. },
  215. // 登录
  216. onLogin() {
  217. this.formType = 'login'
  218. this.$store.commit('app/SHOW_LOGIN')
  219. },
  220. // 注册
  221. onRegister() {
  222. this.formType = 'register'
  223. this.$store.commit('app/SHOW_LOGIN')
  224. },
  225. // 退出登录
  226. logout() {
  227. this.$store.dispatch('user/logout')
  228. this.$removeStorage(this.routePrefix, 'userInfo')
  229. this.backHome()
  230. },
  231. // 回到首页
  232. backHome() {
  233. // if (this.$route.path === this.routePrefix) return
  234. // this.$router.replace(this.routePrefix)
  235. window.location.href = window.location.origin + this.routePrefix
  236. },
  237. // 个人中心
  238. onUserCenter() {
  239. // const path = `${this.routePrefix}/center`
  240. window.location.href =
  241. window.location.origin + `${this.routePrefix}/center`
  242. },
  243. // 响应页面宽度变化
  244. responseWidth() {
  245. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  246. window.addEventListener('resize', (e) => {
  247. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  248. })
  249. },
  250. // 数据初始化刷新浏览器
  251. refreshCacheData() {
  252. this.$removeStorage(this.routePrefix, 'club_list_data')
  253. },
  254. },
  255. }
  256. </script>
  257. <style scoped lang="scss">
  258. @keyframes slide-down {
  259. 0% {
  260. top: 48px;
  261. z-index: 9;
  262. opacity: 0;
  263. }
  264. 100% {
  265. top: 32px;
  266. opacity: 1;
  267. }
  268. }
  269. // PC端
  270. @media screen and (min-width: 768px) {
  271. .layout {
  272. @include useTheme() {
  273. padding-top: 0;
  274. user-select: none;
  275. .header {
  276. position: fixed;
  277. top: 0;
  278. left: 0;
  279. z-index: 999;
  280. width: 100%;
  281. height: 80px;
  282. box-sizing: border-box;
  283. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  284. display: none;
  285. .navbar {
  286. width: 1200px;
  287. margin: 0 auto;
  288. height: 100%;
  289. }
  290. .logo {
  291. cursor: pointer;
  292. img {
  293. display: block;
  294. width: 44px;
  295. height: 44px;
  296. &.ross {
  297. width: 85px;
  298. height: 40px;
  299. margin-right: 15px;
  300. transform: translateY(-2px);
  301. }
  302. }
  303. span {
  304. font-size: 24px;
  305. color: #fff;
  306. }
  307. }
  308. .nav {
  309. .link {
  310. display: inline;
  311. margin-left: 32px;
  312. cursor: pointer;
  313. &:hover {
  314. .text {
  315. color: fetch('color');
  316. }
  317. .icon {
  318. &.icon-register {
  319. background-image: url(~assets/theme-images/wym/pc-link-entry-register-active.png);
  320. }
  321. &.icon-doc {
  322. background-image: url(~assets/theme-images/wym/pc-link-entry-doc-active.png);
  323. }
  324. &.icon-feedback {
  325. background-image: url(~assets/theme-images/wym/pc-link-entry-feedback-active.png);
  326. }
  327. &.icon-challenge {
  328. background-image: url(~assets/theme-images/wym/pc-link-entry-challenge-active.png);
  329. }
  330. }
  331. }
  332. }
  333. .icon {
  334. width: 20px;
  335. height: 20px;
  336. display: inline-block;
  337. vertical-align: -4px;
  338. margin-right: 4px;
  339. background-size: 20px;
  340. background-repeat: no-repeat;
  341. background-position: center;
  342. &.icon-register {
  343. background-image: url(~assets/theme-images/wym/pc-link-entry-register.png);
  344. }
  345. &.icon-doc {
  346. background-image: url(~assets/theme-images/wym/pc-link-entry-doc.png);
  347. }
  348. &.icon-feedback {
  349. background-image: url(~assets/theme-images/wym/pc-link-entry-feedback.png);
  350. }
  351. &.icon-challenge {
  352. background-image: url(~assets/theme-images/wym/pc-link-entry-challenge.png);
  353. }
  354. }
  355. .text {
  356. font-size: 16px;
  357. color: #fff;
  358. }
  359. }
  360. .user-info {
  361. color: #fff;
  362. font-size: 16px;
  363. margin-left: 48px;
  364. .login-btn {
  365. width: 80px;
  366. height: 34px;
  367. color: #fff;
  368. background: rgba(255, 255, 255, 0.39);
  369. font-size: 14px;
  370. text-align: center;
  371. line-height: 34px;
  372. cursor: pointer;
  373. }
  374. .user-center {
  375. position: relative;
  376. .icon {
  377. width: 32px;
  378. height: 32px;
  379. text-align: center;
  380. line-height: 32px;
  381. &.el-icon-user-solid {
  382. font-size: 24px;
  383. cursor: pointer;
  384. }
  385. &.el-icon-arrow-down {
  386. font-size: 22px;
  387. transition: all 0.2s;
  388. }
  389. }
  390. &:hover {
  391. .drop-down {
  392. display: block;
  393. animation: slide-down 0.4s linear forwards;
  394. }
  395. .el-icon-arrow-down {
  396. transform: rotateZ(180deg);
  397. }
  398. }
  399. .drop-down {
  400. display: none;
  401. opacity: 0;
  402. // z-index: -1;
  403. right: 0;
  404. position: absolute;
  405. background: transparent;
  406. box-sizing: border-box;
  407. padding-top: 24px;
  408. .nav {
  409. width: 118px;
  410. padding: 8px 0;
  411. background: #fff;
  412. box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
  413. border-radius: 4px;
  414. li {
  415. font-size: 14px;
  416. color: #282828;
  417. text-align: center;
  418. line-height: 40px;
  419. transition: all 0.4s;
  420. cursor: pointer;
  421. &:hover {
  422. color: #36bbce;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. .login,
  429. .register,
  430. .logout {
  431. cursor: pointer;
  432. &:hover {
  433. color: fetch('color');
  434. }
  435. }
  436. }
  437. }
  438. .content {
  439. min-height: calc(100vh - 80px - 80px);
  440. background-color: #f7f7f7;
  441. overflow: hidden;
  442. }
  443. .footer {
  444. height: 80px;
  445. background-color: #2c3038;
  446. color: #fff;
  447. font-size: 14px;
  448. }
  449. }
  450. }
  451. }
  452. // 移动端
  453. @media screen and (max-width: 768px) {
  454. .layout {
  455. @include useTheme() {
  456. padding-top: 0;
  457. .header {
  458. position: fixed;
  459. top: 0;
  460. left: 0;
  461. z-index: 999;
  462. width: 100%;
  463. padding: 0 4vw;
  464. height: 12.8vw;
  465. box-sizing: border-box;
  466. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  467. display: none;
  468. .navbar {
  469. height: 100%;
  470. }
  471. .logo {
  472. img {
  473. display: block;
  474. width: 8vw;
  475. height: 8vw;
  476. &.ross {
  477. width: 14.5vw;
  478. height: 7vw;
  479. margin-right: 1.9vw;
  480. transform: translateY(-0.6vw);
  481. }
  482. }
  483. span {
  484. font-size: 4vw;
  485. color: #fff;
  486. }
  487. }
  488. .user-info {
  489. color: #fff;
  490. font-size: 3vw;
  491. .logout {
  492. margin: 0 1.6vw;
  493. }
  494. .login-btn {
  495. width: 13.4vw;
  496. height: 6.4vw;
  497. color: #fff;
  498. background: rgba(255, 255, 255, 0.39);
  499. font-size: 3.4vw;
  500. text-align: center;
  501. line-height: 6.4vw;
  502. margin-right: 2.4vw;
  503. }
  504. .user-center {
  505. position: relative;
  506. .icon {
  507. width: 5.6vw;
  508. height: 5.6vw;
  509. text-align: center;
  510. line-height: 5.6vw;
  511. margin-right: 4vw;
  512. &.el-icon-user-solid {
  513. font-size: 24px;
  514. cursor: pointer;
  515. }
  516. &.el-icon-arrow-down {
  517. display: none;
  518. }
  519. }
  520. &:hover {
  521. .drop-down {
  522. display: block;
  523. animation: slide-down 0.4s linear forwards;
  524. }
  525. .el-icon-arrow-down {
  526. transform: rotateZ(180deg);
  527. }
  528. }
  529. .drop-down {
  530. display: none;
  531. opacity: 0;
  532. // z-index: -1;
  533. right: 0;
  534. position: absolute;
  535. background: transparent;
  536. box-sizing: border-box;
  537. padding-top: 1.2vw;
  538. .nav {
  539. width: 26vw;
  540. padding: 1vw 0;
  541. background: #fff;
  542. box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
  543. border-radius: 0.4vw;
  544. li {
  545. font-size: 3.4vw;
  546. color: #282828;
  547. text-align: center;
  548. line-height: 8.6vw;
  549. transition: all 0.4s;
  550. }
  551. }
  552. }
  553. }
  554. }
  555. .collapse-icon {
  556. display: block;
  557. width: 5.6vw;
  558. height: 5.6vw;
  559. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  560. no-repeat center;
  561. background-size: 5.6vw;
  562. }
  563. }
  564. .content {
  565. min-height: calc(100vh - 12.8vw - 12.4vw);
  566. }
  567. .footer {
  568. height: 12.4vw;
  569. background-color: #2c3038;
  570. color: #fff;
  571. font-size: 3vw;
  572. }
  573. }
  574. }
  575. .nav {
  576. width: 63vw;
  577. box-sizing: border-box;
  578. padding: 0 6.4vw;
  579. .link {
  580. display: flex;
  581. justify-content: flex-start;
  582. align-items: center;
  583. border-bottom: 0.1vw solid #c2c2c2;
  584. padding-bottom: 3vw;
  585. padding-top: 6vw;
  586. .icon {
  587. width: 5.6vw;
  588. height: 5.6vw;
  589. vertical-align: -1.2vw;
  590. margin-right: 2.4vw;
  591. background-size: 5.6vw;
  592. background-repeat: no-repeat;
  593. background-position: center;
  594. &.icon-register {
  595. background-image: url(~assets/theme-images/wym/h5-link-entry-register-active.png);
  596. }
  597. &.icon-doc {
  598. background-image: url(~assets/theme-images/wym/h5-link-entry-doc-active.png);
  599. }
  600. &.icon-feedback {
  601. background-image: url(~assets/theme-images/wym/h5-link-entry-feedback-active.png);
  602. }
  603. &.icon-challenge {
  604. background-image: url(~assets/theme-images/wym/h5-link-entry-challenge.png);
  605. }
  606. }
  607. .text {
  608. font-size: 3.4vw;
  609. color: #282828;
  610. }
  611. }
  612. }
  613. }
  614. </style>