Commit bea87d16 by 杨明

uchart

1 parent 03b56eb6
Showing 47 changed files with 1390 additions and 11 deletions
......@@ -10,8 +10,7 @@
"packagesList/activityDetail/activityDetail",
"pages/tab/logout/logout",
"packagesList/log/log",
"custom-tab-bar/index",
"pages/tab/stat/stat"
"custom-tab-bar/index"
],
"requiredPrivateInfos": [
"getLocation"
......
......@@ -2,7 +2,8 @@
"usingComponents": {
"navigation-bar": "../../../components/NavigationBar/NavigationBar",
"tab": "../../../components/Tab/Tab",
"client": "./components/client/client"
"client": "./components/client/client",
"stat": "../stat/stat"
},
"navigationStyle": "custom"
}
......@@ -46,7 +46,6 @@ page {
#client {
height: 100%;
}
.tabContainer {
height: 100rpx;
padding: 0 32rpx;
......
......@@ -4,7 +4,13 @@
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">看产值</navigation-bar>
<view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)">
<!-- <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)">
<stat></stat>
</scroll-view>
</view>
</block>
\ No newline at end of file
// pages/tab/stat/components/browse/browse.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
outputValue: [{
label: '订单总数(单)',
name: 'quotationCount',
unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png'
}, {
label: '总产值(元)',
name: 'outputValue',
_unit: '¥',
iconUrl:'store-assistant-assemble/output/icon05.png'
}],
todayValue: [{
label: '加微客户(人)',
name: 'quotationCount',
unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png'
}, {
label: '订单数(单)',
name: 'successCount',
unit: '',
iconUrl:'store-assistant-assemble/output/icon07.png'
}, {
label: '产值(元)',
name: 'outputValue',
_unit: '¥',
iconUrl:'store-assistant-assemble/output/icon05.png'
}]
},
/**
* 组件的方法列表
*/
methods: {
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* pages/tab/stat/components/browse/browse.wxss */
.output-box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.output-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.output-value {
// display: grid;
// grid-template-columns: repeat(3, 33.33%);
// row-gap: 24rpx;
// padding: 32rpx;
// background-image: linear-gradient(180deg, #FFFFFF 72%, #EBF1FF 100%);
// border-radius: 16rpx;
display: flex;
gap: 20rpx;
.output-item {
box-sizing: border-box;
width: 108px;
height: 136rpx;
background-image: linear-gradient(90deg, #F3FCFC 0%, #F9FEFF 49%, #EFF7FF 100%);
border-radius: 12rpx;
padding: 24rpx 12rpx 24rpx 16rpx;
&:nth-child(n+4) {
margin-top: 16rpx;
}
// .output-num {
// font-weight: 600;
// font-size: 30rpx;
// color: #1B233D;
// line-height: 64rpx;
// ._unit {
// font-size: 28rpx;
// }
// }
.output-num {
font-weight: 700;
font-size: 36rpx;
color: #2D2D33;
text-align-last: left;
._unit {
font-size: 28rpx;
}
}
// .output-label {
// font-size: 24rpx;
// color: #6E6E7A;
// line-height: 36rpx;
// margin-top: 12rpx;
// }
.output-label {
box-sizing: border-box;
display: flex;
justify-content: space-between;
// align-items: center;
font-size: 22rpx;
color: #6E6E7A;
// line-height: 36rpx;
// margin-top: 12rpx;
.label {
margin-top: 5rpx;
}
.icon {
width: 56rpx;
height: 56rpx;
// margin-left: 6rpx;
}
}
}
}
}
.totalCon {
display: flex;
margin: 20rpx 0rpx;
.item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
font-weight: 700;
.unit {
font-size: 30rpx;
}
.label {
font-family: PingFangSC-SNaNrpxibold;
font-weight: 600;
font-size: 24rpx;
color: #323436;
line-height: 36rpx;
margin-bottom: 12rpx;
}
.number {
font-family: numberBold;
// font-weight: 600;
font-size: 48rpx;
color: #2D2D33;
}
}
.item+.item {
width: 40%;
}
.otherItem {
width: 40%;
}
.otherItem+.otherItem {
width: 30%;
}
}
\ No newline at end of file
<!--pages/tab/stat/components/browse/browse.wxml-->
<view class="output-box">
<view class="output-title">
数据总览
</view>
<view class="totalCon">
<view class="item">
<view class="label">住户总数(人)</view>
<veiw class="number">
{{outputData['orderMoneyTotal'] ||0}}
</veiw>
</view>
<view class="item">
<view class="label">加微客户(人)</view>
<veiw class="number">
{{outputData['sendCouponTotal'] ||0}}
</veiw>
</view>
<view class="item">
<view class="label">加微率</view>
<veiw class="number">
{{outputData['sendCouponTotal'] ||0}} <text>%</text>
</veiw>
</view>
</view>
<view class="output-value">
<view class="output-item" wx:for="{{outputValue}}" wx:key="index">
<view class="output-label">
<view class="label">{{item.label}}</view>
<glsx-image src="{{item.iconUrl}}" class="icon" />
</view>
<view class="output-num"><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
</view>
</view>
</view>
<view class="output-box">
<view class="output-title">
当日数据
</view>
<view class="output-value">
<view class="output-item" wx:for="{{todayValue}}" wx:key="index">
<view class="output-label">
<view class="label">{{item.label}}</view>
<glsx-image src="{{item.iconUrl}}" class="icon" />
</view>
<view class="output-num"><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
</view>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/**
* 组件的初始数据
*/
data: {
childrenList: [
{color: '#5D9BF1',label: '燃油车:',value: 12},
{color: '#5CF0D8',label: '新能源车:',value: 23},
]
},
/**
* 组件的方法列表
*/
methods: {
getRatio() {
const ratioList = [
{color: '#5D9BF1',label: '燃油车:',value: 12},
{color: '#5CF0D8',label: '新能源车:',value: 23},
]
this.setData({
ratioList
})
}
}
})
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file
/* pages/tab/stat/components/lodge/lodge.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.box-body {
display: flex;
align-items: center;
justify-content: center;
.children-box {
width: 50%;
text-align: center;
.children-item {
display: flex;
align-items: center;
margin-left: 80rpx;
&:first-child {
margin-bottom: 32rpx;
}
.icon {
width: 24rpx;
height: 24rpx;
border-radius: 4rpx;
margin-right: 12rpx;
}
}
}
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">车辆类型</view>
<view class="box-body">
<circle class="children-box" width="200" Id="car779" ratioList="{{ratioList}}"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{childrenList}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
//index.js
//注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本!
import uCharts from '../../../../../utils/u-charts/u-charts.js';
var uChartsInstance = {};
Component({
properties: {
width: {
type: Number,
value: {}
},
Id: {
type: String
},
ratioList: {
type:Object,
observer(n) {
this.setRatio()
}
}
},
data: {
pixelRatio: 2,
},
methods: {
setRatio() {
const {
width
} = this.data
//这里的第一个 750 对应 css .charts 的 width
const cWidth = width / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height
const cHeight = width / 750 * wx.getSystemInfoSync().windowWidth;
const pixelRatio = wx.getSystemInfoSync().pixelRatio;
this.setData({
cWidth,
cHeight,
pixelRatio
});
this.getServerData();
},
getServerData() {
//模拟从服务器获取数据时的延时
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
const data = this.data.ratioList.map(i=>{
return {
"labelShow": false,
"value": i.value,
}
})
let res = {
series: [{
data
}]
};
this.drawCharts(this.data.Id, res);
},
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;
const color = this.data.ratioList.map(i=>i.color)
uChartsInstance[id] = new uCharts({
type: "ring",
context: ctx,
width: this.data.cWidth * this.data.pixelRatio,
height: this.data.cHeight * this.data.pixelRatio,
series: data.series,
animation: true,
rotate: false,
rotateLock: false,
background: "#FFFFFF",
color,
padding: [5, 5, 5, 5],
dataLabel: false,
enableScroll: false,
legend: {
show: false
},
// title: {
// name: "收益率",
// fontSize: 15,
// color: "#666666"
// },
// subtitle: {
// name: "70%",
// fontSize: 25,
// color: "#7cb5ec"
// },
extra: {
tooltip: {
showBox: false
},
ring: {
ringWidth: this.data.width / 4,
activeOpacity: 0.5,
activeRadius: 10,
offsetAngle: 0,
}
}
})
} else {
console.log("[uCharts]: 未获取到 context");
}
});
},
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* pages/tab/stat/components/circle/circle.wxss */
/*index.wxss*/
.charts {
width: 400rpx;
height: 400rpx;
margin: 0 auto;
}
\ No newline at end of file
<!--pages/tab/stat/components/circle/circle.wxml-->
<view class="charts" style="width: {{width}}rpx;height: {{width}}rpx;">
<canvas style="width: {{width}}rpx;height: {{width}}rpx;" canvas-id="{{Id}}" id="{{Id}}" type="2d"/>
</view>
// pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/**
* 组件的初始数据
*/
data: {
childrenList: [
{color: '#3582EE',label: '中消费力:',value: 20},
{color: '#F9CEF7',label: '高消费力:',value: '20'},
{color: '#5CF0D8',label: '低消费力:',value: '20'}
]
},
/**
* 组件的方法列表
*/
methods: {
getRatio() {
const ratioList = [
{color: '#3582EE',label: '中消费力:',value: 20},
{color: '#F9CEF7',label: '高消费力:',value: 20},
{color: '#5CF0D8',label: '低消费力:',value: 20}
]
this.setData({
ratioList
})
}
}
})
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file
/* pages/tab/stat/components/lodge/lodge.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.box-body {
display: flex;
align-items: center;
justify-content: center;
.children-box {
width: 50%;
.children-item {
display: flex;
align-items: center;
margin-bottom: 26rpx;
&:last-child {
margin-bottom: 0rpx;
}
.icon {
width: 24rpx;
height: 24rpx;
border-radius: 4rpx;
margin-right: 12rpx;
}
}
}
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">消费能力</view>
<view class="box-body">
<circle class="children-box" width="200" Id="com3479" ratioList="{{ratioList}}"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{childrenList}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
//index.js
//注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本!
import uCharts from '../../../../../utils/u-charts/u-charts.js';
var uChartsInstance = {};
Component({
data: {
cWidth: 750,
cHeight: 500,
pixelRatio: 2,
},
attached() {
//这里的第一个 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();
},
methods: {
getServerData() {
//模拟从服务器获取数据时的延时
setTimeout(() => {
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
let res = {
categories: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
series: [{
name: "目标值",
textColor: '#A6A6A6',
data: [{
value: 15,
color: '#3582EE'
}, {
value: 25,
color: '#5CF0D8'
}]
}, ]
};
this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res);
}, 500);
},
drawCharts(id, data) {
const query = wx.createSelectorQuery().in(this);
query.select('#' + id).fields({
node: true,
size: true
}).exec(res => {
if (res[0]) {
console.log(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({
animation: true,
background: "#FFFFFF",
canvas2d: true,
categories: data.categories,
color: ["#3582EE"],
context: ctx,
extra: {
tooltip: {
showBox:false
},
column: {
type: "group",
width: 15,
activeBgColor: "#000000",
}
},
height: this.data.cHeight * this.data.pixelRatio,
legend: {
show: false,
},
padding: [15, 15, 0, 5],
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
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
/* pages/tab/stat/components/consume/consume.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
height: 600rpx;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
display: flex;
text {
font-size: 24rpx;
color: #8A8C90;
margin-left: auto;
}
}
.chart-title {
font-size: 22rpx;
color: #1B233D;
padding-left: 10rpx;
}
.charts {
width: 750rpx;
height: 500rpx;
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">甄选商品偏好(top10)<text>单位:人</text></view>
<view class="chart-title">单位:人</view>
<view class="charts">
<canvas canvas-id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" type="2d" class="charts" bindtouchend="tap" />
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/**
* 组件的初始数据
*/
data: {
childrenList: [
{color: '#5D9BF1',label: '管家添加:',value: 20},
{color: '#5CF0D8',label: '系统添加:',value: '20%'},
]
},
/**
* 组件的方法列表
*/
methods: {
getRatio() {
const ratioList = [
{color: '#5D9BF1',label: '管家添加:',value: 12},
{color: '#5CF0D8',label: '系统添加:',value: 23},
]
this.setData({
ratioList
})
}
}
})
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file
/* pages/tab/stat/components/lodge/lodge.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.box-body {
display: flex;
align-items: center;
justify-content: center;
.children-box {
width: 50%;
.children-item {
display: flex;
align-items: center;
&:first-child {
margin-bottom: 32rpx;
}
.icon {
width: 24rpx;
height: 24rpx;
border-radius: 4rpx;
margin-right: 12rpx;
}
}
}
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">客户来源</view>
<view class="box-body">
<view class="children-box">
<view class="children-item" wx:for="{{childrenList}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view>
</view>
</view>
<circle width="200" Id="custom54" ratioList="{{ratioList}}"></circle>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
/**
* 组件的初始数据
*/
data: {
childrenList: [
{color: '#F9CEF7',label: '自住:',value: 20},
{color: '#5CF0D8',label: '租房:',value: '20%'},
]
},
/**
* 组件的方法列表
*/
methods: {
getRatio() {
const ratioList = [
{color: '#F9CEF7',label: '自住:',value: 12},
{color: '#5CF0D8',label: '租房:',value: 23},
]
this.setData({
ratioList
})
}
}
})
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file
/* pages/tab/stat/components/lodge/lodge.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.box-body {
display: flex;
align-items: center;
justify-content: center;
.children-box {
width: 50%;
.children-item {
display: flex;
align-items: center;
&:first-child {
margin-bottom: 32rpx;
}
.icon {
width: 24rpx;
height: 24rpx;
border-radius: 4rpx;
margin-right: 12rpx;
}
}
}
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">租住比</view>
<view class="box-body">
<view class="children-box">
<view class="children-item" wx:for="{{childrenList}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view>
</view>
</view>
<circle width="200" Id="lodge3479" ratioList="{{ratioList}}"></circle>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/portrait/portrait.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
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: {
boy:100,
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: {
getRatio() {
const ratioList = [
{color: '#F9CEF7',label: '无小孩:',value: 20},
{color: '#3582EE',label: '无小孩:',value: 20},
{color: '#5CF0D8',label: '无小孩:',value: 20},
{color: '#FCEE8D',label: '无小孩:',value: 20}
]
this.setData({
ratioList
})
}
}
})
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file
/* pages/tab/stat/components/portrait/portrait.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
}
.portrait-box {
.portrait-img {
display: flex;
justify-content: center;
.portrait-item {
text-align: center;
&:last-child {
margin-left: 80rpx;
}
}
.icon {
width: 132rpx;
height: 132rpx;
}
.sex {
font-size: 28rpx;
color: #323436;
margin-top: 10rpx;
}
}
.ratio-box {
display: flex;
width: 560rpx;
margin: 20rpx auto 40rpx;
.ratio-item {
border-radius: 12rpx;
height: 60rpx;
line-height: 60rpx;
display: flex;
justify-content: space-between;
text {
padding: 0rpx 16rpx;
}
}
.ratio-left {
background: linear-gradient(-45deg, transparent 60rpx, #3582EE 0);
padding-right: 60rpx;
color: #FFFFFF;
}
.null-left {
background: #3582EE;
color: #FFFFFF;
}
.null-right {
background: #F9CEF7;
color: #B056AB;
}
.ratio-right {
margin-left: -90rpx;
padding-left: 60rpx;
color: #B056AB;
background: linear-gradient(135deg, transparent 60rpx, #F9CEF7 0);
}
}
}
.age-box {
margin-bottom: 30rpx;
}
.process-item {
display: flex;
margin-bottom: 12rpx;
.process-label {
font-size: 24rpx;
color: #A6A6A6;
width: 140rpx;
}
.process-bar__outer {
flex: 1;
background: #F4F5FC;
height: 20rpx;
position: relative;
.process-bar__inner {
position: absolute;
height: 100%;
top: 0rpx;
left: 0rpx;
width: 10%;
background: #3582EE;
}
}
.process-value {
font-size: 24rpx;
color: #2D2D33;
width: 60rpx;
margin-left: 20rpx;
}
}
.time-box {
.process-bar__inner {
background: #5CF0D8 !important;
}
}
.children-box {
width: 590rpx;
height: 144rpx;
background-image: linear-gradient(90deg, #F3FCFC 0%, #F9FEFF 49%, #EFF7FF 100%);
border-radius: 8rpx;
margin: 40rpx auto;
padding: 30rpx 60rpx;
box-sizing: border-box;
display: grid;
grid-template-columns: 50% 50%;
row-gap: 20rpx;
.children-item {
display: flex;
align-items: center;
.icon {
width: 24rpx;
height: 24rpx;
border-radius: 4rpx;
margin-right: 12rpx;
}
}
}
}
\ No newline at end of file
<!--pages/tab/stat/components/portrait/portrait.wxml-->
<view class="box">
<view class="box-title">用户画像</view>
<view class="portrait-box">
<view class="portrait-img">
<view class="portrait-item">
<glsx-image src="store-assistant-assemble/output/boy.png" class="icon" />
<view class="sex">男</view>
</view>
<view class="portrait-item">
<glsx-image src="store-assistant-assemble/output/girl.png" class="icon" />
<view class="sex">女</view>
</view>
</view>
<view class="ratio-box">
<view class="ratio-item {{sexData.girl?'ratio-left':'null-left'}}" style="width: {{sexData.boy}}%" wx:if="{{sexData.boy}}">
<text>{{sexData.boy}}人</text>
<text>{{sexData.boy}}</text>
</view>
<view class="ratio-item {{sexData.boy?'ratio-right':'null-right'}}" style="width: {{sexData.girl}}%" wx:if="{{sexData.girl}}">
<text>{{sexData.girl}}人</text>
<text>{{sexData.girl}}</text>
</view>
</view>
</view>
<view class="box-title">年龄分布</view>
<view class="age-box">
<view wx:for="{{ageList}}" class="process-item">
<view class="process-label">{{item.age}}</view>
<view class="process-bar__outer">
<view class="process-bar__inner" style="width: {{item.ratio}}%">
</view>
</view>
<view class="process-value">{{item.ratio}}</view>
</view>
</view>
<view class="box-title">年代分布</view>
<view class="age-box time-box">
<view wx:for="{{timeList}}" class="process-item">
<view class="process-label">{{item.time}}</view>
<view class="process-bar__outer">
<view class="process-bar__inner" style="width: {{item.ratio}}%">
</view>
</view>
<view class="process-value">{{item.ratio}}</view>
</view>
</view>
<view class="box-title">有无小孩</view>
<circle width="400" ratioList="{{ratioList}}" Id="pot734"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{childrenList}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.label}}{{item.value}}</view>
</view>
</view>
</view>
\ No newline at end of file
//index.js
//注意!基础库【2.9.0】起支持 2d 模式,如不显示请检查基础库版本!
import uCharts from '../../../../../utils/u-charts/u-charts.js';
var uChartsInstance = {};
Component({
data: {
cWidth: 750,
cHeight: 500,
pixelRatio: 2,
},
attached() {
//这里的第一个 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();
},
methods: {
getServerData() {
//模拟从服务器获取数据时的延时
setTimeout(() => {
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
let res = {
categories: ["2018", "2019", "2020", "2021", "2022", "2023"],
series: [{
name: "成交量A",
data: [35, 8, 25, 37, 4, 20]
},
]
};
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",
context: ctx,
width: this.data.cWidth * this.data.pixelRatio,
height: this.data.cHeight * this.data.pixelRatio,
categories: data.categories,
series: data.series,
animation: true,
pixelRatio: this.data.pixelRatio,
background: "#FFFFFF",
color: ["#35C376"],
padding: [15, 10, 0, 15],
enableScroll: false,
legend: {
show: false
},
xAxis: {
disableGrid: true,
axisLineColor: '#fff',
fontColor: '#A6A6A6',
},
yAxis: {
gridType: "dash",
dashLength: 2,
data: [{
axisLine: false,
fontColor: '#A6A6A6',
}]
},
extra: {
tooltip: {
showBox: false
},
line: {
type: "straight",
width: 2,
activeType: "none"
}
}
});
}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
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* pages/tab/stat/components/custom/custom.wxss */
.box {
// background: #F4F8FE;
// border-radius: 32rpx;
// margin: 0 16rpx;
box-sizing: border-box;
padding: 24rpx 32rpx;
margin: 16rpx 0;
background: #FFFFFF;
height: 600rpx;
.box-title {
font-weight: 600;
font-size: 32rpx;
color: #1B233D;
line-height: 48rpx;
margin-bottom: 22rpx;
display: flex;
text {
font-size: 24rpx;
color: #8A8C90;
margin-left: auto;
}
}
.charts{
width: 750rpx;
height: 500rpx;
}
}
\ No newline at end of file
<!--pages/tab/stat/components/custom/custom.wxml-->
<view class="box">
<view class="box-title">浏览时段偏好<text>单位:人</text></view>
<view class="charts">
<canvas canvas-id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" id="MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh" type="2d" class="charts" bindtouchend="tap"/>
</view>
</view>
// pages/tab/stat/stat.js
Page({
Component({
/**
* 页面的初始数据
......@@ -12,7 +12,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
......
{
"usingComponents": {}
"component": true,
"usingComponents": {
"browse": "./components/browse/browse",
"portrait": "./components/portrait/portrait",
"consume": "./components/consume/consume",
"custom": "./components/custom/custom",
"commodity": "./components/commodity/commodity",
"timeline": "./components/timeline/timeline",
"lodge":"./components/lodge/lodge",
"car":"./components/car/car"
}
}
\ No newline at end of file
/* pages/tab/stat/stat.wxss */
\ No newline at end of file
/* pages/tab/stat/stat.wxss */
.stat-box {
background: #F8F9F9;
}
\ No newline at end of file
<!--pages/tab/stat/stat.wxml-->
<text>pages/tab/stat/stat.wxml</text>
<view class="stat-box">
<browse></browse>
<portrait></portrait>
<custom></custom>
<commodity></commodity>
<timeline></timeline>
<lodge></lodge>
<car></car>
<consume></consume>
</view>
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "3.0.1",
"libVersion": "3.1.2",
"condition": {
"miniprogram": {
"list": [
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!