index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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: '/app/approve',
  51. active: false,
  52. },
  53. {
  54. id: 1,
  55. name: '资料库',
  56. image: 'icon-doc.png',
  57. hover: 'icon-doc-active.png',
  58. path: '/app/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: '/app/feedback',
  67. active: false,
  68. },
  69. ],
  70. }
  71. },
  72. computed: {
  73. ...mapGetters([
  74. 'supplierInfo',
  75. 'authUserId',
  76. 'appId',
  77. 'type',
  78. 'accountType',
  79. ]),
  80. },
  81. created() {},
  82. methods: {
  83. toDetail(item) {
  84. const hasLogin = this.$store.getters.accessToken
  85. if (item.id > 0 && !hasLogin) {
  86. // 在微信浏览器中使用微信授权登录
  87. if (isWeChat() && this.appId && this.accountType === 2) {
  88. const payload = { authUserId: this.authUserId, type: this.type }
  89. return toAuthorization(this.appId, payload)
  90. }
  91. this.$toast({ message: '请先登录', duration: 1000 })
  92. this.$store.commit('app/SHOW_LOGIN')
  93. return
  94. }
  95. const url = `/${this.authUserId}${item.path}`
  96. this.$router.push(url)
  97. },
  98. onMouseover(item) {
  99. const isPc = this.$store.getters.isPc
  100. if (!isPc) return
  101. item.active = true
  102. },
  103. onMouselevel(item) {
  104. const isPc = this.$store.getters.isPc
  105. if (!isPc) return
  106. item.active = false
  107. },
  108. },
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. // pc 端
  113. @media screen and (min-width: 768px) {
  114. .page-top {
  115. height: 360px;
  116. background: url(https://static.caimei365.com/www/authentic/pc/bg-home.png);
  117. background-size: auto 360px;
  118. .logo {
  119. display: block;
  120. width: 120px;
  121. height: 120px;
  122. border-radius: 50%;
  123. }
  124. .name {
  125. font-size: 30px;
  126. color: #fff;
  127. }
  128. }
  129. .page-content {
  130. width: 1200px;
  131. margin: 0 auto;
  132. overflow: hidden;
  133. .list {
  134. display: flex;
  135. justify-content: space-between;
  136. align-items: center;
  137. }
  138. .section {
  139. width: 380px;
  140. height: 260px;
  141. margin-left: auto;
  142. margin-right: auto;
  143. background-color: #fff;
  144. transition: all 0.4s;
  145. cursor: pointer;
  146. &:hover {
  147. background-color: #bc1724;
  148. transform: translateY(-10px);
  149. .name {
  150. color: #fff;
  151. }
  152. }
  153. .icon {
  154. width: 86px;
  155. height: 86px;
  156. }
  157. .name {
  158. font-size: 24px;
  159. color: #404040;
  160. }
  161. }
  162. }
  163. }
  164. // 移动 端
  165. @media screen and (max-width: 768px) {
  166. .page-top {
  167. height: 46vw;
  168. background: url(https://static.caimei365.com/www/authentic/h5/bg-home.png);
  169. background-size: auto 46vw;
  170. .logo {
  171. display: block;
  172. width: 14.8vw;
  173. height: 14.8vw;
  174. border-radius: 50%;
  175. }
  176. .name {
  177. font-size: 4vw;
  178. color: #fff;
  179. }
  180. }
  181. .page-content {
  182. .section {
  183. width: 85.6vw;
  184. height: 58vw;
  185. margin-left: auto;
  186. margin-right: auto;
  187. box-shadow: 0px 0.4vw 2vw rgba(0, 6, 32, 0.08);
  188. .icon {
  189. width: 20vw;
  190. height: 20vw;
  191. }
  192. .name {
  193. font-size: 4.8vw;
  194. color: #404040;
  195. }
  196. }
  197. }
  198. }
  199. </style>