|
|
// pages/myAgentDetailNew/index.js
|
|
|
let app = getApp();
|
|
|
const dateUtil = require("../../../utils/dateUtil.js");
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
array: ['30日数据', '7日数据', '今日数据'],
|
|
|
index: 0,
|
|
|
agencyId:'',
|
|
|
record:{},
|
|
|
agencyStatistics:{askOrderNum:0,applyNum:0,arrivedNum:0,passedNum:0,entryNum:0,leaveNum:0},
|
|
|
pmdList:[],
|
|
|
indexPmd:0,
|
|
|
|
|
|
},
|
|
|
openMap(){
|
|
|
var that = this;
|
|
|
|
|
|
console.log(that.data.record.lat);
|
|
|
console.log(that.data.record.lng);
|
|
|
|
|
|
const latitude = that.data.record.lat
|
|
|
const longitude = that.data.record.lng
|
|
|
wx.openLocation({
|
|
|
latitude:Number(latitude),
|
|
|
longitude:Number(longitude),
|
|
|
name:that.data.record.address,
|
|
|
scale: 18
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
bindPickerChange: function(e) {
|
|
|
var that = this;
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
index: e.detail.value
|
|
|
})
|
|
|
if(e.detail.value == 1){
|
|
|
that.getAgencyStatistics(7);
|
|
|
}else if(e.detail.value == 2){
|
|
|
that.getAgencyStatistics(1);
|
|
|
}else{
|
|
|
that.getAgencyStatistics(30);
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
bindPickerChangePmd(e){
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
indexPmd: e.detail.value
|
|
|
})
|
|
|
|
|
|
|
|
|
let currData = {};
|
|
|
currData["agencyId"] = that.data.agencyId;
|
|
|
currData["pmUserId"] = that.data.pmdList[e.detail.value].userId
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + "/agency/updatePmUser",
|
|
|
header: app.globalData.header,
|
|
|
data:currData,
|
|
|
method: "post",
|
|
|
success: function (res) {
|
|
|
console.log(res.data);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
},
|
|
|
});
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
console.log(options.id)
|
|
|
this.setData({
|
|
|
agencyId: options.id
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow() {
|
|
|
this.getDetail();
|
|
|
this.getAgencyStatistics(30)
|
|
|
// console.log(dateUtil.timeForMat(7))
|
|
|
},
|
|
|
getPmdList(){
|
|
|
var that = this;
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + "/agency/getPmds",
|
|
|
header: app.globalData.header,
|
|
|
method: "GET",
|
|
|
success: function (res) {
|
|
|
that.setData({
|
|
|
pmdList:res.data.data
|
|
|
})
|
|
|
res.data.data.forEach((item,index)=>{
|
|
|
// console.log(item.userId +" === "+ that.data.record.pmdUserId)
|
|
|
if(item.userId == that.data.record.pmdUserId){
|
|
|
that.setData({
|
|
|
indexPmd:index
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
console.log(that.data.pmdList);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
getDetail() {
|
|
|
var that = this;
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + "/store/project/detail/" + that.data.agencyId,
|
|
|
header: app.globalData.header,
|
|
|
method: "GET",
|
|
|
success: function (res) {
|
|
|
console.log(res.data);
|
|
|
// console.log(that.convertHtmlToText(res.data.data.articleContent));
|
|
|
that.setData({
|
|
|
record: res.data.data,
|
|
|
// ["record.imageList"] : res.data.data.imageList.splice(0,4)
|
|
|
});
|
|
|
// that.getPmdList();
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
},
|
|
|
});
|
|
|
wx.hideLoading({
|
|
|
success: (res) => {},
|
|
|
})
|
|
|
},
|
|
|
getAgencyStatistics(days){
|
|
|
var that = this;
|
|
|
|
|
|
dateUtil.timeForMat(days)
|
|
|
|
|
|
let currData = {};
|
|
|
currData["projectId"] = that.data.agencyId;
|
|
|
currData["start"] = dateUtil.timeForMat(days).t2;
|
|
|
currData["end"] = dateUtil.timeForMat(days).t1;
|
|
|
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + "/store/project/getStoreProjectStatistics",
|
|
|
header: app.globalData.header,
|
|
|
data:currData,
|
|
|
method: "post",
|
|
|
success: function (res) {
|
|
|
console.log(res.data.data.record);
|
|
|
// console.log(that.convertHtmlToText(res.data.data.articleContent));
|
|
|
that.setData({
|
|
|
agencyStatistics: res.data.data.record,
|
|
|
});
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
}
|
|
|
}) |