|
|
// pages/agentData/index.js
|
|
|
const app = getApp();
|
|
|
const dateUtil = require('../../utils/dateUtil.js');
|
|
|
const commonUtil = require('../../utils/commonUtil.js');
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
week: null,
|
|
|
arrayWeek: [],
|
|
|
indexWeek: 0,
|
|
|
arrayMonth: [],
|
|
|
indexMonth: 0,
|
|
|
currIndex: '1',
|
|
|
date: '',
|
|
|
today:'',
|
|
|
recordList: [],
|
|
|
dataLoading:false
|
|
|
},
|
|
|
bindPickerChangeWeek: function(e) {
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
indexWeek: e.detail.value
|
|
|
})
|
|
|
this.getRecordList();
|
|
|
},
|
|
|
bindPickerChangeMonth: function(e) {
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
indexMonth: e.detail.value
|
|
|
})
|
|
|
this.getRecordList();
|
|
|
},
|
|
|
bindDateChange: function(e) {
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
date: e.detail.value
|
|
|
})
|
|
|
|
|
|
this.getRecordList();
|
|
|
|
|
|
},
|
|
|
changeMenu(e) {
|
|
|
var that = this;
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
this.setData({
|
|
|
currIndex: e.currentTarget.dataset.id,
|
|
|
dataLoading:false
|
|
|
})
|
|
|
this.getRecordList();
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
var date = dateUtil.getNowYearMonthDay();
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
this.setData({
|
|
|
date: date
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
console.log(dateUtil.getNowYearMonthDay());
|
|
|
this.setData({
|
|
|
date:dateUtil.getNowYearMonthDay(),
|
|
|
today:dateUtil.getNowYearMonthDay()
|
|
|
})
|
|
|
|
|
|
this.getRecordList();
|
|
|
this.getWeekNumNow();
|
|
|
this.getMonthNumNow();
|
|
|
},
|
|
|
getRecordList: function () {
|
|
|
var that = this;
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
|
|
|
var url = '/agency/promotionDetail/getPmdAgencyNumStatisticsOfDay';
|
|
|
if (that.data.currIndex == 2) {
|
|
|
url = '/agency/promotionDetail/getPmdAgencyNumStatisticsOfWeek';
|
|
|
} else if (that.data.currIndex == 3) {
|
|
|
url = '/agency/promotionDetail/getPmdAgencyNumStatisticsOfMonth';
|
|
|
}
|
|
|
|
|
|
var dataJson = {
|
|
|
pageNum: 1,
|
|
|
pageSize: 100,
|
|
|
}
|
|
|
|
|
|
if (that.data.currIndex == 1) {
|
|
|
dataJson['date'] = that.data.date;
|
|
|
} else if (that.data.currIndex == 2) {
|
|
|
dataJson['week'] = that.data.indexWeek * 1 + 1;
|
|
|
} else if (that.data.currIndex == 3) {
|
|
|
dataJson['month'] = that.data.indexMonth * 1 + 1;
|
|
|
}
|
|
|
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + url,
|
|
|
data: dataJson,
|
|
|
header: app.globalData.header,
|
|
|
method: "POST",
|
|
|
success: function (res) {
|
|
|
console.log(res.data);
|
|
|
if (res.data.status == 200) {
|
|
|
res.data.data.forEach((item, index) => {
|
|
|
var str = '';
|
|
|
if (app.isNotEmptyCheck(item.userName)) {
|
|
|
str = item.userName;
|
|
|
}
|
|
|
if (app.isNotEmptyCheck(item.tel)) {
|
|
|
str = str + '(' + commonUtil.getTelAfterFour(item.tel) + ')';
|
|
|
}
|
|
|
item['userNameTel'] = str;
|
|
|
})
|
|
|
that.setData({
|
|
|
recordList: res.data.data
|
|
|
});
|
|
|
wx.hideLoading();
|
|
|
} else {
|
|
|
//app.showTips(that, res.data.msg);
|
|
|
}
|
|
|
that.setData({
|
|
|
dataLoading:true
|
|
|
});
|
|
|
wx.hideLoading()
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
that.setData({
|
|
|
dataLoading:true
|
|
|
});
|
|
|
wx.hideLoading()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
getWeekNumNow: function () {
|
|
|
var that = this;
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + '/commons/getWeekNumNow',
|
|
|
data: {},
|
|
|
header: app.globalData.header,
|
|
|
method: "GET",
|
|
|
success: function (res) {
|
|
|
console.log(res.data);
|
|
|
if (res.data.status == 200) {
|
|
|
var week = res.data.data;
|
|
|
var year = dateUtil.getNowYear();
|
|
|
for (var i = 1; i <= week; i++) {
|
|
|
that.data.arrayWeek.push(year + '年第' + i + '周');
|
|
|
}
|
|
|
that.data.indexWeek = week - 1;
|
|
|
|
|
|
that.setData({
|
|
|
arrayWeek: that.data.arrayWeek,
|
|
|
indexWeek: that.data.indexWeek,
|
|
|
});
|
|
|
} else {
|
|
|
//app.showTips(that, res.data.msg);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
getMonthNumNow: function () {
|
|
|
var that = this;
|
|
|
|
|
|
var year = dateUtil.getNowYear();
|
|
|
var month = dateUtil.getNowMonth();
|
|
|
for (var i = 1; i <= 12; i++) {
|
|
|
that.data.arrayMonth.push(year + '年' + i + '月');
|
|
|
}
|
|
|
that.data.indexMonth = month - 1;
|
|
|
|
|
|
that.setData({
|
|
|
arrayMonth: that.data.arrayMonth,
|
|
|
indexMonth: that.data.indexMonth,
|
|
|
});
|
|
|
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
}
|
|
|
}) |