index.vue 4.5 KB

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