app-ross.vue 15 KB

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