use.vue 5.6 KB

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