index.vue 8.9 KB

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