coupon.vue 4.3 KB

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