coupon.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="coupon-wrap bg-white" v-if="!loadding">
  3. <block v-if="DataList.length > 0">
  4. <view class="item-wrap" v-for="(item, index) in DataList" :key="index">
  5. <view :class="'coupon-item coupon-item-'+item.color.text" @click="lookRule(item)">
  6. <!--装饰用的小圆-->
  7. <view class="circles">
  8. <text v-for="(circle,num) in 8" :key="num"></text>
  9. </view>
  10. <view class="info">
  11. <view >{{item.coupon_type.text}}</view>
  12. </view>
  13. <view class="operation d-b-c w-b">
  14. <view class="flex-1 coupon-content">
  15. <view :class="item.is_expire==0&&item.is_use==0?item.color.text:''">
  16. <template v-if=" item.coupon_type.value == 10 ">
  17. <view class="price" >
  18. <text>¥</text>
  19. <text class="f40 fb">{{ item.reduce_price }}</text>
  20. </view>
  21. </template>
  22. <template v-if="item.coupon_type.value == 20 ">
  23. <text class="f40 fb">{{ item.discount }}</text><text>折</text>
  24. </template>
  25. </view>
  26. <view class="f30">{{item.name}}</view>
  27. <view class="f24">
  28. <template v-if="item.expire_type ==10">
  29. 有效期:领取{{ item.expire_day }}天内有效
  30. </template>
  31. <template v-if="item.expire_type ==20">
  32. 有效期:{{item.start_time.text}}至{{item.end_time.text}}
  33. </template>
  34. </view>
  35. </view>
  36. <view class="btns d-c-c">
  37. <button type="default" v-if="item.state.value>0" :class="'btn-'+item.color.text" v-on:click.stop="receive(item.coupon_id )">
  38. 立即领取
  39. </button>
  40. <button type="default" v-else class="btn-gray" v-on:click.stop>
  41. {{ item.state.text }}
  42. </button>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="range_item d-b-c" v-if="item.apply_range == 20" @click.stop="gotoPage('/pages/coupon/detail?coupon_id='+ item.coupon_id+'&apply_range='+item.apply_range)">
  47. <view>仅可购买指定部分商品</view>
  48. <view><text class="icon iconfont icon-jiantou" style="color: #999999; font-size: 24rpx;"></text></view>
  49. </view>
  50. <view class="range_item d-b-c" v-if="item.apply_range == 30" @click.stop="gotoPage('/pages/coupon/detail?coupon_id='+ item.coupon_id+'&apply_range='+item.apply_range)">
  51. <view>仅可购买指定分类商品</view>
  52. <view><text class="icon iconfont icon-jiantou" style="color: #999999; font-size: 24rpx;"></text></view>
  53. </view>
  54. </view>
  55. </block>
  56. <block v-else>
  57. <view class="none-data-box">
  58. <image src="/static/none.png" mode="widthFix"></image>
  59. <text>暂无数据</text>
  60. </view>
  61. </block>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. /*是否加载完成*/
  69. loadding: true,
  70. indicatorDots: true,
  71. autoplay: true,
  72. interval: 2000,
  73. duration: 500,
  74. DataList: [],
  75. /*当前页面*/
  76. page: 1,
  77. /*每页条数*/
  78. list_rows: 10,
  79. };
  80. },
  81. onShow() {
  82. uni.showLoading({
  83. title: '加载中'
  84. });
  85. /*获取优惠券列表*/
  86. this.getData();
  87. },
  88. methods: {
  89. /*获取数据*/
  90. getData() {
  91. let self = this;
  92. self._get('coupon.coupon/lists', {
  93. page: self.page,
  94. list_rows: self.list_rows,
  95. }, function(res) {
  96. self.DataList = res.data.list;
  97. console.log(self.DataList)
  98. self.loadding = false;
  99. uni.hideLoading();
  100. });
  101. },
  102. /*查看规则*/
  103. lookRule(item) {
  104. item.rule = true;
  105. },
  106. /*关闭规则*/
  107. closeRule(item) {
  108. item.rule = false;
  109. },
  110. /*领取优惠券*/
  111. receive(e) {
  112. let self = this;
  113. uni.showLoading({
  114. title: '领取中'
  115. });
  116. self._post('user.coupon/receive', {
  117. coupon_id: e,
  118. }, function(res) {
  119. uni.hideLoading();
  120. uni.showToast({
  121. title: '领取成功',
  122. duration: 2000,
  123. icon: 'success'
  124. });
  125. });
  126. self.getData();
  127. },
  128. }
  129. };
  130. </script>
  131. <style>
  132. .coupon-wrap {
  133. padding: 30rpx;
  134. }
  135. .item-wrap {
  136. margin-bottom: 20rpx;
  137. }
  138. .range_item{
  139. border: 1rpx solid #D9D9D9;
  140. border-top: none;
  141. padding: 8rpx;
  142. border-bottom-left-radius:10rpx ;
  143. border-bottom-right-radius:10rpx ;
  144. color: #666666;
  145. box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
  146. }
  147. </style>