index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view >
  3. <uni-popup ref="inputDialog" class="pop" :mask-click="false" @close="closeAdd">
  4. <view class="popup-content" >
  5. <swiper class="swiper-box" @change="swiperChange">
  6. <swiper-item v-for="(item ,index) in swiperList" :key="index" class="f-straight">
  7. <image class="img-item" :src="item.img" @click="skipLink(item)" mode="widthFix"></image>
  8. <view @click="closeAdd" class="f-horizon-center">
  9. <uni-icons style="display: flex;justify-content: flex-end;" type="closeempty" size="40" color="#fff"/>
  10. </view>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. </uni-popup>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref, onMounted } from 'vue'
  19. import { getWebContent } from '@/api/common'
  20. const current = ref(0)
  21. const inputDialog = ref()
  22. const swiperList = ref([])
  23. // 获取广告图
  24. const getSystemWebContent = async () => {
  25. const { data } = await getWebContent()
  26. swiperList.value = data.appAdvertisement || []
  27. }
  28. getSystemWebContent()
  29. const closeAdd = () => {
  30. inputDialog.value.close()
  31. uni.removeStorageSync('firstOpen')
  32. }
  33. const openDialog = () => {
  34. inputDialog.value.open()
  35. }
  36. const skipLink = ({ link, title }) => {
  37. closeAdd()
  38. if (link) {
  39. const url = link.indexOf('http') !== -1 ? `/pages/addWebView/index?url=${link}&title=${title}` : link
  40. uni.navigateTo({ url })
  41. }
  42. }
  43. const swiperChange = (e) => {
  44. current.value = e.detail.current
  45. }
  46. onMounted(() => {
  47. if(uni.getStorageSync('firstOpen')) openDialog()
  48. })
  49. </script>
  50. <style scoped lang="scss">
  51. .popup-content {
  52. align-items: center;
  53. justify-content: center;
  54. width: 80vw;
  55. height: 100vh;
  56. }
  57. .img-item{
  58. width: 100%;
  59. height: 60vh;
  60. margin: 0;
  61. border-radius: 20px;
  62. }
  63. .swiper-box{
  64. height: 100vh;
  65. }
  66. .f-straight{
  67. display: flex;
  68. justify-content: center;
  69. flex-direction: column;
  70. }
  71. </style>