index.vue 5.0 KB

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