index.vue 4.0 KB

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