bug修复
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class='coupon-content'>
|
<view class='coupon-content'>
|
||||||
<image v-if='item?.status==0' :src='assetsUrl("bg_coupon.png")' />
|
<image v-if='item?.status==0' :src='assetsUrl("bg_coupon.png")' />
|
||||||
<image v-else-if='item?.status==1' :src='assetsUrl("bg_coupon_expired.png")' />
|
<image v-else-if='item?.status==1||item?.status==2' :src='assetsUrl("bg_coupon_expired.png")' />
|
||||||
<view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status==1}'>
|
<view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status!=0}'>
|
||||||
<text>{{ item?.reduce }}</text>
|
<text>{{ item?.reduce }}</text>
|
||||||
<text>满{{ item?.threshold }}元可用</text>
|
<text>满{{ item?.threshold }}元可用</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
|
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status!=0}'>
|
||||||
<text>{{ item?.name }}</text>
|
<text>{{ item?.name }}</text>
|
||||||
<text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
|
<text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
|
||||||
<text class='btn-text' :class='{"btn-text-disabled": item?.status==1}' @click.stop='goPath("/pages/mall/index")'>
|
<text class='btn-text' :class='{"btn-text-disabled": item?.status!=0}' @click.stop='goPath("/pages/mall/index")'>
|
||||||
立即使用
|
立即使用
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<tabbar :titles='["全部","未使用","已使用"]' :indicator-color='"#D95554"' @change='tabChange' />
|
<tabbar :titles='["全部","未使用","已使用"]' :indicator-color='"#D95554"' @change='tabChange' />
|
||||||
<u-list>
|
<u-list @scrolltolower='onLoadMore'>
|
||||||
<coupon-item v-for='item in coupons' :item='item' :key='item.id' />
|
<coupon-item v-for='item in couponList' :item='item' :key='item.id' />
|
||||||
<u-empty v-if='coupons.length === 0' text='暂无优惠券' marginTop='100' />
|
<u-loadmore v-if='couponList.length>0' :status='loadingStatus' />
|
||||||
|
<u-empty v-if='couponList.length === 0' text='暂无优惠券' marginTop='100' />
|
||||||
</u-list>
|
</u-list>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang='ts' setup>
|
<script lang='ts' setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import CouponItem from './components/coupon-item.vue';
|
import CouponItem from './components/coupon-item.vue';
|
||||||
import { getCouponList } from '@/api/user';
|
import { getCouponList } from '@/api/user';
|
||||||
@@ -18,7 +20,9 @@ const store = useUserStore();
|
|||||||
const { userInfo } = storeToRefs(store);
|
const { userInfo } = storeToRefs(store);
|
||||||
|
|
||||||
const couponStatus = ref<number | any>(undefined);
|
const couponStatus = ref<number | any>(undefined);
|
||||||
const coupons = ref<CouponBean[]>([]);
|
const couponList = ref<CouponBean[]>([]);
|
||||||
|
const currentPageNum = ref(1);
|
||||||
|
const loadingStatus = ref('loading');
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
await fetchData();
|
await fetchData();
|
||||||
@@ -36,25 +40,33 @@ const tabChange = (index: number) => {
|
|||||||
couponStatus.value = 1;
|
couponStatus.value = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
currentPageNum.value = 1;
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async (refresh: boolean = true) => {
|
||||||
|
loadingStatus.value = 'loading';
|
||||||
|
if(!refresh) {
|
||||||
|
currentPageNum.value += 1;
|
||||||
|
}
|
||||||
|
|
||||||
const { list } = await getCouponList({
|
const { list } = await getCouponList({
|
||||||
companyId: getCompanyId(),
|
companyId: getCompanyId(),
|
||||||
memberId: userInfo.value?.id,
|
memberId: userInfo.value?.id,
|
||||||
status: couponStatus.value,
|
status: couponStatus.value,
|
||||||
pageNum: 1,
|
pageNum: currentPageNum.value,
|
||||||
pageSize: 20
|
pageSize: 20
|
||||||
});
|
});
|
||||||
coupons.value = list;
|
if(refresh) {
|
||||||
|
couponList.value = list;
|
||||||
|
} else {
|
||||||
|
couponList.value = couponList.value.concat(list);
|
||||||
|
}
|
||||||
|
loadingStatus.value = 'no';
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLoadMore = () => {
|
const onLoadMore = () => {
|
||||||
if(coupons.value.length >= 20) {
|
fetchData(false);
|
||||||
return;
|
|
||||||
}
|
|
||||||
fetchData();
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user