From 225b59b451417929b162fc407d30c4eae84e160e Mon Sep 17 00:00:00 2001 From: lcc Date: Sun, 3 Nov 2024 17:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 494 ++++++++++++++++++++++--------------------- 1 file changed, 253 insertions(+), 241 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 0e387a9..4adba54 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -4,6 +4,7 @@ const app = getApp() let barChartData; let pieChartData; + function barChart(canvas, width, height, dpr) { const chart = echarts.init(canvas, null, { width: width, @@ -15,6 +16,7 @@ function barChart(canvas, width, height, dpr) { chart.setOption(option); return chart; } + function pieChart(canvas, width, height, dpr) { const chart = echarts.init(canvas, null, { width: width, @@ -29,32 +31,32 @@ function pieChart(canvas, width, height, dpr) { Page({ data: { - isShowMain:false,//显示页面内容 - imgUrl:_.config.imgUrl, - userCal:'', - deallist:'', - hoursTip:'', - showBarChart:false,//是否显示Bar图表 - ecBar:{}, - showPieChart:false,//是否显示Pie图表 - ecPie:{}, - isShowNotice:false,//是否显示通知 - stopNotice:false,//是否不再显示通知 - isShowReport:false,//是否显示调拨盘点弹框 - isShowProfile:true,//是否显示授权用户信息按钮 - isShowGoods:false,//是否显示库存预警 + isShowMain: false, //显示页面内容 + imgUrl: _.config.imgUrl, + userCal: '', + deallist: '', + hoursTip: '', + showBarChart: false, //是否显示Bar图表 + ecBar: {}, + showPieChart: false, //是否显示Pie图表 + ecPie: {}, + isShowNotice: false, //是否显示通知 + stopNotice: false, //是否不再显示通知 + isShowReport: false, //是否显示调拨盘点弹框 + isShowProfile: true, //是否显示授权用户信息按钮 + isShowGoods: false, //是否显示库存预警 banneractive: 0, banneractive2: 0, banneractive3: 0, - remindTab:[],//调拨盘点入口 - remindMsg:[],//调拨盘点弹框 - levelStIndex:0, - levelSt:[],//客户等级 - isResetbiz:false,//是否重置过BIZID - isShowVersionInfo:false,//是否显示版本更新 - versionInfo:{ - number:'V3.0.51', - list:[ + remindTab: [], //调拨盘点入口 + remindMsg: [], //调拨盘点弹框 + levelStIndex: 0, + levelSt: [], //客户等级 + isResetbiz: false, //是否重置过BIZID + isShowVersionInfo: false, //是否显示版本更新 + versionInfo: { + number: 'V3.0.51', + list: [ // '', // '', // '', @@ -83,7 +85,7 @@ Page({ score_role_tab: [{ id: 1, name: '个人' - },{ + }, { id: 2, name: '门店' }], @@ -98,14 +100,14 @@ Page({ }) } - if(this.data.biz_id){ + if (this.data.biz_id) { let that = this setTimeout(function () { that.putAppUserResetbiz() }, 500) - }else{ + } else { this.setData({ - isResetbiz:true, + isResetbiz: true, }); this.getUserInfo() } @@ -113,16 +115,16 @@ Page({ //this.getAppStatisticsHorder() //消息通讯 是否显示授权用户信息按钮 - _.eventBus.on("isShowProfile", this, function(res){ + _.eventBus.on("isShowProfile", this, function (res) { this.setData({ - isShowProfile:res, + isShowProfile: res, }) }) //判断是否显示版本更新内容 - if(this.data.versionInfo.list.length>0&&app.getStorageByKey("appversion")!=this.data.versionInfo.number){ + if (this.data.versionInfo.list.length > 0 && app.getStorageByKey("appversion") != this.data.versionInfo.number) { this.setData({ - isShowVersionInfo:true, + isShowVersionInfo: true, }) } @@ -132,12 +134,12 @@ Page({ this.getHoursTip() //确保bizID重置完成再执行 - if(this.data.isResetbiz){ + if (this.data.isResetbiz) { this.setData({ - remindTab:[], - remindMsg:[], - isShowReport:false,//是否显示调拨盘点弹框 - isShowGoods:false, + remindTab: [], + remindMsg: [], + isShowReport: false, //是否显示调拨盘点弹框 + isShowGoods: false, }); this.getAppUserCal() this.getScore() @@ -152,37 +154,40 @@ Page({ //生命周期函数--监听页面卸载 onUnload: function () { //卸载消息通讯 是否显示授权用户信息 - _.eventBus.remove('isShowProfile',this); + _.eventBus.remove('isShowProfile', this); }, - + //候取时间 - getHoursTip(){ + 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="!" -  } + 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 + hoursTip: hoursTip }) }, //更新用户店铺id - putAppUserResetbiz(){ + putAppUserResetbiz() { let params = {}; + let that = this; params['biz_id'] = this.data.biz_id; _.apiQuery.putAppUserResetbiz(params).then(res => { this.setData({ - isResetbiz:true, + isResetbiz: true, }); this.getUserInfo() this.getAppUserCal() - this.getScore() + setTimeout(function () { + that.getScore() + }, 500) // this.getAppTransferRemind() // this.getAppInventoryRemind() // this.getAppGoodsRemind() @@ -191,147 +196,147 @@ Page({ }, //调拨提醒 - getAppTransferRemind(){ + getAppTransferRemind() { _.apiQuery.getAppTransferRemind().then(res => { this.setData({ - diaoboNum:res.data.total, + diaoboNum: res.data.total, }) - if(res.data.total>0){ + 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, + 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', + 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, - isShowGoods:false, + isShowReport: true, + isShowNotice: false, + isShowGoods: false, }) } }); }, //盘点提醒 - getAppInventoryRemind(){ + getAppInventoryRemind() { _.apiQuery.getAppInventoryRemind().then(res => { this.setData({ - pandianNum:res.data.total, + pandianNum: res.data.total, }) - if(res.data.total>0){ + 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, + 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', + 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, - isShowGoods:false, + isShowReport: true, + isShowNotice: false, + isShowGoods: false, }) } }); }, //库存提醒/预警 - getAppGoodsRemind(){ + getAppGoodsRemind() { _.apiQuery.getAppGoodsRemind().then(res => { this.setData({ - inventory:res.data.inventory, - warning:res.data.warning, + inventory: res.data.inventory, + warning: res.data.warning, }) - if(res.data.warning.list&&res.data.warning.list.length>0){ - if(!app.getStorageByKey("showGoods")||app.getStorageByKey("showGoods").data!=new Date().getDate()){ + if (res.data.warning.list && res.data.warning.list.length > 0) { + if (!app.getStorageByKey("showGoods") || app.getStorageByKey("showGoods").data != new Date().getDate()) { //清除 wx.removeStorageSync('showGoods') this.setData({ - isShowGoods:true, + isShowGoods: true, }) let showGoods = {} - if(this.data.biz_id){ + if (this.data.biz_id) { showGoods.data = new Date().getDate() - showGoods.list =[{ - biz_id:this.data.biz_id, - num:1, + showGoods.list = [{ + biz_id: this.data.biz_id, + num: 1, }] - }else{ + } else { showGoods.data = new Date().getDate() - showGoods.list =[{ - biz_id:'b1', - num:1, + showGoods.list = [{ + biz_id: 'b1', + num: 1, }] } - app.setStorage('showGoods',showGoods) - }else{ + app.setStorage('showGoods', showGoods) + } else { let showGoods = app.getStorageByKey("showGoods") let index = -1 - if(this.data.biz_id){ - showGoods.list.forEach((item,i) => { - if(item.biz_id == this.data.biz_id){ + if (this.data.biz_id) { + showGoods.list.forEach((item, i) => { + if (item.biz_id == this.data.biz_id) { index = i item.num = item.num + 1 } }) - }else{ - showGoods.list.forEach((item,i) => { - if(item.biz_id == 'b1'){ + } else { + showGoods.list.forEach((item, i) => { + if (item.biz_id == 'b1') { index = i item.num = item.num + 1 } }) } - if(index > -1){ - if(showGoods.list[index].num<4){ + if (index > -1) { + if (showGoods.list[index].num < 4) { this.setData({ - isShowGoods:true, + isShowGoods: true, }) - app.setStorage('showGoods',showGoods) + app.setStorage('showGoods', showGoods) } - }else{ + } else { this.setData({ - isShowGoods:true, + isShowGoods: true, }) - if(this.data.biz_id){ + if (this.data.biz_id) { showGoods.list.push({ - biz_id:this.data.biz_id, - num:1, + biz_id: this.data.biz_id, + num: 1, }) - }else{ + } else { showGoods.list.push({ - biz_id:'b1', - num:1, + biz_id: 'b1', + num: 1, }) } - app.setStorage('showGoods',showGoods) + app.setStorage('showGoods', showGoods) } } } @@ -339,39 +344,39 @@ Page({ }, //获取用户信息 - getUserInfo(){ + getUserInfo() { _.apiQuery.getUserInfo().then(res => { this.setData({ userInfo: res }) - if(res.group_id>2){ + if (res.group_id > 2) { this.setData({ - score_role_cur:1 + score_role_cur: 1 }) } }); }, //获取用户统计 - getAppUserCal(){ + getAppUserCal() { let params = {}; - if(this.data.biz_id){ + if (this.data.biz_id) { params['biz_id'] = this.data.biz_id; } _.apiQuery.getAppUserCal(params).then(res => { this.setData({ - isShowMain:true, - userCal:res.data, - levelSt:res.data.levelSt, + isShowMain: true, + userCal: res.data, + levelSt: res.data.levelSt, }) - if(res.data.deallist.length>0){ + if (res.data.deallist.length > 0) { let deallist = res.data.deallist - if(res.data.deallist.length%2==1){ + if (res.data.deallist.length % 2 == 1) { deallist.push({}) } this.setData({ - deallist:deallist, + deallist: deallist, }) } @@ -381,12 +386,12 @@ Page({ }, //数据分析-客户数据 - getAppStatisticsHcust(){ + getAppStatisticsHcust() { this.setData({ - showPieChart:false, + showPieChart: false, }) let params = {}; - if(this.data.biz_id){ + if (this.data.biz_id) { params['biz_id'] = this.data.biz_id; } _.apiQuery.getAppStatisticsHcust(params).then(res => { @@ -396,32 +401,32 @@ Page({ formatter: '\n{b|{b}}\n{c|{c}}\n{per|{d}%} ', rich: { b: { - color: '#4C5058', - fontSize: 10, - lineHeight:15, - align:'left', + color: '#4C5058', + fontSize: 10, + lineHeight: 15, + align: 'left', }, c: { color: '#4C5058', fontSize: 10, - lineHeight:15, - align:'left', + lineHeight: 15, + align: 'left', }, per: { color: '#4C5058', fontSize: 10, - lineHeight:15, - align:'left', + 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, + 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() @@ -430,21 +435,21 @@ Page({ }, //数据分析-订单数据 - getAppStatisticsHorder(){ + getAppStatisticsHorder() { this.setData({ - showBarChart:false, + showBarChart: false, }) let params = {}; - if(this.data.biz_id){ + 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, + order_total: res.data.total, + showBarChart: true, + ['ecBar.onInit']: barChart, }) wx.stopPullDownRefresh() @@ -454,7 +459,7 @@ Page({ //推送链接 pushLink(e) { - if(e.currentTarget.dataset.url){ + if (e.currentTarget.dataset.url) { _.$router.openUrlScheme(e.currentTarget.dataset.url) } }, @@ -467,25 +472,25 @@ Page({ }, //不再提示 - checkNotice(e){ + checkNotice(e) { this.setData({ - stopNotice:!this.data.stopNotice, + stopNotice: !this.data.stopNotice, }) }, //关闭通知 - closeNotice(){ - if(this.data.stopNotice){ + closeNotice() { + if (this.data.stopNotice) { app.setStorage('stopNotice', 'true') } this.setData({ - isShowNotice:false, + isShowNotice: false, }) }, //公众号关注组件 - officialaccount(e){ - if(e.detail.status == 0&&!app.getStorageByKey("stopNotice")&&!this.data.isShowReport){ + officialaccount(e) { + if (e.detail.status == 0 && !app.getStorageByKey("stopNotice") && !this.data.isShowReport) { // this.setData({ // isShowNotice:true, // }) @@ -493,20 +498,20 @@ Page({ }, //显示隐藏调拨盘点弹窗 - optShowReport(e){ + optShowReport(e) { this.setData({ - isShowReport:!this.data.isShowReport, + isShowReport: !this.data.isShowReport, }) }, //显示隐藏库存预警弹窗 - optShowGoods(e){ + optShowGoods(e) { this.setData({ - isShowGoods:!this.data.isShowGoods, + isShowGoods: !this.data.isShowGoods, }) }, //开发中 - development(){ + development() { wx.showToast({ title: '暂无数据', icon: 'none', @@ -517,64 +522,64 @@ Page({ //调拨盘点轮播点 bannerChange: function (e) { this.setData({ - banneractive:e.detail.current, + banneractive: e.detail.current, }); }, //banner轮播点 bannerChange2: function (e) { this.setData({ - banneractive2:e.detail.current, + banneractive2: e.detail.current, }); }, //库存预警轮播点 bannerChange3: function (e) { this.setData({ - banneractive3:e.detail.current, + banneractive3: e.detail.current, }); }, //关闭版本提示 - closeVersionInfo(){ + closeVersionInfo() { this.setData({ - isShowVersionInfo:false, + isShowVersionInfo: false, }) - app.setStorage('appversion',this.data.versionInfo.number) + app.setStorage('appversion', this.data.versionInfo.number) }, //切换tab - changeTab(e){ + changeTab(e) { this.setData({ - levelStIndex:e.currentTarget.dataset.index, + levelStIndex: e.currentTarget.dataset.index, }) }, //0924 - changeScoreRoleTab(e){ + changeScoreRoleTab(e) { this.setData({ - score_role_cur:parseInt(e.currentTarget.dataset.index) + score_role_cur: parseInt(e.currentTarget.dataset.index) }) this.getScore() }, //加载最新运营分 - getScore(){ + getScore() { let params = {}; - if(this.data.score_role_cur){ + if (this.data.score_role_cur) { params['type'] = 1; } _.apiQuery.getAppScore(params).then(res => { this.setData({ - scoreData:res.data, - score_trend:res.data.score_trend ?? 1 + scoreData: res.data, + score_trend: res.data.score_trend ?? 1 }) }) }, //页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { this.setData({ - remindTab:[], - remindMsg:[], - isShowReport:false,//是否显示调拨盘点弹框 - isShowGoods:false, + remindTab: [], + remindMsg: [], + isShowReport: false, //是否显示调拨盘点弹框 + isShowGoods: false, }); this.getAppUserCal() this.getAppStatisticsHcust() @@ -593,49 +598,58 @@ function getPieOption() { trigger: 'axis', }, legend: { - top: 'bottom', - orient: 'horizontal', - textStyle:{ - fontSize:9, + 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', - }, - } + + 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', + }, + } + }, + }] }; } @@ -660,24 +674,22 @@ function getBarOption() { }, yAxis: { type: 'category', - data: ['恭喜提车', '保险上牌', '已开发票','车辆确认','配车准备','申请退款','办理按揭','已交定金','已签合同',], + 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 - } + 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 + } + }, ] }; } \ No newline at end of file