123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735 |
- var abs = (val, showPoint = true) => {
- //金额转换 保留2位小数 并每隔3位用逗号分开 1,234.56
- let str = (val / 1).toFixed(2) + ''
- let intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',') //取到整数部分
- let dot = str.substring(str.length, str.indexOf(".")) //取到小数部分搜索
- let ret = intSum + dot;
- return ret;
- }
- let timer = null;
- let timer1 = null;
- // 定义一个索引
- let index = 0;
- // 定义一个索引
- let ind = 0;
- var pietimer1, pietimer
- //左上
- function handle1(res) {
- if (res.data && res.data.length != 0) {
- $('#total').text(`累计新增创客 ${res.data[0].ckcount}`)
- $('#todayAdd').text(`累计新增商户 ${res.data[0].shcount}`)
- }
- }
- // 列表
- function handle2(res_2) {
- $('.firstpanel').empty();
- for (var i = 0; i < res_2.data.length; i++) {
- const element = `<div class="row"> <span class="col">${res_2.data[i].activationTime}</span><span class="col">${res_2.data[i].productName}</span>
- <span class="col">${res_2.data[i].realname}</span>
- <span class="col">${res_2.data[i].count}</span>
- </div>`
- $('.firstpanel').append(element);
- };
- }
- // 左下
- function handle3(res_1) {
- $('.year').text(`${new Date().getFullYear()}年`)
- if (res_1.data && res_1.data.length > 0) {
- $('.withdrawAmount').text(abs(res_1.data[0].withdrawAmount))
- $('.store-count').text(res_1.data[0].count)
- $('.yearsum').text(abs(res_1.data[0].yearsum))
- $('.yearcount').text(res_1.data[0].yearcount)
- $('.quartersum').text(abs(res_1.data[0].quartersum))
- $('.quartercount').text(res_1.data[0].quartercount)
- $('.monthsum').text(abs(res_1.data[0].monthsum))
- $('.monthcount').text(res_1.data[0].monthcount)
- $('.nowsum').text(abs(res_1.data[0].nowsum))
- $('.nowcount').text(res_1.data[0].nowcount)
- }
- }
- // 排行榜
- function handle4(res_3, res_4, res_5) {
- if (res_3 || res_4 || res_5) {
- // console.log('handle4','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
- let resArr = Array.of(res_3.data, res_4.data, res_5.data)
- resArr.map((res, i) => {
- // $(`.user-content${i}`).empty();
- res.map((item, index) => {
- let result = () => {
- if (item.openCount || item.openCount === 0) {
- return item.openCount
- }
- if (item.sum || item.sum === 0) {
- return abs(item.sum)
- }
- }
- $(`.user-content${i} .item${index} .name`).text(item.RealName ? item.RealName : item.realName);
- $(`.user-content${i} .item${index} .count`).text(result());
- // let element = `
- // <div class="item">
- // <span class="name">${item.RealName}</span>
- // <span class="count">${result()}</span>
- // </div>`
- // $(`.user-content${i}`).append(element);
- })
- // console.log(res_3);
- })
- }
- }
- //月度交易额环比
- function handle5(res_10, res_11) {
- let present = (val) => {
- if (val.LastMonthTrade === 0) {
- return '100%'
- } else {
- return (val.ThisMonthTrade / val.LastMonthTrade * 100).toFixed(2) + '%'
- };
- }
- // let present_1 = (val) => {
- // if(val.LastMonthTrade === 0){
- // return '100%'
- // }else{
- // return (((val.ThisMonthTrade / val.LastMonthTrade) - 1) * 100).toFixed(2) + '%'
- // };
- // }
- let present_add = (val) => {
- return (val.ThisMonthCount / val.LastMonthCount * 100).toFixed(2) + '%'
- }
- // let present_add_1 = (val) => {
- // return (((val.ThisMonthCount / val.LastMonthCount) - 1) * 100).toFixed(2) + '%'
- // }
- if (res_10) {
- $('.mounthResult').text(present(res_10.data[0]));
- $('.thismonthsum').text(`${(res_10.data[0].ThisMonthTrade / 10000).toFixed(2)}`);
- $('.lastmonthsum').text(`${(res_10.data[0].LastMonthTrade / 10000).toFixed(2)}`);
- // $('.result').text(`${ present_1(res_10.data[0])}`);
- }
- if (res_11) {
- $('.addPresent').text(present_add(res_11.data[0]));
- $('.addSum').text(`${(res_11.data[0].ThisMonthCount).toFixed(0)}`);
- $('.addResult').text(`${(res_11.data[0].LastMonthCount).toFixed(0)}`);
- // $('.addResult').text(`${present_add_1(res_11.data[0])}`);
- }
- }
- // 右上折线图
- function handle6(res_6, res_7) {
- // 定义数据
- let real_year = new Array(); //年Y轴数据
- let year_xAxis = new Array();
- let month_xAxis = new Array(); //14天x轴数据
- // let house_xAxis = new Array(); //一天x轴数据
- let real_14day = new Array(); //14天Y轴,真实数据
- // let real_house = new Array(); //1天Y轴,真实数据
- res_6.data.map((item) => {
- real_year.push((item.TradeAmount / 10000).toFixed(2))
- year_xAxis.push((item.TradeMonth.slice(-2) + '月'))
- });
- res_7.data.map((item) => {
- real_14day.push((item.TradeAmount / 10000).toFixed(2))
- month_xAxis.unshift(item.TradeDate + '日');
- })
- let data = {
- year: [
- [0],
- real_year
- ],
- month: [],
- quarter: [],
- };
- const chart = echarts.init(document.querySelector(".line"))
- const option = {
- tooltip: {
- trigger: 'axis'
- },
- legend: {
- // 向右距离边框10%
- right: '10%',
- textStyle: {
- color: '#4c9bfd'
- }
- },
- grid: {
- show: true, //显示边框
- borderColor: '#012f4a', //边框颜色
- left: '3%',
- right: '4%',
- bottom: '3%',
- top: '20%', // 距离上边20%
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: year_xAxis,
- axisLabel: {
- color: '#4c9bfd',
- fontSize: 9,
- },
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- }
- },
- yAxis: {
- type: 'value',
- axisLabel: {
- color: '#4c9bfd',
- },
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- splitLine: {
- lineStyle: {
- color: "#012f4a"
- }
- }
- },
- color: ['#00f2f1', '#ed3f35'],
- series: [{
- name: '实际交易额',
- type: 'line',
- stack: '总量',
- smooth: true,
- data: data.year[1],
- }]
- };
- chart.setOption(option);
- window.addEventListener('resize', function () {
- chart.resize();
- })
- if (!timer) {
- // 3.点击切换高亮并且切换折线图显示数据
- $(".sales .caption a").on('click', function () {
- // console.log('111000')
- option.series[0].data = [];
- // caption里面有5个元素,排序并不是以选取元素进行排序的
- index = $(this).index() - 1;
- if (index === 0) {
- data.year[1] = real_year
- option.xAxis.data = year_xAxis
- }
- if (index === 1) {
- option.xAxis.data = month_xAxis
- data.month[1] = real_14day
- }
- if (index === 2) {
- option.xAxis.data = house_xAxis
- data.quarter[1] = real_house
- };
- $(this).addClass("active").siblings("a").removeClass("active");
- // 在结构新增data-type属性,并赋值,通过新增属性获取属性值
- // const attr = $(this).attr('data-type')
- const attr = this.dataset.type
- // 通过新增属性值获取data对象里面的对应数据
- const arr = data[attr];
- option.series[0].data = arr[1];
- // 重新渲染option数据
- chart.setOption(option);
- })
- $(".point .filter a").on('click', function () {
- ind = $(this).index();
- // console.log('indeed', ind)
- $(this).addClass("active").siblings("a").removeClass("active");
- $(".point .data").eq(ind).show().siblings(".data").hide();
- })
- $(".sales").on('mouseover', function () {
- clearInterval(timer);
- })
- $(".point").on('mouseover', function () {
- clearInterval(timer1);
- })
- $(".sales").on('mouseout', function () {
- timer = setInterval(function () {
- // 定时器开启,索引自增
- index++;
- // 当索引值大于等于4,索引重新变为0
- if (index >= 3) {
- index = 0;
- }
- // 自动触发点击事件
- $(".sales .caption a").eq(index).click();
- }, 2000)
- })
- $(".point").on('mouseout', function () {
- timer1 = setInterval(function () {
- // 定时器开启,索引自增
- ind++;
- // 当索引值大于等于4,索引重新变为0
- if (ind >= 4) {
- ind = 0;
- }
- // 自动触发点击事件
- $(".point .filter a").eq(ind).click();
- }, 2000)
- })
- // 定义一个定时器
- timer1 = setInterval(function () {
- // 定时器开启,索引自增
- ind++;
- // 当索引值大于等于4,索引重新变为0
- if (ind >= 4) {
- ind = 0;
- }
- // 自动触发点击事件
- $(".point .filter a").eq(ind).click();
- }, 2000)
- // 定义一个定时器
- timer = setInterval(function () {
- // 定时器开启,索引自增
- index++;
- // 当索引值大于等于4,索引重新变为0
- if (index >= 3) {
- index = 0;
- }
- // 自动触发点击事件
- $(".sales .caption a").eq(index).click();
- }, 2000)
- }
- };
- // 半圆饼图1
- function handle7(res_10) {
- const chart = echarts.init(document.querySelector(".quarter1 .gauge"));
- let present = 0;
- if (res_10.data[0].LastMonthTrade === 0) {
- present = 100;
- } else {
- present = (res_10.data[0].ThisMonthTrade / res_10.data[0].LastMonthTrade * 100).toFixed(2)
- }
- if (present > 100) {
- present = 100
- }
- const option = {
- series: [{
- color: ['skyblue', '#777'],
- name: '销售进度',
- type: 'pie',
- radius: ['130%', '150%'],
- center: ['48%', '80%'],
- label: {
- show: false
- },
- startAngle: 180,
- hoverOffset: 0,
- data: [{
- value: present,
- itemStyle: {
- // 颜色渐变#00c9e0->#005fc1
- color: new echarts.graphic.LinearGradient(
- // (x1,y2) 点到点 (x2,y2) 之间进行渐变
- 0,
- 0,
- 0,
- 1,
- [{
- offset: 0,
- color: "#00c9e0"
- }, // 0 起始颜色
- {
- offset: 1,
- color: "#005fc1"
- } // 1 结束颜色
- ]
- )
- }
- },
- {
- value: 100 - present,
- itemStyle: {
- color: '#12274d'
- }
- },
- {
- value: 100,
- itemStyle: {
- color: 'transparent'
- }
- },
- ],
- // silent: true
- }]
- };
- chart.setOption(option);
- window.addEventListener('resize', function () {
- chart.resize();
- })
- };
- // 半圆饼图2
- function handle8(res_11) {
- const chart = echarts.init(document.querySelector(".quarter2 .gauge"));
- let present = (res_11.data[0].ThisMonthCount / res_11.data[0].LastMonthCount * 100).toFixed(2)
- if (present > 100) {
- present = 100
- }
- const option = {
- series: [{
- color: ['skyblue', '#777'],
- name: '销售进度',
- type: 'pie',
- radius: ['130%', '150%'],
- center: ['48%', '80%'],
- label: {
- show: false
- },
- startAngle: 180,
- hoverOffset: 0,
- data: [{
- value: present,
- itemStyle: {
- // 颜色渐变#00c9e0->#005fc1
- color: new echarts.graphic.LinearGradient(
- // (x1,y2) 点到点 (x2,y2) 之间进行渐变
- 0,
- 0,
- 0,
- 1,
- [{
- offset: 0,
- color: "#00c9e0"
- }, // 0 起始颜色
- {
- offset: 1,
- color: "#005fc1"
- } // 1 结束颜色
- ]
- )
- }
- },
- {
- value: 100 - present,
- itemStyle: {
- color: '#12274d'
- }
- },
- {
- value: 100,
- itemStyle: {
- color: 'transparent'
- }
- },
- ],
- // silent: true
- }]
- };
- chart.setOption(option);
- window.addEventListener('resize', function () {
- chart.resize();
- })
- };
- //饼图1
- function handle9(res_12) {
- const chart = echarts.init(document.querySelector(".piebox1"));
- const option = {
- color: ['#536fc6', '#90cc74', '#f7c95a', '#ee6666', '#73bfdf', '#3ba372', '#fc8450', '#9a60b4', '#eb7acd'],
- title: {
- text: '开机量统计图',
- x: 'center',
- y: 'bottom',
- textStyle: {
- fontSize: '14',
- fontWeight: 'normal',
- color: '#fff',
- }
- },
- series: [{
- name: 'Access From',
- type: 'pie',
- radius: ['50%', '70%'],
- center: ['50%', '45%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 1,
- textColor: '#fff'
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '16',
- fontWeight: 'bold',
- color: '#fff',
- formatter: "{aa|{d}}{bb|%}\n{cc|{b}}",
- rich: {
- bb: {
- color: '#fff'
- },
- }
- }
- },
- labelLine: {
- show: false
- },
- data: []
- }]
- };
- res_12.data.map((item) => {
- option.series[0].data.push({
- value: item.count,
- name: item.name
- })
- option.series.name = item.name
- option.series[0].name = item.name
- })
- chart.setOption(option);
- window.addEventListener('resize', function () {
- chart.resize();
- })
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- // dataIndex: lastIndex +1
- });
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: 0
- });
- let currentIndex = -1
- clearInterval(pietimer)
- pietimer = setInterval(function () {
- var dataLen = option.series[0].data.length;
- // 取消之前高亮的图形
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- currentIndex = (currentIndex + 1) % dataLen;
- // 高亮当前图形
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- // 显示 tooltip
- // chart.dispatchAction({
- // type: 'showTip',
- // seriesIndex: 0,
- // dataIndex: currentIndex
- // });
- }, 1500);
- // 处理点击事件并且跳转到相应的百度搜索页面
- chart.on('mouseover', function (params) {
- console.log('饼图进事件', params)
- clearInterval(pietimer)
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- });
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: params.dataIndex
- });
- });
- chart.on('mouseout', function (params) {
- console.log('饼图出事件', params)
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- });
- currentIndex = params.dataIndex
- clearInterval(pietimer)
- pietimer = setInterval(function () {
- var dataLen = option.series[0].data.length;
- // 取消之前高亮的图形
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- currentIndex = (currentIndex + 1) % dataLen;
- // 高亮当前图形
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- // 显示 tooltip
- // chart.dispatchAction({
- // type: 'showTip',
- // seriesIndex: 0,
- // dataIndex: currentIndex
- // });
- }, 1500);
- });
- };
- //饼图2
- function handle10(res_13) {
- const chart = echarts.init(document.querySelector(".piebox2"));
- const option = {
- color: ['#536fc6', '#90cc74', '#f7c95a', '#ee6666', '#73bfdf', '#3ba372', '#fc8450', '#9a60b4', '#eb7acd'],
- title: {
- text: '交易量统计图',
- x: 'center',
- y: 'bottom',
- textStyle: {
- fontSize: '14',
- fontWeight: 'normal',
- color: '#fff',
- }
- },
- series: [{
- name: 'Access From',
- type: 'pie',
- radius: ['50%', '70%'],
- center: ['50%', '45%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 1,
- textColor: '#fff'
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '16',
- fontWeight: 'bold',
- color: '#fff',
- formatter: "{aa|{d}}{bb|%}\n{cc|{b}}",
- rich: {
- bb: {
- color: '#fff',
- },
- }
- }
- },
- labelLine: {
- show: false
- },
- data: []
- }]
- };
- res_13.data.map((item) => {
- option.series[0].data.push({
- value: item.sum,
- name: item.name
- })
- })
- chart.setOption(option);
- window.addEventListener('resize', function () {
- chart.resize();
- })
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- // dataIndex: lastIndex +1
- });
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: 0
- });
- let currentIndex = -1
- clearInterval(pietimer1)
- pietimer1 = setInterval(function () {
- var dataLen = option.series[0].data.length;
- // 取消之前高亮的图形
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- currentIndex = (currentIndex + 1) % dataLen;
- // 高亮当前图形
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- // 显示 tooltip
- // chart.dispatchAction({
- // type: 'showTip',
- // seriesIndex: 0,
- // dataIndex: currentIndex
- // });
- }, 1500);
- // 处理点击事件并且跳转到相应的百度搜索页面
- chart.on('mouseover', function (params) {
- console.log('饼图进事件', params)
- clearInterval(pietimer1)
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- });
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: params.dataIndex
- });
- });
- chart.on('mouseout', function (params) {
- console.log('饼图出事件', params)
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- });
- currentIndex = params.dataIndex
- clearInterval(pietimer1)
- pietimer1 = setInterval(function () {
- var dataLen = option.series[0].data.length;
- // 取消之前高亮的图形
- chart.dispatchAction({
- type: 'downplay',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- currentIndex = (currentIndex + 1) % dataLen;
- // 高亮当前图形
- chart.dispatchAction({
- type: 'highlight',
- seriesIndex: 0,
- dataIndex: currentIndex
- });
- // 显示 tooltip
- // chart.dispatchAction({
- // type: 'showTip',
- // seriesIndex: 0,
- // dataIndex: currentIndex
- // });
- }, 1500);
- });
- }
|