Commit c10a814e by 前端

Merge branch 'SAAS+v4.31.0' into 'master'

Saas+v4.31.0

See merge request !9
2 parents 7e1a3097 922b1718
Showing 64 changed files with 1572 additions and 30 deletions
......@@ -132,7 +132,15 @@ class outputApi {
...data
})
}
//客户画像展示
portraitView(data) {
return api.post({
method: 'entmicro.api.customer.portrait.view',
apiProjectName: 'entmicro',
...data
})
}
// 我的员工
/** 服务商查询园区店员工产值统计 */
getStaffList(data) {
......
......@@ -10,8 +10,8 @@ import '~/router/routerBefore'
import router from './router/index'
import BusassistantApi from "~/api/busassistantApi/index";
import {
Version
} from 'glsx-common-sdk'
Version
} from 'glsx-common-sdk'
// 有问题 前后顺序不能随意调整
// console.log(test)
......@@ -56,11 +56,11 @@ App({
wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus
wx.$versionConfig = new Version({
request: {
baseUrl: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config',
isSign: false
}
})
request: {
baseUrl: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config',
isSign: false
}
})
// 存储设备信息
setSystem_info()
// console.log('test')
......
......@@ -9,7 +9,8 @@
"login/accountItems/accountItems",
"packagesList/activityDetail/activityDetail",
"pages/tab/logout/logout",
"packagesList/log/log"
"packagesList/log/log",
"custom-tab-bar/index"
],
"requiredPrivateInfos": [
"getLocation"
......@@ -22,6 +23,7 @@
},
"__usePrivacyCheck__": true,
"tabBar": {
"custom": true,
"color": "#5A6066",
"selectedColor": "#3666FE",
"backgroundColor": "#FFFFFF",
......
// custom-tab-bar/index.js
import {
wyMerchantId
} from '~/utils/request/environment'
Component({
options: {
styleIsolation: 'shared'
},
data: {
active: 0,
initList: [{
path: "/pages/tab/output/output",
normal: '/images/output.png',
active: '/images/output_active.png',
text: "产值"
},
{
path: "/pages/tab/discovery/discovery",
normal: '/images/home.png',
active: '/images/home_active.png',
text: "发现",
},
{
path: "/pages/tab/mine/mine",
normal: '/images/mine.png',
active: '/images/mine_active.png',
text: "我的"
}
],
list: [{
path: "/pages/tab/output/output",
normal: '/images/output.png',
active: '/images/output_active.png',
text: "产值"
},
{
path: "/pages/tab/discovery/discovery",
normal: '/images/home.png',
active: '/images/home_active.png',
text: "发现",
},
{
path: "/pages/tab/mine/mine",
normal: '/images/mine.png',
active: '/images/mine_active.png',
text: "我的"
}
]
},
methods: {
onChange(event) {
const {
list
} = this.data
this.setData({
active: event.detail
})
wx.switchTab({
url: list[event.detail].path
})
}
}
})
\ No newline at end of file
{
"usingComponents": {
"van-tabbar": "/miniprogram_npm/@vant/weapp/tabbar/index",
"van-tabbar-item": "/miniprogram_npm/@vant/weapp/tabbar-item/index"
}
}
\ No newline at end of file
/* custom-tab-bar/index.wxss */
.van-tabbar-item{
--tabbar-item-margin-bottom: 10rpx
}
\ No newline at end of file
<van-tabbar active="{{ active }}" bind:change="onChange">
<van-tabbar-item wx:for="{{list}}" wx:key="index">
<image
slot="icon"
src="{{ item.normal }}"
mode="aspectFit"
style="width: 24px; height: 24px;"
/>
<image
slot="icon-active"
src="{{ item.active }}"
mode="aspectFit"
style="width: 24px; height: 24px;"
/>
{{item.text}}
</van-tabbar-item>
</van-tabbar>
\ No newline at end of file
<view class='tips'>
<view class='choose-box' bindtap="choose">
<view class='tips' bindtap="choose">
<view class='choose-box'>
<view class='icon'>
<icon wx:if="{{agree}}" class="icon-small" type="success" size="14" color="#4466F0"></icon>
<icon wx:else class="icon-small" type="circle" size="14" color="#4466F0"></icon>
......
......@@ -69,7 +69,6 @@ Component({
},
onLoad(options) {
console.log(options,'options');
const { merchantId, merchantName } = options;
this.setData({ merchantId, merchantName })
this.getSubscribeConfig(options)
......
<view class="container" style="padding-bottom: calc(100rpx + {{isFullSucreen ? '34' : 0}}px);">
<view class="container" style="padding-bottom: calc(150rpx + {{isFullSucreen ? '34' : 0}}px);">
<navigation-bar bindnavbarReady="navbarReady">
<view class="my-tab">
<view wx:for="{{tabList}}" wx:key="index" bindtap="changeMyTab" data-id="{{index}}" class='my-tab-item {{myTabIdx==index ? "tab-item-active": ""}}'>{{item.name}}</view>
......
......@@ -6,6 +6,10 @@ const IMAGES = Object.freeze({
})
// import { getMockData } from '~/api/api'
import USERAPI from '~/api/usersApi/index'
import util from '~/utils/util'
import {
wyMerchantId
} from '~/utils/request/environment'
Page({
/**
* 页面的初始数据
......@@ -81,6 +85,19 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function (){
if (typeof this.getTabBar === 'function' ) {
this.getTabBar((tabBar) => {
const list = util.deepClone(tabBar.data.initList)
if (wyMerchantId.includes(+wx.$storage.get().userInfo.merchantId)) {
list.splice(1, 1);
}
tabBar.setData({
active: list.length - 1,
list
})
})
}
},
/**
......
......@@ -146,7 +146,7 @@ page {
.logoutBtn {
position: fixed;
bottom: 106rpx;
bottom: 246rpx;
left: 50%;
transform: translateX(-50%);
font-size: 32rpx !important;
......
......@@ -9,6 +9,7 @@
<view class="info">
<view class="name">{{userInfo.merchantName}}</view>
<view class="id">{{userInfo.phone}}</view>
</view>
<button class="logoutBtn" size="default" type="default" isabled="{{false}}" loading="{{false}}" bindtap="logout" hover-class="button-hover">
退出登录
......
......@@ -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;
......
......@@ -2,9 +2,15 @@
<block wx:if="{{isShow}}">
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">看产值</navigation-bar>
<view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)">
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">{{title}}</navigation-bar>
<view class="layout" wx:if="{{isWy}}">
<scroll-view class="stat-scroll" scroll-y="true" style="padding-top:{{navHeight}}px; height: calc(100vh - 360rpx)">
<stat></stat>
</scroll-view>
</view>
<view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)" wx:else>
<client id="client" />
</view>
</view>
</block>
\ No newline at end of file
// pages/tab/stat/components/browse/browse.js
Component({
/**
* 组件的属性列表
*/
properties: {
viewCustomerPortrait: {
type: Object
}
},
/**
* 组件的初始数据
*/
data: {
outputValue: [{
label: '订单总数(单)',
name: 'ordersTotal',
unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png'
}, {
label: '总产值(元)',
name: 'produceValueTotal',
_unit: '¥',
iconUrl:'store-assistant-assemble/output/icon05.png'
}],
todayValue: [{
label: '加微客户(人)',
name: 'todayAddEntmicroCount',
unit: '',
iconUrl:'store-assistant-assemble/output/icon02.png'
}, {
label: '订单数(单)',
name: 'todayOrdersTotal',
unit: '',
iconUrl:'store-assistant-assemble/output/icon07.png'
}, {
label: '产值(元)',
name: 'todayProduceValueTotal',
_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">
{{viewCustomerPortrait['householdTotal'] ||0}}
</veiw>
</view>
<view class="item">
<view class="label">加微客户(人)</view>
<veiw class="number">
{{viewCustomerPortrait['addEntmicroCount'] ||0}}
</veiw>
</view>
<view class="item">
<view class="label">加微率</view>
<veiw class="number">
{{viewCustomerPortrait['addEntmicroRatio'] ||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> {{viewCustomerPortrait[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> {{viewCustomerPortrait[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
// 组件中使用 require方法导入需要的behavior模块
const view = require('../view.js')
Component({
behaviors: [view],
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
getRatio(obj) {
const {
vehicleDistribution
} = obj
this.setRatio('vehicleDistribution', vehicleDistribution,['#5D9BF1', '#5CF0D8', '#5CF0D8'])
}
}
})
{
"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: 40rpx;
&: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="{{vehicleDistribution}}"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{vehicleDistribution}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.name}}:{{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: {}
},
isLabel:{
type: Boolean,
value: false
},
Id: {
type: String
},
ratioList: {
type:Object,
observer(n) {
this.setRatio()
}
}
},
data: {
pixelRatio: 2,
},
methods: {
setRatio() {
const {
width,
isLabel
} = this.data
//这里的第一个 750 对应 css .charts 的 width
const cWidth = (isLabel?700: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": true,
"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,
pixelRatio: this.data.isLabel?this.data.pixelRatio:1,
series: data.series,
animation: true,
rotate: false,
rotateLock: false,
background: "#FFFFFF",
color,
fontSize: 16,
fontColor: color,
padding: [5, 5, 5, 5],
dataLabel: this.data.isLabel?true: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.isLabel?60: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: {{isLabel?700:width}}rpx;height: {{width}}rpx;">
<canvas style="width: {{isLabel?700:width}}rpx;height: {{width}}rpx;" canvas-id="{{Id}}" id="{{Id}}" type="2d"/>
</view>
// pages/tab/stat/components/lodge/lodge.js
// 组件中使用 require方法导入需要的behavior模块
const view = require('../view.js')
Component({
behaviors: [view],
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
getRatio(obj) {
const {
consumeDistribution
} = obj
this.setRatio('consumeDistribution', consumeDistribution,['#3582EE', '#F9CEF7', '#5CF0D8'])
}
}
})
{
"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="{{consumeDistribution}}"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{consumeDistribution}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.name}}:{{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';
const view = require('../view.js')
var uChartsInstance = {};
Component({
behaviors: [view],
data: {
cWidth: 750,
cHeight: 500,
pixelRatio: 2,
},
methods: {
getRatio() {
//这里的第一个 750 对应 css .charts 的 width
const cWidth = 700 / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height
const cHeight = 480 / 750 * wx.getSystemInfoSync().windowWidth;
const pixelRatio = wx.getSystemInfoSync().pixelRatio;
this.setData({
cWidth,
cHeight,
pixelRatio
});
this.getServerData();
},
getServerData() {
let _max = 0;
const {
viewCustomerPortrait: {
productDistribution
}
} = this.data,
categories = (productDistribution || []).map(i => i.name),
data = (productDistribution || []).map((i, k) => {
_max = Math.max(_max, i.value)
return {
value: i.value,
color: k % 2 == 0 ? '#3582EE' : '#5CF0D8'
}
})
let res = {
categories,
series: [{
name: "目标值",
textColor: '#A6A6A6',
data
}, ]
};
this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res, _max);
},
drawCharts(id, data, _max) {
_max = Math.ceil(_max / 5) * 5
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, 5, 5],
pixelRatio: this.data.pixelRatio,
series: data.series,
type: "column",
width: this.data.cWidth * this.data.pixelRatio,
xAxis: {
disableGrid: true,
axisLineColor: '#fff',
fontColor: '#A6A6A6',
fontSize: 10,
marginTop: 4,
rotateLabel:true,
rotateAngle: 45
},
yAxis: {
disableGrid: true,
fontColor: '#A6A6A6',
data: [{
axisLine: false,
fontColor: '#A6A6A6',
min: 0,
max: _max
}]
}
});
} else {
console.error("[uCharts]: 未获取到 context");
}
});
}
}
})
\ 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: 700rpx;
height: 480rpx;
}
}
\ No newline at end of file
<view class="box">
<view class="box-title">甄选商品偏好(top10)<text>单位:人</text></view>
<view class="charts">
<canvas canvas-id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" id="afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL" type="2d" class="charts"/>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js
const view = require('../view.js')
Component({
behaviors: [view],
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
getRatio(obj) {
const {
sourceDistribution
} = obj
this.setRatio('sourceDistribution', sourceDistribution,['#5D9BF1', '#5CF0D8'])
}
}
})
{
"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="{{sourceDistribution}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.name}}:{{item.value}}%</view>
</view>
</view>
<circle width="200" Id="custom54" ratioList="{{sourceDistribution}}"></circle>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/lodge/lodge.js
const view = require('../view.js')
Component({
behaviors: [view],
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
getRatio(n) {
const {
lodgeDistribution
} = n
this.setRatio('lodgeDistribution', lodgeDistribution, ['#F9CEF7', '#5CF0D8'])
}
}
})
\ No newline at end of file
{
"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="{{lodgeDistribution}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.name}}:{{item.value}}%</view>
</view>
</view>
<circle width="200" Id="lodge3479" ratioList="{{lodgeDistribution}}"></circle>
</view>
</view>
\ No newline at end of file
// pages/tab/stat/components/portrait/portrait.js
const view = require('../view.js')
Component({
behaviors: [view],
/**
* 组件的初始数据
*/
data: {
sexData: {
boy: 100,
girl: 0
},
},
/**
* 组件的方法列表
*/
methods: {
getRatio(obj) {
const {
ageDistribution,
eraDistribution,
childDistribution,
sexDistribution
} = obj;
this.setRatio('sexDistribution',sexDistribution,'',true)
this.setRatio('ageDistribution', ageDistribution.reverse())
this.setRatio('eraDistribution', eraDistribution.reverse())
this.setRatio('childDistribution', childDistribution.reverse(), ['#F9CEF7', '#3582EE', '#5CF0D8','#FCEE8D'])
}
}
})
\ No newline at end of file
{
"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 {
font-size: 24rpx;
padding: 0rpx 10rpx;
}
}
.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 {
min-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 {{sexDistribution[0].value?'ratio-left':'null-left'}}" style="width: {{sexDistribution[0].ratio}}%" wx:if="{{sexDistribution[0].value}}">
<text>{{sexDistribution[0].value}}人</text>
<text>{{sexDistribution[0].ratio}}%</text>
</view>
<view class="ratio-item {{sexDistribution[1].value?'ratio-right':'null-right'}}" style="width: {{sexDistribution[1].ratio}}%" wx:if="{{sexDistribution[1].value}}">
<text>{{sexDistribution[1].value}}人</text>
<text>{{sexDistribution[1].ratio}}%</text>
</view>
</view>
</view>
<view class="box-title">年龄分布</view>
<view class="age-box">
<view wx:for="{{ageDistribution}}" class="process-item">
<view class="process-label">{{item.name}}</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="{{eraDistribution}}" class="process-item">
<view class="process-label">{{item.name}}</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="500" ratioList="{{childDistribution}}" Id="pot734" isLabel="{{true}}"></circle>
<view class="children-box">
<view class="children-item" wx:for="{{childDistribution}}">
<view class="icon" style="background: {{item.color}};"></view>
<view class="text">{{item.name}}:{{item.ratio}}%</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';
const view = require('../view.js')
var uChartsInstance = {};
Component({
behaviors: [view],
data: {
cWidth: 750,
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();
},
getServerData() {
let _max = 0;
const {viewCustomerPortrait:{browseDistribution}} = this.data,
categories = browseDistribution.map((i,k)=>{
return k%2==0?i.name:''
}),
data = browseDistribution.map(i=>{
_max = Math.max(_max, i.value)
return i.value
})
//模拟从服务器获取数据时的延时
setTimeout(() => {
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
let res = {
categories,
series: [{
data
}, ]
};
this.drawCharts('MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh', res,_max);
}, 500);
},
drawCharts(id, data,_max) {
_max = Math.ceil(_max / 5) * 5
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, 15, 0, 0],
enableScroll: false,
legend: {
show: false
},
xAxis: {
disableGrid: true,
axisLineColor: '#fff',
fontColor: '#A6A6A6',
fontSize: '10'
},
yAxis: {
gridType: "dash",
dashLength: 2,
data: [{
axisLine: false,
fontColor: '#A6A6A6',
max: _max
}]
},
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>
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
// pages/tab/stat/stat.js
import outputApi from '~/api/outputApi/index'
Component({
/**
* 页面的初始数据
*/
lifetimes: {
attached() {const {
merchantId
} = wx.$storage.get('userInfo')
outputApi.portraitView({merchantId}).then(res=>{
res.produceValueTotal = res.produceValueTotal/100
res.todayProduceValueTotal = res.todayProduceValueTotal/100
this.setData({viewCustomerPortrait:res})
})
}
},
})
\ No newline at end of file
{
"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 */
.stat-box {
background: #F8F9F9;
}
\ No newline at end of file
<!--pages/tab/stat/stat.wxml-->
<view class="stat-box">
<browse viewCustomerPortrait="{{viewCustomerPortrait}}"></browse>
<portrait viewCustomerPortrait="{{viewCustomerPortrait}}"></portrait>
<custom viewCustomerPortrait="{{viewCustomerPortrait}}"></custom>
<commodity viewCustomerPortrait="{{viewCustomerPortrait}}"></commodity>
<timeline viewCustomerPortrait="{{viewCustomerPortrait}}"></timeline>
<lodge viewCustomerPortrait="{{viewCustomerPortrait}}"></lodge>
<car viewCustomerPortrait="{{viewCustomerPortrait}}"></car>
<consume viewCustomerPortrait="{{viewCustomerPortrait}}"></consume>
</view>
\ No newline at end of file
{
"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": [
......@@ -190,7 +190,8 @@
}
},
"setting": {
"urlCheck": true
"urlCheck": false,
"compileHotReLoad": true
},
"projectname": "store-assistant-assemble"
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ const mockObj = {
3生产
*/
// const index = 1
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
......@@ -150,12 +151,12 @@ const pathEnum = {
busassistant: '/rop-scrm-busassistant/',
'rop-merchants': '/rop-merchants/'
}
const defaultMerchantId = {
ip: '44184606',
dev: '44184606',
uat: '44184606',
preRelease: '44184606',
prod: '44189923'
const wyMerchantId = {
ip: [44211774],
dev: [44211774],
uat: [44212578,44212577],
preRelease: [44184606],
prod: [44209565,44209566,44209719,44209718,44209715]
}[target[index]]
let mockUrl = {
......@@ -171,6 +172,6 @@ module.exports = {
pathEnum,
secretKey,
djSecretKey,
defaultMerchantId,
wyMerchantId,
mockUrl
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -345,6 +345,51 @@ const checkRule = function (obj, formRule) {
}
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 = {
......@@ -360,6 +405,8 @@ const Util = {
deepClone,
setNavigationBarTitle,
moneyThreeForTwoThousands,
checkRule
checkRule,
div,
mul
};
export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!