index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. <view class="center">
  40. <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode=""></image>
  41. <view class="center-font">暂无盲票</view>
  42. </view>
  43. <!-- <u-empty text="数据为空" mode="order" /> -->
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import env from '../../config/env.js'
  50. import $http from '@/utils/request.js'
  51. export default {
  52. data() {
  53. return {
  54. stateArr: [{
  55. name: ' 待兑奖',
  56. }, {
  57. name: ' 已兑奖',
  58. }],
  59. state: 2,
  60. pageNum: 1,
  61. total: 0,
  62. list: [],
  63. };
  64. },
  65. onShow() {
  66. this.pageList()
  67. },
  68. onLoad(){
  69. this.rewardNum()
  70. },
  71. methods: {
  72. getList() {
  73. uni.showLoading({
  74. title: '加载中'
  75. });
  76. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  77. status: this.state
  78. }).then(res => {
  79. uni.hideLoading();
  80. if (res.code == 0) {
  81. res.rows.forEach(item => {
  82. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  83. })
  84. this.total = res.total
  85. this.list = this.list.concat(res.rows)
  86. }
  87. }).catch(() => {
  88. uni.hideLoading();
  89. })
  90. },
  91. pageList() {
  92. this.pageNum = 1
  93. this.list = []
  94. this.getList()
  95. },
  96. toChoice(item) {
  97. uni.navigateTo({
  98. url: `/packagePrize/choice/index?id=${ item.ticketId }&type=onLine`
  99. })
  100. },
  101. changeTab(e) {
  102. if (e.index == 0) {
  103. this.state = 2
  104. } else if (e.index == 1) {
  105. this.state = 3
  106. }
  107. this.pageList()
  108. },
  109. rewardNum() {
  110. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  111. status: 2
  112. }).then(res => {
  113. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  114. status: 3
  115. }).then(data => {
  116. if (res.code == 0) {
  117. this.stateArr = [{
  118. name: ' 待兑奖 (' + res.total + ') '
  119. },
  120. {
  121. name: ' 已兑奖 (' + data.total + ') '
  122. },
  123. ]
  124. } else {
  125. this.stateArr = [{
  126. name: ' 待兑奖 (0)',
  127. }, {
  128. name: ' 已兑奖 (0)',
  129. }, ]
  130. }
  131. })
  132. })
  133. }
  134. },
  135. onReachBottom() {
  136. // 判断是否有数据
  137. if (this.total > this.pageNum * 20) {
  138. setTimeout(() => {
  139. ++this.pageNum
  140. this.getList()
  141. }, 500)
  142. } else {
  143. uni.$u.toast('已经到底了')
  144. }
  145. },
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. // 状态
  150. .state {
  151. display: flex;
  152. position: fixed;
  153. background-color: #FFFFFF;
  154. width: 100%;
  155. z-index: 10;
  156. box-shadow: 0 5rpx 5rpx #ececec;
  157. }
  158. // 列表
  159. .list {
  160. padding: 120rpx 0 100rpx;
  161. margin: 0 20rpx 0;
  162. &-item {
  163. display: flex;
  164. background: #FFFFFF;
  165. border-radius: 11px;
  166. padding: 34rpx 10rpx;
  167. margin-bottom: 34rpx;
  168. image {
  169. width: 200rpx;
  170. height: 270rpx;
  171. border-radius: 22rpx;
  172. margin-right: 15rpx;
  173. }
  174. &-content {
  175. flex: 1;
  176. flex-direction: column;
  177. justify-content: space-between;
  178. padding: 16rpx 0;
  179. .top {
  180. width: 100%;
  181. display: flex;
  182. flex-direction: column;
  183. &-title {
  184. font-size: 36rpx;
  185. line-height: 36rpx;
  186. font-weight: bold;
  187. margin-bottom: 46rpx;
  188. }
  189. &-num {
  190. font-size: 26rpx;
  191. line-height: 26rpx;
  192. }
  193. &-price {
  194. margin-top: 30rpx;
  195. font-size: 26rpx;
  196. line-height: 26rpx;
  197. }
  198. }
  199. .bottom {
  200. width: 100%;
  201. justify-content: space-between;
  202. &-price {
  203. height: 26rpx;
  204. overflow: hidden;
  205. font-size: 26rpx;
  206. line-height: 26rpx;
  207. text {
  208. color: #F9822C ;
  209. }
  210. }
  211. &-btn {
  212. width: 220rpx;
  213. height: 72rpx;
  214. line-height: 72rpx;
  215. text-align: center;
  216. background: #F9822C;
  217. border-radius: 36rpx;
  218. color: #FFFFFF;
  219. font-size: 30rpx;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. .empty {
  226. height: 60vh;
  227. .center {
  228. text-align: center;
  229. &-img {
  230. width: 228rpx;
  231. height: 320rpx;
  232. }
  233. &-font {
  234. font-size: 30rpx;
  235. font-weight: 400;
  236. color: #999999;
  237. margin-bottom: 250rpx;
  238. }
  239. }
  240. }
  241. </style>