app-ross.vue 16 KB

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