cm-active-alert.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view>
  3. <view class="notice-model" v-if="couponNoticeFlag" @click="toDetail('notice')">
  4. <image :src="staticUrl + 'logo.png'" class="cover"></image>
  5. <view class="content">
  6. <text class="title">颜选美学</text>
  7. <text class="subTitle">您已获得优惠券奖励,赶紧去领取吧!</text>
  8. </view>
  9. </view>
  10. <uni-popup ref="activeAlertPopup" type="center" :is-mask-click="false">
  11. <view class="popup-content">
  12. <view class="close-btn iconfont icon-iconfontguanbi" @click="onClose"></view>
  13. <image class="image" :src="image" @click="toDetail('active')" mode="widthFix"></image>
  14. </view>
  15. </uni-popup>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapGetters, mapActions } from 'vuex'
  20. export default {
  21. computed: {
  22. ...mapGetters(['couponAlertType', 'couponNoticeFlag', 'userId']),
  23. image() {
  24. let iconName = 'get'
  25. if (this.couponAlertType === 1) iconName = 'get'
  26. if (this.couponAlertType === 2) iconName = 'news'
  27. return `${this.staticUrl}icon-coupons-${iconName}.png`
  28. }
  29. },
  30. watch: {
  31. couponAlertType(nval) {
  32. const activeFlag = this.$getStorage('ACTIVE_FLAG')
  33. if (nval > 0 && !activeFlag) {
  34. this.$refs.activeAlertPopup.open()
  35. }
  36. }
  37. },
  38. methods: {
  39. onClose() {
  40. this.$store.commit('coupon/SET_COUPON_ALERT_TYPE', this.couponAlertType - 1)
  41. if (this.couponAlertType === 0) {
  42. this.$refs.activeAlertPopup.close()
  43. }
  44. },
  45. toDetail(type) {
  46. if (type === 'notice') {
  47. this.$store.commit('coupon/SET_COUPON_NITICE_FLAG', false)
  48. } else {
  49. if (this.userId) {
  50. this.$setStorage('ACTIVE_FLAG', true)
  51. }
  52. this.onClose()
  53. }
  54. this.$router.navigateTo('coupon/coupon-receive')
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .notice-model {
  61. @extend .cm-flex-between;
  62. @extend .fixed-top;
  63. padding: 16rpx 40rpx;
  64. background: rgba(0, 0, 0, 0.7);
  65. width: 750rpx;
  66. box-sizing: border-box;
  67. .cover {
  68. width: 78rpx;
  69. height: 78rpx;
  70. border-radius: 50%;
  71. }
  72. .content {
  73. display: flex;
  74. flex: 1;
  75. flex-direction: column;
  76. align-items: flex-start;
  77. justify-content: center;
  78. margin-left: 24rpx;
  79. .title {
  80. font-size: 26rpx;
  81. color: #fff;
  82. }
  83. .subTitle {
  84. font-size: 26rpx;
  85. color: #fff;
  86. margin-top: 10rpx;
  87. }
  88. }
  89. }
  90. .popup-content {
  91. @extend .cm-flex-center;
  92. flex-direction: column;
  93. align-items: flex-end;
  94. .image {
  95. display: block;
  96. max-width: 600rpx;
  97. }
  98. .close-btn {
  99. text-align: center;
  100. line-height: 38rpx;
  101. margin-bottom: 16rpx;
  102. margin-right: 36rpx;
  103. width: 36rpx;
  104. height: 36rpx;
  105. border-radius: 50%;
  106. border: 2rpx solid #fff;
  107. color: #fff;
  108. font-size: 28rpx;
  109. }
  110. }
  111. </style>