index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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="60" 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">面值:{{ item.facePrice / 100 }}元</view>
  25. <view class="txt">序列号:{{ item.serialNo }}</view>
  26. </view>
  27. <view class="flex btn">
  28. <view class="action" @click="toChoice(item)" v-if="item.status == '2'">立即兑奖</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="flex empty" v-if="!list.length">
  34. <u-empty text="数据为空" mode="order" />
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import env from '../../config/env.js'
  41. import $http from '@/utils/request.js'
  42. export default {
  43. data() {
  44. return {
  45. stateArr: [{
  46. name: ' 待兑奖',
  47. }, {
  48. name: ' 已兑奖',
  49. }],
  50. state: 2,
  51. pageNum: 1,
  52. total: 0,
  53. list: [],
  54. };
  55. },
  56. onShow() {
  57. this.pageList()
  58. },
  59. onLoad(){
  60. this.rewardNum()
  61. },
  62. methods: {
  63. getList() {
  64. uni.showLoading({
  65. title: '加载中'
  66. });
  67. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  68. status: this.state
  69. }).then(res => {
  70. uni.hideLoading();
  71. if (res.code == 0) {
  72. res.rows.forEach(item => {
  73. item.picUrl = env.filePublic + item.picUrl + '?imageView2/2/w/170'
  74. })
  75. this.total = res.total
  76. this.list = this.list.concat(res.rows)
  77. }
  78. }).catch(() => {
  79. uni.hideLoading();
  80. })
  81. },
  82. pageList() {
  83. this.pageNum = 1
  84. this.list = []
  85. this.getList()
  86. },
  87. toChoice(item) {
  88. uni.navigateTo({
  89. url: `/pages/choice/index?id=${ item.ticketId }&type=onLine`
  90. })
  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. rewardNum() {
  101. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  102. status: 2
  103. }).then(res => {
  104. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  105. status: 3
  106. }).then(data => {
  107. if (res.code == 0) {
  108. this.stateArr = [{
  109. name: ' 待兑奖 (' + res.total + ') '
  110. },
  111. {
  112. name: ' 已兑奖 (' + data.total + ') '
  113. },
  114. ]
  115. } else {
  116. this.stateArr = [{
  117. name: ' 待兑奖 (0)',
  118. }, {
  119. name: ' 已兑奖 (0)',
  120. }, ]
  121. }
  122. })
  123. })
  124. }
  125. },
  126. onReachBottom() {
  127. // 判断是否有数据
  128. if (this.total > this.pageNum * 20) {
  129. setTimeout(() => {
  130. ++this.pageNum
  131. this.getList()
  132. }, 500)
  133. } else {
  134. uni.$u.toast('没有更多数据了')
  135. }
  136. },
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .prize-state {
  141. position: fixed;
  142. background-color: #FFFFFF;
  143. width: 100%;
  144. padding-bottom: 16rpx;
  145. z-index: 10;
  146. box-shadow: 0 5rpx 5rpx #ececec;
  147. }
  148. .prize-coupon {
  149. margin-top: 104rpx;
  150. padding: 40rpx 30rpx 140rpx;
  151. &-list {
  152. &-item {
  153. justify-content: space-between;
  154. background-color: #FFFFFF;
  155. padding: 40rpx 20rpx;
  156. border-radius: 10rpx;
  157. margin-bottom: 24rpx;
  158. image {
  159. width: 124rpx;
  160. height: 174rpx;
  161. }
  162. .info {
  163. position: relative;
  164. justify-content: space-between;
  165. flex: 1;
  166. }
  167. .desc {
  168. height: 174rpx;
  169. flex-direction: column;
  170. justify-content: space-between;
  171. align-items: flex-start;
  172. padding-left: 20rpx;
  173. }
  174. .txt {
  175. font-size: 24rpx;
  176. }
  177. .btn {
  178. flex-direction: column;
  179. }
  180. .amt {
  181. font-size: 48rpx;
  182. font-weight: bold;
  183. line-height: 72rpx;
  184. }
  185. text {
  186. font-size: 24rpx;
  187. }
  188. .action {
  189. width: 124rpx;
  190. height: 40rpx;
  191. line-height: 40rpx;
  192. border-radius: 20rpx;
  193. background-color: rgba(215, 9, 9, 100);
  194. color: rgba(255, 255, 255, 100);
  195. font-size: 24rpx;
  196. text-align: center
  197. }
  198. }
  199. &-item:last-child {
  200. margin-bottom: 0;
  201. }
  202. }
  203. }
  204. .empty {
  205. height: 60vh;
  206. }
  207. </style>