index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="coupon">
  3. <!-- 列表 -->
  4. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  5. <view class="discounts-item" v-for="(item,index) in list" :key="index" >
  6. <view class="type-box">
  7. <view class="price">
  8. {{item | filterPrice}}
  9. </view>
  10. <view class="type">
  11. {{item | filterType}}
  12. </view>
  13. </view>
  14. <view class="info">
  15. <view class="title">
  16. {{item.couponName}}
  17. </view>
  18. <view class="limit">
  19. {{item.useStartTime}}后可用
  20. </view>
  21. <view class="desc">
  22. {{item.usrDetail || '-'}}
  23. </view>
  24. </view>
  25. <view class="btn" :class="[item.exist > 0?'used':'']" @click="claim(item.id,item.exist)">
  26. {{item.exist > 0?'已领取':'领取'}}
  27. </view>
  28. </view>
  29. </zs-list>
  30. </view>
  31. </template>
  32. <script>
  33. import {getCouponList,claim} from '@/api/coupon.js'
  34. export default {
  35. data() {
  36. return {
  37. active: '',
  38. open:999,
  39. status:'more',
  40. query:{
  41. currentPage:1,
  42. pageSize:10,
  43. showType:1,
  44. },
  45. list:[],
  46. tabList:[]
  47. }
  48. },
  49. filters: {
  50. filterPrice: function(val) {
  51. if(val.couponType == 1){
  52. return `¥${val.couponDiscount}`
  53. }else if(val.couponType == 2){
  54. return `${val.couponDiscount}折`
  55. }else if(val.couponType == 3){
  56. return `¥${val.couponDiscount}`
  57. }
  58. },
  59. filterType: function(val) {
  60. if(val.couponType == 1){
  61. if(val.couponCondition){
  62. return `满${val.couponCondition}立减`
  63. }else{
  64. return '无门槛立减'
  65. }
  66. }else if(val.couponType == 2){
  67. if(val.couponCondition){
  68. return `满${val.couponCondition}`
  69. }else{
  70. return '无门槛立减'
  71. }
  72. }else if(val.couponType == 3){
  73. if(val.couponCondition){
  74. return `满${val.couponCondition}立减`
  75. }else{
  76. return '无门槛立减'
  77. }
  78. }
  79. },
  80. },
  81. methods: {
  82. handleOpen(val,open){
  83. if(val === this[open]){
  84. this[open] = 999
  85. }else{
  86. this[open] = val
  87. }
  88. },
  89. loadMore(){
  90. this.getCouponList()
  91. },
  92. getCouponList(){
  93. this.status = 'loading'
  94. getCouponList(this.query).then(res=>{
  95. if(res.state == 'Success'){
  96. this.list = this.list.concat(res.content.records)
  97. this.list.length>= res.content.total?this.status = 'noMore':this.status = 'more'
  98. this.query.currentPage++
  99. }
  100. })
  101. },
  102. claim(couponId,type){
  103. if(type == 0){
  104. claim({couponId}).then(res=>{
  105. if(res.state == 'Success'){
  106. uni.showToast({
  107. title:'领取成功',
  108. icon:'success'
  109. })
  110. this.query.currentPage = 1
  111. this.list = []
  112. this.status = 'more'
  113. this.getCouponList()
  114. }
  115. })
  116. }
  117. }
  118. },
  119. created() {
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .coupon{
  125. background: #f5f5f5;
  126. height: 100vh;
  127. padding: 20rpx 24rpx;
  128. .discounts-item {
  129. margin-bottom: 20rpx;
  130. display: flex;
  131. align-items: center;
  132. background-color: rgb(239, 239, 239);
  133. background: url('../../static/new-card.png') no-repeat;
  134. background-repeat: no-repeat;
  135. background-size: 100% 144rpx;
  136. border-radius: 16rpx;
  137. height: 144rpx;
  138. padding: 0 24rpx;
  139. box-sizing: border-box;
  140. .type-box{
  141. text-align: center;
  142. .price{
  143. ont-size: 40rpx;
  144. color: #FF4D3A;
  145. }
  146. .type{
  147. font-size: 20rpx;
  148. color: #AAAAAA;
  149. margin-top: 12rpx;
  150. }
  151. }
  152. .info {
  153. flex: 1;
  154. margin-left: 40rpx;
  155. .title {
  156. font-size: 28rpx;
  157. color: #222222;
  158. }
  159. .desc{
  160. font-size: 20rpx;
  161. color: #AAAAAA;
  162. }
  163. .limit{
  164. font-size: 20rpx;
  165. color: #AAAAAA;
  166. margin:10rpx 0;
  167. }
  168. }
  169. .btn {
  170. width: 118rpx;
  171. height: 48rpx;
  172. line-height: 48rpx;
  173. text-align: center;
  174. font-size: 24rpx;
  175. background: #EE4320;
  176. border-radius: 24rpx;
  177. color: #FFF;
  178. box-sizing: border-box;
  179. }
  180. .btn.used{
  181. border: 2rpx solid #EE421F;
  182. color: #EE421F;
  183. background: none;
  184. }
  185. }
  186. }
  187. </style>