479 lines
10 KiB
JavaScript
479 lines
10 KiB
JavaScript
import _ from '../../commons/js/commons'
|
||
import * as echarts from '../../ecCanvas/components/ec-canvas/echarts';
|
||
const app = getApp()
|
||
|
||
let barChartData;
|
||
let pieChartData;
|
||
function barChart(canvas, width, height, dpr) {
|
||
const chart = echarts.init(canvas, null, {
|
||
width: width,
|
||
height: height,
|
||
devicePixelRatio: dpr // new
|
||
});
|
||
canvas.setChart(chart);
|
||
let option = barChartData
|
||
chart.setOption(option);
|
||
return chart;
|
||
}
|
||
function pieChart(canvas, width, height, dpr) {
|
||
const chart = echarts.init(canvas, null, {
|
||
width: width,
|
||
height: height,
|
||
devicePixelRatio: dpr // new
|
||
});
|
||
canvas.setChart(chart);
|
||
let option = pieChartData
|
||
chart.setOption(option);
|
||
return chart;
|
||
}
|
||
|
||
Page({
|
||
data: {
|
||
imgUrl:_.config.imgUrl,
|
||
userCal:'',
|
||
deallist:'',
|
||
hoursTip:'',
|
||
showBarChart:false,//是否显示Bar图表
|
||
ecBar:{},
|
||
showPieChart:false,//是否显示Pie图表
|
||
ecPie:{},
|
||
isShowNotice:false,//是否显示通知
|
||
stopNotice:false,//是否不再显示通知
|
||
isShowReport:false,
|
||
isShowProfile:true,//是否显示授权用户信息按钮
|
||
banneractive: 0,
|
||
banneractive2: 0,
|
||
remindTab:[],
|
||
remindMsg:[],
|
||
},
|
||
|
||
onLoad(options) {
|
||
for (let key in options) {
|
||
this.setData({
|
||
[key]: options[key]
|
||
})
|
||
}
|
||
|
||
if(this.data.biz_id){
|
||
this.putAppUserResetbiz()
|
||
}else{
|
||
this.getUserInfo()
|
||
}
|
||
|
||
this.getAppStatisticsHcust()
|
||
this.getAppStatisticsHorder()
|
||
|
||
//消息通讯 是否显示授权用户信息按钮
|
||
_.eventBus.on("isShowProfile", this, function(res){
|
||
this.setData({
|
||
isShowProfile:res,
|
||
})
|
||
})
|
||
|
||
},
|
||
|
||
onShow: function () {
|
||
this.setData({
|
||
remindTab:[],
|
||
remindMsg:[],
|
||
});
|
||
this.getAppUserCal()
|
||
this.getHoursTip()
|
||
this.getAppTransferRemind()
|
||
this.getAppInventoryRemind()
|
||
},
|
||
|
||
//生命周期函数--监听页面卸载
|
||
onUnload: function () {
|
||
//卸载消息通讯 是否显示授权用户信息
|
||
_.eventBus.remove('isShowProfile',this);
|
||
},
|
||
|
||
|
||
//候取时间
|
||
getHoursTip(){
|
||
let hoursTip = '';
|
||
let date=new Date();
|
||
if(date.getHours()>=0&&date.getHours()<12){
|
||
hoursTip="上午好!"
|
||
}else if(date.getHours()>=12&&date.getHours()<18){
|
||
hoursTip="下午好!"
|
||
}else{
|
||
hoursTip="晚上好!"
|
||
}
|
||
this.setData({
|
||
hoursTip:hoursTip
|
||
})
|
||
},
|
||
|
||
//更新用户店铺id
|
||
putAppUserResetbiz(){
|
||
let params = {};
|
||
params['biz_id'] = this.data.biz_id;
|
||
_.apiQuery.putAppUserResetbiz(params).then(res => {
|
||
this.getUserInfo()
|
||
this.getAppUserCal()
|
||
});
|
||
},
|
||
|
||
//调拨提醒
|
||
getAppTransferRemind(){
|
||
_.apiQuery.getAppTransferRemind().then(res => {
|
||
if(res.data.total>0){
|
||
let remindTab = this.data.remindTab
|
||
remindTab.push({
|
||
title:'车辆调拨',
|
||
content:'您有新的车辆调拨,需要您进行确认操作。',
|
||
img:'https://qs.haodian.cn/wechat_app/lichebao/allot/car.gif?v=220224',
|
||
url:'/pages/allot/list/index',
|
||
allotNum:res.data.total,
|
||
})
|
||
let remindMsg = this.data.remindMsg
|
||
remindMsg.push({
|
||
title:'调拨提醒',
|
||
content:'您有新的车辆调拨,需要您进行确认操作。',
|
||
img:'https://qs.haodian.cn/wechat_app/lichebao/allot/car.gif?v=220224',
|
||
btn:{
|
||
title:'前往操作',
|
||
url:'/pages/allot/list/index',
|
||
},
|
||
})
|
||
this.setData({
|
||
remindTab,
|
||
remindMsg,
|
||
isShowReport:true,
|
||
isShowNotice:false,
|
||
})
|
||
}else{
|
||
this.setData({
|
||
isShowReport:false,
|
||
})
|
||
}
|
||
});
|
||
},
|
||
|
||
//盘点提醒
|
||
getAppInventoryRemind(){
|
||
_.apiQuery.getAppInventoryRemind().then(res => {
|
||
if(res.data.total>0){
|
||
let remindTab = this.data.remindTab
|
||
remindTab.push({
|
||
title:'车辆盘点',
|
||
content:'您有新的车辆调拨,需要您进行确认操作。',
|
||
img:'https://qs.haodian.cn/wechat_app/lichebao/inventory/icon.png',
|
||
url:'/pages/inventory/list/index',
|
||
allotNum:res.data.total,
|
||
})
|
||
let remindMsg = this.data.remindMsg
|
||
remindMsg.push({
|
||
title:'盘点提醒',
|
||
content:'您有新的车辆盘点,需要您进行确认操作。',
|
||
img:'https://qs.haodian.cn/wechat_app/lichebao/inventory/animation.gif',
|
||
btn:{
|
||
title:'前往操作',
|
||
url:'/pages/inventory/list/index',
|
||
},
|
||
})
|
||
this.setData({
|
||
remindTab,
|
||
remindMsg,
|
||
isShowReport:true,
|
||
isShowNotice:false,
|
||
})
|
||
}else{
|
||
this.setData({
|
||
isShowReport:false,
|
||
})
|
||
}
|
||
});
|
||
},
|
||
|
||
//获取用户信息
|
||
getUserInfo(){
|
||
_.apiQuery.getUserInfo().then(res => {
|
||
this.setData({
|
||
userInfo: res
|
||
})
|
||
});
|
||
},
|
||
|
||
//获取用户统计
|
||
getAppUserCal(){
|
||
let params = {};
|
||
if(this.data.biz_id){
|
||
params['biz_id'] = this.data.biz_id;
|
||
}
|
||
_.apiQuery.getAppUserCal(params).then(res => {
|
||
this.setData({
|
||
userCal:res.data,
|
||
})
|
||
|
||
if(res.data.deallist.length>0){
|
||
let deallist = res.data.deallist
|
||
if(res.data.deallist.length%3==1){
|
||
deallist.push({})
|
||
deallist.push({})
|
||
}
|
||
if(res.data.deallist.length%3==2){
|
||
deallist.push({})
|
||
}
|
||
this.setData({
|
||
deallist:deallist,
|
||
})
|
||
}
|
||
|
||
wx.stopPullDownRefresh()
|
||
|
||
});
|
||
},
|
||
|
||
//数据分析-客户数据
|
||
getAppStatisticsHcust(){
|
||
this.setData({
|
||
showPieChart:false,
|
||
})
|
||
let params = {};
|
||
if(this.data.biz_id){
|
||
params['biz_id'] = this.data.biz_id;
|
||
}
|
||
_.apiQuery.getAppStatisticsHcust(params).then(res => {
|
||
|
||
pieChartData = res.data.stat_data
|
||
pieChartData.series.label = {
|
||
formatter: '\n{b|{b}}\n{c|{c}}\n{per|{d}%} ',
|
||
rich: {
|
||
b: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
c: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
per: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
}
|
||
}
|
||
|
||
this.setData({
|
||
cust_total:res.data.total,
|
||
cust_cont_total:res.data.cont_total,
|
||
cust_top_total:res.data.top_total,
|
||
showPieChart:true,
|
||
['ecPie.onInit']:pieChart,
|
||
})
|
||
|
||
wx.stopPullDownRefresh()
|
||
|
||
});
|
||
},
|
||
|
||
//数据分析-订单数据
|
||
getAppStatisticsHorder(){
|
||
this.setData({
|
||
showBarChart:false,
|
||
})
|
||
let params = {};
|
||
if(this.data.biz_id){
|
||
params['biz_id'] = this.data.biz_id;
|
||
}
|
||
_.apiQuery.getAppStatisticsHorder(params).then(res => {
|
||
|
||
barChartData = res.data.stat_data
|
||
this.setData({
|
||
order_total:res.data.total,
|
||
showBarChart:true,
|
||
['ecBar.onInit']:barChart,
|
||
})
|
||
|
||
wx.stopPullDownRefresh()
|
||
|
||
});
|
||
},
|
||
|
||
//推送链接
|
||
pushLink(e) {
|
||
if(e.currentTarget.dataset.url){
|
||
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
||
}
|
||
},
|
||
|
||
//客服电话
|
||
call(e) {
|
||
wx.makePhoneCall({
|
||
phoneNumber: '18965133055',
|
||
})
|
||
},
|
||
|
||
//不再提示
|
||
checkNotice(e){
|
||
this.setData({
|
||
stopNotice:!this.data.stopNotice,
|
||
})
|
||
},
|
||
|
||
//关闭通知
|
||
closeNotice(){
|
||
if(this.data.stopNotice){
|
||
app.setStorage('stopNotice', 'true')
|
||
}
|
||
this.setData({
|
||
isShowNotice:false,
|
||
})
|
||
},
|
||
|
||
//公众号关注组件
|
||
officialaccount(e){
|
||
if(e.detail.status == 0&&!app.getStorageByKey("stopNotice")&&!this.data.isShowReport){
|
||
// this.setData({
|
||
// isShowNotice:true,
|
||
// })
|
||
}
|
||
},
|
||
|
||
//显示短信弹框
|
||
optShowReport(e){
|
||
this.setData({
|
||
isShowReport:!this.data.isShowReport,
|
||
})
|
||
},
|
||
|
||
//开发中
|
||
development(){
|
||
wx.showToast({
|
||
title: '暂无数据',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
},
|
||
|
||
//banner轮播点
|
||
bannerChange: function (e) {
|
||
this.setData({
|
||
banneractive:e.detail.current,
|
||
});
|
||
},
|
||
//banner轮播点
|
||
bannerChange2: function (e) {
|
||
this.setData({
|
||
banneractive2:e.detail.current,
|
||
});
|
||
},
|
||
|
||
//页面相关事件处理函数--监听用户下拉动作
|
||
onPullDownRefresh: function () {
|
||
this.setData({
|
||
remindTab:[],
|
||
remindMsg:[],
|
||
});
|
||
this.getAppUserCal()
|
||
this.getAppStatisticsHcust()
|
||
this.getAppStatisticsHorder()
|
||
this.getAppTransferRemind()
|
||
this.getAppInventoryRemind()
|
||
},
|
||
|
||
})
|
||
|
||
function getPieOption() {
|
||
return {
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
},
|
||
legend: {
|
||
top: 'bottom',
|
||
orient: 'horizontal',
|
||
textStyle:{
|
||
fontSize:9,
|
||
}
|
||
},
|
||
|
||
series: [
|
||
{
|
||
type: 'pie',
|
||
top: '0',
|
||
radius: ['30%', '48%'],
|
||
data: [
|
||
{value: 1048, name: '未见潜客'},
|
||
{value: 735, name: '到店潜客'},
|
||
{value: 580, name: '订单客户'},
|
||
{value: 484, name: '战败客户'},
|
||
],
|
||
label: {
|
||
formatter: '\n{b|{b}}\n{c|{c}}\n{per|{d}%} ',
|
||
rich: {
|
||
b: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
c: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
per: {
|
||
color: '#4C5058',
|
||
fontSize: 10,
|
||
lineHeight:15,
|
||
align:'left',
|
||
},
|
||
}
|
||
},
|
||
}
|
||
]
|
||
};
|
||
}
|
||
|
||
function getBarOption() {
|
||
return {
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
}
|
||
},
|
||
grid: {
|
||
top: '8%',
|
||
left: '2%',
|
||
right: '5%',
|
||
bottom: '2%',
|
||
containLabel: true
|
||
},
|
||
xAxis: {
|
||
type: 'value',
|
||
boundaryGap: [0, 0.01]
|
||
},
|
||
yAxis: {
|
||
type: 'category',
|
||
data: ['恭喜提车', '保险上牌', '已开发票','车辆确认','配车准备','申请退款','办理按揭','已交定金','已签合同',],
|
||
},
|
||
series: [
|
||
{
|
||
type: 'bar',
|
||
itemStyle: {
|
||
color:'#2e3246',
|
||
borderRadius: [0, 20, 20, 0],
|
||
},
|
||
barWidth:'15',
|
||
data: [33, 23, 29,18, 23, 29,18, 23, 29,],
|
||
label: {
|
||
show: true,
|
||
position: 'right',
|
||
formatter: '{@[n]}',
|
||
valueAnimation: true
|
||
}
|
||
},
|
||
]
|
||
};
|
||
} |