index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. computed: {
  43. ...mapGetters([
  44. 'supplierInfo',
  45. 'authUserId',
  46. 'appId',
  47. 'routePrefix',
  48. 'accountType',
  49. 'themeName',
  50. ]),
  51. },
  52. created() {
  53. this.initEntryItems()
  54. },
  55. beforeDestroy() {
  56. this.$removeStorage(this.routePrefix, 'login_redicret')
  57. },
  58. methods: {
  59. // 初始化入口图标
  60. initEntryItems() {
  61. this.list = [
  62. {
  63. id: 0,
  64. name: '正品授权申请入口',
  65. image: `${this.themeName}-icon-edit.png`,
  66. hover: `icon-edit-active.png`,
  67. path: '/form/club-register',
  68. active: false,
  69. },
  70. {
  71. id: 1,
  72. name: '正品授权',
  73. image: `${this.themeName}-icon-approve.png`,
  74. hover: `icon-approve-active.png`,
  75. path: '/approve',
  76. active: false,
  77. },
  78. {
  79. id: 2,
  80. name: '资料库',
  81. image: `${this.themeName}-icon-doc.png`,
  82. hover: `icon-doc-active.png`,
  83. path: '/database/article',
  84. active: false,
  85. },
  86. {
  87. id: 3,
  88. name: '意见反馈',
  89. image: `${this.themeName}-icon-feedback.png`,
  90. hover: `icon-feedback-active.png`,
  91. path: '/feedback',
  92. active: false,
  93. },
  94. ]
  95. },
  96. toDetail(item) {
  97. const hasLogin = this.$store.getters.accessToken
  98. // 保存登录重定向路由
  99. this.$setStorage(
  100. this.routePrefix,
  101. 'login_redicret',
  102. this.routePrefix + item.path
  103. )
  104. if (item.id > 1 && !hasLogin) {
  105. // 在微信浏览器中使用微信授权登录
  106. if (isWeChat() && this.appId && this.accountType === 2) {
  107. const payload = {
  108. authUserId: this.authUserId,
  109. routePrefix: this.routePrefix,
  110. }
  111. return toAuthorization(this.appId, payload)
  112. }
  113. this.$toast({ message: '请先登录', duration: 1000 })
  114. this.$store.commit('app/SHOW_LOGIN')
  115. return
  116. }
  117. if (item.id === 0) {
  118. const url = this.routePrefix + item.path
  119. this.$router.push(url)
  120. } else {
  121. const url = this.routePrefix + item.path
  122. this.$router.push(url)
  123. }
  124. },
  125. onMouseover(item) {
  126. const isPc = this.$store.getters.isPc
  127. if (!isPc) return
  128. item.active = true
  129. },
  130. onMouselevel(item) {
  131. const isPc = this.$store.getters.isPc
  132. if (!isPc) return
  133. item.active = false
  134. },
  135. },
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. // pc 端
  140. @media screen and (min-width: 768px) {
  141. .page-top {
  142. height: 360px;
  143. @include themify($themes) {
  144. background: themed('banner-home-pc');
  145. background-size: auto 360px;
  146. }
  147. .logo {
  148. display: block;
  149. width: 120px;
  150. height: 120px;
  151. border-radius: 50%;
  152. background: #fff;
  153. }
  154. .name {
  155. font-size: 30px;
  156. color: #fff;
  157. }
  158. }
  159. .page-content {
  160. width: 1200px;
  161. margin: 0 auto;
  162. overflow: hidden;
  163. .list {
  164. display: flex;
  165. justify-content: space-between;
  166. align-items: center;
  167. }
  168. .section {
  169. width: 284px;
  170. height: 260px;
  171. margin-left: auto;
  172. margin-right: auto;
  173. background-color: #fff;
  174. transition: all 0.4s;
  175. cursor: pointer;
  176. &:hover {
  177. @include themify($themes) {
  178. background-color: themed('color');
  179. }
  180. transform: translateY(-10px);
  181. .name {
  182. color: #fff;
  183. }
  184. }
  185. .icon {
  186. width: 86px;
  187. height: 86px;
  188. }
  189. .name {
  190. font-size: 24px;
  191. color: #404040;
  192. }
  193. }
  194. }
  195. }
  196. // 移动 端
  197. @media screen and (max-width: 768px) {
  198. .page-top {
  199. height: 46vw;
  200. @include themify($themes) {
  201. background: themed('banner-home-h5');
  202. background-size: auto 46vw;
  203. }
  204. .logo {
  205. display: block;
  206. width: 14.8vw;
  207. height: 14.8vw;
  208. border-radius: 50%;
  209. background: #fff;
  210. }
  211. .name {
  212. font-size: 4vw;
  213. color: #fff;
  214. }
  215. }
  216. .page-content {
  217. .section {
  218. width: 85.6vw;
  219. height: 58vw;
  220. margin-left: auto;
  221. margin-right: auto;
  222. box-shadow: 0px 0.4vw 2vw rgba(0, 6, 32, 0.08);
  223. .icon {
  224. width: 20vw;
  225. height: 20vw;
  226. }
  227. .name {
  228. font-size: 4.8vw;
  229. color: #404040;
  230. }
  231. }
  232. }
  233. }
  234. </style>