index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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">面值:{{ 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. methods: {
  60. getList() {
  61. uni.showLoading({
  62. title: '加载中'
  63. });
  64. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  65. status: this.state
  66. }).then(res => {
  67. uni.hideLoading();
  68. if (res.code == 0) {
  69. res.rows.forEach(item => {
  70. item.picUrl = env.filePublic + item.picUrl
  71. })
  72. this.total = res.total
  73. this.list = this.list.concat(res.rows)
  74. }
  75. }).catch(() => {
  76. uni.hideLoading();
  77. })
  78. },
  79. pageList() {
  80. this.pageNum = 1
  81. this.list = []
  82. this.getList()
  83. },
  84. toChoice(item) {
  85. uni.navigateTo({
  86. url: `/pages/choice/index?id=${ item.ticketId }&type=onLine`
  87. })
  88. },
  89. changeTab(e) {
  90. if (e.index == 0) {
  91. this.state = 2
  92. } else if (e.index == 1) {
  93. this.state = 3
  94. }
  95. this.pageList()
  96. },
  97. changeChecked() {
  98. },
  99. },
  100. onReachBottom() {
  101. // 判断是否有数据
  102. if (this.total > this.pageNum * 20) {
  103. setTimeout(() => {
  104. ++this.pageNum
  105. this.getList()
  106. }, 500)
  107. } else {
  108. uni.$u.toast('没有更多数据了')
  109. }
  110. },
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .prize-state {
  115. position: fixed;
  116. background-color: #FFFFFF;
  117. width: 100%;
  118. padding-bottom: 16rpx;
  119. z-index: 10;
  120. box-shadow: 0 5rpx 5rpx #ececec;
  121. }
  122. .prize-coupon {
  123. margin-top: 104rpx;
  124. padding: 40rpx 30rpx 140rpx;
  125. &-list {
  126. &-item {
  127. justify-content: space-between;
  128. background-color: #FFFFFF;
  129. padding: 40rpx 20rpx;
  130. border-radius: 10rpx;
  131. margin-bottom: 24rpx;
  132. image {
  133. width: 124rpx;
  134. height: 174rpx;
  135. }
  136. .info {
  137. position: relative;
  138. justify-content: space-between;
  139. flex: 1;
  140. }
  141. .desc {
  142. height: 174rpx;
  143. flex-direction: column;
  144. justify-content: space-between;
  145. align-items: flex-start;
  146. padding-left: 20rpx;
  147. }
  148. .txt {
  149. font-size: 24rpx;
  150. }
  151. .btn {
  152. flex-direction: column;
  153. }
  154. .amt {
  155. font-size: 48rpx;
  156. font-weight: bold;
  157. line-height: 72rpx;
  158. }
  159. text {
  160. font-size: 24rpx;
  161. }
  162. .action {
  163. width: 124rpx;
  164. height: 40rpx;
  165. line-height: 40rpx;
  166. border-radius: 20rpx;
  167. background-color: rgba(215, 9, 9, 100);
  168. color: rgba(255, 255, 255, 100);
  169. font-size: 24rpx;
  170. text-align: center
  171. }
  172. }
  173. &-item:last-child {
  174. margin-bottom: 0;
  175. }
  176. }
  177. }
  178. .empty {
  179. height: 60vh;
  180. }
  181. </style>