app-coupon-modal.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <!-- 初版 代和yu分支融合 -->
  2. <template>
  3. <view class="app-coupon-modal main-center cross-center" v-if="coupon && coupon.list && coupon.list.length > 0">
  4. <view class="coupon-modal">
  5. <image class="title-img" :src="img"></image>
  6. <view class="get-coupon-content">
  7. <view class="invite coupon-head-label" v-if="coupon.type === `invite`">
  8. <view>成功邀请{{coupon.list[0].id}}位好友,获得奖励</view>
  9. </view>
  10. <view v-else class="coupon-head-label">*{{labelText}}</view>
  11. <scroll-view scroll-y="true" class='coupon-list'>
  12. <view class="dir-left-nowrap cross-center coupon-item" v-for="(item, index) in coupon.list"
  13. :key="index">
  14. <view class="price" :class="theme + '-color'">
  15. <image v-if="item.share_type === 1" src='../../../../static/image/hongbao.png'/>
  16. <image v-if="item.share_type === 2" src='../../../../static/image/integral.png'/>
  17. <image v-if="item.share_type === 3" :src="item.pic_url" class="card"/>
  18. <block v-if="item.share_type === 4">
  19. <template v-if="item.type == 2">
  20. <app-price :price="item.sub_price"></app-price>
  21. </template>
  22. <template v-else>
  23. <view class="discount">{{item.discount}}</view>
  24. </template>
  25. </block>
  26. </view>
  27. <view class="right dir-top-nowrap main-center box-grow-1">
  28. <view v-if="[1,2,3].includes(item.share_type)"
  29. :class="[`t-omit${item.share_type === 3 ? '-two': ''}`]">{{item.name}}
  30. </view>
  31. <view v-else class="t-omit">{{item.name}}</view>
  32. <!--<view>{{item.min_price > 0 ? '满' + item.min_price + '元可用' : '满任意金额可用'}}</view>-->
  33. <view class="t-omit content">{{item.content}}</view>
  34. <view class="content" v-if="item.discount_limit">优惠上限:¥{{item.discount_limit}}</view>
  35. </view>
  36. <view class="box-grow-0 btn" :class="theme + '-background'" @click="toGoods(item.page_url)">
  37. 去使用
  38. </view>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. <view class='main-center' @click='closeCouponBox'>
  43. <image src='../../../../static/image/icon/icon-popup-close.png' class="bottom-close"></image>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {mapState} from "vuex";
  50. import appPrice from "../../../page-component/goods/app-price.vue";
  51. export default {
  52. name: "app-coupon-modal",
  53. components: {
  54. 'app-price': appPrice,
  55. },
  56. data() {
  57. return {};
  58. },
  59. computed: {
  60. ...mapState({
  61. mallConfig: state => state.mallConfig,
  62. coupon: state => state.page.coupon,
  63. theme: state => state.mallConfig.theme
  64. }),
  65. labelText() {
  66. if (this.coupon && this.coupon.list && this.coupon.list.length) {
  67. const first = this.coupon.list[0];
  68. switch (first.share_type) {
  69. case 4:
  70. return '优惠券已发放到账户,请到我的优惠券查看';
  71. case 2:
  72. return '积分已发放到账户,请到我的积分查看';
  73. case 1:
  74. return '余额红包已发放到账户,请到我的余额查看';
  75. case 3:
  76. return '卡劵已发放到账户,请到我的卡劵查看';
  77. default:
  78. return '';
  79. }
  80. }
  81. },
  82. img() {
  83. let img = '';
  84. if (this.coupon.type == 'register') {
  85. img = this.mallConfig.__wxapp_img.coupon.get_coupon_title;
  86. } else if (this.coupon.type == 'share') {
  87. img = this.mallConfig.__wxapp_img.coupon.get_coupon_share;
  88. } else if (this.coupon.type == 'receive') {
  89. img = this.mallConfig.__wxapp_img.coupon.get_coupon_receive;
  90. } else if (this.coupon.type === 'award') {
  91. img = this.mallConfig.__wxapp_img.coupon.get_coupon_award;
  92. }
  93. return img
  94. }
  95. },
  96. methods: {
  97. closeCouponBox() {
  98. let coupon = {
  99. list: [],
  100. type: ''
  101. };
  102. this.$store.dispatch('page/actionSetCoupon', coupon)
  103. },
  104. toGoods(page_url) {
  105. uni.navigateTo({
  106. url: page_url
  107. });
  108. this.closeCouponBox();
  109. },
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .invite {
  115. text-align: center;
  116. margin-top: #{20px - 24px};
  117. view {
  118. padding: #{16rpx} #{24rpx};
  119. color: #ffffff;
  120. background: rgba(0, 0, 0, 0.2);
  121. font-size: #{26rpx};
  122. line-height: 1;
  123. display: inline-block;
  124. border-radius: #{34rpx};
  125. }
  126. }
  127. .invite-text {
  128. font-size: #{22rpx};
  129. line-height: 1;
  130. padding-top: #{16rpx};
  131. text:first-child {
  132. color: #ffee01;
  133. font-weight: bold;
  134. }
  135. }
  136. .app-coupon-modal {
  137. position: fixed;
  138. top: 0;
  139. left: 0;
  140. width: 100%;
  141. height: 100%;
  142. background: rgba(0, 0, 0, 0.5);
  143. z-index: 1700;
  144. .coupon-modal {
  145. width: 100%;
  146. overflow: visible;
  147. margin-top: #{-50rpx};
  148. .title-img {
  149. width: #{750rpx};
  150. height: #{360rpx};
  151. display: block;
  152. }
  153. .get-coupon-content {
  154. width: #{580rpx};
  155. background: #ef3030;
  156. border-radius: 0 0 #{16rpx 16rpx};
  157. padding: #{24rpx 30rpx 30rpx 30rpx};
  158. margin: 0 auto;
  159. color: #ffffff;
  160. font-size: $uni-font-size-weak-two;
  161. .coupon-head-label {
  162. margin-bottom: #{16rpx};
  163. }
  164. .coupon-list {
  165. max-height: #{312rpx};
  166. view:first-child {
  167. margin-top: 0;
  168. }
  169. .coupon-item {
  170. width: 100%;
  171. padding: #{0 32rpx};
  172. margin-top: #{16rpx};
  173. border-radius: #{16rpx};
  174. background-color: #ffffff;
  175. height: #{144rpx};
  176. .price {
  177. font-size: #{56rpx};
  178. .discount:after {
  179. content: '折';
  180. font-size: 50%;
  181. }
  182. image {
  183. height: #{80rpx};
  184. width: #{80rpx};
  185. display: block;
  186. }
  187. .card {
  188. border-radius: 50%;
  189. }
  190. }
  191. .right {
  192. margin-left: #{26rpx};
  193. font-size: $uni-font-size-general-one;
  194. color: $uni-important-color-black;
  195. .content {
  196. font-size: #{$uni-font-size-weak-two};
  197. color: $uni-general-color-two;
  198. }
  199. }
  200. .btn {
  201. padding: #{12rpx 16rpx};
  202. border-radius: #{50rpx};
  203. font-size: $uni-font-size-weak-one;
  204. margin-left: #{19rpx};
  205. }
  206. }
  207. }
  208. }
  209. .bottom-close {
  210. width: #{30rpx};
  211. height: #{30rpx};
  212. margin-top: #{64rpx};
  213. }
  214. }
  215. }
  216. </style>