index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. <!-- #ifdef MP-WEIXIN -->
  7. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲票"></u-navbar>
  8. <!-- #endif -->
  9. <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
  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. pagesNum: '',
  88. };
  89. },
  90. onShow() {
  91. this.pagesNum = getCurrentPages().length
  92. this.pageList()
  93. },
  94. onLoad(){
  95. this.rewardNum()
  96. },
  97. methods: {
  98. getList() {
  99. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  100. status: this.state
  101. }).then(res => {
  102. if (res.code == 0) {
  103. res.rows.forEach(item => {
  104. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  105. })
  106. this.total = res.total
  107. this.list = this.list.concat(res.rows)
  108. }
  109. }).catch(() => {
  110. })
  111. },
  112. pageList() {
  113. this.pageNum = 1
  114. this.list = []
  115. this.getList()
  116. },
  117. toChoice(item) {
  118. uni.navigateTo({
  119. url: `/packagePrize/choice/index?id=${ item.ticketId }`
  120. })
  121. // let type = item.type && JSON.parse(item.type).value
  122. // if(type == 'offline') {
  123. // uni.navigateTo({
  124. // url: `/packagePrize/choice/index?id=${ item.ticketId }&type=offline`
  125. // })
  126. // } else if (type == 'online') {
  127. // uni.navigateTo({
  128. // url: `/packagePrize/rolling/index?ticketId=${ item.ticketId }&isTry=0`
  129. // })
  130. // } else {
  131. // uni.$u.toast('请联系客服')
  132. // }
  133. },
  134. changeTab(e) {
  135. if (e.index == 0) {
  136. this.state = 2
  137. } else if (e.index == 1) {
  138. this.state = 3
  139. }
  140. this.pageList()
  141. },
  142. rewardNum() {
  143. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  144. status: 2
  145. }).then(res => {
  146. $http.post(`/api/v1/mp/user/mine/ticket/list?pageNum=${this.pageNum}&pageSize=20`, {
  147. status: 3
  148. }).then(data => {
  149. if (res.code == 0) {
  150. this.stateArr = [{
  151. name: ' 待兑奖 (' + res.total + ') '
  152. },
  153. {
  154. name: ' 已兑奖 (' + data.total + ') '
  155. },
  156. ]
  157. } else {
  158. this.stateArr = [{
  159. name: ' 待兑奖 (0)',
  160. }, {
  161. name: ' 已兑奖 (0)',
  162. }, ]
  163. }
  164. })
  165. })
  166. }
  167. },
  168. onReachBottom() {
  169. if(this.total < this.pageNum * 20) return ;
  170. this.status = 'loading';
  171. ++this.pageNum
  172. if(this.total < this.pageNum * 20) this.status = 'nomore';
  173. else this.status = 'loading';
  174. this.getList()
  175. },
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. // 状态
  180. .state {
  181. display: flex;
  182. position: fixed;
  183. background-color: #FFFFFF;
  184. width: 100%;
  185. z-index: 10;
  186. box-shadow: 0 5rpx 5rpx #ececec;
  187. }
  188. // 列表
  189. .list {
  190. padding: 120rpx 0 100rpx;
  191. margin: 0 20rpx 0;
  192. &-item {
  193. display: flex;
  194. background: #FFFFFF;
  195. border-radius: 11px;
  196. padding: 34rpx 10rpx;
  197. margin-bottom: 34rpx;
  198. image {
  199. width: 200rpx;
  200. height: 270rpx;
  201. border-radius: 22rpx;
  202. margin-right: 15rpx;
  203. }
  204. &-content {
  205. flex: 1;
  206. flex-direction: column;
  207. justify-content: space-between;
  208. padding: 16rpx 0;
  209. .top {
  210. width: 100%;
  211. display: flex;
  212. flex-direction: column;
  213. &-title {
  214. font-size: 36rpx;
  215. line-height: 36rpx;
  216. font-weight: bold;
  217. margin-bottom: 46rpx;
  218. }
  219. &-num {
  220. font-size: 26rpx;
  221. line-height: 26rpx;
  222. }
  223. &-price {
  224. margin-top: 30rpx;
  225. font-size: 26rpx;
  226. line-height: 26rpx;
  227. }
  228. }
  229. .bottom {
  230. width: 100%;
  231. justify-content: space-between;
  232. &-price {
  233. height: 26rpx;
  234. overflow: hidden;
  235. font-size: 26rpx;
  236. line-height: 26rpx;
  237. text {
  238. color: #F9822C ;
  239. }
  240. }
  241. &-pricetwo {
  242. view {
  243. display: inline-block;
  244. height: 26rpx;
  245. font-size: 26rpx;
  246. line-height: 26rpx;
  247. vertical-align: top;
  248. }
  249. text {
  250. display: inline-block;
  251. color: #F9822C ;
  252. width: 350rpx;
  253. height: 26rpx;
  254. font-size: 26rpx;
  255. line-height: 26rpx;
  256. white-space: nowrap;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. }
  260. }
  261. &-btn {
  262. width: 220rpx;
  263. height: 72rpx;
  264. line-height: 72rpx;
  265. text-align: center;
  266. background: #F9822C;
  267. border-radius: 36rpx;
  268. color: #FFFFFF;
  269. font-size: 30rpx;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. .empty {
  276. height: 60vh;
  277. .center {
  278. text-align: center;
  279. &-img {
  280. width: 228rpx;
  281. height: 320rpx;
  282. }
  283. &-font {
  284. font-size: 30rpx;
  285. font-weight: 400;
  286. color: #999999;
  287. margin-bottom: 250rpx;
  288. }
  289. }
  290. }
  291. </style>