use.vue 5.5 KB

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