index.vue 4.8 KB

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