index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. console.log(item);
  98. let type = item.type && JSON.parse(item.type).value
  99. if(type == 'offline') {
  100. uni.navigateTo({
  101. url: `/packagePrize/choice/index?id=${ item.ticketId }&type=offLine`
  102. })
  103. } else if (type == 'online') {
  104. uni.navigateTo({
  105. url: `/packagePrize/rolling/index?ticketId=${ item.ticketId }&isTry=0`
  106. })
  107. } else {
  108. uni.$u.toast('请联系客服')
  109. }
  110. },
  111. changeTab(e) {
  112. if (e.index == 0) {
  113. this.state = 2
  114. } else if (e.index == 1) {
  115. this.state = 3
  116. }
  117. this.pageList()
  118. },
  119. rewardNum() {
  120. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  121. status: 2
  122. }).then(res => {
  123. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  124. status: 3
  125. }).then(data => {
  126. if (res.code == 0) {
  127. this.stateArr = [{
  128. name: ' 待兑奖 (' + res.total + ') '
  129. },
  130. {
  131. name: ' 已兑奖 (' + data.total + ') '
  132. },
  133. ]
  134. } else {
  135. this.stateArr = [{
  136. name: ' 待兑奖 (0)',
  137. }, {
  138. name: ' 已兑奖 (0)',
  139. }, ]
  140. }
  141. })
  142. })
  143. }
  144. },
  145. onReachBottom() {
  146. // 判断是否有数据
  147. if (this.total > this.pageNum * 20) {
  148. setTimeout(() => {
  149. ++this.pageNum
  150. this.getList()
  151. }, 500)
  152. } else {
  153. uni.$u.toast('已经到底了')
  154. }
  155. },
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. // 状态
  160. .state {
  161. display: flex;
  162. position: fixed;
  163. background-color: #FFFFFF;
  164. width: 100%;
  165. z-index: 10;
  166. box-shadow: 0 5rpx 5rpx #ececec;
  167. }
  168. // 列表
  169. .list {
  170. padding: 120rpx 0 100rpx;
  171. margin: 0 20rpx 0;
  172. &-item {
  173. display: flex;
  174. background: #FFFFFF;
  175. border-radius: 11px;
  176. padding: 34rpx 10rpx;
  177. margin-bottom: 34rpx;
  178. image {
  179. width: 200rpx;
  180. height: 270rpx;
  181. border-radius: 22rpx;
  182. margin-right: 15rpx;
  183. }
  184. &-content {
  185. flex: 1;
  186. flex-direction: column;
  187. justify-content: space-between;
  188. padding: 16rpx 0;
  189. .top {
  190. width: 100%;
  191. display: flex;
  192. flex-direction: column;
  193. &-title {
  194. font-size: 36rpx;
  195. line-height: 36rpx;
  196. font-weight: bold;
  197. margin-bottom: 46rpx;
  198. }
  199. &-num {
  200. font-size: 26rpx;
  201. line-height: 26rpx;
  202. }
  203. &-price {
  204. margin-top: 30rpx;
  205. font-size: 26rpx;
  206. line-height: 26rpx;
  207. }
  208. }
  209. .bottom {
  210. width: 100%;
  211. justify-content: space-between;
  212. &-price {
  213. height: 26rpx;
  214. overflow: hidden;
  215. font-size: 26rpx;
  216. line-height: 26rpx;
  217. text {
  218. color: #F9822C ;
  219. }
  220. }
  221. &-btn {
  222. width: 220rpx;
  223. height: 72rpx;
  224. line-height: 72rpx;
  225. text-align: center;
  226. background: #F9822C;
  227. border-radius: 36rpx;
  228. color: #FFFFFF;
  229. font-size: 30rpx;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. .empty {
  236. height: 60vh;
  237. .center {
  238. text-align: center;
  239. &-img {
  240. width: 228rpx;
  241. height: 320rpx;
  242. }
  243. &-font {
  244. font-size: 30rpx;
  245. font-weight: 400;
  246. color: #999999;
  247. margin-bottom: 250rpx;
  248. }
  249. }
  250. }
  251. </style>