Commit 8e58180b by 杨明

物业

1 parent bea87d16
...@@ -132,7 +132,15 @@ class outputApi { ...@@ -132,7 +132,15 @@ class outputApi {
...data ...data
}) })
} }
//客户画像展示
portraitView(data) {
return api.post({
method: 'entmicro.api.customer.portrait.view',
apiProjectName: 'entmicro',
...data
})
}
// 我的员工 // 我的员工
/** 服务商查询园区店员工产值统计 */ /** 服务商查询园区店员工产值统计 */
getStaffList(data) { getStaffList(data) {
......
// custom-tab-bar/index.js // custom-tab-bar/index.js
import {
wyMerchantId
} from '~/utils/request/environment'
Component({ Component({
options:{ options:{
styleIsolation:'shared' styleIsolation:'shared'
...@@ -26,6 +29,15 @@ Component({ ...@@ -26,6 +29,15 @@ Component({
} }
] ]
}, },
lifetimes: {
attached() {
if (wyMerchantId.includes(wx.$storage.get('userInfo').merchantId)) {
const {list} = this.data
list.splice(1,1)
this.setData({list})
}
}
},
methods: { methods: {
onChange(event) { onChange(event) {
const {list} = this.data const {list} = this.data
......
...@@ -83,9 +83,9 @@ Page({ ...@@ -83,9 +83,9 @@ Page({
onShow: function (){ onShow: function (){
if (typeof this.getTabBar === 'function' ) { if (typeof this.getTabBar === 'function' ) {
this.getTabBar((tabBar) => { this.getTabBar((tabBar) => {
console.log(tabBar) const len = tabBar.data.list.length
tabBar.setData({ tabBar.setData({
active: 2 active: len - 1
}) })
}) })
} }
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
<block wx:if="{{isShow}}"> <block wx:if="{{isShow}}">
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">看产值</navigation-bar> <navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">看产值</navigation-bar>
<view class="layout" wx:if="{{isWy}}">
<!-- <view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)">
<client id="client" />
</view> -->
<view class="layout">
<scroll-view class="stat-scroll" scroll-y="true" style="padding-top:{{navHeight}}px; height: calc(100vh - 360rpx)"> <scroll-view class="stat-scroll" scroll-y="true" style="padding-top:{{navHeight}}px; height: calc(100vh - 360rpx)">
<stat></stat> <stat></stat>
</scroll-view> </scroll-view>
</view> </view>
<view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)" wx:else>
<client id="client" />
</view>
</block> </block>
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,9 @@ Component({ ...@@ -4,7 +4,9 @@ Component({
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
viewCustomerPortrait: {
type: Object
}
}, },
/** /**
...@@ -13,28 +15,28 @@ Component({ ...@@ -13,28 +15,28 @@ Component({
data: { data: {
outputValue: [{ outputValue: [{
label: '订单总数(单)', label: '订单总数(单)',
name: 'quotationCount', name: 'ordersTotal ',
unit: '', unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png' iconUrl:'store-assistant-assemble/output/icon02.png'
}, { }, {
label: '总产值(元)', label: '总产值(元)',
name: 'outputValue', name: 'produceValueTotal',
_unit: '¥', _unit: '¥',
iconUrl:'store-assistant-assemble/output/icon05.png' iconUrl:'store-assistant-assemble/output/icon05.png'
}], }],
todayValue: [{ todayValue: [{
label: '加微客户(人)', label: '加微客户(人)',
name: 'quotationCount', name: 'todayAddEntmicroCount',
unit: '', unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png' iconUrl:'store-assistant-assemble/output/icon02.png'
}, { }, {
label: '订单数(单)', label: '订单数(单)',
name: 'successCount', name: 'todayOrdersTotal',
unit: '', unit: '',
iconUrl:'store-assistant-assemble/output/icon07.png' iconUrl:'store-assistant-assemble/output/icon07.png'
}, { }, {
label: '产值(元)', label: '产值(元)',
name: 'outputValue', name: 'todayProduceValueTotal',
_unit: '¥', _unit: '¥',
iconUrl:'store-assistant-assemble/output/icon05.png' iconUrl:'store-assistant-assemble/output/icon05.png'
}] }]
......
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
<view class="item"> <view class="item">
<view class="label">住户总数(人)</view> <view class="label">住户总数(人)</view>
<veiw class="number"> <veiw class="number">
{{outputData['orderMoneyTotal'] ||0}} {{viewCustomerPortrait['householdTotal'] ||0}}
</veiw> </veiw>
</view> </view>
<view class="item"> <view class="item">
<view class="label">加微客户(人)</view> <view class="label">加微客户(人)</view>
<veiw class="number"> <veiw class="number">
{{outputData['sendCouponTotal'] ||0}} {{viewCustomerPortrait['addEntmicroCount'] ||0}}
</veiw> </veiw>
</view> </view>
<view class="item"> <view class="item">
<view class="label">加微率</view> <view class="label">加微率</view>
<veiw class="number"> <veiw class="number">
{{outputData['sendCouponTotal'] ||0}} <text>%</text> {{viewCustomerPortrait['addEntmicroRatio'] ||0}} <text>%</text>
</veiw> </veiw>
</view> </view>
</view> </view>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<view class="label">{{item.label}}</view> <view class="label">{{item.label}}</view>
<glsx-image src="{{item.iconUrl}}" class="icon" /> <glsx-image src="{{item.iconUrl}}" class="icon" />
</view> </view>
<view class="output-num"><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view> <view class="output-num"><text class="_unit">{{item._unit}}</text> {{viewCustomerPortrait[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
</view> </view>
</view> </view>
</view> </view>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<view class="label">{{item.label}}</view> <view class="label">{{item.label}}</view>
<glsx-image src="{{item.iconUrl}}" class="icon" /> <glsx-image src="{{item.iconUrl}}" class="icon" />
</view> </view>
<view class="output-num"><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view> <view class="output-num"><text class="_unit">{{item._unit}}</text> {{viewCustomerPortrait[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js // pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
// 组件中使用 require方法导入需要的behavior模块
const view = require('../view.js')
Component({
behaviors: [view],
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
childrenList: [
{color: '#5D9BF1',label: '燃油车:',value: 12},
{color: '#5CF0D8',label: '新能源车:',value: 23},
]
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
getRatio() { getRatio(obj) {
const ratioList = [ const {
{color: '#5D9BF1',label: '燃油车:',value: 12}, vehicleDistribution
{color: '#5CF0D8',label: '新能源车:',value: 23}, } = obj
] this.setRatio('vehicleDistribution', vehicleDistribution,['#5D9BF1', '#5CF0D8', '#5CF0D8'])
this.setData({
ratioList
})
} }
} }
}) })
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<view class="box-body"> <view class="box-body">
<circle class="children-box" width="200" Id="car779" ratioList="{{ratioList}}"></circle> <circle class="children-box" width="200" Id="car779" ratioList="{{ratioList}}"></circle>
<view class="children-box"> <view class="children-box">
<view class="children-item" wx:for="{{childrenList}}"> <view class="children-item" wx:for="{{vehicleDistribution}}">
<view class="icon" style="background: {{item.color}};"></view> <view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view> <view class="text">{{item.name}}:{{item.value}}%</view>
</view> </view>
</view> </view>
......
...@@ -44,7 +44,7 @@ Component({ ...@@ -44,7 +44,7 @@ Component({
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
const data = this.data.ratioList.map(i=>{ const data = this.data.ratioList.map(i=>{
return { return {
"labelShow": false, "labelShow": true,
"value": i.value, "value": i.value,
} }
}) })
...@@ -79,7 +79,7 @@ Component({ ...@@ -79,7 +79,7 @@ Component({
background: "#FFFFFF", background: "#FFFFFF",
color, color,
padding: [5, 5, 5, 5], padding: [5, 5, 5, 5],
dataLabel: false, dataLabel: true,
enableScroll: false, enableScroll: false,
legend: { legend: {
show: false show: false
......
// pages/tab/stat/components/lodge/lodge.js // pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
// 组件中使用 require方法导入需要的behavior模块
const view = require('../view.js')
Component({
behaviors: [view],
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
childrenList: [
{color: '#3582EE',label: '中消费力:',value: 20},
{color: '#F9CEF7',label: '高消费力:',value: '20'},
{color: '#5CF0D8',label: '低消费力:',value: '20'}
]
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
getRatio() { getRatio(obj) {
const ratioList = [ const {
{color: '#3582EE',label: '中消费力:',value: 20}, consumeDistribution
{color: '#F9CEF7',label: '高消费力:',value: 20}, } = obj
{color: '#5CF0D8',label: '低消费力:',value: 20} this.setRatio('consumeDistribution', consumeDistribution,['#3582EE', '#F9CEF7', '#5CF0D8'])
]
this.setData({
ratioList
})
} }
} }
}) })
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<view class="box-body"> <view class="box-body">
<circle class="children-box" width="200" Id="com3479" ratioList="{{ratioList}}"></circle> <circle class="children-box" width="200" Id="com3479" ratioList="{{ratioList}}"></circle>
<view class="children-box"> <view class="children-box">
<view class="children-item" wx:for="{{childrenList}}"> <view class="children-item" wx:for="{{consumeDistribution}}">
<view class="icon" style="background: {{item.color}};"></view> <view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view> <view class="text">{{item.name}}:{{item.value}}%</view>
</view> </view>
</view> </view>
......
//index.js //index.js
//注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本! //注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本!
import uCharts from '../../../../../utils/u-charts/u-charts.js'; import uCharts from '../../../../../utils/u-charts/u-charts.js';
const view = require('../view.js')
var uChartsInstance = {}; var uChartsInstance = {};
Component({ Component({
data: { behaviors: [view],
cWidth: 750, data: {
cHeight: 500, cWidth: 750,
pixelRatio: 2, cHeight: 500,
pixelRatio: 2,
},
methods: {
setRatio() {
//这里的第一个 750 对应 css .charts 的 width
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height
const cHeight = 500 / 750 * wx.getSystemInfoSync().windowWidth;
const pixelRatio = wx.getSystemInfoSync().pixelRatio;
this.setData({
cWidth,
cHeight,
pixelRatio
});
this.getServerData();
}, },
attached() { getServerData() {
//这里的第一个 750 对应 css .charts 的 width const {viewCustomerPortrait:{productDistribution }} = this.data,
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth; categories = productDistribution.map(i=>i.name),
//这里的 500 对应 css .charts 的 height data = productDistribution.map((i,k)=>{
const cHeight = 500 / 750 * wx.getSystemInfoSync().windowWidth; return {
const pixelRatio = wx.getSystemInfoSync().pixelRatio; value: i.value,
this.setData({ color: k%2 == 0?'#3582EE':'#5CF0D8'
cWidth, }
cHeight, })
pixelRatio let res = {
}); categories,
this.getServerData(); series: [{
name: "目标值",
textColor: '#A6A6A6',
data
}, ]
};
this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res);
}, },
methods: { drawCharts(id, data) {
getServerData() { const query = wx.createSelectorQuery().in(this);
//模拟从服务器获取数据时的延时 query.select('#' + id).fields({
setTimeout(() => { node: true,
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 size: true
let res = { }).exec(res => {
categories: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], if (res[0]) {
series: [{ console.log(res[0])
name: "目标值", const canvas = res[0].node;
textColor: '#A6A6A6', const ctx = canvas.getContext('2d');
data: [{ canvas.width = res[0].width * this.data.pixelRatio;
value: 15, canvas.height = res[0].height * this.data.pixelRatio;
color: '#3582EE' uChartsInstance[id] = new uCharts({
}, { animation: true,
value: 25, background: "#FFFFFF",
color: '#5CF0D8' canvas2d: true,
}] categories: data.categories,
}, ] color: ["#3582EE"],
}; context: ctx,
this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res); extra: {
}, 500); tooltip: {
}, showBox: false
drawCharts(id, data) { },
const query = wx.createSelectorQuery().in(this); column: {
query.select('#' + id).fields({ type: "group",
node: true, width: 15,
size: true activeBgColor: "#000000",
}).exec(res => { }
if (res[0]) { },
console.log(res[0]) height: this.data.cHeight * this.data.pixelRatio,
const canvas = res[0].node; legend: {
const ctx = canvas.getContext('2d'); show: false,
canvas.width = res[0].width * this.data.pixelRatio; },
canvas.height = res[0].height * this.data.pixelRatio; padding: [15, 15, 0, 5],
uChartsInstance[id] = new uCharts({ pixelRatio: this.data.pixelRatio,
animation: true, series: data.series,
background: "#FFFFFF", type: "column",
canvas2d: true, width: this.data.cWidth * this.data.pixelRatio,
categories: data.categories, xAxis: {
color: ["#3582EE"], disableGrid: true,
context: ctx, axisLineColor: '#fff',
extra: { fontColor: '#A6A6A6',
tooltip: { fontSize: '10'
showBox:false },
}, yAxis: {
column: { disableGrid: true,
type: "group", fontColor: '#A6A6A6',
width: 15, data: [{
activeBgColor: "#000000", axisLine: false,
} fontColor: '#A6A6A6',
}, min: 0
height: this.data.cHeight * this.data.pixelRatio, }]
legend: { }
show: false, });
}, } else {
padding: [15, 15, 0, 5], console.error("[uCharts]: 未获取到 context");
pixelRatio: this.data.pixelRatio,
series: data.series,
type: "column",
width: this.data.cWidth * this.data.pixelRatio,
xAxis: {
disableGrid: true,
axisLineColor: '#fff',
fontColor: '#A6A6A6'
},
yAxis: {
disableGrid: true,
fontColor: '#A6A6A6',
data: [{
axisLine: false,
fontColor: '#A6A6A6',
min: 0
}]
}
});
} else {
console.error("[uCharts]: 未获取到 context");
}
});
},
tap(e) {
uChartsInstance[e.target.id].touchLegend(e);
uChartsInstance[e.target.id].showToolTip(e);
} }
});
} }
}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
<view class="box-title">甄选商品偏好(top10)<text>单位:人</text></view> <view class="box-title">甄选商品偏好(top10)<text>单位:人</text></view>
<view class="chart-title">单位:人</view> <view class="chart-title">单位:人</view>
<view class="charts"> <view class="charts">
<canvas canvas-id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" type="2d" class="charts" bindtouchend="tap" /> <canvas canvas-id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" type="2d" class="charts"/>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js // pages/tab/stat/components/lodge/lodge.js
const view = require('../view.js')
Component({ Component({
/** behaviors: [view],
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
childrenList: [
{color: '#5D9BF1',label: '管家添加:',value: 20},
{color: '#5CF0D8',label: '系统添加:',value: '20%'},
]
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
getRatio() { getRatio(obj) {
const ratioList = [ const {
{color: '#5D9BF1',label: '管家添加:',value: 12}, sourceDistribution
{color: '#5CF0D8',label: '系统添加:',value: 23}, } = obj
] this.setRatio('sourceDistribution', sourceDistribution,['#5D9BF1', '#5CF0D8'])
this.setData({
ratioList
})
} }
} }
}) })
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<view class="box-title">客户来源</view> <view class="box-title">客户来源</view>
<view class="box-body"> <view class="box-body">
<view class="children-box"> <view class="children-box">
<view class="children-item" wx:for="{{childrenList}}"> <view class="children-item" wx:for="{{sourceDistribution}}">
<view class="icon" style="background: {{item.color}};"></view> <view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view> <view class="text">{{item.name}}:{{item.value}}%</view>
</view> </view>
</view> </view>
......
// pages/tab/stat/components/lodge/lodge.js // pages/tab/stat/components/lodge/lodge.js
const view = require('../view.js')
Component({ Component({
/** behaviors: [view],
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
childrenList: [
{color: '#F9CEF7',label: '自住:',value: 20},
{color: '#5CF0D8',label: '租房:',value: '20%'},
]
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
getRatio() { getRatio(n) {
const ratioList = [ const {lodgeDistribution} = n
{color: '#F9CEF7',label: '自住:',value: 12}, this.setRatio('lodgeDistribution', lodgeDistribution,['#F9CEF7', '#5CF0D8'])
{color: '#5CF0D8',label: '租房:',value: 23},
]
this.setData({
ratioList
})
} }
} }
}) })
<view class="box"> <view class="box">
<view class="box-title">租住比</view> <view class="box-title">/租住比</view>
<view class="box-body"> <view class="box-body">
<view class="children-box"> <view class="children-box">
<view class="children-item" wx:for="{{childrenList}}"> <view class="children-item" wx:for="{{lodgeDistribution}}">
<view class="icon" style="background: {{item.color}};"></view> <view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view> <view class="text">{{item.name}}:{{item.value}}%</view>
</view> </view>
</view> </view>
......
// pages/tab/stat/components/portrait/portrait.js // pages/tab/stat/components/portrait/portrait.js
const view = require('../view.js')
Component({ Component({
/** behaviors: [view],
* 组件的属性列表
*/
properties: {
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
ageList: [{
age: '<20岁',
ratio: '4'
},{
age: '20-30岁',
ratio: '10'
},{
age: '30-40岁',
ratio: '20'
}],
timeList: [{
time: '50年代',
ratio: '4'
},{
time: '60年代',
ratio: '10'
},{
time: '70年代',
ratio: '20'
}],
sexData: { sexData: {
boy:100, boy: 100,
girl:0 girl: 0
}, },
childrenList: [
{color: '#F9CEF7',label: '无小孩:',value: '20%'},
{color: '#3582EE',label: '无小孩:',value: '20%'},
{color: '#5CF0D8',label: '无小孩:',value: '20%'},
{color: '#FCEE8D',label: '无小孩:',value: '20%'}
]
},
lifetimes: {
attached() {
this.getRatio()
}
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
getRatio() { getRatio(obj) {
const ratioList = [ const {
{color: '#F9CEF7',label: '无小孩:',value: 20}, ageDistribution,
{color: '#3582EE',label: '无小孩:',value: 20}, eraDistribution,
{color: '#5CF0D8',label: '无小孩:',value: 20}, childDistribution,
{color: '#FCEE8D',label: '无小孩:',value: 20} sexDistribution
] } = obj;
this.setData({ this.setRatio('sexDistribution',sexDistribution,'',true)
ratioList this.setRatio('ageDistribution', ageDistribution)
}) this.setRatio('eraDistribution', eraDistribution)
this.setRatio('childDistribution', childDistribution, ['#F9CEF7', '#3582EE', '#5CF0D8','#FCEE8D'])
} }
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
} }
.children-box { .children-box {
width: 590rpx; min-width: 590rpx;
height: 144rpx; height: 144rpx;
background-image: linear-gradient(90deg, #F3FCFC 0%, #F9FEFF 49%, #EFF7FF 100%); background-image: linear-gradient(90deg, #F3FCFC 0%, #F9FEFF 49%, #EFF7FF 100%);
border-radius: 8rpx; border-radius: 8rpx;
......
...@@ -13,44 +13,44 @@ ...@@ -13,44 +13,44 @@
</view> </view>
</view> </view>
<view class="ratio-box"> <view class="ratio-box">
<view class="ratio-item {{sexData.girl?'ratio-left':'null-left'}}" style="width: {{sexData.boy}}%" wx:if="{{sexData.boy}}"> <view class="ratio-item {{sexDistribution[0].value?'ratio-left':'null-left'}}" style="width: {{sexDistribution[0].ratio}}%" wx:if="{{sexDistribution[0].value}}">
<text>{{sexData.boy}}人</text> <text>{{sexDistribution[0].value}}人</text>
<text>{{sexData.boy}}</text> <text>{{sexDistribution[0].ratio}}%</text>
</view> </view>
<view class="ratio-item {{sexData.boy?'ratio-right':'null-right'}}" style="width: {{sexData.girl}}%" wx:if="{{sexData.girl}}"> <view class="ratio-item {{sexDistribution[1].value?'ratio-right':'null-right'}}" style="width: {{sexDistribution[1].ratio}}%" wx:if="{{sexDistribution[1].value}}">
<text>{{sexData.girl}}人</text> <text>{{sexDistribution[1].value}}人</text>
<text>{{sexData.girl}}</text> <text>{{sexDistribution[1].ratio}}%</text>
</view> </view>
</view> </view>
</view> </view>
<view class="box-title">年龄分布</view> <view class="box-title">年龄分布</view>
<view class="age-box"> <view class="age-box">
<view wx:for="{{ageList}}" class="process-item"> <view wx:for="{{ageDistribution}}" class="process-item">
<view class="process-label">{{item.age}}</view> <view class="process-label">{{item.name}}</view>
<view class="process-bar__outer"> <view class="process-bar__outer">
<view class="process-bar__inner" style="width: {{item.ratio}}%"> <view class="process-bar__inner" style="width: {{item.ratio}}%">
</view> </view>
</view> </view>
<view class="process-value">{{item.ratio}}</view> <view class="process-value">{{item.ratio}}%</view>
</view> </view>
</view> </view>
<view class="box-title">年代分布</view> <view class="box-title">年代分布</view>
<view class="age-box time-box"> <view class="age-box time-box">
<view wx:for="{{timeList}}" class="process-item"> <view wx:for="{{eraDistribution}}" class="process-item">
<view class="process-label">{{item.time}}</view> <view class="process-label">{{item.name}}</view>
<view class="process-bar__outer"> <view class="process-bar__outer">
<view class="process-bar__inner" style="width: {{item.ratio}}%"> <view class="process-bar__inner" style="width: {{item.ratio}}%">
</view> </view>
</view> </view>
<view class="process-value">{{item.ratio}}</view> <view class="process-value">{{item.ratio}}%</view>
</view> </view>
</view> </view>
<view class="box-title">有无小孩</view> <view class="box-title">有无小孩</view>
<circle width="400" ratioList="{{ratioList}}" Id="pot734"></circle> <circle width="400" ratioList="{{childDistribution}}" Id="pot734"></circle>
<view class="children-box"> <view class="children-box">
<view class="children-item" wx:for="{{childrenList}}"> <view class="children-item" wx:for="{{childDistribution}}">
<view class="icon" style="background: {{item.color}};"></view> <view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view> <view class="text">{{item.name}}:{{item.ratio}}%</view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
//index.js //index.js
//注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本! //注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本!
import uCharts from '../../../../../utils/u-charts/u-charts.js'; import uCharts from '../../../../../utils/u-charts/u-charts.js';
const view = require('../view.js')
var uChartsInstance = {}; var uChartsInstance = {};
Component({ Component({
data: { behaviors: [view],
cWidth: 750, data: {
cHeight: 500, cWidth: 750,
pixelRatio: 2, cHeight: 500,
pixelRatio: 2,
},
methods: {
getRatio() {
//这里的第一个 750 对应 css .charts 的 width
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height
const cHeight = 500 / 750 * wx.getSystemInfoSync().windowWidth;
this.setData({
cWidth,
cHeight
});
this.getServerData();
}, },
attached() { getServerData() {
//这里的第一个 750 对应 css .charts 的 width const {viewCustomerPortrait:{browseDistribution}} = this.data,
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth; categories = browseDistribution.map(i=>i.name),
//这里的 500 对应 css .charts 的 height data = browseDistribution.map(i=>i.value);
const cHeight = 500 / 750 * wx.getSystemInfoSync().windowWidth; //模拟从服务器获取数据时的延时
this.setData({ setTimeout(() => {
cWidth, //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
cHeight let res = {
}); categories,
this.getServerData(); series: [{
data
}, ]
};
this.drawCharts('MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh', res);
}, 500);
}, },
methods: { drawCharts(id, data) {
getServerData() { const query = wx.createSelectorQuery().in(this);
//模拟从服务器获取数据时的延时 query.select('#' + id).fields({
setTimeout(() => { node: true,
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 size: true
let res = { }).exec(res => {
categories: ["2018", "2019", "2020", "2021", "2022", "2023"], if (res[0]) {
series: [{ const canvas = res[0].node;
name: "成交量A", const ctx = canvas.getContext('2d');
data: [35, 8, 25, 37, 4, 20] canvas.width = res[0].width * this.data.pixelRatio;
}, canvas.height = res[0].height * this.data.pixelRatio;
] uChartsInstance[id] = new uCharts({
};
this.drawCharts('MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh', res);
}, 500);
},
drawCharts(id, data) {
const query = wx.createSelectorQuery().in(this);
query.select('#' + id).fields({ node: true, size: true }).exec(res => {
if (res[0]) {
const canvas = res[0].node;
const ctx = canvas.getContext('2d');
canvas.width = res[0].width * this.data.pixelRatio;
canvas.height = res[0].height * this.data.pixelRatio;
uChartsInstance[id] = new uCharts({
type: "line", type: "line",
context: ctx, context: ctx,
width: this.data.cWidth * this.data.pixelRatio, width: this.data.cWidth * this.data.pixelRatio,
height: this.data.cHeight * this.data.pixelRatio, height: this.data.cHeight * this.data.pixelRatio,
categories: data.categories, categories: data.categories,
series: data.series, series: data.series,
animation: true, animation: true,
pixelRatio: this.data.pixelRatio, pixelRatio: this.data.pixelRatio,
background: "#FFFFFF", background: "#FFFFFF",
color: ["#35C376"], color: ["#35C376"],
padding: [15, 10, 0, 15], padding: [15, 15, 0, 0],
enableScroll: false, enableScroll: false,
legend: { legend: {
show: false show: false
}, },
xAxis: { xAxis: {
disableGrid: true, disableGrid: true,
axisLineColor: '#fff', axisLineColor: '#fff',
fontColor: '#A6A6A6', fontColor: '#A6A6A6',
}, fontSize: '10'
yAxis: { },
gridType: "dash", yAxis: {
dashLength: 2, gridType: "dash",
data: [{ dashLength: 2,
axisLine: false, data: [{
fontColor: '#A6A6A6', axisLine: false,
}] fontColor: '#A6A6A6',
}, }]
extra: { },
tooltip: { extra: {
showBox: false tooltip: {
}, showBox: false
line: { },
type: "straight", line: {
width: 2, type: "straight",
activeType: "none" width: 2,
} activeType: "none"
} }
});
}else{
console.error("[uCharts]: 未获取到 context");
} }
}); });
}, } else {
tap(e) { console.error("[uCharts]: 未获取到 context");
uChartsInstance[e.target.id].touchLegend(e);
uChartsInstance[e.target.id].showToolTip(e);
} }
});
},
tap(e) {
uChartsInstance[e.target.id].touchLegend(e);
uChartsInstance[e.target.id].showToolTip(e);
} }
}
}) })
\ No newline at end of file \ No newline at end of file
<!--pages/tab/stat/components/custom/custom.wxml--> <!--pages/tab/stat/components/custom/custom.wxml-->
<view class="box"> <view class="box">
<view class="box-title">浏览时段偏好<text>单位:人</text></view> <view class="box-title">/浏览时段偏好<text>单位:人</text></view>
<view class="charts"> <view class="charts">
<canvas canvas-id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" type="2d" class="charts" bindtouchend="tap"/> <canvas canvas-id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" type="2d" class="charts" bindtouchend="tap"/>
</view> </view>
......
import util from '~/utils/util'
module.exports = Behavior({
properties: {
viewCustomerPortrait: {
type: Object,
observer(n) {
this.getRatio(n)
}
}
},
// 事件处理函数 和 自定义方法
methods: {
setRatio(k, arr, color,isRatio=false) {
const count = arr.reduce((prev,cur)=>{
return prev+cur.value
},0)
arr.forEach((i, k) => {
i.ratio = isRatio?util.div(100*i.value,count):i.value
if (color) {
i.color = color[k]
}
})
this.setData({
[k]: arr
})
},
},
})
\ No newline at end of file \ No newline at end of file
// pages/tab/stat/stat.js // pages/tab/stat/stat.js
import outputApi from '~/api/outputApi/index'
Component({ Component({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { lifetimes: {
attached() {const {
}, merchantId
} = wx.$storage.get('userInfo')
/** outputApi.portraitView({merchantId}).then(res=>{
* 生命周期函数--监听页面加载 this.setData({viewCustomerPortrait:res})
*/ })
onLoad(options) { }
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
}, },
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
}) })
\ No newline at end of file \ No newline at end of file
<!--pages/tab/stat/stat.wxml--> <!--pages/tab/stat/stat.wxml-->
<view class="stat-box"> <view class="stat-box">
<browse></browse> <browse viewCustomerPortrait="{{viewCustomerPortrait}}"></browse>
<portrait></portrait> <portrait viewCustomerPortrait="{{viewCustomerPortrait}}"></portrait>
<custom></custom> <custom viewCustomerPortrait="{{viewCustomerPortrait}}"></custom>
<commodity></commodity> <commodity viewCustomerPortrait="{{viewCustomerPortrait}}"></commodity>
<timeline></timeline> <!-- <timeline viewCustomerPortrait="{{viewCustomerPortrait}}"></timeline> -->
<lodge></lodge> <!-- <lodge viewCustomerPortrait="{{viewCustomerPortrait}}"></lodge>
<car></car> <car viewCustomerPortrait="{{viewCustomerPortrait}}"></car>
<consume></consume> <consume viewCustomerPortrait="{{viewCustomerPortrait}}"></consume> -->
</view> </view >
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
} }
}, },
"setting": { "setting": {
"urlCheck": true, "urlCheck": false,
"compileHotReLoad": true "compileHotReLoad": true
}, },
"projectname": "store-assistant-assemble" "projectname": "store-assistant-assemble"
......
...@@ -150,12 +150,12 @@ const pathEnum = { ...@@ -150,12 +150,12 @@ const pathEnum = {
busassistant: '/rop-scrm-busassistant/', busassistant: '/rop-scrm-busassistant/',
'rop-merchants': '/rop-merchants/' 'rop-merchants': '/rop-merchants/'
} }
const defaultMerchantId = { const wyMerchantId = {
ip: '44184606', ip: [44211774],
dev: '44184606', dev: [44211774],
uat: '44184606', uat: [44210895],
preRelease: '44184606', preRelease: [44184606],
prod: '44189923' prod: [44209563,44209565,44209566]
}[target[index]] }[target[index]]
let mockUrl = { let mockUrl = {
...@@ -171,6 +171,6 @@ module.exports = { ...@@ -171,6 +171,6 @@ module.exports = {
pathEnum, pathEnum,
secretKey, secretKey,
djSecretKey, djSecretKey,
defaultMerchantId, wyMerchantId,
mockUrl mockUrl
} }
...@@ -345,6 +345,51 @@ const checkRule = function (obj, formRule) { ...@@ -345,6 +345,51 @@ const checkRule = function (obj, formRule) {
} }
return false return false
} }
//除法函数,用来得到精确的除法结果
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用:div(arg1,arg2)
//返回值:arg1除以arg2的精确结果
const div = function (arg1, arg2) {
var t1 = 0,
t2 = 0,
r1,
r2;
try {
t1 = arg1.toString().split(".")[1].length;
} catch (e) {
t1 = 0;
}
try {
t2 = arg2.toString().split(".")[1].length;
} catch (e) {
t2 = 0;
}
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
return mul(r1 / r2, Math.pow(10, t2 - t1));
}
//乘法函数,用来得到精确的乘法结果
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用:mul(arg1,arg2)
//返回值:arg1乘以arg2的精确结果
const mul = function (arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) {
m = 0;
}
try {
m += s2.split(".")[1].length;
} catch (e) {
m = m || 0;
}
const res = (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
Math.pow(10, m)
return Number(res).toFixed(2).replace(/(?<=\.\d*)0+$|\.0*$/, '');
}
const Util = { const Util = {
...@@ -360,6 +405,8 @@ const Util = { ...@@ -360,6 +405,8 @@ const Util = {
deepClone, deepClone,
setNavigationBarTitle, setNavigationBarTitle,
moneyThreeForTwoThousands, moneyThreeForTwoThousands,
checkRule checkRule,
div,
mul
}; };
export default Util; export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!