公司小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.9 KiB

import { post } from "@/common/api.js"
import WalletRecord from '@/common/WalletRecord.js'
export default class WalletMainPage{
//代理佣金
agencycommi = 0;
//金额记录 首页一开始最多10条
amountrecord = [];
//金额记录起始时间
amountstarttime = 0;
//金额记录时间 精确到月份数
amounttime = 0;
//可用金额
availableamount = 0;
//入账中的金额
recordedamount = 0;
///有记录的开始时间
recordStartTime = [2022,1,1];
///每一个屏幕最多可以放8条记录
maxPageCount = 100;
///当前到多少页了,默认时0,在开始获取下一页的时候需要自动+1
pageindex = 0;
///当前月份一共有多少个数据
allCount = 0;
///服务器数据,没什么用
pagecount = 0;
///哪一月的数据,服务器数据,无用
recordmonth = 0;
///那一年的数据,服务器数据,无用
recordyear = 0;
clear(){
this.recordmonth = 0;
this.recordyear = 0;
this.pagecount = 0;
this.allCount = 0;
this.pageindex = 0;
}
/**
* 从网络获取数据
*/
async getPageData(){
var Define = getApp().globalData.Define;
var url = 'users/getwalletfirpage';
var res = await post(url,{});
var data = Define.onNetMessage(res);
if(!data){
return;
}
for(let key in data){
if(key == 'amountrecord'){
//首页首次传递过来的数据时无用的,需要自己获取
}else{
this[key] = data[key];
}
}
console.log("获取到钱包首页数据:",data);
///开始的时间
console.log('记录开始的时间戳:',this.amountstarttime)
var stDate = new Date(this.amountstarttime * 1000);
var sy = stDate.getFullYear();
var sm = stDate.getMonth() + 1;
console.log("记录开始的时间为:"+sy + "-" + sm);
this.recordStartTime = [sy,sm,1];
}
/**
* 获取下一页的数据
*/
async getNextPage(year,month){
if(year != this.recordyear || month != this.recordmonth){
//需要清空当前的数据哈
this.amountrecord = [];
this.pageindex = 0;
this.allCount = 0;
}
if(this.allCount != 0 && this.amountrecord.length == this.allCount){
return;
}
var nextIndex = this.pageindex + 1;
uni.showLoading({
});
console.log('获取指定年份:'+year + ",指定月份:"+month+"的记录");
var res = await post('users/getavailableamount',{
pagecount : this.maxPageCount,
pageindex : nextIndex,
recordmonth : month,
recordyear : year,
});
uni.hideLoading();
var Define = getApp().globalData.Define;
var data = Define.onNetMessage(res);
if(!data){
return;
}
console.log("获取到数据:",data);
for(var key in data){
if(key == 'amountrecord'){
var ress = data[key];
for(var i = 0;i<ress.length;i++){
var obj = ress[i];
var record = new WalletRecord();
for(var rk in obj){
record[rk] = obj[rk];
}
this.amountrecord.push(record);
}
}else{
this[key] = data[key];
}
}
}
}