index.vue 10 KB

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