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.

262 lines
9.4 KiB

import histogram from "../../../components/option/singleColumnarOption"
import stack from "../../../components/option/stackedBarChart"
import sHistogram from "../../../components/option/sColumnarOption"
import pictographicOption from '../../../components/option/pictographicOption'
import negaposiOption from '../../../components/option/negaposiOption2'
const app = getApp()
const dColor = ['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF']
Component({
data: {
imageUrl: getApp().globalData.imageUrl,
showChart: true,
brandOption: histogram([], [], [], '#0084FF'),
brandOption2: histogram([], [], [], '#20cc62'),
brandOption4: sHistogram(),
evalOption: negaposiOption([],{}),
genderOption:negaposiOption([],{}),
genderOptio2:negaposiOption([],{}),
boxArr: new Array(6),
topActive: 0, //品牌传播
userActive:0,//活跃用户信息
brandTop: [],
brandTopData: [],
areaActive:0,
areaData:[],
area:[]
},
lifetimes: {
attached() {
let brandRatioTime = wx.getStorageSync('brandRatioTime')
this.setData({
boxArr: wx.getStorageSync('themeData')
})
let themeName=['主题一','主题二','主题三','主题四','主题五','主题六']
let numb=0
let sGuid = []
this.data.boxArr.forEach((ele) => {
if (ele) sGuid.push(ele.Guids),numb+=1
})
themeName.length = numb
//微博信息量对比
app.globalData.request({
action: 'getContrastCount0528C',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let dy = []
for (let i of res) {
dy.push(i.value)
}
this.setData({
brandOption: histogram(themeName, dy, [], '#0084FF'),
})
})
//微博互动人数
app.globalData.request({
action: 'getInteractCount0528C',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let dy = []
for (let i of res) {
dy.push(i.value)
}
this.setData({
brandOption2: histogram(themeName, dy, [], '#20cc62'),
})
})
//微博调性对比
app.globalData.request({
action: 'getAffectionsC',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let evaluation = {
'正面': [],
'中性': [],
'负面': [],
}
for (let i of res) {
Object.keys(i.Data).forEach(ele => {
evaluation[ele].push(i.Data[ele])
})
}
this.setData({
evalOption: negaposiOption(themeName, evaluation),
})
})
//微博大V
app.globalData.request({
action: 'getBoauthen0528C',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
console.log('imin',res);
let xMsg = []
for (let i of res[0].value) {
xMsg.push(i.key)
}
let data = new Array(res.length).fill([])
data = data.map(ele => {
ele = JSON.stringify(ele)
ele = JSON.parse(ele)
return ele
})
for (let [index, i] of res.entries()) {
for (let j of i.value) {
data[index].push(j.value)
}
}
console.log('cdc',data);
//横轴,数据,纵轴
this.setData({
brandOption4: sHistogram(xMsg, data, themeName, dColor)
})
})
//微博内容方向对比
app.globalData.request({
action: 'getDirect0528C',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
for(let [index,i] of res.entries()){
i.themeName = themeName[index]
i = i.Data.sort((a,b)=>{
return Number(b.value) - Number(a.value)
})
}
this.setData({
brandTop: [res[0], res[1]],
brandTopData: res
})
})
//活跃用户信息
app.globalData.request({
action: 'getRegionWeiBoC',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res=>{
console.log(res)
let newRes =[]
for(let i of res){
let obj ={name:i.Name,region:[],value:[],sum:0}
let arr = []
Object.keys(i.Data).forEach(ele=>{
arr.push({name:ele,value:i.Data[ele]})
})
arr = arr.sort((a,b)=>{
return a.value *1 - b.value*1
})
for(let j of arr){
obj.region.push(j.name)
obj.value.push(j.value)
obj.sum+=j.value*1
}
newRes.push(obj)
}
newRes = newRes.map((ele,index)=>{
ele.name = themeName[index]
ele.func=[pictographicOption(ele.region.slice(0,5),ele.value.slice(0,5),ele.sum),
pictographicOption(ele.region.slice(5,10),ele.value.slice(5,10),ele.sum)]
return ele
})
console.log(newRes);
this.setData({
areaData:newRes,
area:[newRes[0],newRes[1]]
})
})
//男女-认证用户
app.globalData.request({
action: 'getSexMergeWeiBoC',
token: wx.getStorageSync('token'),
sType: 'BrandWeiBo',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res=>{
Array.prototype.sum = function(){
let x = 0
this.forEach(ele=>{
x+=ele
})
return x
}
let sex = {
'男':[],
'未设性别':[],
'女':[],
}
let attestation = {
'普通认证':[],
'机构认证':[],
'非认证':[],
}
for(let i of res){
Object.keys(i.Data.sex).forEach(ele=>{
sex[ele].push(i.Data.sex[ele])
})
Object.keys(i.Data.attestation).forEach(ele=>{
attestation[ele].push(i.Data.attestation[ele])
})
}
console.log(sex);
this.setData({
genderOption:negaposiOption(themeName,sex),
genderOption2:negaposiOption(themeName,attestation)
})
})
},
},
methods: {
//品牌传播top媒体
changeModalHot(event) {
let obj = {
0: [this.data.brandTopData[0] || {}, this.data.brandTopData[1] || {}],
1: [this.data.brandTopData[2] || {}, this.data.brandTopData[3] || {}],
2: [this.data.brandTopData[4] || {}, this.data.brandTopData[5] || {}]
}
let index = event.detail.index
this.setData({
topActive: index,
brandTop: obj[index]
})
},
changeActiveUser(event) {
let obj = {
0: [this.data.areaData[0] || {}, this.data.areaData[1] || {}],
1: [this.data.areaData[2] || {}, this.data.areaData[3] || {}],
2: [this.data.areaData[4] || {}, this.data.areaData[5] || {}]
}
let index = event.detail.index
this.setData({
areaActive: index,
area: obj[index]
})
},
}
})