coupon.vue 7.3 KB

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