index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. <div class="icon-image" :class="'item' + item.id"></div>
  19. <div class="name mt-4" v-text="item.name"></div>
  20. </div>
  21. </div>
  22. </keep-alive>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { mapGetters } from 'vuex'
  28. import { toAuthorization } from '~/utils'
  29. import { isWeChat } from '~/utils/validator'
  30. export default {
  31. layout: 'app',
  32. data() {
  33. return {
  34. list: [],
  35. }
  36. },
  37. computed: {
  38. ...mapGetters([
  39. 'supplierInfo',
  40. 'authUserId',
  41. 'appId',
  42. 'routePrefix',
  43. 'accountType',
  44. ]),
  45. },
  46. created() {
  47. this.initEntryItems()
  48. },
  49. beforeDestroy() {
  50. this.$removeStorage(this.routePrefix, 'login_redicret')
  51. },
  52. methods: {
  53. // 初始化入口图标
  54. initEntryItems() {
  55. this.list = [
  56. {
  57. id: 0,
  58. name: '正品授权申请入口',
  59. path: '/form/club-register',
  60. active: false,
  61. },
  62. {
  63. id: 1,
  64. name: '正品授权',
  65. path: '/approve',
  66. active: false,
  67. },
  68. {
  69. id: 2,
  70. name: '资料库',
  71. path: '/database/article',
  72. active: false,
  73. },
  74. {
  75. id: 3,
  76. name: '意见反馈',
  77. path: '/feedback',
  78. active: false,
  79. },
  80. ]
  81. },
  82. toDetail(item) {
  83. const hasLogin = this.$store.getters.accessToken
  84. // 保存登录重定向路由
  85. this.$setStorage(
  86. this.routePrefix,
  87. 'login_redicret',
  88. this.routePrefix + item.path
  89. )
  90. if (item.id > 1 && !hasLogin) {
  91. // 在微信浏览器中使用微信授权登录
  92. if (isWeChat() && this.appId && this.accountType === 2) {
  93. const payload = {
  94. authUserId: this.authUserId,
  95. routePrefix: this.routePrefix,
  96. }
  97. return toAuthorization(this.appId, payload)
  98. }
  99. this.$toast({ message: '请先登录', duration: 1000 })
  100. this.$store.commit('app/SHOW_LOGIN')
  101. return
  102. }
  103. if (item.id === 0) {
  104. const url = this.routePrefix + item.path
  105. this.$router.push(url)
  106. } else {
  107. const url = this.routePrefix + item.path
  108. this.$router.push(url)
  109. }
  110. },
  111. onMouseover(item) {
  112. const isPc = this.$store.getters.isPc
  113. if (!isPc) return
  114. item.active = true
  115. },
  116. onMouselevel(item) {
  117. const isPc = this.$store.getters.isPc
  118. if (!isPc) return
  119. item.active = false
  120. },
  121. },
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. // pc 端
  126. @media screen and (min-width: 768px) {
  127. .page-top {
  128. height: 360px;
  129. @include themify($themes) {
  130. background: themed('pc-banner-home');
  131. background-size: auto 360px;
  132. }
  133. .logo {
  134. display: block;
  135. width: 120px;
  136. height: 120px;
  137. border-radius: 50%;
  138. background: #fff;
  139. }
  140. .name {
  141. font-size: 30px;
  142. color: #fff;
  143. }
  144. }
  145. .page-content {
  146. width: 1200px;
  147. margin: 0 auto;
  148. overflow: hidden;
  149. .list {
  150. display: flex;
  151. justify-content: space-between;
  152. align-items: center;
  153. }
  154. .section {
  155. width: 284px;
  156. height: 260px;
  157. margin-left: auto;
  158. margin-right: auto;
  159. background-color: #fff;
  160. transition: all 0.4s;
  161. cursor: pointer;
  162. .icon-image {
  163. width: 86px;
  164. height: 86px;
  165. background-size: 86px 86px;
  166. background-repeat: no-repeat;
  167. background-position: center;
  168. &.item0 {
  169. @include themify($themes) {
  170. background-image: themed('pc-icon-home-edit');
  171. }
  172. }
  173. &.item1 {
  174. @include themify($themes) {
  175. background-image: themed('pc-icon-home-approve');
  176. }
  177. }
  178. &.item2 {
  179. @include themify($themes) {
  180. background-image: themed('pc-icon-home-doc');
  181. }
  182. }
  183. &.item3 {
  184. @include themify($themes) {
  185. background-image: themed('pc-icon-home-feedback');
  186. }
  187. }
  188. }
  189. &:hover {
  190. transform: translateY(-10px);
  191. @include themify($themes) {
  192. background-color: themed('color');
  193. }
  194. .icon-image {
  195. &.item0 {
  196. background-image: url(~assets/theme-images/common/pc-icon-edit-active.png) !important;
  197. }
  198. &.item1 {
  199. background-image: url(~assets/theme-images/common/pc-icon-approve-active.png) !important;
  200. }
  201. &.item2 {
  202. background-image: url(~assets/theme-images/common/pc-icon-doc-active.png) !important;
  203. }
  204. &.item3 {
  205. background-image: url(~assets/theme-images/common/pc-icon-feedback-active.png) !important;
  206. }
  207. }
  208. .name {
  209. color: #fff;
  210. }
  211. }
  212. .icon {
  213. width: 86px;
  214. height: 86px;
  215. }
  216. .name {
  217. font-size: 24px;
  218. color: #404040;
  219. }
  220. }
  221. }
  222. }
  223. // 移动 端
  224. @media screen and (max-width: 768px) {
  225. .page-top {
  226. height: 46vw;
  227. @include themify($themes) {
  228. background: themed('h5-banner-home');
  229. background-size: auto 46vw;
  230. }
  231. .logo {
  232. display: block;
  233. width: 14.8vw;
  234. height: 14.8vw;
  235. border-radius: 50%;
  236. background: #fff;
  237. }
  238. .name {
  239. font-size: 4vw;
  240. color: #fff;
  241. }
  242. }
  243. .page-content {
  244. .section {
  245. width: 85.6vw;
  246. height: 58vw;
  247. margin-left: auto;
  248. margin-right: auto;
  249. box-shadow: 0px 0.4vw 2vw rgba(0, 6, 32, 0.08);
  250. .icon {
  251. width: 20vw;
  252. height: 20vw;
  253. }
  254. .name {
  255. font-size: 4.8vw;
  256. color: #404040;
  257. }
  258. .icon-image {
  259. width: 86px;
  260. height: 86px;
  261. background-size: 86px 86px;
  262. background-repeat: no-repeat;
  263. background-position: center;
  264. &.item0 {
  265. @include themify($themes) {
  266. background-image: themed('h5-icon-home-edit');
  267. }
  268. }
  269. &.item1 {
  270. @include themify($themes) {
  271. background-image: themed('h5-icon-home-approve');
  272. }
  273. }
  274. &.item2 {
  275. @include themify($themes) {
  276. background-image: themed('h5-icon-home-doc');
  277. }
  278. }
  279. &.item3 {
  280. @include themify($themes) {
  281. background-image: themed('h5-icon-home-feedback');
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>