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','#FFBF00', '#FF6E25', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'] Component({ data: { imageUrl: getApp().globalData.imageUrl, showChart: true, transformOption: brokenLines([], [], [], []), brandOption: histogram([], [], [], '#0084FF'), brandOption2: histogram([], [], [], '#20cc62'), brandOption3: multipleColumn([], [], [],dColor), brandOption4: sHistogram(), boxArr: new Array(6), topActive: 0, //品牌传播 brandTop: [], brandTopData: [], cloudActive: 0, //词云 evalOption:negaposiOption([],[]), positiveWord:[], negativeWord:[], negativeWordActive:0, positiveWordActive:0, positive:[], negative:[], wdCloudPos: [], wdCloudNeg: [], word: ['一','二','三','四','五','六'], }, 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: app.globalData.getStorage('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: app.globalData.getStorage('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: app.globalData.getStorage('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: app.globalData.getStorage('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: app.globalData.getStorage('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,dColor), }) }) //重点媒体 app.globalData.request({ action: 'getSourceCount0528C', token: app.globalData.getStorage('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, dColor) }) }) //品牌传播TOP媒体 app.globalData.request({ action: 'getSourceTopCount0528C', token: app.globalData.getStorage('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: app.globalData.getStorage('token'), sType:'BrandOverview', ...brandRatioTime, iContrastType: '4', sGuid: sGuid.join(',') }).then(res=>{ let positiveArr = []; let negativeArr = []; res.forEach(ele => { let positiveList = ele.value[0].value; let negativeList = ele.value[1].value; let objPos = { name: ele.key, list: positiveList }; let objNeg = { name: ele.key, list: negativeList }; positiveArr.push(objPos); negativeArr.push(objNeg); }); this.setData({ wdCloudPos: positiveArr, wdCloudNeg: negativeArr }) }) }, }, 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 }) }, changePositive(event) { let index = event.detail.index this.setData({ positiveWordActive: index }) }, } })