index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div class="page">
  3. <div class="page-top" @click="toActivity">
  4. <img class="logo" :src="logoImage" alt="" />
  5. </div>
  6. <div class="page-content">
  7. <keep-alive>
  8. <div class="list">
  9. <div
  10. class="section flex flex-col justify-center items-center rounded-md"
  11. v-for="item in list"
  12. :key="item.id"
  13. >
  14. <icon-image class="icon" :name="item.image"></icon-image>
  15. <div
  16. class="name mt-4"
  17. v-text="item.name"
  18. @click="toDetail(item)"
  19. ></div>
  20. </div>
  21. </div>
  22. </keep-alive>
  23. </div>
  24. <div class="page-footer flex flex-col justify-center">
  25. <div class="name mb-1">需要帮助吗?</div>
  26. <div class="contact">联系我们官方客服</div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { toAuthorization } from '~/utils'
  32. import { isWeChat } from '~/utils/validator'
  33. import { mapGetters } from 'vuex'
  34. export default {
  35. layout: 'app-ldm',
  36. data() {
  37. return {
  38. logoImage: '',
  39. list: [],
  40. banner: {},
  41. screenWidth: ""
  42. }
  43. },
  44. asyncData({ store }) {
  45. const logoImage = store.getters.static + '/ldm-logo-rect-white.png'
  46. return {
  47. logoImage,
  48. list: [
  49. {
  50. id: 0,
  51. name: '正品授权',
  52. image: 'ldm-icon-approve.png',
  53. path: '/approve',
  54. },
  55. {
  56. id: 1,
  57. name: '云资料库',
  58. image: 'ldm-icon-database.png',
  59. path: '/docs/0',
  60. },
  61. ],
  62. }
  63. },
  64. watch: {
  65. screenWidth: {
  66. handler(val) {
  67. const changeBanner = document.getElementsByClassName('page-top')[0]
  68. if (changeBanner) {
  69. if (val > 768) {
  70. if(this.banner.headPcBanner) {
  71. changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')'
  72. }
  73. }else {
  74. if(this.banner.headAppBanner) {
  75. changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')'
  76. }
  77. }
  78. }
  79. },
  80. immediate: true,
  81. deep: true
  82. }
  83. },
  84. computed: {
  85. ...mapGetters(['authUserId', 'appId', 'routePrefix', 'accountType']),
  86. },
  87. mounted() {
  88. this.initAppMessageShareData() // 公众号分享授权页面
  89. window.addEventListener('scroll', () => {
  90. this.scrollTop = document.documentElement.scrollTop
  91. })
  92. this.getBanner() // 获取轮播图
  93. // 监听页面尺寸变化
  94. this.screenWidth = document.body.clientWidth
  95. window.onresize = () => {
  96. return (() => {
  97. this.screenWidth = document.body.clientWidth
  98. })()
  99. }
  100. },
  101. beforeDestroy() {
  102. this.$removeStorage(this.routePrefix, 'login_redicret')
  103. },
  104. created() {
  105. document.title = '官方正品授权查询'
  106. },
  107. methods: {
  108. // 抖音挑战赛
  109. toActivity() {
  110. if(this.screenWidth > 768) {
  111. this.banner.jumpLink && window.open(this.banner.jumpLink)
  112. this.banner.jumpPcPicture && window.open(this.banner.jumpPcPicture)
  113. } else {
  114. this.banner.jumpLink && window.open(this.banner.jumpLink)
  115. this.banner.jumpAppPicture && window.open(this.banner.jumpAppPicture)
  116. }
  117. },
  118. toDetail(item) {
  119. // 保存登录重定向路由
  120. this.$setStorage(
  121. this.routePrefix,
  122. 'login_redicret',
  123. this.routePrefix + item.path
  124. )
  125. const hasLogin = this.$store.getters.accessToken
  126. if (item.id > 1 && !hasLogin) {
  127. // 在微信浏览器中使用微信授权登录
  128. if (isWeChat() && this.appId && this.accountType === 2) {
  129. const payload = {
  130. authUserId: this.authUserId,
  131. routePrefix: this.routePrefix,
  132. }
  133. return toAuthorization(this.appId, payload)
  134. }
  135. this.$toast({ message: '请先登录', duration: 1000 })
  136. this.$store.commit('app/SHOW_LOGIN')
  137. return
  138. }
  139. const url = this.routePrefix + item.path
  140. this.$router.push(url)
  141. },
  142. // banner
  143. async getBanner() {
  144. const { data } = await this.$http.api.bannerImg(this.authUserId)
  145. this.banner = data
  146. const changeBanner = document.getElementsByClassName('page-top')[0]
  147. if (this.screenWidth > 768) {
  148. this.banner.headPcBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')')
  149. }else {
  150. this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
  151. }
  152. },
  153. // 分享当前页面
  154. initAppMessageShareData() {
  155. console.log(window.location.href, window.location.origin)
  156. // 重试次数
  157. let retryCount = 1
  158. this.$wxReady((wx) => {
  159. //需在用户可能点击分享按钮前就先调用
  160. wx.updateAppMessageShareData({
  161. title: '官方正品授权查询', // 分享标题
  162. desc: '官方正品授权', // 分享描述
  163. link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
  164. imgUrl: this.banner.headAppBanner, // 分享图标
  165. fail: () => {
  166. if (retryCount === 0) return
  167. this.initAppMessageShareData()
  168. retryCount--
  169. },
  170. })
  171. })
  172. },
  173. },
  174. }
  175. </script>
  176. <style scoped lang="scss">
  177. @media screen and (min-width: 768px) {
  178. .page-top {
  179. height: 596px;
  180. background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-home.png)
  181. no-repeat center;
  182. background-size: auto 596px;
  183. .logo {
  184. display: none;
  185. }
  186. }
  187. .page-content {
  188. width: 700px;
  189. margin: 0 auto;
  190. min-height: calc(100vh - 596px - 100px);
  191. overflow: hidden;
  192. .list {
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. margin-top: 124px;
  197. margin-bottom: 314px;
  198. .section {
  199. .icon {
  200. width: 120px;
  201. height: 120px;
  202. }
  203. .name {
  204. width: 241px;
  205. height: 73px;
  206. background: #000;
  207. text-align: center;
  208. line-height: 73px;
  209. color: #fff;
  210. font-size: 22px;
  211. cursor: pointer;
  212. }
  213. }
  214. }
  215. }
  216. .page-footer {
  217. position: relative;
  218. height: 100px;
  219. padding-left: 194px;
  220. background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
  221. .name {
  222. font-size: 24px;
  223. color: #9d9d9d;
  224. }
  225. .contact {
  226. font-size: 19px;
  227. color: #9d9d9d;
  228. }
  229. &::before {
  230. position: absolute;
  231. left: 120px;
  232. top: 50%;
  233. transform: translateY(-50%);
  234. content: '';
  235. display: block;
  236. width: 56px;
  237. height: 56px;
  238. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
  239. no-repeat center;
  240. background-size: 56px auto;
  241. }
  242. }
  243. }
  244. @media screen and (max-width: 768px) {
  245. .page-top {
  246. position: relative;
  247. height: 59.6vw;
  248. background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-home.gif);
  249. background-size: auto 59.6vw;
  250. .logo {
  251. position: absolute;
  252. left: 50%;
  253. top: 13.7vw;
  254. width: 37.8vw;
  255. transform: translateX(-50%);
  256. }
  257. }
  258. .page-content {
  259. min-height: calc(100vh - 59.6vw - 15.4vw);
  260. overflow: hidden;
  261. .list {
  262. display: flex;
  263. flex-direction: column;
  264. align-items: center;
  265. margin-top: 10.9vw;
  266. .section {
  267. width: 80vw;
  268. height: 48vw;
  269. background: #f8f8f8;
  270. border: 0.1vw solid #bfbfbf;
  271. margin-bottom: 5.8vw;
  272. .icon {
  273. width: 18.9vw;
  274. height: 18.9vw;
  275. }
  276. .name {
  277. width: 37.8vw;
  278. height: 11.4vw;
  279. background: #000;
  280. text-align: center;
  281. line-height: 11.4vw;
  282. color: #fff;
  283. }
  284. }
  285. }
  286. }
  287. .page-footer {
  288. position: relative;
  289. height: 15.4vw;
  290. padding-left: 12.5vw;
  291. background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
  292. .name {
  293. font-size: 3.2vw;
  294. color: #9d9d9d;
  295. }
  296. .contact {
  297. font-size: 2.6vw;
  298. color: #9d9d9d;
  299. }
  300. &::before {
  301. position: absolute;
  302. left: 2.4vw;
  303. top: 50%;
  304. transform: translateY(-50%);
  305. content: '';
  306. display: block;
  307. width: 7.5vw;
  308. height: 7.5vw;
  309. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
  310. no-repeat center;
  311. background-size: 7.4vw auto;
  312. }
  313. }
  314. }
  315. </style>