use.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. <view class="center">
  43. <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_1.png" mode=""></image>
  44. <view class="center-font">暂无优惠券</view>
  45. </view>
  46. <!-- <u-empty text="数据为空" mode="order" /> -->
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import env from '../../config/env.js'
  52. import $http from '@/utils/request.js'
  53. export default {
  54. data() {
  55. return {
  56. stateArr: [{
  57. name: '已使用'
  58. }, {
  59. name: '已过期',
  60. }],
  61. state: 2,
  62. pageNum: 1,
  63. total: 0,
  64. list: [],
  65. };
  66. },
  67. onShow() {
  68. this.pageList()
  69. },
  70. methods: {
  71. getList() {
  72. let _this = this
  73. let url = '/api/v1/mp/user/mine/coupon/list'
  74. uni.showLoading({
  75. title: '加载中'
  76. });
  77. this.loading = true
  78. $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, {
  79. status: this.state
  80. }).then(res => {
  81. uni.hideLoading();
  82. this.loading = false
  83. if (res.code == 0) {
  84. res.rows.forEach(item => {
  85. let picUrlArr = item.picUrl.split(',')
  86. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  87. item.status = JSON.parse(item.status)
  88. })
  89. _this.total = res.total
  90. _this.list = _this.list.concat(res.rows)
  91. }
  92. }).catch(() => {
  93. uni.hideLoading();
  94. this.loading = false
  95. })
  96. },
  97. pageList() {
  98. this.pageNum = 1
  99. this.list = []
  100. this.getList()
  101. },
  102. changeTab(e) {
  103. if (e.index == 0) {
  104. this.state = 2
  105. } else if (e.index == 1) {
  106. this.state = 3
  107. }
  108. this.pageList()
  109. },
  110. changeChecked() {
  111. },
  112. },
  113. onReachBottom() {
  114. // 判断是否有数据
  115. if (this.total > this.pageNum * 20) {
  116. setTimeout(() => {
  117. ++this.pageNum
  118. this.getList()
  119. }, 500)
  120. } else {
  121. uni.$u.toast('已经到底了')
  122. }
  123. },
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .prize-state {
  128. display: flex;
  129. position: fixed;
  130. background-color: #FFFFFF;
  131. width: 100%;
  132. padding-bottom: 16rpx;
  133. z-index: 10;
  134. }
  135. .prize-coupon {
  136. margin-top: 104rpx;
  137. padding: 30rpx 34rpx 100rpx;
  138. &-list {
  139. &-item {
  140. position: relative;
  141. padding-top: 30rpx;
  142. margin-bottom: 30rpx;
  143. background-color: #fff;
  144. .content {
  145. width: 100%;
  146. height: 184rpx;
  147. justify-content: flex-start;
  148. &-left {
  149. width: 210rpx;
  150. height: 100%;
  151. margin-right: 20rpx;
  152. image {
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .price {
  157. position: absolute;
  158. color: #fff;
  159. text:first-child {
  160. font-size: 70rpx;
  161. padding-right: 20rpx;
  162. }
  163. text:last-child {
  164. font-size: 40rpx;
  165. }
  166. }
  167. }
  168. &-right {
  169. flex: 1;
  170. align-items: flex-start;
  171. flex-direction: column;
  172. justify-content: space-between;
  173. height: 100%;
  174. padding: 24rpx 0;
  175. .title {
  176. font-size: 32rpx;
  177. line-height: 32rpx;
  178. height: 32rpx;
  179. overflow: hidden;
  180. font-weight: bold;
  181. }
  182. .desc {
  183. font-size: 24rpx;
  184. line-height: 24rpx;
  185. color: #999999;
  186. }
  187. }
  188. }
  189. .image-use {
  190. position: absolute;
  191. right: 34rpx;
  192. bottom: 10rpx;
  193. width: 170rpx;
  194. height: 170rpx;
  195. }
  196. }
  197. &-item:last-child {
  198. margin-bottom: 0;
  199. }
  200. }
  201. }
  202. .empty {
  203. height: 60vh;
  204. .center {
  205. text-align: center;
  206. &-img {
  207. width: 228rpx;
  208. height: 320rpx;
  209. }
  210. &-font {
  211. font-size: 30rpx;
  212. font-weight: 400;
  213. color: #999999;
  214. margin-bottom: 250rpx;
  215. }
  216. }
  217. }
  218. </style>