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.

194 lines
7.1 KiB

import stack from "../../../components/option/stackedBarChart"
import pictographicOption from '../../../components/option/pictographicOption2'
import negaposiOption from '../../../components/option/negaposiOption2'
import brokenLines from "../../../components/option/stackingLineOption"
const app = getApp()
const dColor = ['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF']
Component({
data: {
imageUrl: getApp().globalData.imageUrl,
showChart: true,
stackOption: stack([], [], ['#00aaff', '#20cc62', '#ff4852']),
transformOption2:brokenLines([], [], [], []),
boxArr: new Array(6),
evalOption:negaposiOption(),
bbsInfoData:[],
bbsInfo:[],
bbsInfoAction:0,
positiveData:[],
positive:[],
positiveActive:0,
negativeData:[],
negative:[],
negativeActive:0,
},
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: 'getCount0528C',
sType: 'BbsBrand',
iContrastType: '4',
iBBsType: '1',
sGuid: sGuid.join(','),
token: wx.getStorageSync('token'),
...brandRatioTime,
}).then(res => {
for(let [index,i] of res.entries()){
i.key = themeName[index]
}
this.setData({
bbsInfoData:res,
bbsInfo:[res[0],res[1]]
})
})
//论坛发帖趋势对比
app.globalData.request({
action: 'getCountTime0528C',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
iContrastType: '4',
iBBsType:'2',
...brandRatioTime,
sGuid: sGuid.join(',')
}).then(res => {
let dDate = []
let dVal = new Array(res[0].value.length).fill([])
dVal = dVal.map(ele => {
ele = JSON.stringify(ele)
ele = JSON.parse(ele)
return ele
})
for (let i of res) {
dDate.push(i.key)
for (let [index, j] of i.value.entries()) {
dVal[index].push(j)
}
}
this.setData({
transformOption2: brokenLines(themeName, dVal, dColor, dDate),
})
})
//论坛调性对比
app.globalData.request({
action: 'getAffectionsC',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
...brandRatioTime,
iContrastType: '4',
iBBsType:'2',
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: 'getTopicPosAndTopicNeg0528C',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
...brandRatioTime,
iContrastType: '4',
iBBsType:'2',
sGuid: sGuid.join(',')
}).then(res=>{
let newRes =[]
let positive = []
let negative = []
for(let i of res){
for(let [index,j] of i.value.entries()){
let obj ={name:i.key,region:[],value:[],sum:0}
j.value.forEach(ele=>{
obj.region.push(ele.key)
obj.value.push(ele.value)
obj.sum+=ele.value
})
index == 0?positive.push(obj):negative.push(obj)
}
}
positive = positive.map((ele,index)=>{
ele.name = themeName[index]
ele.func=pictographicOption(ele.region.slice(0,5),ele.value.slice(0,5),ele.sum)
return ele
})
negative = negative.map((ele,index)=>{
ele.name = themeName[index]
ele.func=pictographicOption(ele.region.slice(0,5),ele.value.slice(0,5),ele.sum)
return ele
})
this.setData({
positiveData:positive,
positive:[positive[0],positive[1]],
negativeData:negative,
negative:[negative[0],negative[1]],
})
})
},
},
methods: {
//负面
negativeChange(event) {
let obj = {
0: [this.data.negativeData[0] || {}, this.data.negativeData[1] || {}],
1: [this.data.negativeData[2] || {}, this.data.negativeData[3] || {}],
2: [this.data.negativeData[4] || {}, this.data.negativeData[5] || {}]
}
let index = event.detail.index
this.setData({
negativeActive: index,
negative: obj[index]
})
},
//正面
positiveChange(event) {
let obj = {
0: [this.data.positiveData[0] || {}, this.data.positiveData[1] || {}],
1: [this.data.positiveData[2] || {}, this.data.positiveData[3] || {}],
2: [this.data.positiveData[4] || {}, this.data.positiveData[5] || {}]
}
let index = event.detail.index
this.setData({
positiveActive: index,
positive: obj[index]
})
},
//论坛信息
bbsChange(event) {
let obj = {
0: [this.data.bbsInfoData[0] || {}, this.data.bbsInfoData[1] || {}],
1: [this.data.bbsInfoData[2] || {}, this.data.bbsInfoData[3] || {}],
2: [this.data.bbsInfoData[4] || {}, this.data.bbsInfoData[5] || {}]
}
let index = event.detail.index
this.setData({
bbsInfoAction: index,
bbsInfo: obj[index]
})
},
}
})