index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. // url: 'https://minio.menduner.com/dev/260c94447f93c5258e6b5c0db453f9da92ce59bebd1eef6bff3a8063d91d07f1.jpg',
  25. // path: 'https://mp.weixin.qq.com/s/lI7_iHY1yaEqrb_kG1MusA'
  26. // }
  27. // {
  28. // url: 'https://minio.menduner.com/dev/menduner/advertisement.jpg' // 注册广告
  29. // }
  30. ])
  31. const currentPage = getCurrentPages()[0].route
  32. // 获取广告图
  33. const getSystemWebContent = async () => {
  34. const { data } = await getWebContent()
  35. swiperList.value = data.appAdvertisement || []
  36. }
  37. getSystemWebContent()
  38. const closeAdd = () => {
  39. inputDialog.value.close()
  40. uni.removeStorageSync('firstOpen')
  41. }
  42. const openDialog = () => {
  43. inputDialog.value.open()
  44. }
  45. const skipLink = ({ link, title }) => {
  46. closeAdd()
  47. // if (!uni.getStorageSync('token') && currentPage !== 'pages/login/index') {
  48. // uni.switchTab({
  49. // url: '/pages/index/my'
  50. // })
  51. // }
  52. if (link) {
  53. uni.navigateTo({ url: `/pages/addWebView/index?url=${link}&title=${title}` })
  54. }
  55. }
  56. const swiperChange = (e) => {
  57. current.value = e.detail.current
  58. }
  59. onMounted(() => {
  60. if(uni.getStorageSync('firstOpen')) openDialog()
  61. })
  62. </script>
  63. <style scoped lang="scss">
  64. .popup-content {
  65. align-items: center;
  66. justify-content: center;
  67. width: 80vw;
  68. height: 100vh;
  69. }
  70. .img-item{
  71. width: 100%;
  72. height: 60vh;
  73. margin: 0;
  74. border-radius: 20px;
  75. }
  76. .swiper-box{
  77. height: 100vh;
  78. }
  79. .f-straight{
  80. display: flex;
  81. justify-content: center;
  82. flex-direction: column;
  83. }
  84. </style>