shopro-notice-modal.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="popup-box" v-show="newPopupList && newPopupList.length">
  3. <view class="" v-for="(p, index) in newPopupList" :key="index">
  4. <view class="cu-modal" :class="{ show: showModal }" @tap="hideModal(p, index)" v-if="popupCurrent === index && p.image">
  5. <view class="cu-dialog" style="width: 610rpx;background: none;">
  6. <view class="img-box" @tap.stop="onPopup(p.path)"><image class="modal-img" :src="p.image" mode="aspectFit"></image></view>
  7. </view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. /**
  14. * 广告模态框。连续弹窗和只弹一次。
  15. * @property {Object} newPopupList - vuex 初始化传过来的数据
  16. */
  17. import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
  18. let timer = null;
  19. export default {
  20. name: 'shoproNoticeModal',
  21. components: {},
  22. data() {
  23. return {
  24. popupCurrent: 0,
  25. showModal: true
  26. };
  27. },
  28. props: {},
  29. computed: {
  30. ...mapGetters(['popupData', 'isLogin']),
  31. newPopupList() {
  32. if (this.popupData) {
  33. return this.popupData.list;
  34. }
  35. }
  36. },
  37. beforeDestroy() {
  38. clearTimeout(timer);
  39. timer = null;
  40. },
  41. methods: {
  42. hideModal(p, index) {
  43. clearTimeout(timer);
  44. this.showModal = false;
  45. if (p.style == 1) {
  46. this.$store.commit('delPopup', index);
  47. }
  48. timer = setTimeout(() => {
  49. this.popupCurrent += 1;
  50. this.showModal = true;
  51. }, 500);
  52. },
  53. onPopup(path) {
  54. this.$tools.routerTo(path);
  55. }
  56. }
  57. };
  58. </script>
  59. <style lang="scss">
  60. .img-box {
  61. position: relative;
  62. width: 610rpx;
  63. .modal-img {
  64. width: 100%;
  65. will-change: transform;
  66. height: 830rpx;
  67. }
  68. }
  69. </style>