index.vue 7.4 KB

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