coupon.vue 7.4 KB

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