import brokenLines from "../../../components/option/stackingLineOption" import histogram from "../../../components/option/singleColumnarOption" import stack from "../../../components/option/stackedBarChart" import multipleColumn from "../../../components/option/multipleColumn" import sHistogram from "../../../components/option/sColumnarOption" const app = getApp() const dColor = ['#FF4852','#FFBF00', '#FF6E25', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'] Component({ data: { imageUrl: getApp().globalData.imageUrl, showChart: true, transformOption: brokenLines([], [], [], []), transformOption2: brokenLines([], [], [], []), brandOption: histogram([], [], [], '#0084FF'), brandOption2: histogram([], [], [], '#20cc62'), brandOption3: multipleColumn([], [], []), brandOption4: sHistogram(), brandOption5: multipleColumn([], [], []), stackOption: stack([], [], ['#00aaff', '#20cc62', '#ff4852']), boxArr: new Array(6), topActive: 0, //品牌传播 brandTop: [], brandTopData: [], negativeWordActive: 0, //词云 positiveWordActive: 0, //词云 positiveWord: [], positive:[], negative:[], negativeWord: [], //负面 wdCloudPos: [], wdCloudNeg: [], }, lifetimes: { attached() { 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: 'getCountTime0528C', sType: 'BrandOverview', token: app.globalData.getStorage('token'), ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.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(SeriesName, dVal, dColor, dtime), }) }) //整体信息量 app.globalData.request({ action: 'getContrastCount0528C', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }).then(res => { let dx = [] let dy = [] for (let i of res) { dx.push(i.key) dy.push(i.value) } this.setData({ brandOption: histogram(dx, dy, [], '#0084FF'), }) }) //整体互动人数 app.globalData.request({ action: 'getInteractCount0528C', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }).then(res => { let dx = [] let dy = [] for (let i of res) { dx.push(i.key) dy.push(i.value) } this.setData({ brandOption2: histogram(dx, dy, [], '#20cc62'), }) }) //品牌条形对比 app.globalData.request({ action: 'getAffectionsC', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', 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: 'getSourcetypeC', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }).then(res => { let arr = [] let channelMsg = [] for (let i of res) { let obj = { name: i.Name } 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(SeriesName, channelMsg, arr), }) }) //品牌事件对比 app.globalData.request({ action: 'getSourcetypeC', sType: 'HotEvent0528', token: app.globalData.getStorage('token'), ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }, 'http://cloud.sws010.com/api/v7.ashx').then(res => { let channelMsg = [] let dataArr = [] for (let [index, i] of res.entries()) { if (index == 0) { channelMsg = Object.keys(i.Data) } let obj = {} obj.name = i.Name obj.data = Object.keys(i.Data).map(ele => { return i.Data[ele] }) dataArr.push(obj) } this.setData({ brandOption5: multipleColumn(SeriesName, channelMsg, dataArr), }) }) //重点媒体 app.globalData.request({ action: 'getSourceCount0528C', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.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, SeriesName, dColor) }) }) //品牌传播TOP媒体 app.globalData.request({ action: 'getSourceTopCount0528C', token: app.globalData.getStorage('token'), sType: 'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }).then(res => { this.setData({ brandTop: [res[0], res[1]], brandTopData: res }) }) //销量对比 app.globalData.request({ action: 'getCheZhuCountTimeC', token: app.globalData.getStorage('token'), sType: 'Marketing1C', iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.join(',') }).then(res => { let dDate = [] let dVal = new Array(res.Data[0].value.length).fill([]) dVal = dVal.map(ele => { ele = JSON.stringify(ele) ele = JSON.parse(ele) return ele }) for (let i of res.Data) { dDate.push(i.key) for (let [index, j] of i.value.entries()) { dVal[index].push(j) } } this.setData({ salesDate: res.Time, transformOption2: brokenLines(SeriesName, dVal, dColor, dDate), }) }) // 正负词云 app.globalData.request({ action: 'getPositiveAndNegative0528C', token: app.globalData.getStorage('token'), sType:'BrandOverview', ...brandRatioTime, iContrastType: '2', sBrand:sBrand.join(','), sSeriesName: SeriesName.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 }) }, } })