web-africa-h5/pages/market/bonus-detail/spend_index.vue

277 lines
8.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view class="d-e-c tips-box">
<!-- <u-icon name="info-circle-fill" size="32rpx" color="#CCCCCC"></u-icon> -->
<text class="f28 gray9 ml10">{{ $t('w_0157') }}</text>
<text class="f32 ml20 fb">{{ formatNum(queryBonusTotal) }}</text>
</view>
<view class="d-b-c search-data border-b f26 mb20">
<view class="flex-1 gray9">{{ $t('w_0352') }}</view>
<picker mode="date" :value="form.startDate" :start="startDate" :end="endDate" @change="bindDateChange1">
<view class="picker-item-data">{{ form.startDate || $t('CK_KS_3') }}</view>
</picker>
<view style="margin: 0 60rpx;">{{ $t('w_0139') }}</view>
<picker mode="date" :value="form.endDate" :start="startDate" :end="endDate" @change="bindDateChange2">
<view class="picker-item-data">{{ form.endDate || $t('CK_KS_9') }}</view>
</picker>
<view class="search-radio" @click="searchSubmit"><text class="icon iconfont icon-sousuo"></text></view>
</view>
<!-- <view class="d-s-c tips-box">
<u-icon name="info-circle-fill" size="32rpx" color="#CCCCCC"></u-icon>
<text class="f24 gray9 ml10">SVIP会员享受3%报单服务补贴</text>
</view> -->
<view class="wallet-list">
<view class="bonus-item" v-for="(item, index) in listData" :key="index">
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('N_I_130') }}</view>
<view class="bonus-item-content f26 gray3">{{ item.settleDate }}</view>
</view>
<!-- <view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('w_0156') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.repurPushIncome) }}</view>
</view> -->
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('w_0155') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.repurRangeIncome) }}</view>
</view>
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('fn_046') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.sameLevelIncome) }}</view>
</view>
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('fn_047') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.pointShareIncome) }}</view>
</view>
<!-- <view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('N_I_141') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.repurExpandIncome) }}</view>
</view> -->
<!-- <view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('N_I_136') }}</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.backPoints) }}</view>
</view>
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('N_I_137') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.serviceSpend) }}</view>
</view> -->
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{$t('N_I_136')}}({{currencyIcon()}})</view>
<view class="bonus-item-content f26 gray3">{{formatNum(item.backPoints)}}</view>
</view>
<view class="bonus-item-item">
<view class="bonus-item-name f26 gray9">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
<view class="bonus-item-content f26 gray3">{{ formatNum(item.repurRealSubtotal) }}</view>
</view>
<!-- <view class="d-e-c bonus-bottom border-t">
<view class="order-btn">查看详情</view>
</view> -->
</view>
</view>
<view class="d-c-c p30" v-if="listData.length == 0 && !loading">
<text class="iconfont icon-wushuju"></text>
<text class="cont">{{ $t('w_0405') }}</text>
</view>
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
</view>
</template>
<script>
import uniLoadMore from '@/components/uni-load-more.vue';
export default {
components: {
uniLoadMore
},
data() {
const currentDate = this.getDate({
format: true
});
return {
/*有没有等多*/
no_more: false,
/*是否正在加载*/
loading: true,
listData: [],
form: {
pageNum: 1,
pageSize: 10,
startDate: '',
endDate: '',
gradeId: ''
},
total: 0,
queryBonusTotal: 0
};
},
onLoad() {
let data = this.defaultDates();
this.form.startDate = this.getDate2(data[0]);
this.form.endDate = this.getDate2(data[1]);
},
onShow() {
/*获取数据*/
this.listData = [];
this.form.pageNum = 1;
this.getData();
this.getQueryBonusTotal();
},
onReachBottom() {
let self = this;
if (self.form.pageNum * self.form.pageSize < self.total) {
self.form.pageNum++;
self.getData();
}
self.no_more = true;
},
computed: {
/*加载中状态*/
loadingType() {
if (this.loading) {
return 1;
} else {
if (this.listData.length != 0 && this.no_more) {
return 2;
} else {
return 0;
}
}
},
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
methods: {
getQueryBonusTotal() {
let self = this;
self._post('bonus/api/bonus/query-bonus-total', {}, function(res) {
self.queryBonusTotal = res.rows[0].realIncomeTotal;
});
},
getData() {
let self = this;
self.loading = true;
var formdata = self.form;
self._post(
'bonus/api/bonus/query-bonus-repurchase',
formdata,
function(res) {
self.listData = res.rows;
self.total = res.total;
if (self.total < self.form.pageNum * self.form.pageSize) {
self.no_more = true;
}
}, {},
() => {
self.loading = false;
}
);
},
defaultDates() {
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
// 获取当前月份的第一天
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
// 如果今天是本月的1号则设置为上个月的1号到上个月的最后一天
if (today.getDate() === 1) {
const previousMonthFirstDay = new Date(today.getFullYear(), today.getMonth() - 1, 1);
const previousMonthLastDay = new Date(today.getFullYear(), today.getMonth(), 0); // 0号表示上个月的最后一天
return [previousMonthFirstDay, previousMonthLastDay];
} else {
// 否则设置为这个月的1号到昨天
return [firstDayOfMonth, yesterday];
}
},
getDate2(date) {
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
bindDateChange1: function(e) {
this.form.startDate = e.detail.value;
},
bindDateChange2: function(e) {
this.form.endDate = e.detail.value;
},
resetSubmit: function() {
this.form.gradeId = '';
this.form.startDate = '';
this.form.endDate = '';
},
searchSubmit: function() {
/*获取数据*/
this.listData = [];
this.form.pageNum = 1;
this.getData();
}
}
};
</script>
<style lang="scss">
.tips-box {
padding: 30rpx 20rpx;
background-color: #fff;
border-bottom: 1rpx solid #eee;
}
.bonus-item {
padding: 20rpx 25rpx 20rpx 23rpx;
background-color: #fff;
margin-bottom: 20rpx;
.bonus-bottom {
height: 104rpx;
.order-btn {
box-sizing: border-box;
padding: 0 26rpx;
min-width: 146rpx;
height: 52rpx;
line-height: 52rpx;
text-align: center;
border-radius: 26rpx;
font-size: 24rpx;
color: #fff;
border: 1rpx solid #eee;
margin-left: 18rpx;
background: #fb3024;
border: 1rpx solid #fb3024;
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
}
}
}
.bonus-item-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
</style>