app-ph.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. padding-top: 80px;
  199. user-select: none;
  200. .header {
  201. position: fixed;
  202. top: 0;
  203. left: 0;
  204. z-index: 999;
  205. width: 100%;
  206. height: 80px;
  207. box-sizing: border-box;
  208. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  209. .navbar {
  210. width: 1200px;
  211. margin: 0 auto;
  212. height: 100%;
  213. }
  214. .logo {
  215. cursor: pointer;
  216. img {
  217. display: block;
  218. width: 44px;
  219. height: 44px;
  220. &.ross {
  221. width: 85px;
  222. height: 27px;
  223. margin-right: 15px;
  224. transform: translateY(-2px);
  225. }
  226. }
  227. span {
  228. font-size: 24px;
  229. color: #fff;
  230. }
  231. }
  232. .nav {
  233. .link {
  234. display: inline;
  235. margin-left: 32px;
  236. cursor: pointer;
  237. &:hover {
  238. .text {
  239. @include themify($themes) {
  240. color: themed('color');
  241. }
  242. }
  243. .icon {
  244. &.icon-register {
  245. background-image: url(~assets/theme-images/normal/pc/link-entry-register-active.png);
  246. }
  247. &.icon-doc {
  248. background-image: url(~assets/theme-images/normal/pc/link-entry-doc-active.png);
  249. }
  250. &.icon-feedback {
  251. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback-active.png);
  252. }
  253. }
  254. }
  255. }
  256. .icon {
  257. width: 20px;
  258. height: 20px;
  259. display: inline-block;
  260. vertical-align: -4px;
  261. margin-right: 4px;
  262. background-size: 20px;
  263. background-repeat: no-repeat;
  264. background-position: center;
  265. &.icon-register {
  266. background-image: url(~assets/theme-images/normal/pc/link-entry-register.png);
  267. }
  268. &.icon-doc {
  269. background-image: url(~assets/theme-images/normal/pc/link-entry-doc.png);
  270. }
  271. &.icon-feedback {
  272. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback.png);
  273. }
  274. }
  275. .text {
  276. font-size: 16px;
  277. color: #fff;
  278. }
  279. }
  280. .user-info {
  281. color: #fff;
  282. font-size: 16px;
  283. margin-left: 48px;
  284. .login-btn {
  285. width: 80px;
  286. height: 34px;
  287. color: #fff;
  288. background: rgba(255, 255, 255, 0.39);
  289. font-size: 14px;
  290. text-align: center;
  291. line-height: 34px;
  292. cursor: pointer;
  293. }
  294. .user-center {
  295. position: relative;
  296. .icon {
  297. width: 32px;
  298. height: 32px;
  299. text-align: center;
  300. line-height: 32px;
  301. &.el-icon-user-solid {
  302. font-size: 24px;
  303. cursor: pointer;
  304. }
  305. &.el-icon-arrow-down {
  306. font-size: 22px;
  307. transition: all 0.2s;
  308. }
  309. }
  310. &:hover {
  311. .drop-down {
  312. display: block;
  313. animation: slide-down 0.4s linear forwards;
  314. }
  315. .el-icon-arrow-down {
  316. transform: rotateZ(180deg);
  317. }
  318. }
  319. .drop-down {
  320. display: none;
  321. opacity: 0;
  322. // z-index: -1;
  323. right: 0;
  324. position: absolute;
  325. background: transparent;
  326. box-sizing: border-box;
  327. padding-top: 24px;
  328. .nav {
  329. width: 118px;
  330. padding: 8px 0;
  331. background: #fff;
  332. box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
  333. border-radius: 4px;
  334. li {
  335. font-size: 14px;
  336. color: #282828;
  337. text-align: center;
  338. line-height: 40px;
  339. transition: all 0.4s;
  340. cursor: pointer;
  341. &:hover {
  342. @include themify($themes) {
  343. color: themed('color');
  344. }
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .login,
  351. .register,
  352. .logout {
  353. cursor: pointer;
  354. &:hover {
  355. @include themify($themes) {
  356. color: themed('color');
  357. }
  358. }
  359. }
  360. }
  361. }
  362. .content {
  363. min-height: calc(100vh - 80px - 80px);
  364. background-color: #f7f7f7;
  365. overflow: hidden;
  366. }
  367. .footer {
  368. height: 80px;
  369. background-color: #2c3038;
  370. color: #fff;
  371. font-size: 14px;
  372. }
  373. }
  374. }
  375. // 移动端
  376. @media screen and (max-width: 768px) {
  377. .layout {
  378. padding-top: 12.8vw;
  379. .header {
  380. position: fixed;
  381. top: 0;
  382. left: 0;
  383. z-index: 999;
  384. width: 100%;
  385. padding: 0 4vw;
  386. height: 12.8vw;
  387. box-sizing: border-box;
  388. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  389. .navbar {
  390. height: 100%;
  391. }
  392. .logo {
  393. img {
  394. display: block;
  395. width: 8vw;
  396. height: 8vw;
  397. &.ross {
  398. width: 12.2vw;
  399. height: 3.9vw;
  400. margin-right: 1.9vw;
  401. transform: translateY(-0.6vw);
  402. }
  403. }
  404. span {
  405. font-size: 4vw;
  406. color: #fff;
  407. }
  408. }
  409. .user-info {
  410. color: #fff;
  411. font-size: 3vw;
  412. .logout {
  413. margin: 0 1.6vw;
  414. }
  415. .login-btn {
  416. width: 13.4vw;
  417. height: 6.4vw;
  418. color: #fff;
  419. background: rgba(255, 255, 255, 0.39);
  420. font-size: 3.4vw;
  421. text-align: center;
  422. line-height: 6.4vw;
  423. margin-right: 2.4vw;
  424. }
  425. .user-center {
  426. position: relative;
  427. .icon {
  428. width: 5.6vw;
  429. height: 5.6vw;
  430. text-align: center;
  431. line-height: 5.6vw;
  432. margin-right: 4vw;
  433. &.el-icon-user-solid {
  434. font-size: 24px;
  435. cursor: pointer;
  436. }
  437. &.el-icon-arrow-down {
  438. display: none;
  439. }
  440. }
  441. &:hover {
  442. .drop-down {
  443. display: block;
  444. animation: slide-down 0.4s linear forwards;
  445. }
  446. .el-icon-arrow-down {
  447. transform: rotateZ(180deg);
  448. }
  449. }
  450. .drop-down {
  451. display: none;
  452. opacity: 0;
  453. right: 0;
  454. position: absolute;
  455. background: transparent;
  456. box-sizing: border-box;
  457. padding-top: 1.2vw;
  458. .nav {
  459. width: 26vw;
  460. padding: 1vw 0;
  461. background: #fff;
  462. box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
  463. border-radius: 0.4vw;
  464. li {
  465. font-size: 3.4vw;
  466. color: #282828;
  467. text-align: center;
  468. line-height: 8.6vw;
  469. transition: all 0.4s;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .collapse-icon {
  476. display: block;
  477. width: 5.6vw;
  478. height: 5.6vw;
  479. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  480. no-repeat center;
  481. background-size: 5.6vw;
  482. }
  483. }
  484. .content {
  485. min-height: calc(100vh - 12.8vw - 12.4vw);
  486. }
  487. .footer {
  488. height: 12.4vw;
  489. background-color: #2c3038;
  490. color: #fff;
  491. font-size: 3vw;
  492. }
  493. }
  494. .nav {
  495. width: 63vw;
  496. box-sizing: border-box;
  497. padding: 0 6.4vw;
  498. .link {
  499. display: flex;
  500. justify-content: flex-start;
  501. align-items: center;
  502. border-bottom: 0.1vw solid #c2c2c2;
  503. padding-bottom: 3vw;
  504. padding-top: 6vw;
  505. .icon {
  506. width: 5.6vw;
  507. height: 5.6vw;
  508. vertical-align: -1.2vw;
  509. margin-right: 2.4vw;
  510. background-size: 5.6vw;
  511. background-repeat: no-repeat;
  512. background-position: center;
  513. &.icon-register {
  514. background-image: url(~assets/theme-images/normal/h5/link-entry-register-active.png);
  515. }
  516. &.icon-doc {
  517. background-image: url(~assets/theme-images/normal/h5/link-entry-doc-active.png);
  518. }
  519. &.icon-feedback {
  520. background-image: url(~assets/theme-images/normal/h5/link-entry-feedback-active.png);
  521. }
  522. }
  523. .text {
  524. font-size: 3.4vw;
  525. color: #282828;
  526. }
  527. }
  528. }
  529. }
  530. </style>