coupon.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="优惠券使用记录"></u-navbar>
  4. <!-- 优惠券筛选 -->
  5. <view class="prize-state">
  6. <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="40" lineHeight="1"
  7. lineColor="#D70909" :activeStyle="{
  8. color: '#D70909',
  9. transform: 'scale(1)'
  10. }" :inactiveStyle="{
  11. color: '#333',
  12. transform: 'scale(1)'
  13. }" itemStyle="padding-left: 25px; padding-right: 25px; height: 44px;">
  14. </u-tabs>
  15. </view>
  16. <!-- 已使用 -->
  17. <view class="prize-coupon">
  18. <view class="prize-coupon-list">
  19. <view class="prize-coupon-list-item" v-for="(item, index) in list" :key="index">
  20. <image src="../../static/icon/coupon_bg2.png" mode=""></image>
  21. <view class="info">
  22. <view class="info-item">
  23. <text>使用期限:</text>
  24. <text>{{ $parseTime(item.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</text>
  25. </view>
  26. <view class="info-item">
  27. <text>使用范围:</text>
  28. <text>{{ item.useAreaDesc || '-' }}</text>
  29. </view>
  30. </view>
  31. <view class="flex price-title">
  32. <view class="price"><text>¥</text>{{ item.discount / 100 }}</view>
  33. <view class="title">{{ item.title }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="flex empty" v-if="!list.length">
  39. <u-empty text="数据为空" mode="order" />
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import env from '../../config/env.js'
  45. import $http from '@/utils/request.js'
  46. export default {
  47. data() {
  48. return {
  49. stateArr: [{
  50. name: '已使用'
  51. }, {
  52. name: '已过期',
  53. }],
  54. state: 2,
  55. pageNum: 1,
  56. total: 0,
  57. list: [],
  58. };
  59. },
  60. onShow() {
  61. this.pageList()
  62. },
  63. methods: {
  64. getList() {
  65. let _this = this
  66. let url = '/api/v1/mp/user/mine/coupon/list'
  67. uni.showLoading({
  68. title: '加载中'
  69. });
  70. this.loading = true
  71. $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, {
  72. status: this.state
  73. }).then(res => {
  74. uni.hideLoading();
  75. this.loading = false
  76. if (res.code == 0) {
  77. res.rows.forEach(item => {
  78. let picUrlArr = item.picUrl.split(',')
  79. item.picUrl = env.filePublic + picUrlArr[0]
  80. item.status = JSON.parse(item.status)
  81. })
  82. _this.total = res.total
  83. _this.list = _this.list.concat(res.rows)
  84. }
  85. }).catch(() => {
  86. uni.hideLoading();
  87. this.loading = false
  88. })
  89. },
  90. pageList() {
  91. this.pageNum = 1
  92. this.list = []
  93. this.getList()
  94. },
  95. changeTab(e) {
  96. if (e.index == 0) {
  97. this.state = 2
  98. } else if (e.index == 1) {
  99. this.state = 3
  100. }
  101. this.pageList()
  102. },
  103. changeChecked() {
  104. },
  105. },
  106. onReachBottom() {
  107. // 判断是否有数据
  108. if (this.total > this.pageNum * 20) {
  109. setTimeout(() => {
  110. ++this.pageNum
  111. this.getList()
  112. }, 500)
  113. } else {
  114. uni.$u.toast('没有更多数据了')
  115. }
  116. },
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .prize-state {
  121. position: fixed;
  122. background-color: #FFFFFF;
  123. width: 100%;
  124. padding-bottom: 16rpx;
  125. z-index: 10;
  126. }
  127. .prize-coupon {
  128. margin-top: 104rpx;
  129. padding: 40rpx 30rpx 100rpx;
  130. &-list {
  131. &-item {
  132. position: relative;
  133. background-color: #FFFFFF;
  134. margin-bottom: 20rpx;
  135. border-radius: 10rpx;
  136. image {
  137. width: 100%;
  138. height: 156rpx;
  139. margin-bottom: 24rpx;
  140. }
  141. .info {
  142. padding-left: 40rpx;
  143. padding-bottom: 8rpx;
  144. .info-item {
  145. line-height: 40rpx;
  146. color: #333333;
  147. margin-bottom: 12rpx;
  148. }
  149. }
  150. .price-title {
  151. justify-content: flex-start;
  152. position: absolute;
  153. top: 0;
  154. width: 100%;
  155. padding: 36rpx 0 0 40rpx;
  156. .price {
  157. color: #FFFFFF;
  158. font-size: 60rpx;
  159. margin-right: 20rpx;
  160. text {
  161. font-size: 40rpx;
  162. }
  163. }
  164. .title {
  165. color: #FFFFFF;
  166. font-size: 48rpx;
  167. }
  168. }
  169. }
  170. &-item:last-child {
  171. margin-bottom: 0;
  172. }
  173. }
  174. }
  175. .empty {
  176. height: 60vh;
  177. }
  178. </style>