From 72deeebb1d61d40f532db49629edae378c84a81b Mon Sep 17 00:00:00 2001 From: Esdese <2114339600@qq.com> Date: Fri, 5 Aug 2022 14:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=AF=94=E6=97=B6=E9=97=B4=E8=BD=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/varComm/pages/brandRatio/index.js | 12 + pages/varComm/pages/brandRatio/index.json | 3 +- pages/varComm/pages/brandRatio/index.wxml | 4 +- pages/varComm/pages/brandRatio/index.wxss | 40 ++- .../varComm/pages/brandRatio/survey/index.js | 249 +++++++++--------- 5 files changed, 183 insertions(+), 125 deletions(-) diff --git a/pages/varComm/pages/brandRatio/index.js b/pages/varComm/pages/brandRatio/index.js index 342dfd6..2a0c8c8 100644 --- a/pages/varComm/pages/brandRatio/index.js +++ b/pages/varComm/pages/brandRatio/index.js @@ -7,6 +7,7 @@ Page({ data: { boxArr:new Array(6), tabActive:0, + sonCom:true }, /** @@ -16,11 +17,22 @@ Page({ this.setData({ boxArr:wx.getStorageSync('brandData') }) + wx.setStorageSync('brandRatioTime', {sTimeType:'1'}) }, changeTab(val) { let n = val.detail.index; this.setData({ tabActive: n }) + }, + changeTime(event){ + let {detail} = event + wx.setStorageSync('brandRatioTime', detail) + this.setData({ + sonCom:false + }) + this.setData({ + sonCom:true + }) } }) \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.json b/pages/varComm/pages/brandRatio/index.json index 8b5425e..2571870 100644 --- a/pages/varComm/pages/brandRatio/index.json +++ b/pages/varComm/pages/brandRatio/index.json @@ -1,7 +1,8 @@ { "usingComponents": { "time-component":"/components/timecomponent/index", + "time-custom": "../../../../components/timeCustom/index", "survey":"./survey/index" }, "navigationBarTitleText": "品牌对比" -} \ No newline at end of file +} diff --git a/pages/varComm/pages/brandRatio/index.wxml b/pages/varComm/pages/brandRatio/index.wxml index 86350ec..cd24fb5 100644 --- a/pages/varComm/pages/brandRatio/index.wxml +++ b/pages/varComm/pages/brandRatio/index.wxml @@ -1,6 +1,6 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/pages/varComm/pages/brandRatio/index.wxss b/pages/varComm/pages/brandRatio/index.wxss index 84035a6..7499a25 100644 --- a/pages/varComm/pages/brandRatio/index.wxss +++ b/pages/varComm/pages/brandRatio/index.wxss @@ -151,4 +151,42 @@ page { } .view-tabs .van-tabs__line { background: transparent; - } \ No newline at end of file + } + .timelist { + width: 670rpx; + height: 80rpx; + line-height: 80rpx; + margin:0 auto; + display: flex; + flex-wrap: nowrap; + background: white; + justify-content:space-between; + padding-left: 8rpx; + padding-right: 8rpx; + margin-top: 32rpx; + border-radius: 8rpx; +} + +.timelist view { + text-align: center; + color: #999999; + font-size: 24rpx; + width: 166rpx; +} + +.timelist .active { + color: #027AFF; + background-color: #f9f9f9; + font-weight: bolder; + width: 166rpx; + height: 64rpx; + line-height: 64rpx; + margin-top: 8rpx; + border-radius: 4rpx; +} +.tc-d-t { + font-size: 14px; + padding: 15px 0px; + color: #909497; + text-align: center; +} \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/survey/index.js b/pages/varComm/pages/brandRatio/survey/index.js index fc9e696..b69b0c6 100644 --- a/pages/varComm/pages/brandRatio/survey/index.js +++ b/pages/varComm/pages/brandRatio/survey/index.js @@ -1,142 +1,152 @@ 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 stack from "../../../../../components/option/stackedBarChart" +import multipleColumn from "../../../../../components/option/multipleColumn" import sHistogram from "../../../../../components/option/sColumnarOption" const app = getApp() -const dColor=['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF'] +const dColor = ['#FF4852', '#FF6E25', '#FFBF00', '#20CC62', '#00D6D6', '#00AAFF', '#7257FF'] Component({ - data:{ + 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:[], - cloudActive:0, //词云 - positiveWord:[], - negativeWord:[],//负面 + 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: [], + cloudActive: 0, //词云 + positiveWord: [], + negativeWord: [], //负面 }, - lifetimes:{ + lifetimes: { attached() { + let brandRatioTime = wx.getStorageSync('brandRatioTime') this.setData({ - boxArr:wx.getStorageSync('brandData') - }) - let sBrand = [] - this.data.boxArr.forEach((ele)=>{ - if(ele) sBrand.push(ele.brandname) - }) + boxArr: wx.getStorageSync('brandData') + }) + let sBrand = [] + this.data.boxArr.forEach((ele) => { + if (ele) sBrand.push(ele.brandname) + }) //信息量趋势数据 app.globalData.request({ action: 'getCountTime0528C', - sType:'BrandOverview', + sType: 'BrandOverview', token: wx.getStorageSync('token'), - sTimeType:'34', - iContrastType:'1', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let dtime = [] let dVal = [] let dataObj = {} - for(let i of res){ + 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)){ + 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) + } + dataObj[j.key].push(obj) } } - Object.keys(dataObj).forEach(ele=>{ + Object.keys(dataObj).forEach(ele => { dVal.push(dataObj[ele]) - }) + }) this.setData({ - transformOption: brokenLines(sBrand,dVal,dColor,dtime), + transformOption: brokenLines(sBrand, dVal, dColor, dtime), }) }) //整体信息量 app.globalData.request({ action: 'getContrastCount0528C', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let dx = [] let dy = [] - for(let i of res){ + for (let i of res) { dx.push(i.key) dy.push(i.value) } this.setData({ - brandOption: histogram(dx,dy,[],'#0084FF'), + brandOption: histogram(dx, dy, [], '#0084FF'), }) }) //整体互动人数 app.globalData.request({ action: 'getInteractCount0528C', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let dx = [] let dy = [] - for(let i of res){ + for (let i of res) { dx.push(i.key) dy.push(i.value) } this.setData({ - brandOption2: histogram(dx,dy,[],'#20cc62'), + brandOption2: histogram(dx, dy, [], '#20cc62'), }) }) //品牌条形对比 app.globalData.request({ action: 'getAffectionsC', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let yMsg = [] - let data = [[],[],[]] - for(let i of res){ + 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']) + stackOption: stack(yMsg, data, ['#00aaff', '#20cc62', '#ff4852']) }) }) //渠道分布 app.globalData.request({ action: 'getSourcetypeC', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let arr = [] let channelMsg = [] - for(let i of res){ - let obj = {name:i.Name} + for (let i of res) { + let obj = { + name: i.Name + } let da = [] - Object.keys(i.Data).forEach(ele=>{ + Object.keys(i.Data).forEach(ele => { da.push(i.Data[ele]) channelMsg.push(ele) }) @@ -145,98 +155,97 @@ Component({ } channelMsg = [...new Set(channelMsg)] this.setData({ - brandOption3:multipleColumn(sBrand,channelMsg,arr), + brandOption3: multipleColumn(sBrand, channelMsg, arr), }) }) //品牌事件对比 app.globalData.request({ action: 'getSourcetypeC', - sType:'HotEvent0528', + sType: 'HotEvent0528', token: wx.getStorageSync('token'), - sTimeType:'34', - iContrastType:'1', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - },'http://cloud.sws010.com/api/v7.ashx').then(res=>{ - console.log(res); + }, 'http://cloud.sws010.com/api/v7.ashx').then(res => { let channelMsg = [] let dataArr = [] - for(let [index,i] of res.entries()){ - if(index==0){ + 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=>{ + obj.data = Object.keys(i.Data).map(ele => { return i.Data[ele] }) dataArr.push(obj) } this.setData({ - brandOption5:multipleColumn(sBrand,channelMsg,dataArr), + brandOption5: multipleColumn(sBrand, channelMsg, dataArr), }) }) //重点媒体 app.globalData.request({ action: 'getSourceCount0528C', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let xMsg = [] - for(let i of res[0].value){ + for (let i of res[0].value) { xMsg.push(i.key) - } + } let data = new Array(res.length).fill([]) - for(let [index,i] of res.entries()){ - for(let j of i.value){ - data[index].push(j.value) + for (let [index, i] of res.entries()) { + for (let j of i.value) { + data[index].push(j.value) } } //横轴,数据,纵轴 this.setData({ - brandOption4:sHistogram(xMsg,data,sBrand,[]) + brandOption4: sHistogram(xMsg, data, sBrand, []) }) }) //品牌传播TOP媒体 app.globalData.request({ action: 'getSourceTopCount0528C', token: wx.getStorageSync('token'), - sType:'BrandOverview', - sTimeType:'34', - iContrastType:'1', + sType: 'BrandOverview', + ...brandRatioTime, + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { this.setData({ - brandTop:[res[0],res[1]], - brandTopData:res + brandTop: [res[0], res[1]], + brandTopData: res }) }) //销量对比 app.globalData.request({ action: 'getCheZhuCountTimeC', token: wx.getStorageSync('token'), - sType:'Marketing1C', - iContrastType:'1', + sType: 'Marketing1C', + iContrastType: '1', sBrand: sBrand.join(',') - }).then(res=>{ + }).then(res => { let dDate = [] let dVal = new Array(res.Data[0].value.length).fill([]) - dVal = dVal.map(ele=>{ + dVal = dVal.map(ele => { ele = JSON.stringify(ele) ele = JSON.parse(ele) return ele }) - for(let i of res.Data){ + for (let i of res.Data) { dDate.push(i.key) - for(let [index,j] of i.value.entries()){ + for (let [index, j] of i.value.entries()) { dVal[index].push(j) } } this.setData({ - salesDate:res.Time, - transformOption2: brokenLines(sBrand,dVal,dColor,dDate), + salesDate: res.Time, + transformOption2: brokenLines(sBrand, dVal, dColor, dDate), }) }) //正负词云 @@ -273,29 +282,27 @@ Component({ // positiveWord, // negativeWord // }) - + // }) - }, - -}, -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 - console.log(index); + }, - this.setData({ - topActive: index, - brandTop:obj[index] - }) - }, - changeModalHot2(event) { - }, -} + 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] + }) + }, + changeModalHot2(event) { + + }, + } }) \ No newline at end of file