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 2070 additions and 479 deletions
...@@ -132,7 +132,15 @@ class outputApi { ...@@ -132,7 +132,15 @@ class outputApi {
...data ...data
}) })
} }
//客户画像展示
portraitView(data) {
return api.post({
method: 'entmicro.api.customer.portrait.view',
apiProjectName: 'entmicro',
...data
})
}
// 我的员工 // 我的员工
/** 服务商查询园区店员工产值统计 */ /** 服务商查询园区店员工产值统计 */
getStaffList(data) { getStaffList(data) {
......
...@@ -10,8 +10,8 @@ import '~/router/routerBefore' ...@@ -10,8 +10,8 @@ import '~/router/routerBefore'
import router from './router/index' import router from './router/index'
import BusassistantApi from "~/api/busassistantApi/index"; import BusassistantApi from "~/api/busassistantApi/index";
import { import {
Version Version
} from 'glsx-common-sdk' } from 'glsx-common-sdk'
// 有问题 前后顺序不能随意调整 // 有问题 前后顺序不能随意调整
// console.log(test) // console.log(test)
...@@ -56,11 +56,11 @@ App({ ...@@ -56,11 +56,11 @@ App({
wx.$storage = $Storage /** 挂载全局缓存方法 */ wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus wx.$eventbus = eventbus
wx.$versionConfig = new Version({ wx.$versionConfig = new Version({
request: { request: {
baseUrl: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config', baseUrl: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config',
isSign: false isSign: false
} }
}) })
// 存储设备信息 // 存储设备信息
setSystem_info() setSystem_info()
// console.log('test') // console.log('test')
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
"login/accountItems/accountItems", "login/accountItems/accountItems",
"packagesList/activityDetail/activityDetail", "packagesList/activityDetail/activityDetail",
"pages/tab/logout/logout", "pages/tab/logout/logout",
"packagesList/log/log" "packagesList/log/log",
"custom-tab-bar/index"
], ],
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation" "getLocation"
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
}, },
"__usePrivacyCheck__": true, "__usePrivacyCheck__": true,
"tabBar": { "tabBar": {
"custom": true,
"color": "#5A6066", "color": "#5A6066",
"selectedColor": "#3666FE", "selectedColor": "#3666FE",
"backgroundColor": "#FFFFFF", "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 \ 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 \ 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 \ 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 \ No newline at end of file
<view class='tips'> <view class='tips' bindtap="choose">
<view class='choose-box' bindtap="choose"> <view class='choose-box'>
<view class='icon'> <view class='icon'>
<icon wx:if="{{agree}}" class="icon-small" type="success" size="14" color="#4466F0"></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> <icon wx:else class="icon-small" type="circle" size="14" color="#4466F0"></icon>
......
...@@ -69,7 +69,6 @@ Component({ ...@@ -69,7 +69,6 @@ Component({
}, },
onLoad(options) { onLoad(options) {
console.log(options,'options');
const { merchantId, merchantName } = options; const { merchantId, merchantName } = options;
this.setData({ merchantId, merchantName }) this.setData({ merchantId, merchantName })
this.getSubscribeConfig(options) this.getSubscribeConfig(options)
......
...@@ -4,303 +4,292 @@ ...@@ -4,303 +4,292 @@
// import {scenceList} from "./constant/data" // import {scenceList} from "./constant/data"
import ActivityApi from "~/api/activityApi/index"; import ActivityApi from "~/api/activityApi/index";
import { import {
getActivityRecord getActivityRecord
} from '~/api/viewprod' } from '~/api/viewprod'
import { import {
IMG_VERSION IMG_VERSION
} from "~/utils/constantData"; } from "~/utils/constantData";
import { import {
imgUrlMixin imgUrlMixin
} from "~/mixins/index"; } from "~/mixins/index";
const IMG_URL = wx.$imgUrl; const IMG_URL = wx.$imgUrl;
let leftMenuIndex = 0 let leftMenuIndex = 0
Component({ Page({
properties: { // behaviors: [imgUrlMixin],
myTabIdx: Number data: {
}, // navList: ["增值服务", "客户数字化"],
behaviors: [imgUrlMixin], myTabIdx: 0,
data: { IMG_URL,
// navList: ["增值服务", "客户数字化"], // subscriptionBannerUrl: Object.freeze(subscriptionBannerUrl),
// myTabIdx: 0, // subscriptionSystemData: Object.freeze(subscriptionSystemData),
IMG_URL, activityList: [],
// subscriptionBannerUrl: Object.freeze(subscriptionBannerUrl), resScenceList: [],
// subscriptionSystemData: Object.freeze(subscriptionSystemData), curTabIdx: 0,
activityList: [], curTabId: 0,
resScenceList: [], img_version: IMG_VERSION(),
curTabIdx: 0, headerHeight: 0,
curTabId: 0, actNum: 0,
img_version: IMG_VERSION(), // navStyle,
headerHeight: 0, sceneCodeList: [],
actNum: 0, showPage: false,
// navStyle, systemData: [],
sceneCodeList: [], productData: [],
showPage: false, },
systemData: [], // 产品点击事件
productData: [], proClick(e) {
}, //登录的用户手机号
methods: { let userInfo = wx.$storage.get("userInfo");
// 产品点击事件 const {
proClick(e) { info,
//登录的用户手机号 sceneCode
let userInfo = wx.$storage.get("userInfo"); } = e.detail
const { let obj = {
info, phone: userInfo.phone,
sceneCode id: info.id,
} = e.detail sceneCode
let obj = { }
phone: userInfo.phone, wx.$router.go('/packagesList/packageDiscovery/pages/productDetail/productDetail', obj)
id: info.id, },
sceneCode
}
wx.$router.go('/packagesList/packageDiscovery/pages/productDetail/productDetail', obj)
},
sysMenuClick(e) { sysMenuClick(e) {
const { const {
id id
} = e.detail; } = e.detail;
leftMenuIndex = id; leftMenuIndex = id;
}, },
// 视频点击事件 // 视频点击事件
videoClick(e) { videoClick(e) {
const { info, sceneCode } = e.detail const {
// 一级菜单ID info,
const typeId = this.data.myTabIdx == 0 ? this.data.productDataId : this.data.systemDataId sceneCode
const obj = { } = e.detail
hasPhoneNumber: this.data.hasPhoneNumber, // 一级菜单ID
id: info.info.id, const typeId = this.data.myTabIdx == 0 ? this.data.productDataId : this.data.systemDataId
tabsActive: info.tabsActive, const obj = {
sceneCode, hasPhoneNumber: this.data.hasPhoneNumber,
typeId id: info.info.id,
} tabsActive: info.tabsActive,
wx.$router.go('/packagesList/packageDiscovery/pages/videoDetail/videoDetail', obj) sceneCode,
}, typeId
leftClick(e) { }
const { wx.$router.go('/packagesList/packageDiscovery/pages/videoDetail/videoDetail', obj)
sceneid },
} = e.detail leftClick(e) {
const idx = this.data.resScenceList?.findIndex(item => item.sceneid == sceneid) || 0 const {
this.setData({ sceneid
curTabId: sceneid, } = e.detail
curTabIdx: idx const idx = this.data.resScenceList?.findIndex(item => item.sceneid == sceneid) || 0
}) this.setData({
}, curTabId: sceneid,
senceClick(e) { curTabIdx: idx
// const { scenIndex } = e.detail })
// wx.$router.go('/packageStoreAssistant/packageDiscovery/pages/scenarioDetail/scenarioDetail', { },
// actNum: scenIndex senceClick(e) {
// }) // const { scenIndex } = e.detail
// 如果没有sceneCode,或者没有配置banner跳转 isBannerLink 2-没有配置 1-有配置 // wx.$router.go('/packageStoreAssistant/packageDiscovery/pages/scenarioDetail/scenarioDetail', {
if (!e.detail.sceneCode || e.detail.isBannerLink != 1) return // actNum: scenIndex
const { // })
hasPhoneNumber // 如果没有sceneCode,或者没有配置banner跳转 isBannerLink 2-没有配置 1-有配置
} = this.data if (!e.detail.sceneCode || e.detail.isBannerLink != 1) return
// 获取场景 const {
let systemItem = this.data.systemData.find(item => item.sceneCode == e.detail.sceneCode) hasPhoneNumber
let productItem = this.data.productData.find(item => item.sceneCode == e.detail.sceneCode) } = this.data
let id = '' // 获取场景
if (systemItem) { let systemItem = this.data.systemData.find(item => item.sceneCode == e.detail.sceneCode)
id = systemItem.subList.length ? systemItem.subList[0].productList[0]?.id : systemItem.productList[0].id let productItem = this.data.productData.find(item => item.sceneCode == e.detail.sceneCode)
} else { let id = ''
id = productItem.subList.length ? productItem.subList[0].productList[0]?.id : productItem.productList[0].id if (systemItem) {
} id = systemItem.subList.length ? systemItem.subList[0].productList[0]?.id : systemItem.productList[0].id
if (!id) return } else {
wx.$router.go('/packagesList/packageDiscovery/pages/productDetail/productDetail', { id = productItem.subList.length ? productItem.subList[0].productList[0]?.id : productItem.productList[0].id
hasPhoneNumber, }
id, if (!id) return
sceneCode: e.detail.sceneCode wx.$router.go('/packagesList/packageDiscovery/pages/productDetail/productDetail', {
}) hasPhoneNumber,
}, id,
sceneCode: e.detail.sceneCode
})
},
activityClick(e) { activityClick(e) {
const id = e.detail const id = e.detail
wx.$router.go( wx.$router.go(
"/packagesList/packageDiscovery/pages/activityDetail/activityDetail", { "/packagesList/packageDiscovery/pages/activityDetail/activityDetail", {
id id
} }
); );
}, },
// 获取全部活动列表 // 获取全部活动列表
getActivityRecord() { getActivityRecord() {
getActivityRecord({}).then(({ getActivityRecord({}).then(({
data, data,
code, code,
message message
}) => { }) => {
if (code == -1) { if (code == -1) {
wx.showToast({ wx.showToast({
title: message, title: message,
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
} }
this.setData({ this.setData({
activityList: data activityList: data
}) })
}) })
}, },
changeMyTab(e) { changeMyTab(e) {
const { const {
id id
} = e.currentTarget.dataset } = e.currentTarget.dataset
this.setData({ this.setData({
myTabIdx: id myTabIdx: id
}); });
}, },
onLoad(option) { onShow() {
// this.setData({ if (typeof this.getTabBar === 'function' ) {
// tabIndex: option?.tabIndex || 0 this.getTabBar((tabBar) => {
// }) tabBar.setData({
this.getActivityRecord() active: 1
const app = getApp() })
app.getBaseData().then(res => { })
const productData = res[0].subList }
const systemData = res[1].subList },
// this.getSceneData(productData) onLoad(option) {
this.setData({ // this.setData({
[`tabList[0].name`]: res[0].name, // tabIndex: option?.tabIndex || 0
[`tabList[1]name`]: res[1].name, // })
systemData, this.getActivityRecord()
systemDataId: res[1].id, const app = getApp()
productData, app.getBaseData().then(res => {
productDataId: res[0].id, const productData = res[0].subList
}) const systemData = res[1].subList
}) // this.getSceneData(productData)
}, this.setData({
emitUserInfo(options) { [`tabList[0].name`]: res[0].name,
[`tabList[1]name`]: res[1].name,
systemData,
systemDataId: res[1].id,
productData,
productDataId: res[0].id,
})
})
},
emitUserInfo(options) {
}, },
getSceneData(list) { getSceneData(list) {
const { const {
merchantId merchantId
} = wx.$storage.get("userInfo"); } = wx.$storage.get("userInfo");
wx.showLoading({ wx.showLoading({
title: "加载中...", title: "加载中...",
}); });
ActivityApi.getOpenSceneList({ ActivityApi.getOpenSceneList({
merchantId, merchantId,
}) })
.then((res) => { .then((res) => {
wx.hideLoading(); wx.hideLoading();
let productData = [] let productData = []
if (res.code == 21) { if (res.code == 21) {
wx.$router.reLaunch('/packageStoreAssistant/packageAuth/pages/authentication/login/login') wx.$router.reLaunch('/packageStoreAssistant/packageAuth/pages/authentication/login/login')
return; return;
} }
if (res?.data?.length > 0) { if (res?.data?.length > 0) {
// let res ={ // let res ={
// data: [ // data: [
// { // {
// sceneCode: "SC001", // sceneCode: "SC001",
// status: 1, // status: 1,
// }, // },
// { // {
// sceneCode: "SC002", // sceneCode: "SC002",
// status: 1, // status: 1,
// }, // },
// { // {
// sceneCode: "SC003", // sceneCode: "SC003",
// status: 1, // status: 1,
// }, // },
// { // {
// sceneCode: "SC004", // sceneCode: "SC004",
// status: 1, // status: 1,
// }, // },
// { // {
// sceneCode: "SC005", // sceneCode: "SC005",
// status: 1, // status: 1,
// }, // },
// ] // ]
// } // }
let openList = [] let openList = []
res.data.forEach(item => { res.data.forEach(item => {
if (item.status == 1) { if (item.status == 1) {
openList.push(item.sceneCode) openList.push(item.sceneCode)
} }
}) })
productData = list.filter(item => openList.includes(item.sceneCode)) productData = list.filter(item => openList.includes(item.sceneCode))
} }
}) })
.catch((err) => { .catch((err) => {
this.setData({ this.setData({
showPage: true, showPage: true,
}); });
}); });
}, },
navbarReady(e) { navbarReady(e) {
let { let {
height height
} = e.detail; } = e.detail;
this.setData({ this.setData({
headerHeight: height, headerHeight: height,
}); });
}, },
onPageScroll(scrollTop) { onPageScroll(scrollTop) {
let opacity = scrollTop / 100; let opacity = scrollTop / 100;
let color = `rgba(255,255,255${opacity > 1 ? 1 : opacity})`; let color = `rgba(255,255,255${opacity > 1 ? 1 : opacity})`;
// this.setData({ // this.setData({
// navStyle: scrollTop == 0 ? navStyle : `background-color:${color};` // navStyle: scrollTop == 0 ? navStyle : `background-color:${color};`
// }) // })
wx.$eventbus.emit("evt_page_scroll", { wx.$eventbus.emit("evt_page_scroll", {
scrollTop scrollTop
}); });
}, },
changeSwiper(e) { changeSwiper(e) {
this.setData({ this.setData({
actNum: e.detail.currentItemId, actNum: e.detail.currentItemId,
}); });
}, },
// 跳转咨询页面 // 跳转咨询页面
goConsult() { goConsult() {
wx.openCustomerServiceChat({ wx.openCustomerServiceChat({
extInfo: { extInfo: {
url: "https://work.weixin.qq.com/kfid/kfcf7b721472201345e" url: "https://work.weixin.qq.com/kfid/kfcf7b721472201345e"
}, },
corpId: "ww047bdc0f1e76cc13", corpId: "ww047bdc0f1e76cc13",
complete: (r) => { }, complete: (r) => {},
}); });
}, },
applyActivity() { applyActivity() {
wx.$router.go( wx.$router.go(
"/packagesList/packageActivity/pages/applyActivity/applyActivity" "/packagesList/packageActivity/pages/applyActivity/applyActivity"
); );
}, },
// 显示测算弹窗 // 显示测算弹窗
showCalculate() { showCalculate() {
wx.$router.go( wx.$router.go(
"/packagesList/packageDiscovery/pages/measure/measure/measure" "/packagesList/packageDiscovery/pages/measure/measure/measure"
); );
}, },
}, attached() {
attached() { this.setData({
this.setData({ isFullSucreen: wx.$api.isFullSucreen(),
isFullSucreen: wx.$api.isFullSucreen(), });
}); },
},
pageLifetimes: {
show() {
// const app = getApp()
// app.getBaseData().then(res => {
// const productData = res[0].subList
// const systemData = res[1].subList
// // this.getSceneData(productData)
// this.setData({
// [`tabList[0].name`]: res[0].name,
// [`tabList[1]name`]: res[1].name,
// systemData,
// systemDataId: res[1].id,
// productData,
// productDataId: res[0].id,
// })
// })
}
}
}); });
\ No newline at end of file \ No newline at end of file
<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"> <navigation-bar bindnavbarReady="navbarReady">
<view class="my-tab"> <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> <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({ ...@@ -6,6 +6,10 @@ const IMAGES = Object.freeze({
}) })
// import { getMockData } from '~/api/api' // import { getMockData } from '~/api/api'
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import util from '~/utils/util'
import {
wyMerchantId
} from '~/utils/request/environment'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -81,6 +85,19 @@ Page({ ...@@ -81,6 +85,19 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function (){ 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 { ...@@ -146,7 +146,7 @@ page {
.logoutBtn { .logoutBtn {
position: fixed; position: fixed;
bottom: 106rpx; bottom: 246rpx;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
font-size: 32rpx !important; font-size: 32rpx !important;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<view class="info"> <view class="info">
<view class="name">{{userInfo.merchantName}}</view> <view class="name">{{userInfo.merchantName}}</view>
<view class="id">{{userInfo.phone}}</view> <view class="id">{{userInfo.phone}}</view>
</view> </view>
<button class="logoutBtn" size="default" type="default" isabled="{{false}}" loading="{{false}}" bindtap="logout" hover-class="button-hover"> <button class="logoutBtn" size="default" type="default" isabled="{{false}}" loading="{{false}}" bindtap="logout" hover-class="button-hover">
退出登录 退出登录
......
// 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 util from '~/utils/util'
import { getMockData } from '~/api/api' import {
IMG_URL
} from '~/utils/constantData'
import {
getMockData
} from '~/api/api'
import {
wyMerchantId
} from '~/utils/request/environment'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
IMG_URL, IMG_URL,
isShow: true, isShow: true,
navStyle: 'background-color: rgba(0,0,0,0);', navStyle: 'background-color: rgba(0,0,0,0);',
loginType: 0, loginType: 0,
agree: true, agree: true,
tabIndx: 0, tabIndx: 0,
// tabList: ['我的客户', '我的门店', '我的员工'], // tabList: ['我的客户', '我的门店', '我的员工'],
tabList: ['我的客户', '我的员工'], tabList: ['我的客户', '我的员工'],
popupShow: false, popupShow: false,
subIndex: -1, subIndex: -1,
merchantList: [ merchantList: [{
{ merchantId: 0,
merchantId: 0, merchantName: 'string',
merchantName: 'string', show: true
show: true },
}, {
{ merchantId: 1,
merchantId: 1, merchantName: 'test',
merchantName: 'test', show: true
show: true }
],
isShowService: false,
},
// 切换园区
tapPicker() {
let {
isSuper
} = this.data
isSuper &&
this.setData({
moveArrow: !this.data.moveArrow,
popupShow: !this.data.popupShow
})
},
navbarReady(e) {
let {
height,
statusBarHeight
} = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight
})
// console.log(e)
},
changeTabIndx(e) {
this.setData({
tabIndx: e.detail
})
},
init() {
this.setUserInfo()
this.getMerchantRange()
// this.getMockInfo()
},
setUserInfo() {
let {
userInfo
} = wx.$storage.get()
// console.log(userInfo)
this.setData({
userInfo,
isSuper: userInfo.isSuper
})
},
async getMockInfo() {
let {
serviceMerchatList
} = await getMockData() || {
serviceMerchatList: []
}
this.setData({
isShowService: serviceMerchatList.includes(this.data.userInfo.merchantId + '')
})
},
getMerchantRange(e) {
// 重新刷新
// let { detail } = e || null
// console.log(detail)
if (e) {
this.setUserInfo()
let clientModule = this.selectComponent('#client')
// let merchantModule = this.selectComponent('#merchant')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
// merchantModule.init && merchantModule.init()
}
let {
isSuper,
userInfo
} = this.data
// 判断是超管才需要切换账号
if (isSuper) {
USERAPI.adminSelectLogin()
.then(result => {
// console.log(result)
let {
merchantList: merchantRange
} = result
// console.log(merchantRange)
let subIndex = -1
merchantRange.forEach((item, index) => {
item.show = true
if (item.merchantId == userInfo.subLoginUser.merchantId) {
subIndex = index
item.act = true
} }
], })
isShowService: false, this.setData({
}, merchantRange,
// 切换园区 subIndex
tapPicker() { })
let { isSuper } = this.data
isSuper &&
this.setData({
moveArrow: !this.data.moveArrow,
popupShow: !this.data.popupShow
})
},
navbarReady(e) {
let { height, statusBarHeight } = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight
})
// console.log(e)
},
changeTabIndx(e) {
this.setData({
tabIndx: e.detail
})
},
init() {
this.setUserInfo()
this.getMerchantRange()
// this.getMockInfo()
},
setUserInfo() {
let { userInfo } = wx.$storage.get()
// console.log(userInfo)
this.setData({
userInfo,
isSuper: userInfo.isSuper
}) })
}, .catch(err => {})
async getMockInfo() { } else {
let { serviceMerchatList } = await getMockData() || { serviceMerchatList: [] } let merchantRange = [{
this.setData({ merchantId: userInfo.subLoginUser.merchantId,
isShowService: serviceMerchatList.includes(this.data.userInfo.merchantId + '') merchantName: userInfo.subLoginUser.merchantName
}) }]
}, this.setData({
getMerchantRange(e) { merchantRange,
// 重新刷新 subIndex: 0
// let { detail } = e || null })
// console.log(detail) }
if (e) { },
this.setUserInfo()
let clientModule = this.selectComponent('#client')
// let merchantModule = this.selectComponent('#merchant')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
// merchantModule.init && merchantModule.init()
}
let { isSuper, userInfo } = this.data
// 判断是超管才需要切换账号 onRoute(options) {
if (isSuper) { if (!options || wx.$util.isEmptyObj(options)) return
USERAPI.adminSelectLogin() let {
.then(result => { page = 'client', refresh = true
// console.log(result) } = options
let { merchantList: merchantRange } = result if (page == 'client' && refresh) {
// console.log(merchantRange) let clientModule = this.selectComponent('#client')
let subIndex = -1 clientModule.getClientApi && clientModule.clientRefresh()
merchantRange.forEach((item, index) => { clientModule.getBusinessData && clientModule.getBusinessData()
item.show = true }
if (item.merchantId == userInfo.subLoginUser.merchantId) { },
subIndex = index /**
item.act = true * 生命周期函数--监听页面加载
} */
}) onLoad(options) {
this.setData({ if (wyMerchantId.includes(+wx.$storage.get().userInfo.merchantId)) {
merchantRange, this.setData({
subIndex isWy: true
}) })
}) this.getTabBar().setData({
.catch(err => { }) active: 2,
} else { isShow:false
let merchantRange = [{ merchantId: userInfo.subLoginUser.merchantId, merchantName: userInfo.subLoginUser.merchantName }] })
this.setData({ }
merchantRange, const {
subIndex: 0 merchantId,
}) type,
} merchantName
}, } = options
if (merchantId) {
wx.navigateTo({
url: `/packagesList/outDetail/index?merchantId=${merchantId}&type=${type}&merchantName=${merchantName}`,
})
this.setData({
isShow: false
}, () => {
setTimeout(() => {
this.setData({
isShow: true
})
}, 1000)
})
onRoute(options) { }
if (!options || wx.$util.isEmptyObj(options)) return this.init()
let { page = 'client', refresh = true } = options },
if (page == 'client' && refresh) {
let clientModule = this.selectComponent('#client')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const {merchantId,type,merchantName} = options
if (merchantId) {
wx.navigateTo({
url: `/packagesList/outDetail/index?merchantId=${merchantId}&type=${type}&merchantName=${merchantName}`,
})
this.setData({ isShow: false }, () => {
setTimeout(() => {
this.setData({ isShow: true })
}, 1000)
})
} /**
this.init() * 生命周期函数--监听页面初次渲染完成
}, */
onReady() {
// console.log(getTextWidth('随后获取dom元素的clientWidth 随后获取dom元素的clientWidth随后获取dom元素的clientWidth随后获取dom元素的clientWidth', '12px'))
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面显示
*/ */
onReady() { onShow() {
// console.log(getTextWidth('随后获取dom元素的clientWidth 随后获取dom元素的clientWidth随后获取dom元素的clientWidth随后获取dom元素的clientWidth', '12px')) let title = '看产值'
}, 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);
*/ title = wx.$storage.get().userInfo.merchantName
onShow() { }, }
tabBar.setData({
active: 0,list
})
})
}
this.setData({title})
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() { }, onHide() {},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload() { }, onUnload() {},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { }, onPullDownRefresh() {},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { }, onReachBottom() {},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() { } onShareAppMessage() {}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"usingComponents": { "usingComponents": {
"navigation-bar": "../../../components/NavigationBar/NavigationBar", "navigation-bar": "../../../components/NavigationBar/NavigationBar",
"tab": "../../../components/Tab/Tab", "tab": "../../../components/Tab/Tab",
"client": "./components/client/client" "client": "./components/client/client",
"stat": "../stat/stat"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }
...@@ -46,7 +46,6 @@ page { ...@@ -46,7 +46,6 @@ page {
#client { #client {
height: 100%; height: 100%;
} }
.tabContainer { .tabContainer {
height: 100rpx; height: 100rpx;
padding: 0 32rpx; padding: 0 32rpx;
......
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
<block wx:if="{{isShow}}"> <block wx:if="{{isShow}}">
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">看产值</navigation-bar> <navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">{{title}}</navigation-bar>
<view class="layout" wx:if="{{isWy}}">
<view class="layout" id="layout" style="padding-top:{{navHeight}}px; height: calc(100vh - 150rpx)"> <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" /> <client id="client" />
</view> </view>
</block> </block>
\ No newline at end of file \ 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 \ 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 \ 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 \ 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 \ 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 \ 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 \ 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 \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ 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 \ 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 \ 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 \ 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 \ 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 \ No newline at end of file
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file \ 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 \ 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 \ 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 \ 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 \ 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 \ 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 \ No newline at end of file
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file \ 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 \ 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 \ 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 \ No newline at end of file
{
"component": true,
"usingComponents": {
"circle": "../circle/circle"
}
}
\ No newline at end of file \ 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 \ 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 \ 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 \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ 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 \ 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 \ 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 \ 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 \ No newline at end of file
/* pages/tab/stat/stat.wxss */
.stat-box {
background: #F8F9F9;
}
\ No newline at end of file \ 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 \ No newline at end of file
{ {
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "3.0.1", "libVersion": "3.1.2",
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
...@@ -190,7 +190,8 @@ ...@@ -190,7 +190,8 @@
} }
}, },
"setting": { "setting": {
"urlCheck": true "urlCheck": false,
"compileHotReLoad": true
}, },
"projectname": "store-assistant-assemble" "projectname": "store-assistant-assemble"
} }
\ No newline at end of file \ No newline at end of file
...@@ -13,6 +13,7 @@ const mockObj = { ...@@ -13,6 +13,7 @@ const mockObj = {
3生产 3生产
*/ */
// const index = 1 // const index = 1
const accountInfo = wx.getAccountInfoSync() const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync() const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo); // console.log(systemInfo);
...@@ -150,12 +151,12 @@ const pathEnum = { ...@@ -150,12 +151,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: [44212578,44212577],
preRelease: '44184606', preRelease: [44184606],
prod: '44189923' prod: [44209565,44209566,44209719,44209718,44209715]
}[target[index]] }[target[index]]
let mockUrl = { let mockUrl = {
...@@ -171,6 +172,6 @@ module.exports = { ...@@ -171,6 +172,6 @@ module.exports = {
pathEnum, pathEnum,
secretKey, secretKey,
djSecretKey, djSecretKey,
defaultMerchantId, wyMerchantId,
mockUrl 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) { ...@@ -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!