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.

281 lines
10 KiB

import brokenLines from "../../../components/option/stackingLineOption"
import histogram from "../../../components/option/singleColumnarOption"
import multipleColumn from "../../../components/option/multipleColumn"
import sHistogram from "../../../components/option/sColumnarOption"
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,
transformOption: brokenLines([], [], [], []),
brandOption: histogram([], [], [], '#0084FF'),
brandOption2: histogram([], [], [], '#20cc62'),
brandOption3: multipleColumn([], [], []),
brandOption4: sHistogram(),
boxArr: new Array(6),
topActive: 0, //品牌传播
brandTop: [],
brandTopData: [],
cloudActive: 0, //词云
evalOption:negaposiOption([],[]),
positiveWord:[],
negativeWord:[],
negativeWordActive:0,
positiveWordActive:0,
positive:[],
negative:[]
},
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: 'getCountTime0528C',
sType: 'BrandOverview',
token: wx.getStorageSync('token'),
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let dtime = []
let dVal = []
let dataObj = {}
for (let i of res) {
dtime.push(i.key)
for (let j of i.value) {
let obj = {
key: j.key,
value: j.value
}
if (!dataObj.hasOwnProperty(j.key)) {
dataObj[j.key] = []
}
dataObj[j.key].push(obj)
}
}
Object.keys(dataObj).forEach(ele => {
dVal.push(dataObj[ele])
})
this.setData({
transformOption: brokenLines(themeName, dVal, dColor, dtime),
})
})
//整体信息量
app.globalData.request({
action: 'getContrastCount0528C',
token: wx.getStorageSync('token'),
sType: 'BrandOverview',
...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: 'BrandOverview',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let dx = []
let dy = []
for (let i of res) {
dx.push(i.key)
dy.push(i.value)
}
this.setData({
brandOption2: histogram(themeName, dy, [], '#20cc62'),
})
})
//主题调性对比
app.globalData.request({
action: 'getAffectionsC',
token: wx.getStorageSync('token'),
sType: 'BrandOverview',
...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),
})
})
//渠道分布
app.globalData.request({
action: 'getSourcetypeC',
token: wx.getStorageSync('token'),
sType: 'BrandOverview',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
let arr = []
let channelMsg = []
for (let [index,i] of res.entries()) {
let obj = {
name: themeName[index]
}
let da = []
Object.keys(i.Data).forEach(ele => {
da.push(i.Data[ele])
channelMsg.push(ele)
})
obj.data = da
arr.push(obj)
}
channelMsg = [...new Set(channelMsg)]
this.setData({
brandOption3: multipleColumn(themeName, channelMsg, arr),
})
})
//重点媒体
app.globalData.request({
action: 'getSourceCount0528C',
token: wx.getStorageSync('token'),
sType: 'BrandOverview',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(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)
}
}
//横轴,数据,纵轴
this.setData({
brandOption4: sHistogram(xMsg, data, themeName, [])
})
})
//品牌传播TOP媒体
app.globalData.request({
action: 'getSourceTopCount0528C',
token: wx.getStorageSync('token'),
sType: 'BrandOverview',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res => {
for(let [index,i] of res.entries()){
i.themeName = themeName[index]
}
this.setData({
brandTop: [res[0], res[1]],
brandTopData: res
})
})
//正负词云
app.globalData.request({
action: 'getPositiveAndNegative0528C',
token: wx.getStorageSync('token'),
sType:'BrandOverview',
...brandRatioTime,
iContrastType: '4',
sGuid: sGuid.join(',')
}).then(res=>{
let positiveWord = []
let negativeWord = []
for(let [index,i] of res.entries()){
let pobj = {}
let nobj = {}
pobj.name = themeName[index]
nobj.name = themeName[index]
for(let j of i.value){
if(j.key=='正面词'){
pobj.value = j.value.map(ele=>{
return [ele.key,ele.value]
})
}else{
nobj.value = j.value.map(ele=>{
return [ele.key,ele.value]
})
}
}
positiveWord.push(pobj)
negativeWord.push(nobj)
}
this.setData({
positiveWord,
negativeWord,
positive:[positiveWord[0],positiveWord[1]],
negative:[negativeWord[0],negativeWord[1]],
})
})
},
},
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]
})
},
changeNegative(event) {
let index = event.detail.index
this.setData({
negativeWordActive: index,
negative: [this.data.negativeWord[index*2],this.data.negativeWord[index*2+1]]
})
},
changePositive(event) {
let index = event.detail.index
this.setData({
positiveWordActive: index,
positive: [this.data.positiveWord[index*2],this.data.positiveWord[index*2+1]]
})
},
}
})