index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <img class="logo" :src="supplierInfo.logo" />
  5. <div class="name mt-2" v-text="supplierInfo.shopName"></div>
  6. </div>
  7. <div class="page-content">
  8. <keep-alive>
  9. <div class="list">
  10. <div
  11. class="section flex flex-col justify-center items-center mt-6 mb-6 rounded-md"
  12. v-for="item in list"
  13. :key="item.id"
  14. @click="toDetail(item)"
  15. @mouseover="onMouseover(item)"
  16. @mouseleave="onMouselevel(item)"
  17. >
  18. <icon-image
  19. class="icon"
  20. :name="item.image"
  21. v-if="!item.active"
  22. ></icon-image>
  23. <icon-image class="icon" :name="item.hover" v-else></icon-image>
  24. <div class="name mt-4" v-text="item.name"></div>
  25. </div>
  26. </div>
  27. </keep-alive>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapGetters } from 'vuex'
  33. import { toAuthorization } from '~/utils'
  34. import { isWeChat } from '~/utils/validator'
  35. export default {
  36. layout: 'app',
  37. data() {
  38. return {
  39. list: [],
  40. }
  41. },
  42. asyncData() {
  43. return {
  44. list: [
  45. {
  46. id: 0,
  47. name: '授权认证',
  48. image: 'icon-approve.png',
  49. hover: 'icon-approve-active.png',
  50. path: '/approve',
  51. active: false,
  52. },
  53. {
  54. id: 1,
  55. name: '资料库',
  56. image: 'icon-doc.png',
  57. hover: 'icon-doc-active.png',
  58. path: '/database/article',
  59. active: false,
  60. },
  61. {
  62. id: 2,
  63. name: '意见反馈',
  64. image: 'icon-feedback.png',
  65. hover: 'icon-feedback-active.png',
  66. path: '/feedback',
  67. active: false,
  68. },
  69. ],
  70. }
  71. },
  72. computed: {
  73. ...mapGetters([
  74. 'supplierInfo',
  75. 'authUserId',
  76. 'appId',
  77. 'routePrefix',
  78. 'accountType',
  79. ]),
  80. },
  81. beforeDestroy() {
  82. this.$removeStorage(this.routePrefix, 'login_redicret')
  83. },
  84. methods: {
  85. toDetail(item) {
  86. const hasLogin = this.$store.getters.accessToken
  87. // 保存登录重定向路由
  88. this.$setStorage(
  89. this.routePrefix,
  90. 'login_redicret',
  91. this.routePrefix + item.path
  92. )
  93. if (item.id > 0 && !hasLogin) {
  94. // 在微信浏览器中使用微信授权登录
  95. if (isWeChat() && this.appId && this.accountType === 2) {
  96. const payload = {
  97. authUserId: this.authUserId,
  98. routePrefix: this.routePrefix,
  99. }
  100. return toAuthorization(this.appId, payload)
  101. }
  102. this.$toast({ message: '请先登录', duration: 1000 })
  103. this.$store.commit('app/SHOW_LOGIN')
  104. return
  105. }
  106. const url = this.routePrefix + item.path
  107. this.$router.push(url)
  108. },
  109. onMouseover(item) {
  110. const isPc = this.$store.getters.isPc
  111. if (!isPc) return
  112. item.active = true
  113. },
  114. onMouselevel(item) {
  115. const isPc = this.$store.getters.isPc
  116. if (!isPc) return
  117. item.active = false
  118. },
  119. },
  120. }
  121. </script>
  122. <style scoped lang="scss">
  123. // pc 端
  124. @media screen and (min-width: 768px) {
  125. .page-top {
  126. height: 360px;
  127. background: url(https://static.caimei365.com/www/authentic/pc/bg-home.png);
  128. background-size: auto 360px;
  129. .logo {
  130. display: block;
  131. width: 120px;
  132. height: 120px;
  133. border-radius: 50%;
  134. }
  135. .name {
  136. font-size: 30px;
  137. color: #fff;
  138. }
  139. }
  140. .page-content {
  141. width: 1200px;
  142. margin: 0 auto;
  143. overflow: hidden;
  144. .list {
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. }
  149. .section {
  150. width: 380px;
  151. height: 260px;
  152. margin-left: auto;
  153. margin-right: auto;
  154. background-color: #fff;
  155. transition: all 0.4s;
  156. cursor: pointer;
  157. &:hover {
  158. background-color: #bc1724;
  159. transform: translateY(-10px);
  160. .name {
  161. color: #fff;
  162. }
  163. }
  164. .icon {
  165. width: 86px;
  166. height: 86px;
  167. }
  168. .name {
  169. font-size: 24px;
  170. color: #404040;
  171. }
  172. }
  173. }
  174. }
  175. // 移动 端
  176. @media screen and (max-width: 768px) {
  177. .page-top {
  178. height: 46vw;
  179. background: url(https://static.caimei365.com/www/authentic/h5/bg-home.png);
  180. background-size: auto 46vw;
  181. .logo {
  182. display: block;
  183. width: 14.8vw;
  184. height: 14.8vw;
  185. border-radius: 50%;
  186. }
  187. .name {
  188. font-size: 4vw;
  189. color: #fff;
  190. }
  191. }
  192. .page-content {
  193. .section {
  194. width: 85.6vw;
  195. height: 58vw;
  196. margin-left: auto;
  197. margin-right: auto;
  198. box-shadow: 0px 0.4vw 2vw rgba(0, 6, 32, 0.08);
  199. .icon {
  200. width: 20vw;
  201. height: 20vw;
  202. }
  203. .name {
  204. font-size: 4.8vw;
  205. color: #404040;
  206. }
  207. }
  208. }
  209. }
  210. </style>