You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
6.1 KiB

const app = getApp();
import brokenLine from "../../option/stackingLineOption"
const dColor = ['#FF4852','#FFBF00', '#FF6E25', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF']
Component({
data: {
// totallist:totallist,
imageUrl: getApp().globalData.imageUrl,
active: 0,
countYear: 0,
count6month: 0,
countAll: 0,
totallist: [],
showChart: true,
// dataOption: brokenLine(dName,dValue,dColor,dx)
},
onShow() {
this.getTabBar().init();
},
lifetimes: {
attached() {
let sTimeType = wx.getStorageSync("sTimeType2") || 34;
let sStartTime = wx.getStorageSync("sStartTime") || '';
let sEndTime = wx.getStorageSync("sEndTime") || '';
this.getData(sTimeType, sStartTime, sEndTime);
}
},
methods: {
// 时间
changeTime(e) {
let sTimeType = e.detail.sTimeType;
let sStartTime = e.detail.sStartTime;
let sEndTime = e.detail.sEndTime;
this.getData(sTimeType, sStartTime, sEndTime)
},
getData(sTimeType, sStartTime, sEndTime) {
wx.showToast({
title: '加载中',
icon: 'loading',
duration: 300000
})
Promise.all([
this.getAmount(sTimeType, sStartTime, sEndTime),
this.getTrend(sTimeType, sStartTime, sEndTime)
]).then(() => {
setTimeout(() => {
wx.hideToast();
}, 500)
})
},
// 入库数据趋势
getTrend(sTimeType, sStartTime, sEndTime) {
return new Promise((resolve, reject) => {
let obj = {
action: 'getSourcetypeTimeDynamicHome',
sType: 'Home',
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime
}
app.globalData.request(obj).then(res => {
let data = res || [];
let times = []
let dNameObj = {}
for(let i = 0; i < data.length; i++) {
times.push(data[i].Time);
let a1 = data[i].Data || [];
for(let j = 0; j < a1.length; j++) {
let row = a1[j];
if(dNameObj[row.key]) {
let val = dNameObj[row.key];
val.push(row.value);
} else {
dNameObj[row.key] = [row.value];
}
}
}
const bar = [];
const dName = [];
for(let key in dNameObj) {
dName.push(key);
bar.push(dNameObj[key])
}
this.setData({
dataOption: brokenLine(dName, bar, dColor, times)
})
resolve(true)
}).catch(() => {
reject(false)
})
})
},
// 入库数据量
getAmount(sTimeType, sStartTime, sEndTime) {
return new Promise((resolve, reject) => {
let obj = {
action: 'getHomeCount0528',
sType: 'Home',
sTimeType: sTimeType,
sStartTime: sStartTime,
sEndTime: sEndTime,
iStatus: 1
}
app.globalData.request(obj).then(res => {
const data = res;
const sourcetypeCount = data.sourcetypeCount || [];
const arr = []
const imgObj = {
'微博': '/weibo.png',
'微信': '/weixin.png',
'APP': '/app.png',
'论坛': '/luntan.png',
'新闻': '/xinwen.png',
'其他': '/qita.png',
'短视频': '/shipin.png'
}
arr.push({
num: data.count,
text: '入库数据',
url: '/ruku.png'
})
sourcetypeCount.forEach(ele => {
let obj = {
num: ele.value,
text: ele.key + '数据',
url: imgObj[ele.key]
}
arr.push(obj)
})
this.setData({
countYear: data.count_year,
count6month: data.count_6month,
countAll: data.count_all,
totallist: arr
})
resolve(true)
}).catch(() => {
reject(false)
})
})
},
priceSel(e) {
this.setData({
intervalSel: e.currentTarget.dataset.index
})
},
getKey(val) {
switch (val) {
case "入库数据":
return -1
case "新闻数据":
return 1
case "论坛数据":
return 3
case "微信数据":
return 4
case "APP数据":
return 6
case "微博数据":
return 5
case "短视频数据":
return 7
case "其他数据":
return 2
default:
return null
}
},
dynamic(e) {
var value = e.currentTarget.id
wx.setStorageSync('sQuDao', this.getKey(value))
wx.navigateTo({
url: "/pages/index/total/tatal"
})
},
}
})