From f7f2ea583399859eb19b66d1c8bbd0fe12e64688 Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Fri, 15 Jul 2022 18:09:55 +0800 Subject: [PATCH] wyl --- components/indexCom/dataChild/index.js | 11 +-- components/indexCom/portraitChild/index.js | 96 +++++++++----------- components/indexCom/portraitChild/index.wxml | 8 +- 3 files changed, 49 insertions(+), 66 deletions(-) diff --git a/components/indexCom/dataChild/index.js b/components/indexCom/dataChild/index.js index b1c1049..b1ff8d9 100644 --- a/components/indexCom/dataChild/index.js +++ b/components/indexCom/dataChild/index.js @@ -1,16 +1,7 @@ const app = getApp(); import brokenLine from "../../option/stackingLineOption" const dName=['微博', '其他','短视频', '微信','APP', '论坛', '新闻'] -// const dValue=[ -// [250, 326, 178, 349, 900, 1300, 140,], -// [200, 382, 661, 34, 909, 1308, 150], -// [20, 32, 41, 354, 90, 130, 10], -// [210, 322, 551, 364, 960, 1307, 10], -// [1520, 1052, 141, 174, 1690, 250, 220], -// [1400, 2000, 1500, 1800, 1490, 900, 310], -// [25, 167, 564, 256, 1009, 2000, 140]] const dColor=['#FF4852','#FF6E25','#FFBF00','#20CC62','#00D6D6','#00AAFF','#7257FF'] - // const dx=['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '24:00'] Component({ data: { // totallist:totallist, @@ -77,7 +68,7 @@ Component({ }) }) - }, + }, // 入库数据量 getAmount(sTimeType, sStartTime, sEndTime){ diff --git a/components/indexCom/portraitChild/index.js b/components/indexCom/portraitChild/index.js index e5136ee..ed98871 100644 --- a/components/indexCom/portraitChild/index.js +++ b/components/indexCom/portraitChild/index.js @@ -2,64 +2,56 @@ import pieOption from '../../option/pieOption' import pictographicOption from '../../option/pictographicOption' const color=['#0084FF','#20CC62','#FFBF00'] const dataList=[ - { value: 1650245, name: "女性",color:'#0084FF'}, - { value: 1650245, name: "未知" ,color:'#20CC62'}, - { value: 3307418, name: "男性" ,color:'#FFBF00'}, + { name: "女性",color:'#0084FF'}, + { name: "未知" ,color:'#20CC62'}, + { name: "男性" ,color:'#FFBF00'}, ] -const dRegion=['四川', '广东', '浙江', '北京','江西',] -const dValue=[100, 40, 66, 10,30] + +const app = getApp() Component({ data: { - dataList:dataList, - // regionList:[ - // { - // district:'广东', - // value:10 - // }, - // { - // district:'河南', - // value:10 - // }, - // { - // district:'江苏', - // value:10 - // }, - // { - // district:'浙江', - // value:10 - // }, - // { - // district:'安徽', - // value:10 - // }, - // { - // district:'安徽', - // value:10 - // }, - // { - // district:'安徽', - // value:10 - // },{ - // district:'安徽', - // value:10 - // }, - // { - // district:'安徽', - // value:10 - // },{ - // district:'安徽', - // value:10 - // }, - // ], + showChart: true, - sexOption: pieOption(color,dataList), - regionOption:pictographicOption(dRegion,dValue), - }, - onShow() { - this.getTabBar().init(); - + // sexOption: pieOption(color,dataList), + // regionOption:pictographicOption(dRegion,dValue), }, + lifetimes:{ + attached(){ + app.globalData.request({action: 'getSexOrAttestationOrRegionHome0528',sType:'Home' ,sTimeType: 34}).then(res => { + const sex=res.sex + const attestation=res.attestation + const sexList=[] + const attestationList=[] + let sexSum=0 + let attestationSum=0 + const sexAccounted=[] + const attestationAccounted=[] + const region=[] + // res.forEach(ele => { + // }) + for(let i=0;i<3;i++){ + sexSum+=sex[i].value + attestationSum+=attestation[i].value + } + for(let i=0;i<3;i++){ + sexAccounted.push(Math.round((sex[i].value/sexSum)*100)) + attestationAccounted.push(Math.round((sex[i].value/attestationSum)*100)) + sexList.push({name:sex[i].key,value:sex[i].value,color:color[i],accounted:sexAccounted[i]}) + attestationList.push({name:attestation[i].key,value:attestation[i].value,color:color[i],accounted:attestationAccounted[i]}) + } + console.log(sexList) + console.log(attestationList) + this.setData({ + sexList:sexList, + attestationList:attestationList, + sexOption:pieOption(color,sex), + attestationOption:pieOption(color,attestation) + // regionOption:pictographicOption(dRegion,dValue), + }) + }) + } + }, methods: { priceSel(e){ diff --git a/components/indexCom/portraitChild/index.wxml b/components/indexCom/portraitChild/index.wxml index 3e02b1c..a0451eb 100644 --- a/components/indexCom/portraitChild/index.wxml +++ b/components/indexCom/portraitChild/index.wxml @@ -9,7 +9,7 @@ - + {{item.name}} @@ -20,7 +20,7 @@ 占比 - 32% + {{item.accounted}}% @@ -35,7 +35,7 @@ - + {{item.name}} @@ -46,7 +46,7 @@ 占比 - 32% + {{item.accounted}}%