index.vue 7.5 KB

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