|
|
<template>
|
|
|
<div style="height: 100%;">
|
|
|
<div class="head"></div>
|
|
|
<ClassicTabs ref="tabs" v-model="selectLabel" :data="tabLabels" @on-filter-change="onFilterChange"></ClassicTabs>
|
|
|
|
|
|
<div class="tab-slide-container">
|
|
|
<Slide
|
|
|
ref="slide"
|
|
|
:loop="false"
|
|
|
:auto-play="false"
|
|
|
:show-dots="false"
|
|
|
:initial-index="initialIndex"
|
|
|
:options="slideOptions"
|
|
|
@scroll="scroll"
|
|
|
@change="changePage"
|
|
|
>
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<ExchangeBox v-model="inputCouponCode" @click="onSubmitCode"></ExchangeBox>
|
|
|
|
|
|
<div class="filter-wrapper" v-if="showFilter">
|
|
|
<div class="filter-mask" @click="onMaskClick"></div>
|
|
|
<FilterBar :list="filterList" v-model="selectFilterId" class="filter"></FilterBar>
|
|
|
</div>
|
|
|
|
|
|
<div class="head"></div>
|
|
|
|
|
|
<Scroll :data="yohoList.notuse" :options="scrollOptions" v-if="yohoList.notuse.length">
|
|
|
<CouponItem :item="item" v-for="(item, index) in yohoList.notuse" :key ="index"></CouponItem>
|
|
|
</Scroll>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<Scroll :data="yohoList.use" :options="scrollOptions" v-if="yohoList.use.length">
|
|
|
<CouponItem :item="item" v-for="(item, index) in yohoList.use" :key ="index" v-if="yohoList.use.length"></CouponItem>
|
|
|
</Scroll>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<Scroll :data="yohoList.overtime" :options="scrollOptions" v-if="yohoList.overtime.length">
|
|
|
<CouponItem :item="item" v-for="(item, index) in yohoList.overtime" :key ="index" v-if="yohoList.overtime.length"></CouponItem>
|
|
|
</Scroll>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
</Slide>
|
|
|
<div style="height: 100%;">
|
|
|
<div class="head"></div>
|
|
|
<ClassicTabs ref="tabs" v-model="selectLabel" :data="tabLabels" @on-filter-change="onFilterChange"></ClassicTabs>
|
|
|
|
|
|
<div class="tab-slide-container">
|
|
|
<Slide
|
|
|
ref="slide"
|
|
|
:loop="false"
|
|
|
:auto-play="false"
|
|
|
:show-dots="false"
|
|
|
:initial-index="initialIndex"
|
|
|
:options="slideOptions"
|
|
|
@scroll="scroll"
|
|
|
@change="changePage"
|
|
|
>
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<ExchangeBox v-model="inputCouponCode" @click="onSubmitCode"></ExchangeBox>
|
|
|
|
|
|
<div class="filter-wrapper" v-if="showFilter">
|
|
|
<div class="filter-mask" @click="onMaskClick"></div>
|
|
|
<FilterBar :list="filterList" v-model="selectFilterId" class="filter"></FilterBar>
|
|
|
</div>
|
|
|
|
|
|
<div class="head"></div>
|
|
|
|
|
|
<ScrollView ref="notuse" :data="getNotUseList" :options="scrollOptions" v-if="getNotUseList.length" :reach-bottom="reachBottom">
|
|
|
<CouponItem :item="item" v-for="(item, index) in getNotUseList" :key="index"></CouponItem>
|
|
|
</ScrollView>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<ScrollView ref="use" :data="getUseList" :options="scrollOptions" v-if="getUseList.length" :reach-bottom="reachBottom">
|
|
|
<CouponItem :item="item" v-for="(item, index) in getUseList" :key="index"></CouponItem>
|
|
|
</ScrollView>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
|
|
|
<SlideItem style="background-color: #f0f0f0;">
|
|
|
<ScrollView ref="overtime" :data="getOvertimeList" options="scrollOptions" v-if="getOvertimeList.length" :reach-bottom="reachBottom">
|
|
|
<CouponItem :item="item" v-for="(item, index) in getOvertimeList" :key="index"></CouponItem>
|
|
|
</ScrollView>
|
|
|
<Empty v-else></Empty>
|
|
|
</SlideItem>
|
|
|
</Slide>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {createNamespacedHelpers} from 'vuex';
|
|
|
|
|
|
const {mapState, mapActions} = createNamespacedHelpers('coupon/yoho');
|
|
|
const {mapState, mapActions, mapGetters} = createNamespacedHelpers('coupon/yoho');
|
|
|
|
|
|
import Tabs from '../components/tabs';
|
|
|
import FilterBar from '../components/filter-bar';
|
|
|
import ExchangeBox from '../components/exchange-box';
|
|
|
import CouponItem from '../components/coupon-item';
|
|
|
import Empty from '../components/empty';
|
|
|
import ScrollView from '../components/scroll-view';
|
|
|
|
|
|
import {Slide, Scroll} from 'cube-ui';
|
|
|
import {Slide} from 'cube-ui';
|
|
|
|
|
|
const TYPE = {notuse: 'notuse', use: 'use', overtime: 'overtime'};
|
|
|
|
|
|
export default {
|
|
|
name: 'YohoCouponListPage',
|
|
|
asyncData({store}) {
|
|
|
return store.dispatch('coupon/yoho/fetchYohoList', {
|
|
|
return Promise.all([
|
|
|
store.dispatch('coupon/yoho/fetchYohoList', {
|
|
|
type: TYPE.notuse,
|
|
|
filter: 0,
|
|
|
limit: 20,
|
|
|
page: 1
|
|
|
});
|
|
|
}),
|
|
|
store.dispatch('coupon/yoho/fetchYohoList', {
|
|
|
type: TYPE.use,
|
|
|
}),
|
|
|
store.dispatch('coupon/yoho/fetchYohoList', {
|
|
|
type: TYPE.overtime,
|
|
|
})
|
|
|
]);
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
selectLabel: '未使用',
|
|
|
selectType: TYPE.notuse,
|
|
|
showFilter: false,
|
|
|
selectFilterId: 0,
|
|
|
inputCouponCode: '',
|
...
|
...
|
@@ -99,6 +106,13 @@ export default { |
|
|
],
|
|
|
scrollOptions: {
|
|
|
directionLockThreshold: 0,
|
|
|
pullUpLoad: {
|
|
|
threshold: 0,
|
|
|
txt: {
|
|
|
more: '加载更多',
|
|
|
noMore: '以上是最新的内容'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
slideOptions: {
|
|
|
listenScroll: true,
|
...
|
...
|
@@ -109,7 +123,8 @@ export default { |
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['yohoList', 'filterList']),
|
|
|
...mapState(['filterList']),
|
|
|
...mapGetters(['getNotUseList', 'getUseList', 'getOvertimeList']),
|
|
|
initialIndex() {
|
|
|
let index = 0;
|
|
|
|
...
|
...
|
@@ -120,28 +135,17 @@ export default { |
|
|
created() {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getNum();
|
|
|
this.fetchYohoNum();
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['getCouponCode']),
|
|
|
...mapActions(['getCouponCode', 'fetchYohoList', 'fetchYohoNum']),
|
|
|
changePage(current) {
|
|
|
const tab = this.tabLabels[current];
|
|
|
|
|
|
this.selectLabel = this.tabLabels[current].label;
|
|
|
|
|
|
this.$store.dispatch('coupon/yoho/fetchYohoList', {
|
|
|
type: tab.type,
|
|
|
filter: tab.selectFilterId,
|
|
|
limit: 20,
|
|
|
page: 1
|
|
|
});
|
|
|
this.selectType = this.tabLabels[current].type;
|
|
|
},
|
|
|
scroll() {
|
|
|
|
|
|
},
|
|
|
getNum() {
|
|
|
return this.$store.dispatch('coupon/yoho/fetchYohoNum', {});
|
|
|
},
|
|
|
onFilterChange(show) {
|
|
|
this.showFilter = show;
|
|
|
},
|
...
|
...
|
@@ -152,17 +156,21 @@ export default { |
|
|
onSubmitCode() {
|
|
|
this.getCouponCode({code: this.inputCouponCode}).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
this.inputCouponCode = '';
|
|
|
this.$createToast({
|
|
|
txt: result.message,
|
|
|
type: 'correct'
|
|
|
});
|
|
|
}).show();
|
|
|
} else {
|
|
|
this.$createToast({
|
|
|
txt: result.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
}).show();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
reachBottom() {
|
|
|
this.fetchYohoList({type: this.selectType});
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
...
|
...
|
@@ -178,9 +186,9 @@ export default { |
|
|
ExchangeBox,
|
|
|
Slide,
|
|
|
SlideItem: Slide.Item,
|
|
|
Scroll,
|
|
|
CouponItem,
|
|
|
Empty
|
|
|
Empty,
|
|
|
ScrollView
|
|
|
}
|
|
|
};
|
|
|
</script>
|
...
|
...
|
@@ -194,10 +202,6 @@ export default { |
|
|
height: 100%;
|
|
|
}
|
|
|
|
|
|
.cube-scroll-wrapper {
|
|
|
padding-top: 20px;
|
|
|
}
|
|
|
|
|
|
.filter-wrapper {
|
|
|
width: calc(100% / 3);
|
|
|
height: 100%;
|
...
|
...
|
|