|
|
|
|
// pages/wodeBill/index.js
|
|
|
|
|
const app = getApp();
|
|
|
|
|
import { timeShowXXX, getUserApplyOrderStatusById, formatDateYMDHM } from "../../utils/dateUtil";
|
|
|
|
|
import { query } from "../../utils/commonUtil";
|
|
|
|
|
import { customRequest } from '../../utils/request.js';
|
|
|
|
|
Page({
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
inputVal: "搜索账单",
|
|
|
|
|
searchParam: {
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
keys: "",
|
|
|
|
|
status: "",
|
|
|
|
|
},
|
|
|
|
|
recordList: [],
|
|
|
|
|
recordObj: {},
|
|
|
|
|
currIndex: 0,
|
|
|
|
|
chaShowed: false,
|
|
|
|
|
hasMoreData: false, // 获取更多数据是否显示
|
|
|
|
|
isTrigger: false,
|
|
|
|
|
theStyle: "noStay",
|
|
|
|
|
noData: false
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad (options) {
|
|
|
|
|
console.log(options);
|
|
|
|
|
if (options.state == 0) {
|
|
|
|
|
this.data.searchParam.status = "";
|
|
|
|
|
} else if (options.state == 10) {
|
|
|
|
|
this.data.searchParam.status = 10;
|
|
|
|
|
} else if (options.state == 20) {
|
|
|
|
|
this.data.searchParam.status = 20;
|
|
|
|
|
} else if (options.state == 30) {
|
|
|
|
|
this.data.searchParam.status = 30;
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
currIndex: options.state,
|
|
|
|
|
searchParam: this.data.searchParam,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady () {
|
|
|
|
|
console.log(this.renderer);
|
|
|
|
|
console.log(wx.getSystemInfoSync());
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow () {
|
|
|
|
|
console.log(this.data.inputVal);
|
|
|
|
|
this.data.searchParam.pageNum = 1;
|
|
|
|
|
this.setData({
|
|
|
|
|
recordList: [],
|
|
|
|
|
searchParam: this.data.searchParam,
|
|
|
|
|
});
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide () { },
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload () { },
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh () { },
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom () { },
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
return app.sharePageImage()
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
跳转搜索页面
|
|
|
|
|
*/
|
|
|
|
|
goSearch () {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: "../search/index?from=wodeBill",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
搜索关键词
|
|
|
|
|
*/
|
|
|
|
|
searchKey: function (e) {
|
|
|
|
|
console.log("onsearch");
|
|
|
|
|
console.log(this.data.inputVal);
|
|
|
|
|
this.data.recordList = [];
|
|
|
|
|
this.data.searchParam.pageNum = 1;
|
|
|
|
|
// this.data.searchParam.keys = this.data.inputVal;
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
清空输入框
|
|
|
|
|
*/
|
|
|
|
|
clearInput: function () {
|
|
|
|
|
console.log(123);
|
|
|
|
|
this.setData({
|
|
|
|
|
inputVal: "搜索账单",
|
|
|
|
|
chaShowed: false,
|
|
|
|
|
});
|
|
|
|
|
this.data.recordList = [];
|
|
|
|
|
this.data.searchParam.keys = "";
|
|
|
|
|
this.data.searchParam.pageNum = 1;
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
onScrollToLower: function () {
|
|
|
|
|
if (this.data.hasMoreData) {
|
|
|
|
|
this.data.searchParam.pageNum = this.data.searchParam.pageNum + 1;
|
|
|
|
|
this.getList();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onScrollRefresh () {
|
|
|
|
|
this.data.recordList = [];
|
|
|
|
|
this.data.searchParam.pageNum = 1;
|
|
|
|
|
console.log("isonScrollRefresh");
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
getList () {
|
|
|
|
|
let that = this;
|
|
|
|
|
console.log("loading");
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: "加载中...",
|
|
|
|
|
});
|
|
|
|
|
this.data.searchParam.keys = this.data.inputVal == "搜索账单" ? "" : this.data.inputVal;
|
|
|
|
|
customRequest("/yishoudan/factory/bill/list",{header:'headers', method: 'POST', data: that.data.searchParam}).then((res)=>{
|
|
|
|
|
if (res.data.status == 200) {
|
|
|
|
|
res.data.data.pageBean.recordList.forEach((item) => {
|
|
|
|
|
item.showTime = formatDateYMDHM(item.updateTime);
|
|
|
|
|
if (item.totalSalary != undefined) {
|
|
|
|
|
item.totalSalaryStr = Math.floor(item.totalSalary);
|
|
|
|
|
// item.totalSalaryDot = item.totalSalary.toFixed(2).slice(-2);
|
|
|
|
|
item.totalSalaryDot = item.totalSalary.toFixed(2);
|
|
|
|
|
if (item.totalSalaryDot == "00") {
|
|
|
|
|
item.isInt = true;
|
|
|
|
|
} else {
|
|
|
|
|
item.isInt = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.data.data.pageBean.recordList != null && res.data.data.pageBean.recordList.length < 20) {
|
|
|
|
|
var recordListTemp = res.data.data.pageBean.recordList;
|
|
|
|
|
that.data.recordList = that.data.recordList.concat(recordListTemp);
|
|
|
|
|
that.setData({
|
|
|
|
|
hasMoreData: false,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
var recordListTemp = res.data.data.pageBean.recordList;
|
|
|
|
|
that.data.recordList = that.data.recordList.concat(recordListTemp);
|
|
|
|
|
that.setData({
|
|
|
|
|
hasMoreData: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
let obj = {};
|
|
|
|
|
that.data.recordList.forEach((item) => {
|
|
|
|
|
console.log(new Date(item.updateTime).getMonth() + 1);
|
|
|
|
|
let key = new Date(item.updateTime).getFullYear() + "年" + (new Date(item.updateTime).getMonth() + 1) + "月";
|
|
|
|
|
if (obj[key]) {
|
|
|
|
|
obj[key].push(item);
|
|
|
|
|
obj[key][0]["money"] += item.totalSalaryStr;
|
|
|
|
|
} else {
|
|
|
|
|
obj[key] = [];
|
|
|
|
|
obj[key].push(item);
|
|
|
|
|
obj[key][0]["money"] = item.totalSalaryStr;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log(obj);
|
|
|
|
|
// for(var k in obj){
|
|
|
|
|
// console.log(obj[k]);
|
|
|
|
|
// obj[k].forEach((item)=>{
|
|
|
|
|
// money += item.totalSalary
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
// obj[k].totalMoney = money
|
|
|
|
|
// }
|
|
|
|
|
console.log(obj);
|
|
|
|
|
if (Object.getOwnPropertyNames(obj).length == 0) {
|
|
|
|
|
that.data.noData = true
|
|
|
|
|
} else {
|
|
|
|
|
that.data.noData = false
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
that.setData({
|
|
|
|
|
recordObj: obj,
|
|
|
|
|
noData: that.data.noData,
|
|
|
|
|
recordList: that.data.recordList,
|
|
|
|
|
isTrigger: false,
|
|
|
|
|
});
|
|
|
|
|
console.log(that.data.recordObj);
|
|
|
|
|
console.log(that.data.recordList);
|
|
|
|
|
} else if (res.data.status == 9999) {
|
|
|
|
|
app.logout().then(() => {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: "/pages/login/index",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
})
|
|
|
|
|
// wx.request({
|
|
|
|
|
// url: app.globalData.ip + "/yishoudan/factory/bill/list",
|
|
|
|
|
// data: that.data.searchParam,
|
|
|
|
|
// header: app.globalData.headers,
|
|
|
|
|
// method: "POST",
|
|
|
|
|
// success: function (res) {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
// if (res.data.status == 200) {
|
|
|
|
|
// res.data.data.pageBean.recordList.forEach((item) => {
|
|
|
|
|
// item.showTime = formatDateYMDHM(item.updateTime);
|
|
|
|
|
// if (item.totalSalary != undefined) {
|
|
|
|
|
// item.totalSalaryStr = Math.floor(item.totalSalary);
|
|
|
|
|
// // item.totalSalaryDot = item.totalSalary.toFixed(2).slice(-2);
|
|
|
|
|
// item.totalSalaryDot = item.totalSalary.toFixed(2);
|
|
|
|
|
// if (item.totalSalaryDot == "00") {
|
|
|
|
|
// item.isInt = true;
|
|
|
|
|
// } else {
|
|
|
|
|
// item.isInt = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// if (res.data.data.pageBean.recordList != null && res.data.data.pageBean.recordList.length < 20) {
|
|
|
|
|
// var recordListTemp = res.data.data.pageBean.recordList;
|
|
|
|
|
// that.data.recordList = that.data.recordList.concat(recordListTemp);
|
|
|
|
|
// that.setData({
|
|
|
|
|
// hasMoreData: false,
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// var recordListTemp = res.data.data.pageBean.recordList;
|
|
|
|
|
// that.data.recordList = that.data.recordList.concat(recordListTemp);
|
|
|
|
|
// that.setData({
|
|
|
|
|
// hasMoreData: true,
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// let obj = {};
|
|
|
|
|
// that.data.recordList.forEach((item) => {
|
|
|
|
|
// console.log(new Date(item.updateTime).getMonth() + 1);
|
|
|
|
|
// let key = new Date(item.updateTime).getFullYear() + "年" + (new Date(item.updateTime).getMonth() + 1) + "月";
|
|
|
|
|
// if (obj[key]) {
|
|
|
|
|
// obj[key].push(item);
|
|
|
|
|
// obj[key][0]["money"] += item.totalSalaryStr;
|
|
|
|
|
// } else {
|
|
|
|
|
// obj[key] = [];
|
|
|
|
|
// obj[key].push(item);
|
|
|
|
|
// obj[key][0]["money"] = item.totalSalaryStr;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// console.log(obj);
|
|
|
|
|
// // for(var k in obj){
|
|
|
|
|
// // console.log(obj[k]);
|
|
|
|
|
// // obj[k].forEach((item)=>{
|
|
|
|
|
// // money += item.totalSalary
|
|
|
|
|
|
|
|
|
|
// // })
|
|
|
|
|
// // obj[k].totalMoney = money
|
|
|
|
|
// // }
|
|
|
|
|
// console.log(obj);
|
|
|
|
|
// if (Object.getOwnPropertyNames(obj).length == 0) {
|
|
|
|
|
// that.data.noData = true
|
|
|
|
|
// } else {
|
|
|
|
|
// that.data.noData = false
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// that.setData({
|
|
|
|
|
// recordObj: obj,
|
|
|
|
|
// noData: that.data.noData,
|
|
|
|
|
// recordList: that.data.recordList,
|
|
|
|
|
// isTrigger: false,
|
|
|
|
|
// });
|
|
|
|
|
// console.log(that.data.recordObj);
|
|
|
|
|
// console.log(that.data.recordList);
|
|
|
|
|
// } else if (res.data.status == 9999) {
|
|
|
|
|
// app.logout().then(() => {
|
|
|
|
|
// wx.reLaunch({
|
|
|
|
|
// url: "/pages/login/index",
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// wx.hideLoading();
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// this.data.recordList.push('123')
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
跳转账单详情页
|
|
|
|
|
*/
|
|
|
|
|
goDetail: function (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
var info = JSON.stringify({ ...e.currentTarget.dataset.info, status: this.data.currIndex });
|
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
// url: '/pages/editAgent/index?agencyId=' + id,
|
|
|
|
|
// url:'/pages/agentDetail/index?agencyId=' + id
|
|
|
|
|
url: "/pages/wodeBillDetail/index?info=" + info,
|
|
|
|
|
// url: '/pages/wodeBillSharePage/index?id=' + info// 路径,传递参数到指定页面。
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
changeMenu (e) {
|
|
|
|
|
var that = this;
|
|
|
|
|
that.data.searchParam.pageNum = 1;
|
|
|
|
|
// that.data.searchParam.status = e.currentTarget.dataset.id;
|
|
|
|
|
if (e.currentTarget.dataset.id == 0) {
|
|
|
|
|
this.data.searchParam.status = "";
|
|
|
|
|
} else if (e.currentTarget.dataset.id == 10) {
|
|
|
|
|
this.data.searchParam.status = 10;
|
|
|
|
|
} else if (e.currentTarget.dataset.id == 20) {
|
|
|
|
|
this.data.searchParam.status = 20;
|
|
|
|
|
} else if (e.currentTarget.dataset.id == 30) {
|
|
|
|
|
this.data.searchParam.status = 30;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
currIndex: e.currentTarget.dataset.id,
|
|
|
|
|
recordList: [],
|
|
|
|
|
searchParam: this.data.searchParam,
|
|
|
|
|
});
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
pageScroll (e) {
|
|
|
|
|
let that = this;
|
|
|
|
|
// console.log(e);
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// console.log(e);
|
|
|
|
|
// }, 1000);
|
|
|
|
|
// console.log(wx.createSelectorQuery().select(".step"));
|
|
|
|
|
|
|
|
|
|
// query(".monthTitle", function (res) {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
// if (res[0].top <= 105) {
|
|
|
|
|
// that.setData({
|
|
|
|
|
// theStyle: "stayThere",
|
|
|
|
|
// });
|
|
|
|
|
// console.log(123455667);
|
|
|
|
|
// } else {
|
|
|
|
|
// that.setData({
|
|
|
|
|
// theStyle: "noStay",
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
},
|
|
|
|
|
});
|