index.vue 8.9 KB

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