use.vue 4.8 KB

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