index.vue 8.6 KB

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