index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲票" leftIconSize="0"></u-navbar>
  5. <!-- #endif -->
  6. <!-- #ifndef MP-ALIPAY -->
  7. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲票"></u-navbar>
  8. <!-- #endif -->
  9. <!-- 状态 -->
  10. <view class="state">
  11. <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="60" lineHeight="3"
  12. lineColor="#F9822C" :activeStyle="{
  13. color: '#F9822C',
  14. transform: 'scale(1.1)',
  15. width: '100px'
  16. }" :inactiveStyle="{
  17. color: '#999',
  18. transform: 'scale(1)',
  19. width: '100px'
  20. }" itemStyle="padding-left: 25px; padding-right: 25px; height: 44px; text-align: center;">
  21. </u-tabs>
  22. </view>
  23. <!-- 列表 -->
  24. <view class="list">
  25. <view class="list-item" v-for="(item, index) in list" :key="index">
  26. <image :src="item.picUrl" mode="aspectFit"></image>
  27. <view class="list-item-content flex">
  28. <view class="top">
  29. <view class="top-title">{{ item.title }}</view>
  30. <view class="top-num">序列号:{{ item.serialNo }}</view>
  31. <view class="top-price" v-if="item.status != '2'">面值:¥{{ $numberFormat(item.facePrice) }}</view>
  32. </view>
  33. <view class="bottom flex" v-if="item.status == '2'">
  34. <view class="bottom-price">面值:<text>¥{{ $numberFormat(item.facePrice) }}</text></view>
  35. <view class="bottom-btn" @click="toChoice(item)">立即兑奖</view>
  36. </view>
  37. <view class="bottom" v-else>
  38. <!-- #ifdef MP-ALIPAY -->
  39. <view class="bottom-pricetwo"><view>奖品:</view><text>{{ item.prizeInfo || '-' }}</text></view>
  40. <!-- #endif -->
  41. <!-- #ifndef MP-ALIPAY -->
  42. <view class="bottom-price ells-one">奖品:<text>{{ item.prizeInfo || '-' }}</text></view>
  43. <!-- #endif -->
  44. </view>
  45. </view>
  46. </view>
  47. <u-loadmore :line="true" v-if="list.length>5" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
  48. </view>
  49. <view class="flex empty" v-if="!list.length">
  50. <view class="center">
  51. <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode="scaleToFill"></image>
  52. <view class="center-font">暂无盲票</view>
  53. </view>
  54. <!-- <u-empty text="数据为空" mode="order" /> -->
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import env from '../../config/env.js'
  61. import $http from '@/utils/request.js'
  62. export default {
  63. data() {
  64. return {
  65. status: 'nomore',//上拉刷新状态
  66. stateArr: [{
  67. name: ' 待兑奖',
  68. }, {
  69. name: ' 已兑奖',
  70. }],
  71. state: 2,
  72. pageNum: 1,
  73. total: 0,
  74. list: [],
  75. };
  76. },
  77. onShow() {
  78. this.pageList()
  79. },
  80. onLoad(){
  81. this.rewardNum()
  82. },
  83. methods: {
  84. getList() {
  85. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  86. status: this.state
  87. }).then(res => {
  88. if (res.code == 0) {
  89. res.rows.forEach(item => {
  90. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  91. })
  92. this.total = res.total
  93. this.list = this.list.concat(res.rows)
  94. }
  95. }).catch(() => {
  96. })
  97. },
  98. pageList() {
  99. this.pageNum = 1
  100. this.list = []
  101. this.getList()
  102. },
  103. toChoice(item) {
  104. let type = item.type && JSON.parse(item.type).value
  105. if(type == 'offline') {
  106. uni.navigateTo({
  107. url: `/packagePrize/choice/index?id=${ item.ticketId }&type=offline`
  108. })
  109. } else if (type == 'online') {
  110. uni.navigateTo({
  111. url: `/packagePrize/rolling/index?ticketId=${ item.ticketId }&isTry=0`
  112. })
  113. } else {
  114. uni.$u.toast('请联系客服')
  115. }
  116. },
  117. changeTab(e) {
  118. if (e.index == 0) {
  119. this.state = 2
  120. } else if (e.index == 1) {
  121. this.state = 3
  122. }
  123. this.pageList()
  124. },
  125. rewardNum() {
  126. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  127. status: 2
  128. }).then(res => {
  129. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  130. status: 3
  131. }).then(data => {
  132. if (res.code == 0) {
  133. this.stateArr = [{
  134. name: ' 待兑奖 (' + res.total + ') '
  135. },
  136. {
  137. name: ' 已兑奖 (' + data.total + ') '
  138. },
  139. ]
  140. } else {
  141. this.stateArr = [{
  142. name: ' 待兑奖 (0)',
  143. }, {
  144. name: ' 已兑奖 (0)',
  145. }, ]
  146. }
  147. })
  148. })
  149. }
  150. },
  151. onReachBottom() {
  152. if(this.total < this.pageNum * 20) return ;
  153. this.status = 'loading';
  154. ++this.pageNum
  155. if(this.total < this.pageNum * 20) this.status = 'nomore';
  156. else this.status = 'loading';
  157. this.getList()
  158. },
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. // 状态
  163. .state {
  164. display: flex;
  165. position: fixed;
  166. background-color: #FFFFFF;
  167. width: 100%;
  168. z-index: 10;
  169. box-shadow: 0 5rpx 5rpx #ececec;
  170. }
  171. // 列表
  172. .list {
  173. padding: 120rpx 0 100rpx;
  174. margin: 0 20rpx 0;
  175. &-item {
  176. display: flex;
  177. background: #FFFFFF;
  178. border-radius: 11px;
  179. padding: 34rpx 10rpx;
  180. margin-bottom: 34rpx;
  181. image {
  182. width: 200rpx;
  183. height: 270rpx;
  184. border-radius: 22rpx;
  185. margin-right: 15rpx;
  186. }
  187. &-content {
  188. flex: 1;
  189. flex-direction: column;
  190. justify-content: space-between;
  191. padding: 16rpx 0;
  192. .top {
  193. width: 100%;
  194. display: flex;
  195. flex-direction: column;
  196. &-title {
  197. font-size: 36rpx;
  198. line-height: 36rpx;
  199. font-weight: bold;
  200. margin-bottom: 46rpx;
  201. }
  202. &-num {
  203. font-size: 26rpx;
  204. line-height: 26rpx;
  205. }
  206. &-price {
  207. margin-top: 30rpx;
  208. font-size: 26rpx;
  209. line-height: 26rpx;
  210. }
  211. }
  212. .bottom {
  213. width: 100%;
  214. justify-content: space-between;
  215. &-price {
  216. height: 26rpx;
  217. overflow: hidden;
  218. font-size: 26rpx;
  219. line-height: 26rpx;
  220. text {
  221. color: #F9822C ;
  222. }
  223. }
  224. &-pricetwo {
  225. view {
  226. display: inline-block;
  227. height: 26rpx;
  228. font-size: 26rpx;
  229. line-height: 26rpx;
  230. vertical-align: top;
  231. }
  232. text {
  233. display: inline-block;
  234. color: #F9822C ;
  235. width: 350rpx;
  236. height: 26rpx;
  237. font-size: 26rpx;
  238. line-height: 26rpx;
  239. white-space: nowrap;
  240. overflow: hidden;
  241. text-overflow: ellipsis;
  242. }
  243. }
  244. &-btn {
  245. width: 220rpx;
  246. height: 72rpx;
  247. line-height: 72rpx;
  248. text-align: center;
  249. background: #F9822C;
  250. border-radius: 36rpx;
  251. color: #FFFFFF;
  252. font-size: 30rpx;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. .empty {
  259. height: 60vh;
  260. .center {
  261. text-align: center;
  262. &-img {
  263. width: 228rpx;
  264. height: 320rpx;
  265. }
  266. &-font {
  267. font-size: 30rpx;
  268. font-weight: 400;
  269. color: #999999;
  270. margin-bottom: 250rpx;
  271. }
  272. }
  273. }
  274. </style>