index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲票"></u-navbar>
  4. <!-- 状态 -->
  5. <view class="state">
  6. <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="60" lineHeight="3"
  7. lineColor="#F9822C" :activeStyle="{
  8. color: '#F9822C',
  9. transform: 'scale(1.1)',
  10. width: '100px'
  11. }" :inactiveStyle="{
  12. color: '#999',
  13. transform: 'scale(1)',
  14. width: '100px'
  15. }" itemStyle="padding-left: 25px; padding-right: 25px; height: 44px; text-align: center;">
  16. </u-tabs>
  17. </view>
  18. <!-- 列表 -->
  19. <view class="list">
  20. <view class="list-item" v-for="(item, index) in list" :key="index">
  21. <image :src="item.picUrl" mode="aspectFit"></image>
  22. <view class="list-item-content flex">
  23. <view class="top">
  24. <view class="top-title">{{ item.title }}</view>
  25. <view class="top-num">序列号:{{ item.serialNo }}</view>
  26. <view class="top-price" v-if="item.status != '2'">面值:¥{{ $numberFormat(item.facePrice) }}</view>
  27. </view>
  28. <view class="bottom flex" v-if="item.status == '2'">
  29. <view class="bottom-price">面值:<text>¥{{ $numberFormat(item.facePrice) }}</text></view>
  30. <view class="bottom-btn" @click="toChoice(item)">立即兑奖</view>
  31. </view>
  32. <view class="bottom" v-else>
  33. <view class="bottom-price ells-one">奖品:<text>{{ item.prizeInfo || '-' }}</text></view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="flex empty" v-if="!list.length">
  39. <u-empty text="数据为空" mode="order" />
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import env from '../../config/env.js'
  46. import $http from '@/utils/request.js'
  47. export default {
  48. data() {
  49. return {
  50. stateArr: [{
  51. name: ' 待兑奖',
  52. }, {
  53. name: ' 已兑奖',
  54. }],
  55. state: 2,
  56. pageNum: 1,
  57. total: 0,
  58. list: [],
  59. };
  60. },
  61. onShow() {
  62. this.pageList()
  63. },
  64. onLoad(){
  65. this.rewardNum()
  66. },
  67. methods: {
  68. getList() {
  69. uni.showLoading({
  70. title: '加载中'
  71. });
  72. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  73. status: this.state
  74. }).then(res => {
  75. uni.hideLoading();
  76. if (res.code == 0) {
  77. res.rows.forEach(item => {
  78. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  79. })
  80. this.total = res.total
  81. this.list = this.list.concat(res.rows)
  82. }
  83. }).catch(() => {
  84. uni.hideLoading();
  85. })
  86. },
  87. pageList() {
  88. this.pageNum = 1
  89. this.list = []
  90. this.getList()
  91. },
  92. toChoice(item) {
  93. uni.navigateTo({
  94. url: `/packagePrize/choice/index?id=${ item.ticketId }&type=onLine`
  95. })
  96. },
  97. changeTab(e) {
  98. if (e.index == 0) {
  99. this.state = 2
  100. } else if (e.index == 1) {
  101. this.state = 3
  102. }
  103. this.pageList()
  104. },
  105. rewardNum() {
  106. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  107. status: 2
  108. }).then(res => {
  109. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  110. status: 3
  111. }).then(data => {
  112. if (res.code == 0) {
  113. this.stateArr = [{
  114. name: ' 待兑奖 (' + res.total + ') '
  115. },
  116. {
  117. name: ' 已兑奖 (' + data.total + ') '
  118. },
  119. ]
  120. } else {
  121. this.stateArr = [{
  122. name: ' 待兑奖 (0)',
  123. }, {
  124. name: ' 已兑奖 (0)',
  125. }, ]
  126. }
  127. })
  128. })
  129. }
  130. },
  131. onReachBottom() {
  132. // 判断是否有数据
  133. if (this.total > this.pageNum * 20) {
  134. setTimeout(() => {
  135. ++this.pageNum
  136. this.getList()
  137. }, 500)
  138. } else {
  139. uni.$u.toast('已经到底了')
  140. }
  141. },
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. // 状态
  146. .state {
  147. display: flex;
  148. position: fixed;
  149. background-color: #FFFFFF;
  150. width: 100%;
  151. z-index: 10;
  152. box-shadow: 0 5rpx 5rpx #ececec;
  153. }
  154. // 列表
  155. .list {
  156. padding: 120rpx 0 100rpx;
  157. margin: 0 20rpx 0;
  158. &-item {
  159. display: flex;
  160. background: #FFFFFF;
  161. border-radius: 11px;
  162. padding: 34rpx 10rpx;
  163. margin-bottom: 34rpx;
  164. image {
  165. width: 200rpx;
  166. height: 270rpx;
  167. border-radius: 22rpx;
  168. margin-right: 15rpx;
  169. }
  170. &-content {
  171. flex: 1;
  172. flex-direction: column;
  173. justify-content: space-between;
  174. padding: 16rpx 0;
  175. .top {
  176. width: 100%;
  177. display: flex;
  178. flex-direction: column;
  179. &-title {
  180. font-size: 36rpx;
  181. line-height: 36rpx;
  182. font-weight: bold;
  183. margin-bottom: 46rpx;
  184. }
  185. &-num {
  186. font-size: 26rpx;
  187. line-height: 26rpx;
  188. }
  189. &-price {
  190. margin-top: 30rpx;
  191. font-size: 26rpx;
  192. line-height: 26rpx;
  193. }
  194. }
  195. .bottom {
  196. width: 100%;
  197. justify-content: space-between;
  198. &-price {
  199. height: 26rpx;
  200. overflow: hidden;
  201. font-size: 26rpx;
  202. line-height: 26rpx;
  203. text {
  204. color: #F9822C ;
  205. }
  206. }
  207. &-btn {
  208. width: 220rpx;
  209. height: 72rpx;
  210. line-height: 72rpx;
  211. text-align: center;
  212. background: #F9822C;
  213. border-radius: 36rpx;
  214. color: #FFFFFF;
  215. font-size: 30rpx;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. .empty {
  222. height: 60vh;
  223. }
  224. </style>