Refactor:分包
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<view class="bill-details" ref="container">
|
||||
<view class="nav acea-row">
|
||||
<view class="item" :class="types == 0 ? 'on' : ''" @click="changeTypes(0)">全部</view>
|
||||
<view class="item" :class="types == 1 ? 'on' : ''" @click="changeTypes(1)">消费</view>
|
||||
<view class="item" :class="types == 2 ? 'on' : ''" @click="changeTypes(2)">充值</view>
|
||||
</view>
|
||||
<view class="sign-record">
|
||||
<view class="list">
|
||||
<view class="item" v-for="(item, listIndex) in list" :key="listIndex">
|
||||
<view class="data">{{ item.time }}</view>
|
||||
<view class="listn" v-for="(val, key) in item.list" :key="key">
|
||||
<view class="itemn acea-row row-between-wrapper">
|
||||
<view>
|
||||
<view class="name line1">{{ val.title }}</view>
|
||||
<view>{{ val.addTime }}</view>
|
||||
</view>
|
||||
<view
|
||||
class="num"
|
||||
:class="val.pm == 0 ? 'font-color-red' : ''"
|
||||
>{{ val.pm == 0 ? "-" : "+" }}{{ force2Decimal(val.number) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Loading :loaded="loaded" :loading="loading"></Loading>
|
||||
<view v-if="loaded && list.length === 0">
|
||||
<image :src="webUrl + '/noConsumption.png'" class="no-data"></image>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getCommissionInfo } from "@/api/user";
|
||||
import Loading from "@/components/Loading";
|
||||
import { pageListenMixins } from '@/mixins/pageListenMixins'
|
||||
export default {
|
||||
name: "UserBill",
|
||||
components: {
|
||||
Loading
|
||||
},
|
||||
mixins: [pageListenMixins],
|
||||
data: function() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
types: 0,
|
||||
where: {
|
||||
page: 1,
|
||||
limit: 5
|
||||
},
|
||||
list: [],
|
||||
loaded: false,
|
||||
loading: false,
|
||||
pageKeyId: Object.freeze('userBalanceBill')
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
"$yroute.query.types": function(newVal) {
|
||||
let that = this;
|
||||
if (newVal != undefined) {
|
||||
that.types = newVal;
|
||||
that.list = [];
|
||||
that.where.page = 1;
|
||||
that.loaded = false;
|
||||
that.loading = false;
|
||||
that.getIndex();
|
||||
}
|
||||
},
|
||||
types: function() {
|
||||
this.getIndex();
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
let that = this;
|
||||
|
||||
that.types = that.$yroute.query.types||0;
|
||||
that.getIndex();
|
||||
},
|
||||
onReachBottom() {
|
||||
!this.loading && this.getIndex();
|
||||
},
|
||||
methods: {
|
||||
force2Decimal(v){
|
||||
return this.$force2Decimal(v);
|
||||
},
|
||||
code: function() {
|
||||
this.sendCode();
|
||||
},
|
||||
changeTypes: function(val) {
|
||||
if (val != this.types) {
|
||||
this.types = val;
|
||||
this.list = [];
|
||||
this.where.page = 1;
|
||||
this.loaded = false;
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
getIndex: function() {
|
||||
let that = this;
|
||||
if (that.loaded == true || that.loading == true) return;
|
||||
that.loading = true;
|
||||
getCommissionInfo(that.where, that.types).then(
|
||||
res => {
|
||||
that.loading = false;
|
||||
that.loaded = res.data.length < that.where.limit;
|
||||
that.where.page = that.where.page + 1;
|
||||
that.list.push.apply(that.list, res.data);
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
title: err.msg || err.response.data.msg|| err.response.data.message,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.no-data {
|
||||
display: block;
|
||||
width: 500rpx;
|
||||
height: 500rpx;
|
||||
margin: 100rpx auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user