app-coupon-modal.vue 9.4 KB

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