app-ph.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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. 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. }
  126. this.isMounted = true
  127. },
  128. // 校验公众号类型
  129. async checkAccountType() {
  130. try {
  131. // 1订阅号,2服务号
  132. if (!this.appId) return
  133. const res = await this.$http.api.checkAccountType({ appId: this.appId })
  134. this.$store.commit('supplier/SET_ACCOUNT_TYPE', res.data)
  135. } catch (error) {
  136. console.log(error)
  137. }
  138. },
  139. // 登录
  140. onLogin() {
  141. this.formType = 'login'
  142. this.$store.commit('app/SHOW_LOGIN')
  143. },
  144. // 注册
  145. onRegister() {
  146. this.formType = 'register'
  147. this.$store.commit('app/SHOW_LOGIN')
  148. },
  149. // 退出登录
  150. logout() {
  151. this.$store.dispatch('user/logout')
  152. this.$removeStorage(this.routePrefix, 'userInfo')
  153. this.backHome()
  154. },
  155. // 回到首页
  156. backHome() {
  157. // if (this.$route.path === this.routePrefix) return
  158. // this.$router.replace(this.routePrefix)
  159. window.location.href = window.location.origin + this.routePrefix
  160. },
  161. // 个人中心
  162. onUserCenter() {
  163. // const path = `${this.routePrefix}/center`
  164. window.location.href =
  165. window.location.origin + `${this.routePrefix}/center`
  166. },
  167. // 响应页面宽度变化
  168. responseWidth() {
  169. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  170. window.addEventListener('resize', (e) => {
  171. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  172. })
  173. },
  174. // 数据初始化刷新浏览器
  175. refreshCacheData() {
  176. this.$removeStorage(this.routePrefix, 'club_list_data')
  177. },
  178. },
  179. }
  180. </script>
  181. <style scoped lang="scss">
  182. @keyframes slide-down {
  183. 0% {
  184. top: 48px;
  185. z-index: 9;
  186. opacity: 0;
  187. }
  188. 100% {
  189. top: 32px;
  190. opacity: 1;
  191. }
  192. }
  193. // PC端
  194. @media screen and (min-width: 768px) {
  195. .layout {
  196. padding-top: 80px;
  197. user-select: none;
  198. .header {
  199. position: fixed;
  200. top: 0;
  201. left: 0;
  202. z-index: 999;
  203. width: 100%;
  204. height: 80px;
  205. box-sizing: border-box;
  206. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  207. .navbar {
  208. width: 1200px;
  209. margin: 0 auto;
  210. height: 100%;
  211. }
  212. .logo {
  213. cursor: pointer;
  214. img {
  215. display: block;
  216. width: 44px;
  217. height: 44px;
  218. &.ross {
  219. width: 85px;
  220. height: 27px;
  221. margin-right: 15px;
  222. transform: translateY(-2px);
  223. }
  224. }
  225. span {
  226. font-size: 24px;
  227. color: #fff;
  228. }
  229. }
  230. .nav {
  231. .link {
  232. display: inline;
  233. margin-left: 32px;
  234. cursor: pointer;
  235. &:hover {
  236. .text {
  237. @include themify($themes) {
  238. color: themed('color');
  239. }
  240. }
  241. .icon {
  242. &.icon-register {
  243. background-image: url(~assets/theme-images/normal/pc/link-entry-register-active.png);
  244. }
  245. &.icon-doc {
  246. background-image: url(~assets/theme-images/normal/pc/link-entry-doc-active.png);
  247. }
  248. &.icon-feedback {
  249. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback-active.png);
  250. }
  251. }
  252. }
  253. }
  254. .icon {
  255. width: 20px;
  256. height: 20px;
  257. display: inline-block;
  258. vertical-align: -4px;
  259. margin-right: 4px;
  260. background-size: 20px;
  261. background-repeat: no-repeat;
  262. background-position: center;
  263. &.icon-register {
  264. background-image: url(~assets/theme-images/normal/pc/link-entry-register.png);
  265. }
  266. &.icon-doc {
  267. background-image: url(~assets/theme-images/normal/pc/link-entry-doc.png);
  268. }
  269. &.icon-feedback {
  270. background-image: url(~assets/theme-images/normal/pc/link-entry-feedback.png);
  271. }
  272. }
  273. .text {
  274. font-size: 16px;
  275. color: #fff;
  276. }
  277. }
  278. .user-info {
  279. color: #fff;
  280. font-size: 16px;
  281. margin-left: 48px;
  282. .login-btn {
  283. width: 80px;
  284. height: 34px;
  285. color: #fff;
  286. background: rgba(255, 255, 255, 0.39);
  287. font-size: 14px;
  288. text-align: center;
  289. line-height: 34px;
  290. cursor: pointer;
  291. }
  292. .user-center {
  293. position: relative;
  294. .icon {
  295. width: 32px;
  296. height: 32px;
  297. text-align: center;
  298. line-height: 32px;
  299. &.el-icon-user-solid {
  300. font-size: 24px;
  301. cursor: pointer;
  302. }
  303. &.el-icon-arrow-down {
  304. font-size: 22px;
  305. transition: all 0.2s;
  306. }
  307. }
  308. &:hover {
  309. .drop-down {
  310. display: block;
  311. animation: slide-down 0.4s linear forwards;
  312. }
  313. .el-icon-arrow-down {
  314. transform: rotateZ(180deg);
  315. }
  316. }
  317. .drop-down {
  318. display: none;
  319. opacity: 0;
  320. // z-index: -1;
  321. right: 0;
  322. position: absolute;
  323. background: transparent;
  324. box-sizing: border-box;
  325. padding-top: 24px;
  326. .nav {
  327. width: 118px;
  328. padding: 8px 0;
  329. background: #fff;
  330. box-shadow: 0px 6px 16px rgba(40, 40, 40, 0.1);
  331. border-radius: 4px;
  332. li {
  333. font-size: 14px;
  334. color: #282828;
  335. text-align: center;
  336. line-height: 40px;
  337. transition: all 0.4s;
  338. cursor: pointer;
  339. &:hover {
  340. @include themify($themes) {
  341. color: themed('color');
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. .login,
  349. .register,
  350. .logout {
  351. cursor: pointer;
  352. &:hover {
  353. @include themify($themes) {
  354. color: themed('color');
  355. }
  356. }
  357. }
  358. }
  359. }
  360. .content {
  361. min-height: calc(100vh - 80px - 80px);
  362. background-color: #f7f7f7;
  363. overflow: hidden;
  364. }
  365. .footer {
  366. height: 80px;
  367. background-color: #2c3038;
  368. color: #fff;
  369. font-size: 14px;
  370. }
  371. }
  372. }
  373. // 移动端
  374. @media screen and (max-width: 768px) {
  375. .layout {
  376. padding-top: 12.8vw;
  377. .header {
  378. position: fixed;
  379. top: 0;
  380. left: 0;
  381. z-index: 999;
  382. width: 100%;
  383. padding: 0 4vw;
  384. height: 12.8vw;
  385. box-sizing: border-box;
  386. background: linear-gradient(90deg, #101010 0%, #404040 100%);
  387. .navbar {
  388. height: 100%;
  389. }
  390. .logo {
  391. img {
  392. display: block;
  393. width: 8vw;
  394. height: 8vw;
  395. &.ross {
  396. width: 12.2vw;
  397. height: 3.9vw;
  398. margin-right: 1.9vw;
  399. transform: translateY(-0.6vw);
  400. }
  401. }
  402. span {
  403. font-size: 4vw;
  404. color: #fff;
  405. }
  406. }
  407. .user-info {
  408. color: #fff;
  409. font-size: 3vw;
  410. .logout {
  411. margin: 0 1.6vw;
  412. }
  413. .login-btn {
  414. width: 13.4vw;
  415. height: 6.4vw;
  416. color: #fff;
  417. background: rgba(255, 255, 255, 0.39);
  418. font-size: 3.4vw;
  419. text-align: center;
  420. line-height: 6.4vw;
  421. margin-right: 2.4vw;
  422. }
  423. .user-center {
  424. position: relative;
  425. .icon {
  426. width: 5.6vw;
  427. height: 5.6vw;
  428. text-align: center;
  429. line-height: 5.6vw;
  430. margin-right: 4vw;
  431. &.el-icon-user-solid {
  432. font-size: 24px;
  433. cursor: pointer;
  434. }
  435. &.el-icon-arrow-down {
  436. display: none;
  437. }
  438. }
  439. &:hover {
  440. .drop-down {
  441. display: block;
  442. animation: slide-down 0.4s linear forwards;
  443. }
  444. .el-icon-arrow-down {
  445. transform: rotateZ(180deg);
  446. }
  447. }
  448. .drop-down {
  449. display: none;
  450. opacity: 0;
  451. right: 0;
  452. position: absolute;
  453. background: transparent;
  454. box-sizing: border-box;
  455. padding-top: 1.2vw;
  456. .nav {
  457. width: 26vw;
  458. padding: 1vw 0;
  459. background: #fff;
  460. box-shadow: 0px 0.6vw 20vw rgba(40, 40, 40, 0.1);
  461. border-radius: 0.4vw;
  462. li {
  463. font-size: 3.4vw;
  464. color: #282828;
  465. text-align: center;
  466. line-height: 8.6vw;
  467. transition: all 0.4s;
  468. }
  469. }
  470. }
  471. }
  472. }
  473. .collapse-icon {
  474. display: block;
  475. width: 5.6vw;
  476. height: 5.6vw;
  477. background: url(~assets/theme-images/common/h5-icon-collapse.png)
  478. no-repeat center;
  479. background-size: 5.6vw;
  480. }
  481. }
  482. .content {
  483. min-height: calc(100vh - 12.8vw - 12.4vw);
  484. }
  485. .footer {
  486. height: 12.4vw;
  487. background-color: #2c3038;
  488. color: #fff;
  489. font-size: 3vw;
  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>