Commit 8e58180b by 杨明

物业

1 parent bea87d16
...@@ -132,6 +132,14 @@ class outputApi { ...@@ -132,6 +132,14 @@ class outputApi {
...data ...data
}) })
} }
//客户画像展示
portraitView(data) {
return api.post({
method: 'entmicro.api.customer.portrait.view',
apiProjectName: 'entmicro',
...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
}) })
}) })
} }
......
// pages/tab/output/output.js // pages/tab/output/output.js
import { getSessionId, setSessionId } from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import { IMG_URL } from '~/utils/constantData' import {
import { getMockData } from '~/api/api' IMG_URL
} from '~/utils/constantData'
import {
getMockData
} from '~/api/api'
import {
wyMerchantId
} from '~/utils/request/environment'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -18,8 +24,7 @@ Page({ ...@@ -18,8 +24,7 @@ Page({
tabList: ['我的客户', '我的员工'], tabList: ['我的客户', '我的员工'],
popupShow: false, popupShow: false,
subIndex: -1, subIndex: -1,
merchantList: [ merchantList: [{
{
merchantId: 0, merchantId: 0,
merchantName: 'string', merchantName: 'string',
show: true show: true
...@@ -34,7 +39,9 @@ Page({ ...@@ -34,7 +39,9 @@ Page({
}, },
// 切换园区 // 切换园区
tapPicker() { tapPicker() {
let { isSuper } = this.data let {
isSuper
} = this.data
isSuper && isSuper &&
this.setData({ this.setData({
moveArrow: !this.data.moveArrow, moveArrow: !this.data.moveArrow,
...@@ -42,7 +49,10 @@ Page({ ...@@ -42,7 +49,10 @@ Page({
}) })
}, },
navbarReady(e) { navbarReady(e) {
let { height, statusBarHeight } = e.detail let {
height,
statusBarHeight
} = e.detail
this.setData({ this.setData({
tabBarStyle: height / 2 + statusBarHeight tabBarStyle: height / 2 + statusBarHeight
}) })
...@@ -59,7 +69,9 @@ Page({ ...@@ -59,7 +69,9 @@ Page({
// this.getMockInfo() // this.getMockInfo()
}, },
setUserInfo() { setUserInfo() {
let { userInfo } = wx.$storage.get() let {
userInfo
} = wx.$storage.get()
// console.log(userInfo) // console.log(userInfo)
this.setData({ this.setData({
userInfo, userInfo,
...@@ -67,7 +79,11 @@ Page({ ...@@ -67,7 +79,11 @@ Page({
}) })
}, },
async getMockInfo() { async getMockInfo() {
let { serviceMerchatList } = await getMockData() || { serviceMerchatList: [] } let {
serviceMerchatList
} = await getMockData() || {
serviceMerchatList: []
}
this.setData({ this.setData({
isShowService: serviceMerchatList.includes(this.data.userInfo.merchantId + '') isShowService: serviceMerchatList.includes(this.data.userInfo.merchantId + '')
}) })
...@@ -84,14 +100,19 @@ Page({ ...@@ -84,14 +100,19 @@ Page({
clientModule.getBusinessData && clientModule.getBusinessData() clientModule.getBusinessData && clientModule.getBusinessData()
// merchantModule.init && merchantModule.init() // merchantModule.init && merchantModule.init()
} }
let { isSuper, userInfo } = this.data let {
isSuper,
userInfo
} = this.data
// 判断是超管才需要切换账号 // 判断是超管才需要切换账号
if (isSuper) { if (isSuper) {
USERAPI.adminSelectLogin() USERAPI.adminSelectLogin()
.then(result => { .then(result => {
// console.log(result) // console.log(result)
let { merchantList: merchantRange } = result let {
merchantList: merchantRange
} = result
// console.log(merchantRange) // console.log(merchantRange)
let subIndex = -1 let subIndex = -1
merchantRange.forEach((item, index) => { merchantRange.forEach((item, index) => {
...@@ -106,9 +127,12 @@ Page({ ...@@ -106,9 +127,12 @@ Page({
subIndex subIndex
}) })
}) })
.catch(err => { }) .catch(err => {})
} else { } else {
let merchantRange = [{ merchantId: userInfo.subLoginUser.merchantId, merchantName: userInfo.subLoginUser.merchantName }] let merchantRange = [{
merchantId: userInfo.subLoginUser.merchantId,
merchantName: userInfo.subLoginUser.merchantName
}]
this.setData({ this.setData({
merchantRange, merchantRange,
subIndex: 0 subIndex: 0
...@@ -118,7 +142,9 @@ Page({ ...@@ -118,7 +142,9 @@ Page({
onRoute(options) { onRoute(options) {
if (!options || wx.$util.isEmptyObj(options)) return if (!options || wx.$util.isEmptyObj(options)) return
let { page = 'client', refresh = true } = options let {
page = 'client', refresh = true
} = options
if (page == 'client' && refresh) { if (page == 'client' && refresh) {
let clientModule = this.selectComponent('#client') let clientModule = this.selectComponent('#client')
clientModule.getClientApi && clientModule.clientRefresh() clientModule.getClientApi && clientModule.clientRefresh()
...@@ -129,14 +155,31 @@ Page({ ...@@ -129,14 +155,31 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const {merchantId,type,merchantName} = options if (wyMerchantId.includes(wx.$storage.get('userInfo').merchantId)) {
this.setData({
isWy: true
})
this.getTabBar().setData({
active: 2,
isShow:false
})
}
const {
merchantId,
type,
merchantName
} = options
if (merchantId) { if (merchantId) {
wx.navigateTo({ wx.navigateTo({
url: `/packagesList/outDetail/index?merchantId=${merchantId}&type=${type}&merchantName=${merchantName}`, url: `/packagesList/outDetail/index?merchantId=${merchantId}&type=${type}&merchantName=${merchantName}`,
}) })
this.setData({ isShow: false }, () => { this.setData({
isShow: false
}, () => {
setTimeout(() => { setTimeout(() => {
this.setData({ isShow: true }) this.setData({
isShow: true
})
}, 1000) }, 1000)
}) })
...@@ -155,7 +198,7 @@ Page({ ...@@ -155,7 +198,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
if (typeof this.getTabBar === 'function' ) { if (typeof this.getTabBar === 'function') {
this.getTabBar((tabBar) => { this.getTabBar((tabBar) => {
tabBar.setData({ tabBar.setData({
active: 0 active: 0
...@@ -167,25 +210,25 @@ Page({ ...@@ -167,25 +210,25 @@ Page({
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() { }, onHide() {},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload() { }, onUnload() {},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { }, onPullDownRefresh() {},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { }, onReachBottom() {},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() { } onShareAppMessage() {}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -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: {
}, // 组件中使用 require方法导入需要的behavior模块
lifetimes: { const view = require('../view.js')
attached() {
this.getRatio()
}
},
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: {
}, // 组件中使用 require方法导入需要的behavior模块
lifetimes: { const view = require('../view.js')
attached() {
this.getRatio()
}
},
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({
behaviors: [view],
data: { data: {
cWidth: 750, cWidth: 750,
cHeight: 500, cHeight: 500,
pixelRatio: 2, pixelRatio: 2,
}, },
attached() {
methods: {
setRatio() {
//这里的第一个 750 对应 css .charts 的 width //这里的第一个 750 对应 css .charts 的 width
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth; const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height //这里的 500 对应 css .charts 的 height
...@@ -21,27 +27,24 @@ Component({ ...@@ -21,27 +27,24 @@ Component({
}); });
this.getServerData(); this.getServerData();
}, },
methods: {
getServerData() { getServerData() {
//模拟从服务器获取数据时的延时 const {viewCustomerPortrait:{productDistribution }} = this.data,
setTimeout(() => { categories = productDistribution.map(i=>i.name),
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 data = productDistribution.map((i,k)=>{
return {
value: i.value,
color: k%2 == 0?'#3582EE':'#5CF0D8'
}
})
let res = { let res = {
categories: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], categories,
series: [{ series: [{
name: "目标值", name: "目标值",
textColor: '#A6A6A6', textColor: '#A6A6A6',
data: [{ data
value: 15,
color: '#3582EE'
}, {
value: 25,
color: '#5CF0D8'
}]
}, ] }, ]
}; };
this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res); this.drawCharts('afMCYQMEmXXVAjNQFJvvfxbLSHuxNEOL', res);
}, 500);
}, },
drawCharts(id, data) { drawCharts(id, data) {
const query = wx.createSelectorQuery().in(this); const query = wx.createSelectorQuery().in(this);
...@@ -64,7 +67,7 @@ Component({ ...@@ -64,7 +67,7 @@ Component({
context: ctx, context: ctx,
extra: { extra: {
tooltip: { tooltip: {
showBox:false showBox: false
}, },
column: { column: {
type: "group", type: "group",
...@@ -84,7 +87,8 @@ Component({ ...@@ -84,7 +87,8 @@ Component({
xAxis: { xAxis: {
disableGrid: true, disableGrid: true,
axisLineColor: '#fff', axisLineColor: '#fff',
fontColor: '#A6A6A6' fontColor: '#A6A6A6',
fontSize: '10'
}, },
yAxis: { yAxis: {
disableGrid: true, disableGrid: true,
...@@ -100,10 +104,6 @@ Component({ ...@@ -100,10 +104,6 @@ Component({
console.error("[uCharts]: 未获取到 context"); console.error("[uCharts]: 未获取到 context");
} }
}); });
},
tap(e) {
uChartsInstance[e.target.id].touchLegend(e);
uChartsInstance[e.target.id].showToolTip(e);
} }
} }
......
...@@ -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
Component({ const view = require('../view.js')
/**
* 组件的属性列表
*/
properties: {
},
lifetimes: {
attached() {
this.getRatio()
}
},
Component({
behaviors: [view],
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
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
Component({ const view = require('../view.js')
/**
* 组件的属性列表
*/
properties: {
}, Component({
lifetimes: { behaviors: [view],
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
Component({ const view = require('../view.js')
/**
* 组件的属性列表
*/
properties: {
},
Component({
behaviors: [view],
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
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({
behaviors: [view],
data: { data: {
cWidth: 750, cWidth: 750,
cHeight: 500, cHeight: 500,
pixelRatio: 2, pixelRatio: 2,
}, },
attached() {
methods: {
getRatio() {
//这里的第一个 750 对应 css .charts 的 width //这里的第一个 750 对应 css .charts 的 width
const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth; const cWidth = 750 / 750 * wx.getSystemInfoSync().windowWidth;
//这里的 500 对应 css .charts 的 height //这里的 500 对应 css .charts 的 height
...@@ -19,25 +23,28 @@ Component({ ...@@ -19,25 +23,28 @@ Component({
}); });
this.getServerData(); this.getServerData();
}, },
methods: {
getServerData() { getServerData() {
const {viewCustomerPortrait:{browseDistribution}} = this.data,
categories = browseDistribution.map(i=>i.name),
data = browseDistribution.map(i=>i.value);
//模拟从服务器获取数据时的延时 //模拟从服务器获取数据时的延时
setTimeout(() => { setTimeout(() => {
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
let res = { let res = {
categories: ["2018", "2019", "2020", "2021", "2022", "2023"], categories,
series: [{ series: [{
name: "成交量A", data
data: [35, 8, 25, 37, 4, 20] }, ]
},
]
}; };
this.drawCharts('MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh', res); this.drawCharts('MkatSdTACyZKZRwWnLaWPTKfZrUmkBlh', res);
}, 500); }, 500);
}, },
drawCharts(id, data) { drawCharts(id, data) {
const query = wx.createSelectorQuery().in(this); const query = wx.createSelectorQuery().in(this);
query.select('#' + id).fields({ node: true, size: true }).exec(res => { query.select('#' + id).fields({
node: true,
size: true
}).exec(res => {
if (res[0]) { if (res[0]) {
const canvas = res[0].node; const canvas = res[0].node;
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
...@@ -54,7 +61,7 @@ Component({ ...@@ -54,7 +61,7 @@ Component({
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
...@@ -63,6 +70,7 @@ Component({ ...@@ -63,6 +70,7 @@ Component({
disableGrid: true, disableGrid: true,
axisLineColor: '#fff', axisLineColor: '#fff',
fontColor: '#A6A6A6', fontColor: '#A6A6A6',
fontSize: '10'
}, },
yAxis: { yAxis: {
gridType: "dash", gridType: "dash",
...@@ -83,7 +91,7 @@ Component({ ...@@ -83,7 +91,7 @@ Component({
} }
} }
}); });
}else{ } else {
console.error("[uCharts]: 未获取到 context"); console.error("[uCharts]: 未获取到 context");
} }
}); });
......
<!--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!