123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <view class="digitShelf-pagesCons">
- <view class="tab-body">
- <view>
- <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"
- swiperWidth="750"></u-tabs-swiper>
- </view>
- <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
- <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, indexs) in tabList" :key="indexs">
- <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom" v-if="swiperCurrent==indexs">
- <view
- class="check-order-list"
- v-for="(item,index) in list"
- :key="item.id"
- :class="'imgbg-'+current"
- >
- <view>
- <view class="dio dio-left"></view>
- <view class="dio dio-right"></view>
- <view class="check-order-left">
- ¥<text>{{item.ticketValue}}</text>
- </view>
- <view class="check-order-right">
- <view class="check-order-title">{{item.activeName}}</view>
- <view class="check-order-subtitle">{{item.activeTitle}}</view>
- <view class="check-order-date">
- <view>{{item.validStartDate}} 至</view>
- <view>{{item.validEndDate}} 到期 </view>
- <!-- <view class="use-date" v-if="current==1">使用时间:2021-12-31</view> -->
- </view>
- <view v-if="item.ticketExplain">
- <view class="check-order-desc" :class="'border-'+current" @click="showDesc(item)">
- <text>使用说明:</text>
- <u-icon :name="item.showDesc?'arrow-up':'arrow-down'"></u-icon>
- </view>
- <view class="check-order-desc-content" v-if="item.showDesc">
- {{item.ticketExplain}}
- </view>
- </view>
- </view>
- </view>
- </view>
- <view style="padding: 20upx;">
- <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>
- <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
- </view>
- </scroll-view>
- </swiper-item>
- </swiper>
- </view>
- </view>
- </template>
- <script>
- import { ticketQueryList } from '@/api/user.js'
- import moment from 'moment'
- export default {
- data() {
- return {
- theme:'',
- status: 'loading',
- noDataText: '暂无优惠券',
- tabList: [
- {
- dispName: '未使用',
- typeId: 1,
- count: 0
- },
- {
- dispName: '已使用',
- typeId: 2,
- count: 0
- },
- {
- dispName: '已过期',
- typeId: 3,
- count: 0
- },
- ],
- current: 0,
- swiperCurrent: 0,
- // 查询条件
- pageNo: 1,
- pageSize: 10,
- list: [],
- total: 0,
- }
- },
- onLoad() {
- let _this = this
- _this.pageInit()
- _this.theme = getApp().globalData.theme
- uni.$on('refreshOrder',function(data){
- _this.list = []
- _this.status = "loading"
- _this.pageInit()
- })
- },
- methods:{
- message(title){
- uni.showToast({
- icon:'none',
- title: title
- })
- },
- pageInit(){
- this.total = 0
- this.pageNo = 1
- this.getRow()
- },
- showDesc(item){
- item.showDesc = !item.showDesc
- this.list.splice()
- },
- // tabs通知swiper切换
- tabsChange(index) {
- this.list = []
- this.status = "loading"
- this.swiperCurrent = index;
- },
- swiperChange(event){
- this.list = []
- this.status = "loading"
- this.swiperCurrent = event.detail.current
- },
- // swiper-item左右移动,通知tabs的滑块跟随移动
- transition(e) {
- let dx = e.detail.dx;
- this.$refs.uTabs.setDx(dx);
- },
- // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
- // swiper滑动结束,分别设置tabs和swiper的状态
- animationfinish(e) {
- let current = e.detail.current;
- if(current != this.current){
- this.$refs.uTabs.setFinishCurrent(current);
- this.swiperCurrent = current;
- this.current = current;
- this.pageInit()
- }
- },
- // scroll-view到底部加载更多
- onreachBottom() {
- console.log(this.list.length, this.total)
- if(this.list.length < this.total){
- this.pageNo += 1
- this.getRow()
- }else{
- this.status = "nomore"
- }
- },
- checkNums (states, i){
- if(states){
- let arr = states.split(',')
- return arr[i]
- }
- return 0
- },
- // 查询列表
- getRow (pageNo) {
- let _this = this
- if (pageNo) {
- this.pageNo = pageNo
- }
- let params = {
- pageNo: this.pageNo,
- pageSize: this.pageSize,
- ticketState: 'UNUSED'
- }
- // 状态条件
- if(this.swiperCurrent == 1){
- params.ticketState = 'USED'
- }
- if(this.swiperCurrent == 2){
- params.ticketState = 'DATED'
- }
- this.status = "loading"
- ticketQueryList(params).then(res => {
- if (res.code == 200 || res.status == 204 || res.status == 200) {
- const list = res.data.list || []
- list.map(k => k.showDesc = false)
- _this.list = _this.list.concat(list)
- _this.total = res.data.count || 0
- } else {
- _this.list = []
- _this.total = 0
- _this.noDataText = res.message
- }
- _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
- })
- },
- }
- }
- </script>
- <style lang="scss">
- page{
- height: 100%;
- }
- .digitShelf-pagesCons{
- height: 100%;
- display: flex;
- flex-direction: column;
- .tab-body{
- .check-list{
- height: calc(100vh - 44px);
- }
- .imgbg-0{
- background: #fde2da;
- .check-order-left{
- color: #f44336;
- }
- .check-order-right{
- border-left: 1rpx dashed #ff7d73;
- }
- }
- .imgbg-1{
- background: #dbf5ce;
- .check-order-left{
- color: #4CAF50;
- }
- .check-order-right{
- border-left: 1rpx dashed #4CAF50;
- }
- }
- .imgbg-2{
- background: #e2e2e2;
- .check-order-left{
- color: #9E9E9E;
- }
- .check-order-right{
- border-left: 1rpx dashed #9E9E9E;
- }
- }
- .check-order-list{
- margin: 25upx;
- border-radius: 30upx;
- overflow: hidden;
- > view{
- &:first-child{
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-around;
- }
- }
- .dio{
- width: 30rpx;
- height: 30rpx;
- background: #f8f8f8;
- border-radius: 100rpx;
- position: absolute;
- z-index: 1000;
- }
- .dio-left{
- left: -15rpx;
- top: 50%;
- margin-top: -15rpx;
- }
- .dio-right{
- right: -15rpx;
- top: 50%;
- margin-top: -15rpx;
- }
- .check-order-left{
- width: 30%;
- display: flex;
- align-items: center;
- justify-content:center;
- font-size: 30rpx;
- text{
- font-size: 65rpx;
- }
- }
- .check-order-right{
- width: 70%;
- padding: 25rpx;
- background-color: #fff;
- .check-order-title{
- font-size: 32rpx;
- }
- .check-order-subtitle{
- font-size: 28rpx;
- color: #666;
- margin: 10rpx 0;
- }
- .check-order-date{
- font-size: 24rpx;
- color: #666;
- .use-date{
- color: #ff5500;
- }
- }
- }
- .check-order-desc{
- font-size: 24rpx;
- color: #666;
- padding: 10rpx 0 0;
- display: flex;
- justify-content: space-between;
- }
- .check-order-desc-content{
- padding: 5rpx 25rpx 25rpx 25rpx;
- font-size: 24rpx;
- }
- }
- }
- }
- </style>
|