sel-coupon-popup.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <u-popup mode="bottom" v-model="show">
  3. <view class="content">
  4. <scroll-view class="scbox" scroll-y="true">
  5. <!--
  6. <DiscountsItem
  7. :select="selectIndex == index"
  8. v-for="(item, index) in couponList"
  9. :data="item"
  10. :key="index"
  11. @click="changeDiscount(item, index)"></DiscountsItem>
  12. -->
  13. <u-radio-group v-model="selCouponId" @change="changeDiscount">
  14. <view class="item" v-for="(item, index) in couponList" :key="index">
  15. <!-- :disabled="item.status==1" -->
  16. <u-radio :name="item.id" :disabled="item.status!=2||(Number(item.min_amount)>Number(priceInfo.countPrice))" >
  17. <view class="coupnInfo">
  18. <view class="price_color">
  19. {{item|filterCouponToTitle}}
  20. </view>
  21. <view class="time">
  22. <view class="date">有效期至 {{ formatDateF(item.limit_time*1000) }}</view>
  23. </view>
  24. </view>
  25. </u-radio>
  26. </view>
  27. <view class="item">
  28. <u-radio :name="null">
  29. <view class="coupnInfo">
  30. 不使用优惠券
  31. </view>
  32. </u-radio>
  33. </view>
  34. </u-radio-group>
  35. </scroll-view>
  36. </view>
  37. </u-popup>
  38. </template>
  39. <script>
  40. import DiscountsItem from '@/pages-mine/components/discounts-item.vue';
  41. import { formatDate } from '@/utils/tools.js'
  42. export default {
  43. name: 'sel-coupon-popup',
  44. components: {
  45. DiscountsItem
  46. },
  47. props: {
  48. // 数据源
  49. data: {
  50. type: Object,
  51. default: () => {
  52. return {};
  53. }
  54. },
  55. priceInfo: {
  56. type: Object,
  57. default: () => {
  58. return {};
  59. }
  60. }
  61. },
  62. data() {
  63. return {
  64. show:false,
  65. selCouponId:null,
  66. couponList:[],
  67. usingCoupon:{},
  68. };
  69. },
  70. filters:{
  71. filterCouponToTitle(e){
  72. if(e.min_amount>0){
  73. // 有满减
  74. return e.title+'(满'+e.min_amount+'减'+e.amount+')';
  75. }else{
  76. return e.title+'(&yen;'+e.amount+')';
  77. }
  78. }
  79. },
  80. methods: {
  81. formatDateF(v){
  82. return formatDate(v);
  83. },
  84. showPopup(e){
  85. console.log(e)
  86. // couponList: Array(1), usingCoupon
  87. this.couponList = e.couponList;
  88. this.usingCoupon = e.usingCoupon;
  89. console.log(this.couponList,this.couponList)
  90. this.show = true;
  91. },
  92. changeDiscount(id) {
  93. console.log(id)
  94. if(id){
  95. this.usingCoupon = this.couponList.find(e=>e.id==id)
  96. this.$emit('done',this.usingCoupon)
  97. }else{
  98. this.$emit('done',{})
  99. }
  100. this.show = false;
  101. return;
  102. this.usingCoupon = item;
  103. },
  104. }
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. .price_color{
  109. font-size: 32rpx;
  110. font-weight: 500;
  111. }
  112. .scbox{
  113. box-sizing: border-box;
  114. height: 600rpx;
  115. padding: 30rpx;
  116. }
  117. .item{
  118. margin-bottom: 30rpx;
  119. }
  120. .coupnInfo{
  121. padding-left: 30rpx;
  122. }
  123. /deep/.u-radio{
  124. float: none !important;
  125. }
  126. </style>