index.vue 7.2 KB

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