index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. window.addEventListener('scroll', () => {
  89. this.scrollTop = document.documentElement.scrollTop
  90. })
  91. this.getBanner() // 获取轮播图
  92. // 监听页面尺寸变化
  93. this.screenWidth = document.body.clientWidth
  94. window.onresize = () => {
  95. return (() => {
  96. this.screenWidth = document.body.clientWidth
  97. })()
  98. }
  99. },
  100. beforeDestroy() {
  101. this.$removeStorage(this.routePrefix, 'login_redicret')
  102. },
  103. created() {
  104. document.title = '官方正品授权查询'
  105. },
  106. methods: {
  107. // 抖音挑战赛
  108. toActivity() {
  109. if(this.screenWidth > 768) {
  110. this.banner.jumpLink && window.open(this.banner.jumpLink)
  111. this.banner.jumpPcPicture && window.open(this.banner.jumpPcPicture)
  112. } else {
  113. this.banner.jumpLink && window.open(this.banner.jumpLink)
  114. this.banner.jumpAppPicture && window.open(this.banner.jumpAppPicture)
  115. }
  116. },
  117. toDetail(item) {
  118. // 保存登录重定向路由
  119. this.$setStorage(
  120. this.routePrefix,
  121. 'login_redicret',
  122. this.routePrefix + item.path
  123. )
  124. const hasLogin = this.$store.getters.accessToken
  125. if (item.id > 1 && !hasLogin) {
  126. // 在微信浏览器中使用微信授权登录
  127. if (isWeChat() && this.appId && this.accountType === 2) {
  128. const payload = {
  129. authUserId: this.authUserId,
  130. routePrefix: this.routePrefix,
  131. }
  132. return toAuthorization(this.appId, payload)
  133. }
  134. this.$toast({ message: '请先登录', duration: 1000 })
  135. this.$store.commit('app/SHOW_LOGIN')
  136. return
  137. }
  138. const url = this.routePrefix + item.path
  139. this.$router.push(url)
  140. },
  141. // banner
  142. async getBanner() {
  143. const { data } = await this.$http.api.bannerImg(this.authUserId)
  144. this.banner = data
  145. const changeBanner = document.getElementsByClassName('page-top')[0]
  146. if (this.screenWidth > 768) {
  147. this.banner.headPcBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')')
  148. }else {
  149. this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
  150. }
  151. },
  152. },
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. @media screen and (min-width: 768px) {
  157. .page-top {
  158. height: 596px;
  159. background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-home.png)
  160. no-repeat center;
  161. background-size: auto 596px;
  162. .logo {
  163. display: none;
  164. }
  165. }
  166. .page-content {
  167. width: 700px;
  168. margin: 0 auto;
  169. min-height: calc(100vh - 596px - 100px);
  170. overflow: hidden;
  171. .list {
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-between;
  175. margin-top: 124px;
  176. margin-bottom: 314px;
  177. .section {
  178. .icon {
  179. width: 120px;
  180. height: 120px;
  181. }
  182. .name {
  183. width: 241px;
  184. height: 73px;
  185. background: #000;
  186. text-align: center;
  187. line-height: 73px;
  188. color: #fff;
  189. font-size: 22px;
  190. cursor: pointer;
  191. }
  192. }
  193. }
  194. }
  195. .page-footer {
  196. position: relative;
  197. height: 100px;
  198. padding-left: 194px;
  199. background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
  200. .name {
  201. font-size: 24px;
  202. color: #9d9d9d;
  203. }
  204. .contact {
  205. font-size: 19px;
  206. color: #9d9d9d;
  207. }
  208. &::before {
  209. position: absolute;
  210. left: 120px;
  211. top: 50%;
  212. transform: translateY(-50%);
  213. content: '';
  214. display: block;
  215. width: 56px;
  216. height: 56px;
  217. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
  218. no-repeat center;
  219. background-size: 56px auto;
  220. }
  221. }
  222. }
  223. @media screen and (max-width: 768px) {
  224. .page-top {
  225. position: relative;
  226. height: 59.6vw;
  227. background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-home.gif);
  228. background-size: auto 59.6vw;
  229. .logo {
  230. position: absolute;
  231. left: 50%;
  232. top: 13.7vw;
  233. width: 37.8vw;
  234. transform: translateX(-50%);
  235. }
  236. }
  237. .page-content {
  238. min-height: calc(100vh - 59.6vw - 15.4vw);
  239. overflow: hidden;
  240. .list {
  241. display: flex;
  242. flex-direction: column;
  243. align-items: center;
  244. margin-top: 10.9vw;
  245. .section {
  246. width: 80vw;
  247. height: 48vw;
  248. background: #f8f8f8;
  249. border: 0.1vw solid #bfbfbf;
  250. margin-bottom: 5.8vw;
  251. .icon {
  252. width: 18.9vw;
  253. height: 18.9vw;
  254. }
  255. .name {
  256. width: 37.8vw;
  257. height: 11.4vw;
  258. background: #000;
  259. text-align: center;
  260. line-height: 11.4vw;
  261. color: #fff;
  262. }
  263. }
  264. }
  265. }
  266. .page-footer {
  267. position: relative;
  268. height: 15.4vw;
  269. padding-left: 12.5vw;
  270. background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
  271. .name {
  272. font-size: 3.2vw;
  273. color: #9d9d9d;
  274. }
  275. .contact {
  276. font-size: 2.6vw;
  277. color: #9d9d9d;
  278. }
  279. &::before {
  280. position: absolute;
  281. left: 2.4vw;
  282. top: 50%;
  283. transform: translateY(-50%);
  284. content: '';
  285. display: block;
  286. width: 7.5vw;
  287. height: 7.5vw;
  288. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
  289. no-repeat center;
  290. background-size: 7.4vw auto;
  291. }
  292. }
  293. }
  294. </style>