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.

196 lines
7.1 KiB

import stack from "../../../components/option/stackedBarChart"
import pictographicOption from '../../../components/option/pictographicOption2'
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),
bbsInfoData:[],
bbsInfo:[],
bbsInfoAction:0,
positiveData:[],
positive:[],
positiveActive:0,
negativeData:[],
negative:[],
negativeActive:0,
},
lifetimes: {
attached() {
3 years ago
let brandRatioTime = wx.getStorageSync('brandRatioTime') || 34
let sBrand = wx.getStorageSync('sBrand')
this.setData({
boxArr: wx.getStorageSync('modelsData')
})
let SeriesName = []
this.data.boxArr.forEach((ele) => {
if (ele) SeriesName.push(ele.name)
})
//论坛信息
app.globalData.request({
action: 'getCount0528C',
sType: 'BbsBrand',
iContrastType: '2',
iBBsType: '1',
sBrand: sBrand.join(','),
sSeriesName: SeriesName.join(','),
token: wx.getStorageSync('token'),
...brandRatioTime,
}).then(res => {
this.setData({
bbsInfoData:res,
bbsInfo:[res[0],res[1]]
})
})
//论坛发帖趋势对比
app.globalData.request({
action: 'getCountTime0528C',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
iContrastType: '2',
iBBsType:'1',
...brandRatioTime,
sBrand: sBrand.join(','),
sSeriesName: SeriesName.join(',')
}).then(res => {
console.log(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(SeriesName, dVal, dColor, dDate),
})
})
//论坛调性对比
app.globalData.request({
action: 'getAffectionsC',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
...brandRatioTime,
iContrastType: '2',
iBBsType:'1',
sBrand: sBrand.join(','),
sSeriesName: SeriesName.join(',')
}).then(res => {
let yMsg = []
let data = [
[],
[],
[]
]
for (let i of res) {
yMsg.push(i.Name)
data[0].push(i.Data['正面'])
data[1].push(i.Data['中性'])
data[2].push(i.Data['负面'])
}
this.setData({
stackOption: stack(yMsg, data, ['#00aaff', '#20cc62', '#ff4852'])
})
})
//论坛正面话题对比
app.globalData.request({
action: 'getTopicPosAndTopicNeg0528C',
token: wx.getStorageSync('token'),
sType: 'BbsBrand',
...brandRatioTime,
iContrastType: '2',
iBBsType:'1',
sBrand: sBrand.join(','),
sSeriesName: SeriesName.join(',')
}).then(res=>{
let newRes =[]
let positive = []
let negative = []
console.log(res);
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=>{
ele.func=pictographicOption(ele.region.slice(0,5),ele.value.slice(0,5),ele.sum)
return ele
})
negative = negative.map(ele=>{
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
console.log(obj[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
console.log(obj[index]);
this.setData({
bbsInfoAction: index,
bbsInfo: obj[index]
})
},
}
})