app-ph.vue 14 KB

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