index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 (link) {
  48. const url = link.indexOf('http') !== -1 ? `/pages/addWebView/index?url=${link}&title=${title}` : link
  49. uni.navigateTo({ url })
  50. }
  51. }
  52. const swiperChange = (e) => {
  53. current.value = e.detail.current
  54. }
  55. onMounted(() => {
  56. if(uni.getStorageSync('firstOpen')) openDialog()
  57. })
  58. </script>
  59. <style scoped lang="scss">
  60. .popup-content {
  61. align-items: center;
  62. justify-content: center;
  63. width: 80vw;
  64. height: 100vh;
  65. }
  66. .img-item{
  67. width: 100%;
  68. height: 60vh;
  69. margin: 0;
  70. border-radius: 20px;
  71. }
  72. .swiper-box{
  73. height: 100vh;
  74. }
  75. .f-straight{
  76. display: flex;
  77. justify-content: center;
  78. flex-direction: column;
  79. }
  80. </style>