coupon.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="digitShelf-pagesCons">
  3. <view class="tab-body">
  4. <view>
  5. <u-tabs-swiper ref="uTabs" :list="tabList" :offset="[5,40]" bar-width='100' active-color="#1283d4" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, indexs) in tabList" :key="indexs">
  10. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
  11. <view
  12. class="check-order-list"
  13. v-for="(item,index) in list"
  14. :key="item.id"
  15. >
  16. <view>
  17. <view class="dio dio-left"></view>
  18. <view class="dio dio-right"></view>
  19. <view class="check-order-left" :class="'imgbg-'+current">
  20. ¥<text>{{item.ticketValue}}</text>
  21. </view>
  22. <view class="check-order-right">
  23. <view class="check-order-title">{{item.activeName}}</view>
  24. <view class="check-order-subtitle">{{item.activeTitle}}</view>
  25. <view class="check-order-date">
  26. <view>{{item.validStartDate}} 至</view>
  27. <view>{{item.validEndDate}} 到期 </view>
  28. <!-- <view class="use-date" v-if="current==1">使用时间:2021-12-31</view> -->
  29. </view>
  30. </view>
  31. </view>
  32. <view v-if="item.ticketExplain">
  33. <view class="check-order-desc" :class="'border-'+current" @click="item.showDesc = !item.showDesc">
  34. <text>使用说明:</text>
  35. <u-icon name="arrow-down"></u-icon>
  36. </view>
  37. <view class="check-order-desc-content">
  38. {{item.ticketExplain}}
  39. </view>
  40. </view>
  41. </view>
  42. <view style="padding: 20upx;">
  43. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  44. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  45. </view>
  46. </scroll-view>
  47. </swiper-item>
  48. </swiper>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import carNo from '@/components/carNo.vue'
  54. import { ticketQueryList } from '@/api/user.js'
  55. import moment from 'moment'
  56. export default {
  57. components: {carNo},
  58. data() {
  59. return {
  60. theme:'',
  61. status: 'loading',
  62. noDataText: '暂无数据',
  63. tabList: [
  64. {
  65. dispName: '未使用',
  66. typeId: 1,
  67. count: 0
  68. },
  69. {
  70. dispName: '已使用',
  71. typeId: 2,
  72. count: 0
  73. },
  74. {
  75. dispName: '已过期',
  76. typeId: 3,
  77. count: 0
  78. },
  79. ],
  80. current: 0,
  81. swiperCurrent: 0,
  82. // 查询条件
  83. pageNo: 1,
  84. pageSize: 10,
  85. list: [],
  86. total: 0,
  87. }
  88. },
  89. onLoad() {
  90. let _this = this
  91. _this.pageInit()
  92. _this.theme = getApp().globalData.theme
  93. uni.$on('refreshOrder',function(data){
  94. _this.list = []
  95. _this.status = "loading"
  96. _this.pageInit()
  97. })
  98. },
  99. methods:{
  100. // 复制
  101. copyVin(vin){
  102. uni.setClipboardData({
  103. data: vin||'',
  104. })
  105. },
  106. message(title){
  107. uni.showToast({
  108. icon:'none',
  109. title: title
  110. })
  111. },
  112. pageInit(){
  113. this.total = 0
  114. this.pageNo = 1
  115. this.getRow()
  116. },
  117. // tabs通知swiper切换
  118. tabsChange(index) {
  119. this.swiperCurrent = index;
  120. },
  121. swiperChange(event){
  122. this.list = []
  123. this.status = "loading"
  124. },
  125. // swiper-item左右移动,通知tabs的滑块跟随移动
  126. transition(e) {
  127. let dx = e.detail.dx;
  128. this.$refs.uTabs.setDx(dx);
  129. },
  130. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  131. // swiper滑动结束,分别设置tabs和swiper的状态
  132. animationfinish(e) {
  133. let current = e.detail.current;
  134. if(current != this.current){
  135. this.$refs.uTabs.setFinishCurrent(current);
  136. this.swiperCurrent = current;
  137. this.current = current;
  138. this.pageInit()
  139. }
  140. },
  141. // scroll-view到底部加载更多
  142. onreachBottom() {
  143. console.log(this.list.length, this.total)
  144. if(this.list.length < this.total){
  145. this.pageNo += 1
  146. this.getRow()
  147. }else{
  148. this.status = "nomore"
  149. }
  150. },
  151. checkNums (states, i){
  152. if(states){
  153. let arr = states.split(',')
  154. return arr[i]
  155. }
  156. return 0
  157. },
  158. // 查询列表
  159. getRow (pageNo) {
  160. let _this = this
  161. if (pageNo) {
  162. this.pageNo = pageNo
  163. }
  164. let params = {
  165. pageNo: this.pageNo,
  166. pageSize: this.pageSize,
  167. ticketState: 'UNUSED'
  168. }
  169. // 状态条件
  170. if(this.swiperCurrent == 1){
  171. params.ticketState = 'USED'
  172. }
  173. if(this.swiperCurrent == 2){
  174. params.ticketState = 'DATED'
  175. }
  176. this.status = "loading"
  177. ticketQueryList(params).then(res => {
  178. if (res.code == 200 || res.status == 204 || res.status == 200) {
  179. const list = res.data.list || []
  180. list.map(k => k.showDesc = false)
  181. _this.list = _this.list.concat(list)
  182. _this.total = res.data.count || 0
  183. } else {
  184. _this.list = []
  185. _this.total = 0
  186. _this.noDataText = res.message
  187. }
  188. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  189. })
  190. },
  191. }
  192. }
  193. </script>
  194. <style lang="scss">
  195. page{
  196. height: 100%;
  197. }
  198. .digitShelf-pagesCons{
  199. height: 100%;
  200. display: flex;
  201. flex-direction: column;
  202. .tab-body{
  203. .check-list{
  204. height: calc(100vh - 44px);
  205. }
  206. .check-order-list{
  207. background: #ffffff;
  208. margin: 25upx;
  209. border-radius: 30upx;
  210. overflow: hidden;
  211. box-shadow: 1px 1px 3px #EEEEEE;
  212. > view{
  213. &:first-child{
  214. position: relative;
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-around;
  218. }
  219. }
  220. .dio{
  221. width: 30rpx;
  222. height: 30rpx;
  223. background: #f8f8f8;
  224. border-radius: 100rpx;
  225. position: absolute;
  226. z-index: 1000;
  227. }
  228. .dio-left{
  229. left: -15rpx;
  230. top: 85rpx;
  231. }
  232. .dio-right{
  233. right: -15rpx;
  234. top: 85rpx;
  235. }
  236. .check-order-left{
  237. width: 30%;
  238. height: 200rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content:center;
  242. font-size: 30rpx;
  243. text{
  244. font-size: 65rpx;
  245. }
  246. color: #fff;
  247. }
  248. .imgbg-0{
  249. background: #2196F3;
  250. }
  251. .imgbg-1{
  252. background: #f7e7b8;
  253. color: #FF9800;
  254. }
  255. .imgbg-2{
  256. background: #d2d1d1;
  257. }
  258. .check-order-right{
  259. width: 70%;
  260. padding: 0 25rpx;
  261. .check-order-title{
  262. font-size: 32rpx;
  263. }
  264. .check-order-subtitle{
  265. font-size: 28rpx;
  266. color: #666;
  267. margin: 10rpx 0;
  268. }
  269. .check-order-date{
  270. font-size: 24rpx;
  271. color: #666;
  272. .use-date{
  273. color: #ff5500;
  274. }
  275. }
  276. }
  277. .check-order-desc{
  278. font-size: 24rpx;
  279. color: #666;
  280. padding: 10rpx 20rpx;
  281. border-top: 1rpx solid #2196F3;
  282. display: flex;
  283. justify-content: space-between;
  284. }
  285. .border-0{
  286. border-top: 1rpx solid #eee;
  287. }
  288. .border-1{
  289. border-top: 1rpx solid #f7e7b8;
  290. }
  291. .border-2{
  292. border-top: 1rpx solid #d2d1d1;
  293. }
  294. .check-order-desc-content{
  295. padding: 5rpx 25rpx 25rpx 25rpx;
  296. font-size: 24rpx;
  297. }
  298. }
  299. }
  300. }
  301. </style>