s-popup-image.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view>
  3. <view v-for="(item, index) in popupList" :key="item.src">
  4. <su-popup
  5. v-if="index === currentIndex"
  6. :show="item.isShow"
  7. type="center"
  8. backgroundColor="none"
  9. round="0"
  10. :showClose="true"
  11. :isMaskClick="false"
  12. @close="onClose(index)"
  13. >
  14. <view class="img-box">
  15. <image
  16. class="modal-img"
  17. :src="sheep.$url.cdn(item.src)"
  18. mode="widthFix"
  19. @tap.stop="onPopup(item.url)"
  20. />
  21. </view>
  22. </su-popup>
  23. </view>
  24. </view>
  25. </template>
  26. <script setup>
  27. import sheep from '@/sheep';
  28. import { computed, ref } from 'vue';
  29. import { onShow } from '@dcloudio/uni-app';
  30. import { saveAdvHistory } from '@/sheep/hooks/useModal';
  31. // const modalStore = sheep.$store('modal');
  32. const modalStore = JSON.parse(uni.getStorageSync('modal-store') || '{}');
  33. const advHistory = modalStore.advHistory || [];
  34. const currentIndex = ref(0);
  35. const popupList = computed(() => {
  36. const list = sheep.$store('app').template.basic?.popupImage?.list || [];
  37. const newList = [];
  38. if (list.length > 0) {
  39. list.forEach((adv) => {
  40. if (adv.show === 1 && advHistory.includes(adv.src)) {
  41. adv.isShow = false;
  42. } else {
  43. adv.isShow = true;
  44. newList.push(adv);
  45. }
  46. saveAdvHistory(adv);
  47. });
  48. }
  49. return newList;
  50. });
  51. function onPopup(path) {
  52. sheep.$router.go(path);
  53. }
  54. function onClose(index) {
  55. currentIndex.value = index + 1;
  56. popupList.value[index].isShow = false;
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .img-box {
  61. width: 610rpx;
  62. // height: 800rpx;
  63. }
  64. .modal-img {
  65. width: 100%;
  66. height: 100%;
  67. }
  68. </style>