coupon.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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="showDesc(item)">
  34. <text>使用说明:</text>
  35. <u-icon :name="item.showDesc?'arrow-up':'arrow-down'"></u-icon>
  36. </view>
  37. <view class="check-order-desc-content" v-if="item.showDesc">
  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. message(title){
  101. uni.showToast({
  102. icon:'none',
  103. title: title
  104. })
  105. },
  106. pageInit(){
  107. this.total = 0
  108. this.pageNo = 1
  109. this.getRow()
  110. },
  111. showDesc(item){
  112. item.showDesc = !item.showDesc
  113. this.list.splice()
  114. },
  115. // tabs通知swiper切换
  116. tabsChange(index) {
  117. this.swiperCurrent = index;
  118. },
  119. swiperChange(event){
  120. this.list = []
  121. this.status = "loading"
  122. },
  123. // swiper-item左右移动,通知tabs的滑块跟随移动
  124. transition(e) {
  125. let dx = e.detail.dx;
  126. this.$refs.uTabs.setDx(dx);
  127. },
  128. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  129. // swiper滑动结束,分别设置tabs和swiper的状态
  130. animationfinish(e) {
  131. let current = e.detail.current;
  132. if(current != this.current){
  133. this.$refs.uTabs.setFinishCurrent(current);
  134. this.swiperCurrent = current;
  135. this.current = current;
  136. this.pageInit()
  137. }
  138. },
  139. // scroll-view到底部加载更多
  140. onreachBottom() {
  141. console.log(this.list.length, this.total)
  142. if(this.list.length < this.total){
  143. this.pageNo += 1
  144. this.getRow()
  145. }else{
  146. this.status = "nomore"
  147. }
  148. },
  149. checkNums (states, i){
  150. if(states){
  151. let arr = states.split(',')
  152. return arr[i]
  153. }
  154. return 0
  155. },
  156. // 查询列表
  157. getRow (pageNo) {
  158. let _this = this
  159. if (pageNo) {
  160. this.pageNo = pageNo
  161. }
  162. let params = {
  163. pageNo: this.pageNo,
  164. pageSize: this.pageSize,
  165. ticketState: 'UNUSED'
  166. }
  167. // 状态条件
  168. if(this.swiperCurrent == 1){
  169. params.ticketState = 'USED'
  170. }
  171. if(this.swiperCurrent == 2){
  172. params.ticketState = 'DATED'
  173. }
  174. this.status = "loading"
  175. ticketQueryList(params).then(res => {
  176. if (res.code == 200 || res.status == 204 || res.status == 200) {
  177. const list = res.data.list || []
  178. list.map(k => k.showDesc = false)
  179. _this.list = _this.list.concat(list)
  180. _this.total = res.data.count || 0
  181. } else {
  182. _this.list = []
  183. _this.total = 0
  184. _this.noDataText = res.message
  185. }
  186. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  187. })
  188. },
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. page{
  194. height: 100%;
  195. }
  196. .digitShelf-pagesCons{
  197. height: 100%;
  198. display: flex;
  199. flex-direction: column;
  200. .tab-body{
  201. .check-list{
  202. height: calc(100vh - 44px);
  203. }
  204. .check-order-list{
  205. background: #ffffff;
  206. margin: 25upx;
  207. border-radius: 30upx;
  208. overflow: hidden;
  209. box-shadow: 1px 1px 3px #EEEEEE;
  210. > view{
  211. &:first-child{
  212. position: relative;
  213. display: flex;
  214. align-items: center;
  215. justify-content: space-around;
  216. }
  217. }
  218. .dio{
  219. width: 30rpx;
  220. height: 30rpx;
  221. background: #f8f8f8;
  222. border-radius: 100rpx;
  223. position: absolute;
  224. z-index: 1000;
  225. }
  226. .dio-left{
  227. left: -15rpx;
  228. top: 85rpx;
  229. }
  230. .dio-right{
  231. right: -15rpx;
  232. top: 85rpx;
  233. }
  234. .check-order-left{
  235. width: 30%;
  236. height: 200rpx;
  237. display: flex;
  238. align-items: center;
  239. justify-content:center;
  240. font-size: 30rpx;
  241. text{
  242. font-size: 65rpx;
  243. }
  244. color: #fff;
  245. }
  246. .imgbg-0{
  247. background: #2196F3;
  248. }
  249. .imgbg-1{
  250. background: #4CAF50;
  251. color: #ffffff;
  252. }
  253. .imgbg-2{
  254. background: #d2d1d1;
  255. }
  256. .check-order-right{
  257. width: 70%;
  258. padding: 0 25rpx;
  259. .check-order-title{
  260. font-size: 32rpx;
  261. }
  262. .check-order-subtitle{
  263. font-size: 28rpx;
  264. color: #666;
  265. margin: 10rpx 0;
  266. }
  267. .check-order-date{
  268. font-size: 24rpx;
  269. color: #666;
  270. .use-date{
  271. color: #ff5500;
  272. }
  273. }
  274. }
  275. .check-order-desc{
  276. font-size: 24rpx;
  277. color: #666;
  278. padding: 10rpx 20rpx;
  279. border-top: 1rpx solid #2196F3;
  280. display: flex;
  281. justify-content: space-between;
  282. }
  283. .border-0{
  284. border-top: 1rpx solid #eee;
  285. }
  286. .border-1{
  287. border-top: 1rpx solid #CDDC39;
  288. }
  289. .border-2{
  290. border-top: 1rpx solid #d2d1d1;
  291. }
  292. .check-order-desc-content{
  293. padding: 5rpx 25rpx 25rpx 25rpx;
  294. font-size: 24rpx;
  295. }
  296. }
  297. }
  298. }
  299. </style>