coupon.vue 4.4 KB

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