app-ross.vue 16 KB

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