mall-uniapp/pages/users/user_bill/index.vue

176 lines
4.2 KiB
Vue
Raw Normal View History

2020-08-13 08:12:57 +00:00
<template>
<view>
<view class='bill-details'>
<view class='nav acea-row'>
2021-02-06 09:25:18 +00:00
<view class='item' :class='type==="all" ? "on":""' @click='changeType("all")'>全部</view>
<view class='item' :class='type==="expenditure" ? "on":""' @click='changeType("expenditure")'>支出</view>
<view class='item' :class='type==="income" ? "on":""' @click='changeType("income")'>收入</view>
2020-08-13 08:12:57 +00:00
</view>
<view class='sign-record'>
<view class='list' v-for="(item,index) in userBillList" :key="index">
<view class='item'>
<view class='data'>{{item.date}}</view>
<view class='listn'>
<view class='itemn acea-row row-between-wrapper' v-for="(vo,indexn) in item.list" :key="indexn">
<view>
<view class='name line1'>{{vo.title}}</view>
<view>{{vo.add_time}}</view>
</view>
<view class='num' v-if="vo.pm">+{{vo.number}}</view>
<view class='num font-color' v-else>-{{vo.number}}</view>
</view>
</view>
</view>
</view>
<view class='loadingicon acea-row row-center-wrapper' v-if="userBillList.length>0">
<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
</view>
<view v-if="userBillList.length == 0">
<emptyPage title="暂无账单的记录哦~"></emptyPage>
</view>
</view>
</view>
<!-- #ifdef MP -->
2021-05-07 10:31:36 +00:00
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
2020-08-13 08:12:57 +00:00
<!-- #endif -->
<home></home>
</view>
</template>
<script>
import {
2021-02-06 09:25:18 +00:00
getBillList
2020-08-13 08:12:57 +00:00
} from '@/api/user.js';
import {
toLogin
} from '@/libs/login.js';
import {
mapGetters
} from "vuex";
// #ifdef MP
import authorize from '@/components/Authorize';
// #endif
import emptyPage from '@/components/emptyPage.vue';
import home from '@/components/home';
export default {
components: {
// #ifdef MP
authorize,
// #endif
emptyPage,
home
},
data() {
return {
loadTitle: '加载更多',
loading: false,
loadend: false,
page: 1,
limit: 10,
2021-02-06 09:25:18 +00:00
type: 'all',
2020-08-13 08:12:57 +00:00
userBillList: [],
isAuto: false, //没有授权的不会自动授权
isShowAuth: false //是否隐藏授权
};
},
computed: mapGetters(['isLogin']),
onShow() {
if (this.isLogin) {
this.getUserBillList();
} else {
2021-05-07 10:31:36 +00:00
// #ifdef H5 || APP-PLUS
2020-08-13 08:12:57 +00:00
toLogin();
2021-05-07 10:31:36 +00:00
// #endif
// #ifdef MP
this.isAuto = true;
this.$set(this, 'isShowAuth', true);
// #endif
2020-08-13 08:12:57 +00:00
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
2021-02-06 09:25:18 +00:00
this.type = options.type;
2020-08-13 08:12:57 +00:00
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
this.getUserBillList();
},
methods: {
/**
* 授权回调
*/
onLoadFun: function() {
this.getUserBillList();
},
// 授权关闭
authColse: function(e) {
this.isShowAuth = e
},
/**
* 获取账户明细
*/
getUserBillList: function() {
let that = this;
if (that.loadend) return;
2020-08-13 08:12:57 +00:00
if (that.loading) return;
that.loading = true;
that.loadTitle = "";
let data = {
page: that.page,
2021-02-06 09:25:18 +00:00
limit: that.limit,
type: that.type
2020-08-13 08:12:57 +00:00
}
2021-02-06 09:25:18 +00:00
getBillList(data).then(function(res) {
2020-08-13 08:12:57 +00:00
let list = res.data.list?res.data.list:[],
loadend = res.data.list < res.data.limit;
2020-08-13 08:12:57 +00:00
that.userBillList = that.$util.SplitArray(list, that.userBillList);
that.$set(that, 'userBillList', that.userBillList);
that.loadend = loadend;
that.loading = false;
that.loadTitle = loadend ? "哼😕~我也是有底线的~" : "加载更多";
that.page = that.page + 1;
}, function(res) {
that.loading = false;
that.loadTitle = '加载更多';
});
},
/**
* 切换导航
*/
changeType: function(type) {
this.type = type;
this.loadend = false;
this.page = 1;
this.$set(this, 'userBillList', []);
this.getUserBillList();
},
}
}
</script>
<style scoped lang='scss'>
.bill-details .nav {
background-color: #fff;
height: 90rpx;
width: 100%;
line-height: 90rpx;
}
.bill-details .nav .item {
flex: 1;
text-align: center;
font-size: 30rpx;
color: #282828;
}
.bill-details .nav .item.on {
color: #e93323;
border-bottom: 3rpx solid #e93323;
}
</style>