Compare commits
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Eslint config file
|
||||
* Documentation: https://eslint.org/docs/user-guide/configuring/
|
||||
* Install the Eslint extension before using this feature.
|
||||
*/
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
ecmaFeatures: {
|
||||
modules: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
globals: {
|
||||
wx: true,
|
||||
App: true,
|
||||
Page: true,
|
||||
getCurrentPages: true,
|
||||
getApp: true,
|
||||
Component: true,
|
||||
requirePlugin: true,
|
||||
requireMiniProgram: true,
|
||||
},
|
||||
// extends: 'eslint:recommended',
|
||||
rules: {},
|
||||
}
|
||||
@@ -1 +1,31 @@
|
||||
.idea/
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# 环境变量文件(含敏感配置,禁止提交)
|
||||
# .env
|
||||
# .env.*
|
||||
.mcp.json
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.claude
|
||||
.turbo
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,10 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 已忽略包含查询文件的默认文件夹
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ClaudeCodeTabState">
|
||||
<option name="tabCount" value="4" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
<component name="KubernetesApiProvider">{
|
||||
"isMigrated": true
|
||||
}</component>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/bodyWeight.iml" filepath="$PROJECT_DIR$/.idea/bodyWeight.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,336 +0,0 @@
|
||||
App({
|
||||
onLaunch() {
|
||||
this.initPpScale();
|
||||
},
|
||||
|
||||
globalData: {
|
||||
// wx.request 请求的服务地址
|
||||
wxRequestUrl: "https://device.shuziweidao.com/gateway/",
|
||||
// wxRequestUrl: "http://192.168.1.207:8889/",
|
||||
|
||||
// 秤的所有信息
|
||||
ppScale: {
|
||||
version: "",
|
||||
|
||||
plugin: null,
|
||||
activeProtocol: null,
|
||||
domain1: "http://device.shuziweidao.com:80/gateway", // 老版本 没有鉴权
|
||||
domain2: "http://device.shuziweidao.com:80/weight", // 新版本 有鉴权
|
||||
// domain1: "http://192.168.1.207:8889", // 老版本 没有鉴权
|
||||
// domain2: "http://192.168.1.207:8889/weight", // 新版本 有鉴权
|
||||
wifi: {
|
||||
ssid: "",
|
||||
password: ""
|
||||
},
|
||||
options: {
|
||||
key: "lefudc91611833e18d94",
|
||||
secret: "eQ50JYimMp0X7uhNLj6D3lTEk4TUUvEG7dvaqKM9t1U="
|
||||
},
|
||||
device: {
|
||||
setting: [{
|
||||
"advLength": 999,
|
||||
"calorieStatus": 0,
|
||||
"createBy": null,
|
||||
"deviceAccuracyType": 2,
|
||||
"deviceCalcuteType": 3,
|
||||
"deviceConnectType": 2,
|
||||
"deviceFuncType": 223,
|
||||
"deviceName": "CF568_G",
|
||||
"devicePowerType": 3,
|
||||
"deviceProtocolType": 3,
|
||||
"deviceType": 1,
|
||||
"deviceUnitType": "0,1,11",
|
||||
"id": 65,
|
||||
"imgUrl": null,
|
||||
"macAddressStart": 6,
|
||||
"remark": null,
|
||||
"sign": "FF",
|
||||
"status": 0,
|
||||
"uhStatus": 1,
|
||||
"updateBy": null
|
||||
}, {
|
||||
"advLength": 999,
|
||||
"calorieStatus": 0,
|
||||
"createBy": null,
|
||||
"deviceAccuracyType": 2,
|
||||
"deviceCalcuteType": 3,
|
||||
"deviceConnectType": 2,
|
||||
"deviceFuncType": 223,
|
||||
"deviceName": "YX-B4-568-BW",
|
||||
"devicePowerType": 3,
|
||||
"deviceProtocolType": 3,
|
||||
"deviceType": 1,
|
||||
"deviceUnitType": "0,1,11",
|
||||
"id": 65,
|
||||
"imgUrl": null,
|
||||
"macAddressStart": 6,
|
||||
"remark": null,
|
||||
"sign": "FF",
|
||||
"status": 0,
|
||||
"uhStatus": 1,
|
||||
"updateBy": null
|
||||
}, {
|
||||
"advLength": 999,
|
||||
"calorieStatus": 0,
|
||||
"createBy": null,
|
||||
"deviceAccuracyType": 2,
|
||||
"deviceCalcuteType": 4,
|
||||
"deviceConnectType": 2,
|
||||
"deviceFuncType": 65759,
|
||||
"deviceName": "CF636_G",
|
||||
"devicePowerType": 3,
|
||||
"deviceProtocolType": 3,
|
||||
"deviceType": 1,
|
||||
"deviceUnitType": "0,1,2",
|
||||
"id": 216,
|
||||
"imgUrl": null,
|
||||
"macAddressStart": 6,
|
||||
"remark": null,
|
||||
"sign": "FF",
|
||||
"status": 0,
|
||||
"uhStatus": 1,
|
||||
"updateBy": null
|
||||
}, {
|
||||
"advLength": 999,
|
||||
"calorieStatus": 0,
|
||||
"createBy": null,
|
||||
"deviceAccuracyType": 2,
|
||||
"deviceCalcuteType": 4,
|
||||
"deviceConnectType": 2,
|
||||
"deviceFuncType": 65759,
|
||||
"deviceName": "YX-B8-636-BW",
|
||||
"devicePowerType": 3,
|
||||
"deviceProtocolType": 3,
|
||||
"deviceType": 1,
|
||||
"deviceUnitType": "0,1,2",
|
||||
"id": 216,
|
||||
"imgUrl": null,
|
||||
"macAddressStart": 6,
|
||||
"remark": null,
|
||||
"sign": "FF",
|
||||
"status": 0,
|
||||
"uhStatus": 1,
|
||||
"updateBy": null
|
||||
}, {
|
||||
"advLength": 999,
|
||||
"calorieStatus": 0,
|
||||
"createBy": null,
|
||||
"deviceAccuracyType": 2,
|
||||
"deviceCalcuteType": 4,
|
||||
"deviceConnectType": 2,
|
||||
"deviceFuncType": 223,
|
||||
"deviceName": "CF577",
|
||||
"devicePowerType": 3,
|
||||
"deviceProtocolType": 3,
|
||||
"deviceType": 1,
|
||||
"deviceUnitType": "0,1,11",
|
||||
"id": 51,
|
||||
"imgUrl": null,
|
||||
"macAddressStart": 6,
|
||||
"remark": null,
|
||||
"sign": "FF",
|
||||
"status": 0,
|
||||
"uhStatus": 1,
|
||||
"updateBy": null
|
||||
}], // 即将要搜索周边秤的配置
|
||||
list: [], // 根据配置搜索到秤的列表
|
||||
name: "",
|
||||
mac: null, // 选中的设备mac地址/SN码
|
||||
connection: null, // 默认选中连接的设备
|
||||
connectState: null, // 当前连接设备的状态
|
||||
version: null, // 当前连接设备的固件版本
|
||||
},
|
||||
reconnect: {
|
||||
count: 0, // 当前已重连次数
|
||||
max: 3, // 最大重连次数
|
||||
timer: null // 重连定时器
|
||||
}
|
||||
},
|
||||
|
||||
_callbacks: {} // 用于存储所有 globalData 属性的监听回调
|
||||
},
|
||||
|
||||
initPpScale() {
|
||||
this.globalData.ppScale.plugin = requirePlugin('ppScale-plugin');
|
||||
},
|
||||
|
||||
// 保活定时器引用
|
||||
_keepAliveTimer: null,
|
||||
|
||||
/**
|
||||
* 启动保活定时器,每 15 秒发送一次保活指令
|
||||
* 内部已做去重处理,重复调用安全
|
||||
*/
|
||||
startKeepAlive() {
|
||||
this.stopKeepAlive();
|
||||
this._keepAliveTimer = setInterval(() => {
|
||||
if (this.globalData.ppScale.activeProtocol) {
|
||||
this.globalData.ppScale.activeProtocol.sendKeepAliveCode();
|
||||
}
|
||||
}, 15000);
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除保活定时器
|
||||
*/
|
||||
stopKeepAlive() {
|
||||
if (this._keepAliveTimer) {
|
||||
clearInterval(this._keepAliveTimer);
|
||||
this._keepAliveTimer = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面离开时的统一清理:停止保活 + 重置重连计数 + connectState 置空 + 停止蓝牙
|
||||
*/
|
||||
cleanupConnection() {
|
||||
this.stopKeepAlive();
|
||||
this.resetReconnectCount();
|
||||
this.setGlobalData('ppScale.device.connectState', null);
|
||||
this.globalData.ppScale.plugin.Blue.stop();
|
||||
},
|
||||
|
||||
/**
|
||||
* 注册全局 bus 事件监听(connectState / syncDeviceTimeSuccess / deviceWillDisconnect)
|
||||
* 依赖 Blue.stop() 清空订阅,onShow 时直接调用,无需标志位
|
||||
*/
|
||||
registerBusListeners() {
|
||||
const plugin = this.globalData.ppScale.plugin;
|
||||
|
||||
// 蓝牙连接状态监听
|
||||
plugin.bus.subscribe('connectState', (res) => {
|
||||
console.log("app.js ===> connectState", res);
|
||||
this.setGlobalData('ppScale.device.connectState', res);
|
||||
if (res == plugin.BLUE_STATE.CONNECTSUCCESS) {
|
||||
this.globalData.ppScale.reconnect.count = 0;
|
||||
this.startKeepAlive();
|
||||
}
|
||||
if (res == plugin.BLUE_STATE.CONNECTFAILED) {
|
||||
this.stopKeepAlive();
|
||||
this.reconnectDevice();
|
||||
}
|
||||
wx.hideLoading();
|
||||
});
|
||||
|
||||
// 同步时间
|
||||
plugin.bus.subscribe('syncDeviceTimeSuccess', (res) => {
|
||||
console.log("app.js ===> syncDeviceTimeSuccess", res);
|
||||
});
|
||||
|
||||
// 设备自动断开监听
|
||||
plugin.bus.subscribe('deviceWillDisconnect', (res) => {
|
||||
console.log("app.js ===> deviceWillDisconnect", res);
|
||||
this.stopKeepAlive();
|
||||
this.setGlobalData('ppScale.device.connectState', plugin.BLUE_STATE.CONNECTFAILED);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 自动重连设备,最多重试 max 次,超过后停止,由用户手动重连
|
||||
* 只在配置页(configureDevice)活跃时执行,防止跨页面干扰
|
||||
*/
|
||||
reconnectDevice() {
|
||||
const reconnect = this.globalData.ppScale.reconnect;
|
||||
|
||||
// 仅在配置页活跃时执行重连
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
if (!currentPage || !currentPage.route || !currentPage.route.includes('configureDevice')) {
|
||||
console.log("app.js ===> 非配置页,跳过自动重连");
|
||||
return;
|
||||
}
|
||||
|
||||
if (reconnect.count >= reconnect.max) {
|
||||
console.log("app.js ===> 自动重连已达上限,等待用户手动重试");
|
||||
return;
|
||||
}
|
||||
|
||||
reconnect.count++;
|
||||
console.log(`app.js ===> 自动重连第 ${reconnect.count}/${reconnect.max} 次`);
|
||||
|
||||
// 延迟 2 秒后重连,避免连续冲突
|
||||
if (reconnect.timer) {
|
||||
clearTimeout(reconnect.timer);
|
||||
}
|
||||
reconnect.timer = setTimeout(() => {
|
||||
this.globalData.ppScale.plugin.Blue.disconnect((disres) => {
|
||||
if (disres.errCode == 0) {
|
||||
console.log("app.js ===> 断开成功,开始重新扫描设备");
|
||||
this.globalData.ppScale.plugin.Blue.startBluetoothDevicesDiscovery();
|
||||
} else {
|
||||
console.log("app.js ===> 断开失败,errCode:", disres.errCode);
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
/**
|
||||
* 重置重连计数,用于用户手动点击重试或页面离开时调用
|
||||
*/
|
||||
resetReconnectCount() {
|
||||
const reconnect = this.globalData.ppScale.reconnect;
|
||||
reconnect.count = 0;
|
||||
if (reconnect.timer) {
|
||||
clearTimeout(reconnect.timer);
|
||||
reconnect.timer = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 注册 globalData 某个属性的监听
|
||||
* @param {string} keyPath 要监听的 globalData 属性路径,例如 'ppScale.device.connectState'
|
||||
* @param {function} callback 属性变化时执行的回调函数 (newValue, oldValue) => {}
|
||||
*/
|
||||
watch(keyPath, callback) {
|
||||
if (!this.globalData._callbacks[keyPath]) {
|
||||
this.globalData._callbacks[keyPath] = [];
|
||||
}
|
||||
this.globalData._callbacks[keyPath].push(callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消 globalData 某个属性的监听
|
||||
* @param {string} keyPath 要取消监听的 globalData 属性路径
|
||||
* @param {function} callback 之前注册的回调函数
|
||||
*/
|
||||
unwatch(keyPath, callback) {
|
||||
if (this.globalData._callbacks[keyPath]) {
|
||||
this.globalData._callbacks[keyPath] = this.globalData._callbacks[keyPath].filter(cb => cb !== callback);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置 globalData 的值并触发所有相关监听器
|
||||
* 支持点表示法设置嵌套属性,例如 'ppScale.device.connectState'
|
||||
* @param {string} keyPath 要设置的 globalData 属性路径
|
||||
* @param {*} value 要设置的新值
|
||||
*/
|
||||
setGlobalData(keyPath, value) {
|
||||
const keys = keyPath.split('.');
|
||||
let current = this.globalData;
|
||||
let oldValue = undefined;
|
||||
|
||||
// 遍历到目标属性的父级
|
||||
for (let i = 0; i < keys.length - 1; i++) {
|
||||
if (!current[keys[i]]) {
|
||||
current[keys[i]] = {}; // 如果路径不存在,创建空对象
|
||||
}
|
||||
current = current[keys[i]];
|
||||
}
|
||||
|
||||
// 获取旧值
|
||||
oldValue = current[keys[keys.length - 1]];
|
||||
|
||||
// 只有当值发生变化时才更新并通知
|
||||
if (oldValue !== value) {
|
||||
current[keys[keys.length - 1]] = value; // 设置新值
|
||||
|
||||
// 触发监听器
|
||||
if (this.globalData._callbacks[keyPath]) {
|
||||
this.globalData._callbacks[keyPath].forEach(callback => {
|
||||
callback(value, oldValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/home/home",
|
||||
"pages/help/help",
|
||||
"pages/searchDevice/searchDevice",
|
||||
"pages/configureDevice/configureDevice",
|
||||
"pages/my/my"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarBackgroundColor": "#ffffff"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#808080",
|
||||
"selectedColor": "#1385FA",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"iconPath": "/images/tabBar/home.png",
|
||||
"selectedIconPath": "/images/tabBar/home_.png",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/my/my",
|
||||
"iconPath": "/images/tabBar/my.png",
|
||||
"selectedIconPath": "/images/tabBar/my_.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "v2",
|
||||
"plugins": {
|
||||
"ppScale-plugin": {
|
||||
"version": "0.0.24",
|
||||
"provider": "wx0826af4e4908f524"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "您的位置信息将用于发现附近的蓝牙设备,以便连接蓝牙秤。"
|
||||
}
|
||||
},
|
||||
"requiredPrivateInfos": [
|
||||
"getLocation"
|
||||
],
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #F5F7FB;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
button {
|
||||
all: unset;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
button::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.scrollView {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.arrowAfter {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.arrowAfter::after {
|
||||
position: absolute;
|
||||
right: 6rpx;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
content: "";
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-left: 5rpx solid #b6b6b6;
|
||||
border-top: 5rpx solid #b6b6b6;
|
||||
transform: rotate(135deg);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
data: {
|
||||
devices: []
|
||||
},
|
||||
|
||||
// 生命周期方法
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.setData({
|
||||
devices: app.globalData.ppScale.device.list
|
||||
})
|
||||
},
|
||||
detached() {
|
||||
this.setData({
|
||||
devices: []
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
selectDevice(e) {
|
||||
let device = this.data.devices[e.currentTarget.dataset.i];
|
||||
this.triggerEvent('deviceEvent', {
|
||||
device: device,
|
||||
status: true
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<view class="configureDevice1">
|
||||
<view class="title">蓝牙</view>
|
||||
<view class="describe">可用设备</view>
|
||||
<view class="deviceName">
|
||||
<block wx:for="{{devices}}" wx:key="index">
|
||||
<view data-i="{{index}}" bind:tap="selectDevice">
|
||||
<view>
|
||||
<image src="/images/configureDevice/bluetooth.png"/>
|
||||
</view>
|
||||
<view>
|
||||
<view>{{item.name}}</view>
|
||||
<!-- <view>正在配对</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,70 +0,0 @@
|
||||
.configureDevice1 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 60rpx 60rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.describe {
|
||||
color: #B6B6B6;
|
||||
width: 100%;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 30rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.deviceName {
|
||||
width: 100%;
|
||||
height: calc(100% - 166rpx);
|
||||
}
|
||||
|
||||
.deviceName>view {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.deviceName>view>view:nth-of-type(1) {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
margin-right: 22rpx;
|
||||
}
|
||||
|
||||
.deviceName>view>view:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.deviceName>view>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 32rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
.deviceName>view>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
color: #808080;
|
||||
width: 100%;
|
||||
height: 28rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
@@ -1,315 +0,0 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
/**
|
||||
* 根据生日计算年龄
|
||||
* @param {string} birthday 生日字符串,如 "1990-05-20"
|
||||
* @returns {number|null} 年龄,无法计算时返回 null
|
||||
*/
|
||||
function calcAge(birthday) {
|
||||
if (!birthday) return null;
|
||||
let birthDate = new Date(birthday.replace(/-/g, '/'));
|
||||
if (isNaN(birthDate.getTime())) return null;
|
||||
let today = new Date();
|
||||
let age = today.getFullYear() - birthDate.getFullYear();
|
||||
let monthDiff = today.getMonth() - birthDate.getMonth();
|
||||
// 未过生日则减一岁
|
||||
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
||||
age--;
|
||||
}
|
||||
return age;
|
||||
}
|
||||
|
||||
Component({
|
||||
data: {
|
||||
BLUE_STATE: {},
|
||||
device: null,
|
||||
connectState: "",
|
||||
userList: [],
|
||||
},
|
||||
|
||||
// 存储回调函数的引用,以便在 detached 时取消监听
|
||||
_connectStateWatcher: null,
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log(`[Component] connectState 获取: ${app.globalData.ppScale.device.connectState}`);
|
||||
this.setData({
|
||||
BLUE_STATE: app.globalData.ppScale.plugin.BLUE_STATE,
|
||||
connectState: app.globalData.ppScale.device.connectState,
|
||||
device: app.globalData.ppScale.device.connection
|
||||
})
|
||||
this._connectStateWatcher = (newValue, oldValue) => {
|
||||
console.log(`[Component] connectState 变化: ${oldValue} -> ${newValue}`);
|
||||
this.setData({
|
||||
connectState: newValue || ''
|
||||
});
|
||||
};
|
||||
app.watch('ppScale.device.connectState', this._connectStateWatcher);
|
||||
|
||||
this.fetchUserList();
|
||||
},
|
||||
detached() {
|
||||
if (this._connectStateWatcher) {
|
||||
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
// 长按型号区域初始化设备
|
||||
onDeviceLongPress() {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "确定要初始化设备吗?将清除设备中的所有数据(用户信息、历史数据、配网数据、设置信息)。",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
if (!app.globalData.ppScale.activeProtocol) {
|
||||
wx.showToast({ title: "设备未连接,请重试", icon: "none" });
|
||||
return;
|
||||
}
|
||||
wx.showLoading({ title: "正在初始化设备...", mask: true });
|
||||
app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (status) => {
|
||||
wx.hideLoading();
|
||||
if (status == 0) {
|
||||
wx.showToast({ title: "设备初始化成功", icon: "success" });
|
||||
// 断开蓝牙连接并返回上一页
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({ delta: 1 });
|
||||
}, 1500);
|
||||
} else {
|
||||
wx.showToast({ title: "设备初始化失败,请重试", icon: "none" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 手动重连设备
|
||||
connectedDevice() {
|
||||
app.resetReconnectCount();
|
||||
this.triggerEvent('connectedDeviceEvent', {
|
||||
device: this.data.device
|
||||
});
|
||||
},
|
||||
|
||||
addUser() {
|
||||
if (this.data.userList.length >= 10) {
|
||||
wx.showToast({
|
||||
title: "超过最大用户数",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 列表为空时,第一个用户只能是员工(主用户)
|
||||
const isFirstUser = this.data.userList.length === 0;
|
||||
this.selectComponent("#configureDevice2AddUser").showModal(isFirstUser);
|
||||
},
|
||||
|
||||
getAddUserInfo() {
|
||||
this.fetchUserList();
|
||||
},
|
||||
|
||||
// 获取设备绑定的用户列表
|
||||
fetchUserList() {
|
||||
if (!app.globalData.ppScale.device.mac) {
|
||||
wx.showToast({ title: '设备 MAC 地址为空,请重新连接', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
$.ajax("weighingScale/v2/select/user", { sn }, "GET", true, "正在获取用户列表...").then(res => {
|
||||
if (res.result && res.result.length) {
|
||||
let list = res.result.map(user => {
|
||||
// 没有 age 时通过 birthday 计算
|
||||
if (!user.age && user.birthday) {
|
||||
user.age = calcAge(user.birthday);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
this.setData({ userList: list });
|
||||
} else {
|
||||
this.setData({ userList: [] });
|
||||
}
|
||||
}).catch(() => {
|
||||
wx.showToast({
|
||||
title: "用户列表获取失败",
|
||||
icon: "none"
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 删除用户
|
||||
delUserClick(e) {
|
||||
let id = e.currentTarget.dataset.id;
|
||||
const userList = this.data.userList;
|
||||
const target = userList.find(u => u.id === id);
|
||||
|
||||
// 主用户(userType=1)有子用户时不允许删除
|
||||
if (target && target.userType === 1) {
|
||||
const hasSubUser = userList.some(u => u.userType === 0);
|
||||
if (hasSubUser) {
|
||||
wx.showToast({ title: "请先删除所有普通用户", icon: "none" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "确定要删除该用户吗?",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
$.ajax("weighingScale/v2/del/user", { id }, "DELETE", true, "正在删除...", "application/x-www-form-urlencoded").then(() => {
|
||||
wx.showToast({
|
||||
title: "删除成功",
|
||||
icon: "success"
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.fetchUserList();
|
||||
}, 1500)
|
||||
}).catch(() => {
|
||||
wx.showToast({
|
||||
title: "删除失败,请重试",
|
||||
icon: "none"
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
setUserInfo() {
|
||||
if (this.data.connectState != this.data.BLUE_STATE.CONNECTSUCCESS && this.data.connectState != this.data.BLUE_STATE.WIFISUCCESS) {
|
||||
wx.showToast({
|
||||
title: "设备连接失败,请重试。",
|
||||
icon: "none"
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
let userList = this.data.userList;
|
||||
if (!userList.length) {
|
||||
wx.showToast({
|
||||
title: "暂无用户信息,请先添加用户",
|
||||
icon: "none"
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
// 找出主用户,所有用户下发时 userID 统一使用主用户的 userId
|
||||
const mainUser = userList.find(u => u.userType === 1);
|
||||
if (!mainUser) {
|
||||
wx.showToast({ title: "未找到主用户,请先添加员工用户", icon: "none" });
|
||||
return;
|
||||
}
|
||||
const mainUserId = mainUser.userId;
|
||||
|
||||
wx.showLoading({ title: "正在同步用户数据...", mask: true });
|
||||
|
||||
// 第一步:清除秤上所有用户信息(15秒超时保护)
|
||||
let clearTimer = setTimeout(() => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "清除设备数据超时,请重试", icon: "none" });
|
||||
}, 15000);
|
||||
|
||||
app.globalData.ppScale.activeProtocol.codeClearDeviceData("01", (clearRes) => {
|
||||
clearTimeout(clearTimer);
|
||||
console.log("codeClearDeviceData res", clearRes);
|
||||
if (clearRes !== 0x00) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "同步用户失败,请重试", icon: "none" });
|
||||
return;
|
||||
}
|
||||
|
||||
// 第二步:全量下发本地用户列表
|
||||
let syncIndex = 0;
|
||||
let syncTimer = null;
|
||||
|
||||
// 清除超时定时器
|
||||
const clearSyncTimer = () => {
|
||||
if (syncTimer) {
|
||||
clearTimeout(syncTimer);
|
||||
syncTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
// 重置超时定时器,10秒无响应则认定失败
|
||||
const resetSyncTimer = () => {
|
||||
clearSyncTimer();
|
||||
syncTimer = setTimeout(() => {
|
||||
console.log("dataSyncUserInfo 超时,第" + (syncIndex + 1) + "个用户下发超时");
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "用户信息下发超时,请重试", icon: "none" });
|
||||
}, 15000);
|
||||
};
|
||||
|
||||
const syncNext = () => {
|
||||
if (syncIndex >= userList.length) {
|
||||
// 全部下发完成,清除定时器
|
||||
clearSyncTimer();
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "用户信息同步成功", icon: "success" });
|
||||
setTimeout(() => {
|
||||
this._checkWifiAndNext();
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
const user = userList[syncIndex];
|
||||
// 主用户 memberID 为空,子用户 memberID 为子用户自己的 userId
|
||||
const memberID = user.userId === mainUserId ? "" : user.userId;
|
||||
wx.showLoading({ title: "正在下发第" + (syncIndex + 1) + "/" + userList.length + "个用户...", mask: true });
|
||||
// 每次下发前重置10秒超时定时器
|
||||
resetSyncTimer();
|
||||
app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
|
||||
userID: mainUserId,
|
||||
userName: user.realname,
|
||||
memberID: memberID,
|
||||
age: user.age || '',
|
||||
gender: user.sex === 2 ? 0 : user.sex,
|
||||
height: user.height || '',
|
||||
isAthleteMode: 0,
|
||||
deviceHeaderIndex: syncIndex,
|
||||
currentWeight: user.weight || '',
|
||||
targetWeight: "",
|
||||
idealWeight: "",
|
||||
recentData: [],
|
||||
}, (res) => {
|
||||
console.log("dataSyncUserInfo res", res, "user:", user.realname, "userID:", mainUserId, "memberID:", memberID);
|
||||
if (res == 0) {
|
||||
// 成功:重置定时器,继续下发下一个用户
|
||||
resetSyncTimer();
|
||||
syncIndex++;
|
||||
syncNext();
|
||||
} else {
|
||||
// 失败自动重试当前用户,重置定时器
|
||||
resetSyncTimer();
|
||||
syncNext();
|
||||
}
|
||||
});
|
||||
};
|
||||
syncNext();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 同步完成后检测配网状态,决定跳转到哪一步
|
||||
* 已配网(0x01) → progressIndex: 3,跳过配网步骤
|
||||
* 未配网 → progressIndex: 2,进入配网步骤
|
||||
*/
|
||||
_checkWifiAndNext() {
|
||||
wx.showLoading({ title: "正在检测配网状态...", mask: true });
|
||||
app.globalData.ppScale.activeProtocol.codeFetchWifiConfig((res) => {
|
||||
wx.hideLoading();
|
||||
if (res === undefined || res === null) {
|
||||
// 获取失败,自动重试
|
||||
this._checkWifiAndNext();
|
||||
return;
|
||||
}
|
||||
// 0x01 表示已配网,跳过配网步骤直接进入下一步
|
||||
const progressIndex = res === 0x01 ? 3 : 2;
|
||||
this.triggerEvent('deviceEvent', { status: true, progressIndex });
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"configureDevice_2_addUser": "/components/configureDevice_2_addUser/configureDevice_2_addUser"
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<view class="configureDevice2">
|
||||
<view class="header">
|
||||
<view>
|
||||
<view bind:longpress="fetchUserList">智能蓝牙秤</view>
|
||||
<view bind:longpress="onDeviceLongPress">型号:{{device.name}}</view>
|
||||
</view>
|
||||
<view>
|
||||
<block wx:if="{{connectState == BLUE_STATE.CONNECTSUCCESS || connectState == BLUE_STATE.WIFISUCCESS}}">
|
||||
<view style="background-color: #2AC79F;"></view>
|
||||
<view style="color: #2AC79F;">连接成功</view>
|
||||
</block>
|
||||
<block wx:elif="{{connectState == BLUE_STATE.SCANING}}">
|
||||
<view style="background-color: #3194FB;"></view>
|
||||
<view style="color: #3194FB;">正在搜索...</view>
|
||||
</block>
|
||||
<block wx:elif="{{connectState == BLUE_STATE.READY}}">
|
||||
<view style="background-color: #3194FB;"></view>
|
||||
<view style="color: #3194FB;">蓝牙就绪</view>
|
||||
</block>
|
||||
<block wx:elif="{{connectState == BLUE_STATE.UNAVAILABLE}}">
|
||||
<view style="background-color: #F24439;"></view>
|
||||
<view style="color: #F24439;">蓝牙不可用</view>
|
||||
</block>
|
||||
<block wx:elif="{{connectState == BLUE_STATE.CONNECTFAILED}}">
|
||||
<view style="background-color: #F24439;"></view>
|
||||
<view bind:tap="connectedDevice" style="color: #F24439;">连接失败,点击重试</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view style="background-color: #999999;"></view>
|
||||
<view style="color: #999999;">未连接</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section">
|
||||
<view class="from">
|
||||
<block wx:if="{{userList && userList.length}}">
|
||||
<scroll-view class="~scrollView" scroll-y>
|
||||
<view class="scrollViewContent">
|
||||
<block wx:for="{{userList}}" wx:key="id">
|
||||
<view class="userList">
|
||||
<view class="userAvatar">
|
||||
<block wx:if="{{item.avatar}}">
|
||||
<image src="{{item.avatar}}" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<block wx:if="{{item.sex === 1}}">
|
||||
<image src="/images/configureDevice/userAvatarMan.png" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<image src="/images/configureDevice/userAvatarWoman.png" />
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
<view class="userInfo">
|
||||
<view class="userInfo_1">
|
||||
<view>{{item.realname}}</view>
|
||||
<view class="{{item.sex === 1 ? 'man' : 'woman'}}">
|
||||
<view>
|
||||
<block wx:if="{{item.sex === 1}}">
|
||||
<image src="/images/configureDevice/man.png" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<image src="/images/configureDevice/woman.png" mode=""/>
|
||||
</block>
|
||||
</view>
|
||||
<view>{{item.age}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="userInfo_2">
|
||||
<view>身高:{{item.height}}cm</view>
|
||||
<view></view>
|
||||
<view>体重:{{item.weight}}kg</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delUser" bind:tap="delUserClick" data-id="{{item.id}}">-</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="nullData">
|
||||
<view>
|
||||
<image src="/images/configureDevice/null.png" />
|
||||
</view>
|
||||
<view>暂无用户数据</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<view bind:tap="addUser">添加用户</view>
|
||||
<view bind:tap="setUserInfo">下一步</view>
|
||||
</view>
|
||||
<view class="describe">
|
||||
请认真填写和完善员工健康信息,用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。<text>(填写数据同时,踩亮蓝牙称并与其保持连接)。</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<configureDevice_2_addUser id="configureDevice2AddUser" bind:returnDate="getAddUserInfo" />
|
||||
@@ -1,281 +0,0 @@
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
height: 58rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.placeholderClass {
|
||||
color: #B6B6B6;
|
||||
height: 58rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.valueClass {
|
||||
color: #77849E;
|
||||
height: 58rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.configureDevice2 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 30rpx 40rpx;
|
||||
box-sizing: border-box;
|
||||
border-bottom: 1rpx solid #EAECF1;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(1) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(1)>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
height: 32rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
line-height: 32rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(1)>view:nth-of-type(2) {
|
||||
color: #808080;
|
||||
height: 26rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 26rpx;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(2) {
|
||||
height: 28rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 14rpx;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
height: 28rpx;
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
}
|
||||
|
||||
.section {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
.from {
|
||||
width: 100%;
|
||||
padding: 24rpx 0;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scrollViewContent {
|
||||
width: 100%;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.userList {
|
||||
width: 100%;
|
||||
height: 162rpx;
|
||||
border-radius: 16px;
|
||||
padding: 0 30rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 24rpx;
|
||||
border: 1rpx solid #E6E6EA;
|
||||
}
|
||||
|
||||
.userAvatar {
|
||||
width: 90rpx;
|
||||
height: 90rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
flex: 1;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.userInfo_1 {
|
||||
width: 100%;
|
||||
height: 32rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.userInfo_1>view:nth-of-type(1) {
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
height: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 32rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.userInfo_1>view:nth-of-type(2) {
|
||||
height: 32rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 0 8rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.userInfo_1 .man {
|
||||
background: linear-gradient(90deg, #54D9FC 0%, #6FC1FB 100%);
|
||||
}
|
||||
|
||||
.userInfo_1 .woman {
|
||||
background: linear-gradient(90deg, #FF91B6 0%, #FD6C9D 100%);
|
||||
}
|
||||
|
||||
.userInfo_1>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
width: 20rpx;
|
||||
height: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.userInfo_1>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
color: #FFFFFF;
|
||||
height: 32rpx;
|
||||
font-weight: bold;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
.userInfo_2 {
|
||||
width: 100%;
|
||||
height: 26rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.userInfo_2>view {
|
||||
color: #77849E;
|
||||
height: 26rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 26rpx;
|
||||
}
|
||||
|
||||
.userInfo_2>view:nth-of-type(2) {
|
||||
margin: 0 20rpx;
|
||||
width: 4rpx;
|
||||
height: 24rpx;
|
||||
border-radius: 1rpx;
|
||||
background-color: #EAECF1;
|
||||
}
|
||||
|
||||
.delUser {
|
||||
color: #FFFFFF;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
line-height: 34rpx;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
background-color: #F24439;
|
||||
}
|
||||
|
||||
.nullData {
|
||||
width: 100%;
|
||||
padding: 200rpx 0 250rpx;
|
||||
}
|
||||
|
||||
.nullData>view:first-of-type {
|
||||
width: 230rpx;
|
||||
height: 160rpx;
|
||||
margin: 0 auto 15rpx;
|
||||
}
|
||||
|
||||
.nullData>view:last-of-type {
|
||||
color: #B6B6B6;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 0 55rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn>view:nth-of-type(1) {
|
||||
color: #1385FA;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 86rpx;
|
||||
border-radius: 44rpx;
|
||||
margin-bottom: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #1385FA;
|
||||
}
|
||||
|
||||
.btn>view:nth-of-type(2) {
|
||||
color: #FFFFFF;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 86rpx;
|
||||
border-radius: 44rpx;
|
||||
margin-bottom: 40rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #1385FA;
|
||||
border: 1px solid #1385FA;
|
||||
}
|
||||
|
||||
.describe {
|
||||
color: #77849E;
|
||||
width: 100%;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 0 30rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.describe text {
|
||||
color: #F24439;
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
import $ from "../../utils/request";
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
|
||||
},
|
||||
data: {
|
||||
animationData: null,
|
||||
modalStatus: false,
|
||||
// 是否是第一个用户(主用户),true 时只能选员工
|
||||
isFirstUser: false,
|
||||
// 用户类型:employee=员工,family=家庭用户
|
||||
userType: 'employee',
|
||||
// 员工模式
|
||||
workNo: "",
|
||||
userInfo: null,
|
||||
// 家庭用户模式 - 手动填写
|
||||
familyInfo: {
|
||||
name: '',
|
||||
sex: 1,
|
||||
birthday: '',
|
||||
height: '',
|
||||
weight: ''
|
||||
},
|
||||
// 性别选择器选项
|
||||
genderOptions: ['男', '女'],
|
||||
genderIndex: 0,
|
||||
},
|
||||
lifetimes: {
|
||||
// 在组件实例进入页面节点树时执行
|
||||
attached() {
|
||||
|
||||
},
|
||||
|
||||
// 在组件实例被从页面节点树移除时执行
|
||||
detached() {
|
||||
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 显示对话框
|
||||
showModal(isFirstUser = false) {
|
||||
this.setData({ isFirstUser: !!isFirstUser });
|
||||
// 先瞬间将弹窗移到屏幕下方(duration:0,不产生过渡)
|
||||
let initAnim = wx.createAnimation({ duration: 0 });
|
||||
initAnim.translateY(1200).step();
|
||||
this.setData({ animationData: initAnim.export(), modalStatus: true });
|
||||
// 留一帧让渲染生效,再执行滑入动画
|
||||
setTimeout(() => {
|
||||
let animation = wx.createAnimation({ duration: 300, timingFunction: 'ease' });
|
||||
animation.translateY(0).step();
|
||||
this.setData({ animationData: animation.export() });
|
||||
}, 50);
|
||||
},
|
||||
|
||||
// 隐藏对话框
|
||||
hideModal() {
|
||||
// 执行滑出动画
|
||||
let animation = wx.createAnimation({ duration: 300, timingFunction: 'ease' });
|
||||
animation.translateY(1200).step();
|
||||
this.setData({ animationData: animation.export() });
|
||||
// 等动画结束后再隐藏节点
|
||||
setTimeout(() => {
|
||||
this.setData({ modalStatus: false });
|
||||
}, 300);
|
||||
},
|
||||
|
||||
// 关闭弹窗并重置所有数据
|
||||
closeModal() {
|
||||
this.setData({
|
||||
isFirstUser: false,
|
||||
userType: 'employee',
|
||||
workNo: "",
|
||||
userInfo: null,
|
||||
familyInfo: {
|
||||
name: '',
|
||||
sex: 1,
|
||||
birthday: '',
|
||||
height: '',
|
||||
weight: ''
|
||||
},
|
||||
genderIndex: 0,
|
||||
});
|
||||
this.hideModal();
|
||||
},
|
||||
|
||||
// 切换用户类型,同时清空所有已填数据
|
||||
switchUserType(e) {
|
||||
// 主用户模式下禁止切换
|
||||
if (this.data.isFirstUser) return;
|
||||
const type = e.currentTarget.dataset.type;
|
||||
if (type === this.data.userType) return;
|
||||
this.setData({
|
||||
userType: type,
|
||||
workNo: "",
|
||||
userInfo: null,
|
||||
familyInfo: {
|
||||
name: '',
|
||||
sex: 1,
|
||||
birthday: '',
|
||||
height: '',
|
||||
weight: ''
|
||||
},
|
||||
genderIndex: 0,
|
||||
});
|
||||
},
|
||||
|
||||
// 监听工号输入(员工模式),输入满 8 位时自动查询
|
||||
onWorkNoInput(e) {
|
||||
const value = e.detail.value;
|
||||
this.setData({ workNo: value, userInfo: null });
|
||||
if (value.trim().length === 8) {
|
||||
this.searchUser();
|
||||
}
|
||||
},
|
||||
|
||||
// 监听身高输入(员工模式)
|
||||
onHeightInput(e) {
|
||||
this.setData({ 'userInfo.height': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听体重输入(员工模式)
|
||||
onWeightInput(e) {
|
||||
this.setData({ 'userInfo.weight': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听家庭用户姓名输入
|
||||
onFamilyNameInput(e) {
|
||||
this.setData({ 'familyInfo.name': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听家庭用户性别选择
|
||||
onFamilyGenderChange(e) {
|
||||
const index = e.detail.value;
|
||||
// 1=男,2=女
|
||||
this.setData({
|
||||
genderIndex: index,
|
||||
'familyInfo.sex': index === '0' || index === 0 ? 1 : 2
|
||||
});
|
||||
},
|
||||
|
||||
// 监听家庭用户生日选择
|
||||
onFamilyBirthdayChange(e) {
|
||||
this.setData({ 'familyInfo.birthday': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听家庭用户身高输入
|
||||
onFamilyHeightInput(e) {
|
||||
this.setData({ 'familyInfo.height': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听家庭用户体重输入
|
||||
onFamilyWeightInput(e) {
|
||||
this.setData({ 'familyInfo.weight': e.detail.value });
|
||||
},
|
||||
|
||||
// 根据工号查询用户信息(员工模式)
|
||||
searchUser() {
|
||||
let workNo = this.data.workNo.trim();
|
||||
if (!workNo) {
|
||||
wx.showToast({
|
||||
title: "请输入工号",
|
||||
icon: "none"
|
||||
})
|
||||
return;
|
||||
}
|
||||
let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
$.ajax("weighingScale/v2/getUserInfoByWkno", {
|
||||
workNo: workNo,
|
||||
sn: sn
|
||||
}, "GET", true, "正在查询...").then(res => {
|
||||
if (res.result) {
|
||||
this.setData({ userInfo: res.result });
|
||||
} else {
|
||||
this.setData({ userInfo: null });
|
||||
wx.showToast({
|
||||
title: "未查询到该工号的用户信息",
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
this.setData({ userInfo: null });
|
||||
wx.showToast({
|
||||
title: (err && err.message) || "查询失败",
|
||||
icon: "none"
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 确定提交
|
||||
submit() {
|
||||
const sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
|
||||
if (this.data.userType === 'employee') {
|
||||
// 员工模式:必须先查询到用户信息
|
||||
if (!this.data.userInfo) {
|
||||
wx.showToast({ title: "请先查询用户信息", icon: "none" });
|
||||
return;
|
||||
}
|
||||
let userInfo = this.data.userInfo;
|
||||
if (!userInfo.height) {
|
||||
wx.showToast({ title: "请输入身高", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!userInfo.weight) {
|
||||
wx.showToast({ title: "请输入体重", icon: "none" });
|
||||
return;
|
||||
}
|
||||
userInfo.sn = sn;
|
||||
$.ajax("weighingScale/v2/edit/user", userInfo, "POST", true, "正在添加...").then(res => {
|
||||
wx.showToast({ title: "添加成功", icon: "success" });
|
||||
this.triggerEvent('returnDate', { userInfo });
|
||||
this.closeModal();
|
||||
}).catch(() => {
|
||||
wx.showToast({ title: "添加失败,请重试", icon: "none" });
|
||||
});
|
||||
|
||||
} else {
|
||||
// 家庭用户模式:校验手动填写的字段
|
||||
const familyInfo = this.data.familyInfo;
|
||||
if (!familyInfo.name.trim()) {
|
||||
wx.showToast({ title: "请输入姓名", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!familyInfo.birthday) {
|
||||
wx.showToast({ title: "请选择生日", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!familyInfo.height) {
|
||||
wx.showToast({ title: "请输入身高", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!familyInfo.weight) {
|
||||
wx.showToast({ title: "请输入体重", icon: "none" });
|
||||
return;
|
||||
}
|
||||
const submitData = {
|
||||
realname: familyInfo.name.trim(),
|
||||
sex: familyInfo.sex,
|
||||
birthday: familyInfo.birthday,
|
||||
height: familyInfo.height,
|
||||
weight: familyInfo.weight,
|
||||
sn: sn
|
||||
};
|
||||
$.ajax("weighingScale/v2/edit/user", submitData, "POST", true, "正在添加...").then(res => {
|
||||
wx.showToast({ title: "添加成功", icon: "success" });
|
||||
this.triggerEvent('returnDate', { userInfo: submitData });
|
||||
this.closeModal();
|
||||
}).catch(() => {
|
||||
wx.showToast({ title: "添加失败,请重试", icon: "none" });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
<!--屏幕背景变暗的背景 -->
|
||||
<view class="modalBg" wx:if="{{modalStatus}}" bindtap="hideModal"></view>
|
||||
|
||||
<!--弹出框 -->
|
||||
<view animation="{{animationData}}" class="modal" wx:if="{{modalStatus}}">
|
||||
<view class="header">
|
||||
<view></view>
|
||||
<view>添加用户</view>
|
||||
</view>
|
||||
<view class="seaction">
|
||||
<!-- 用户类型切换(主用户模式下隐藏) -->
|
||||
<view class="select" wx:if="{{!isFirstUser}}">
|
||||
<view
|
||||
class="{{userType === 'employee' ? 'selectActive' : ''}}"
|
||||
bindtap="switchUserType"
|
||||
data-type="employee"
|
||||
>员工</view>
|
||||
<view
|
||||
class="{{userType === 'family' ? 'selectActive' : ''}}"
|
||||
bindtap="switchUserType"
|
||||
data-type="family"
|
||||
>家庭用户</view>
|
||||
</view>
|
||||
|
||||
<!-- 员工模式 -->
|
||||
<block wx:if="{{userType === 'employee'}}">
|
||||
<!-- 工号输入 -->
|
||||
<view class="input">
|
||||
<view>工号:</view>
|
||||
<view>
|
||||
<input type="text" maxlength="8" placeholder="输入工号自动显示员工信息" value="{{workNo}}" bindinput="onWorkNoInput" bindconfirm="searchUser" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 姓名(只读) -->
|
||||
<view class="only">
|
||||
<view>姓名:</view>
|
||||
<view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.realname || ''}}
|
||||
</block>
|
||||
<!-- <block wx:else>-->
|
||||
<!-- <text style="color: #808080;">请先输入工号</text>-->
|
||||
<!-- </block>-->
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 性别(只读) -->
|
||||
<view class="only">
|
||||
<view>性别:</view>
|
||||
<view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.sex === 1 ? '男' : userInfo.sex === 2 ? '女' : ''}}
|
||||
</block>
|
||||
<!-- <block wx:else>-->
|
||||
<!-- <text style="color: #808080;">请先输入工号</text>-->
|
||||
<!-- </block>-->
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 生日(只读) -->
|
||||
<view class="only">
|
||||
<view>生日:</view>
|
||||
<view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.birthday || ''}}
|
||||
</block>
|
||||
<!-- <block wx:else>-->
|
||||
<!-- <text style="color: #808080;">请先输入工号</text>-->
|
||||
<!-- </block>-->
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 身高(可输入) -->
|
||||
<view class="inputUnit">
|
||||
<view>身高:</view>
|
||||
<view>
|
||||
<view>
|
||||
<input type="digit" value="{{userInfo.height || ''}}" bindinput="onHeightInput" placeholder="请输入身高" />
|
||||
</view>
|
||||
<view>cm</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 体重(可输入) -->
|
||||
<view class="inputUnit">
|
||||
<view>体重:</view>
|
||||
<view>
|
||||
<view>
|
||||
<input type="digit" value="{{userInfo.weight || ''}}" bindinput="onWeightInput" placeholder="请输入体重" />
|
||||
</view>
|
||||
<view>kg</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 家庭用户模式 -->
|
||||
<block wx:if="{{userType === 'family'}}">
|
||||
<!-- 姓名(手动输入) -->
|
||||
<view class="input">
|
||||
<view>姓名:</view>
|
||||
<view>
|
||||
<input type="text" placeholder="请输入姓名" value="{{familyInfo.name}}" bindinput="onFamilyNameInput" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 性别(picker 选择) -->
|
||||
<view class="only">
|
||||
<view>性别:</view>
|
||||
<view>
|
||||
<view>
|
||||
<picker range="{{genderOptions}}" value="{{genderIndex}}" bindchange="onFamilyGenderChange">
|
||||
<view style="color: #252535; font-size: 32rpx; font-weight: 500; height: 100rpx; line-height: 100rpx;">
|
||||
{{genderOptions[genderIndex]}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 生日(picker date 选择) -->
|
||||
<view class="only">
|
||||
<view>生日:</view>
|
||||
<view>
|
||||
<view>
|
||||
<picker mode="date" value="{{familyInfo.birthday}}" start="1900-01-01" bindchange="onFamilyBirthdayChange">
|
||||
<view style="color: {{familyInfo.birthday ? '#252535' : '#808080'}}; font-size: 32rpx; font-weight: 500; height: 100rpx; line-height: 100rpx;">
|
||||
{{familyInfo.birthday || '请选择生日'}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 身高(手动输入) -->
|
||||
<view class="inputUnit">
|
||||
<view>身高:</view>
|
||||
<view>
|
||||
<view>
|
||||
<input type="digit" value="{{familyInfo.height}}" bindinput="onFamilyHeightInput" placeholder="请输入身高" />
|
||||
</view>
|
||||
<view>cm</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 体重(手动输入) -->
|
||||
<view class="inputUnit">
|
||||
<view>体重:</view>
|
||||
<view>
|
||||
<view>
|
||||
<input type="digit" value="{{familyInfo.weight}}" bindinput="onFamilyWeightInput" placeholder="请输入体重" />
|
||||
</view>
|
||||
<view>kg</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
</view>
|
||||
<view class="footer">
|
||||
<view bind:tap="closeModal">取消</view>
|
||||
<view bind:tap="submit">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,215 +0,0 @@
|
||||
.modalBg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #000;
|
||||
opacity: 0.2;
|
||||
overflow: hidden;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.modal {
|
||||
height: 1200rpx;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 11;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
overflow: hidden;
|
||||
background-color: #ffffff;
|
||||
border-radius: 30rpx 30rpx 0 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
padding-top: 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(1) {
|
||||
width: 72rpx;
|
||||
height: 6rpx;
|
||||
border-radius: 3rpx;
|
||||
margin: 0 auto 40rpx;
|
||||
background-color: #77849E;
|
||||
}
|
||||
|
||||
.header>view:nth-of-type(2) {
|
||||
color: #252535;
|
||||
height: 32rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.seaction {
|
||||
flex: 1;
|
||||
padding: 0 30rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.seaction>view:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 4rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 40rpx;
|
||||
border-radius: 16rpx;
|
||||
background-color: #F3F5F8;
|
||||
}
|
||||
|
||||
.select>view {
|
||||
color: #808080;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 16rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.selectActive {
|
||||
color: #1385FA !important;
|
||||
font-weight: bold;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.only,
|
||||
.input,
|
||||
.inputUnit {
|
||||
width: 100%;
|
||||
height: 102rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(1),
|
||||
.input>view:nth-of-type(1),
|
||||
.inputUnit>view:nth-of-type(1) {
|
||||
color: #333333;
|
||||
height: 102rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 102rpx;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2),
|
||||
.inputUnit>view:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 102rpx;
|
||||
padding: 0 30rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
border: 1rpx solid #E6E6EA;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(1),
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
color: #252535;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(2),
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
color: #77849E;
|
||||
height: 28rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
}
|
||||
|
||||
.input>view:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 102rpx;
|
||||
padding: 0 30rpx;
|
||||
border-radius: 16rpx;
|
||||
border: 1rpx solid #E6E6EA;
|
||||
}
|
||||
|
||||
.input>view:nth-of-type(2) input,
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(1) input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #252535;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.inputUnit>view:nth-of-type(2) {
|
||||
|
||||
}
|
||||
|
||||
.searchBtn {
|
||||
color: #FFFFFF;
|
||||
width: 120rpx;
|
||||
height: 102rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 102rpx;
|
||||
margin-left: 16rpx;
|
||||
border-radius: 16rpx;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
|
||||
.footer {
|
||||
width: 100%;
|
||||
padding: 0 30rpx;
|
||||
height: 120rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
background-color: #FFFFFF;
|
||||
border-top: 1rpx solid #EAECF1;
|
||||
}
|
||||
|
||||
.footer>view:nth-of-type(1) {
|
||||
color: #1385FA;
|
||||
width: 330rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
border-radius: 44rpx;
|
||||
text-align: center;
|
||||
line-height: 86rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #1385FA;
|
||||
}
|
||||
|
||||
.footer>view:nth-of-type(2) {
|
||||
color: #FFFFFF;
|
||||
width: 330rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
border-radius: 44rpx;
|
||||
text-align: center;
|
||||
line-height: 86rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #1385FA;
|
||||
border: 1rpx solid #1385FA;
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
data: {
|
||||
progress: 0,
|
||||
// loading=正在获取,failed=获取失败,success=获取成功
|
||||
wifiStatus: 'loading',
|
||||
wifiList: [],
|
||||
|
||||
selectWifi: null,
|
||||
type: true,
|
||||
selectWifiPWD: ""
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
// WiFi 列表获取由父页面在 activeProtocol 就绪后显式调用,此处不自动触发
|
||||
},
|
||||
detached() {
|
||||
console.log('configureDevice3 detached');
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
initWifi() {
|
||||
this.setData({ wifiStatus: 'loading' });
|
||||
wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true });
|
||||
const activeProtocol = app.globalData.ppScale.activeProtocol;
|
||||
if (!activeProtocol) {
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiStatus: 'failed' });
|
||||
return;
|
||||
}
|
||||
// 15秒超时:断开设备静默重连
|
||||
const timer = setTimeout(() => {
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiStatus: 'failed' });
|
||||
// 延长时间 失败调用退出wifi配网
|
||||
activeProtocol.dataExitWifiConfig((res) => {
|
||||
console.log("dataExitWifiConfig", res)
|
||||
})
|
||||
}, 15000);
|
||||
// 延时两秒后再调用接口
|
||||
setTimeout(() => {
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
console.log("wifi列表", res)
|
||||
clearTimeout(timer);
|
||||
wx.hideLoading();
|
||||
if (res.length === 0) {
|
||||
activeProtocol.dataExitWifiConfig((res) => {
|
||||
console.log("dataExitWifiConfig", res)
|
||||
})
|
||||
this.setData({ wifiStatus: 'failed' });
|
||||
return;
|
||||
}
|
||||
this.setData({ wifiList: res, wifiStatus: 'success' });
|
||||
});
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
// 最小化后重连,重置所有状态并重新获取 WiFi 列表
|
||||
reInitWifi() {
|
||||
this.setData({
|
||||
progress: 0,
|
||||
wifiStatus: 'loading',
|
||||
wifiList: [],
|
||||
selectWifi: null,
|
||||
selectWifiPWD: ""
|
||||
});
|
||||
this.initWifi();
|
||||
},
|
||||
|
||||
selectDevice(e) {
|
||||
this.setData({
|
||||
progress: 1,
|
||||
selectWifi: e.currentTarget.dataset.item,
|
||||
})
|
||||
},
|
||||
|
||||
inputTypeChange() {
|
||||
this.setData({
|
||||
type: !this.data.type
|
||||
})
|
||||
},
|
||||
|
||||
passwordInput(e) {
|
||||
this.setData({
|
||||
selectWifiPWD: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
setWifiPWD() {
|
||||
this.setData({ progress: 2 });
|
||||
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
this.netWorkCallBack(res);
|
||||
});
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6",
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
this.netWorkCallBack(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
netWorkCallBack(res) {
|
||||
if(res == 23) {
|
||||
app.globalData.ppScale.wifi.ssid = this.data.selectWifi.ssid;
|
||||
app.globalData.ppScale.wifi.password = this.data.selectWifiPWD;
|
||||
|
||||
this.triggerEvent('deviceEvent', {
|
||||
status: true
|
||||
});
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配网失败,错误码:" + res
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<view class="configureDevice3">
|
||||
<block wx:if="{{progress === 0}}">
|
||||
<view class="progress0">
|
||||
<view class="progress0_title">
|
||||
<view>可用Wi-Fi</view>
|
||||
<view>网络列表(设备暂不支持5GWi-Fi网络)</view>
|
||||
</view>
|
||||
|
||||
<view class="progress0_content">
|
||||
<block wx:if="{{wifiList && wifiList.length}}">
|
||||
<scroll-view class="scrollView" scroll-y>
|
||||
<view class="scrollViewContent">
|
||||
<block wx:for="{{wifiList}}" wx:key="index">
|
||||
<view data-item="{{item}}" bind:tap="selectDevice" class="~arrowAfter">
|
||||
<view>
|
||||
<image src="/images/configureDevice/wifi.png" />
|
||||
</view>
|
||||
<view>{{item.ssid}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="nullData">
|
||||
<view>
|
||||
<image src="/images/configureDevice/null.png" />
|
||||
</view>
|
||||
<block wx:if="{{wifiStatus === 'loading'}}">
|
||||
<view>正在获取WiFi列表中...</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view bind:tap="reInitWifi">获取WiFi失败,点击重试</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:if="{{progress === 1}}">
|
||||
<view class="progress1">
|
||||
<view class="progress1_title">输入Wi-Fi密码</view>
|
||||
<view class="progress1_form">
|
||||
<view>
|
||||
<view>
|
||||
<image src="/images/configureDevice/wifiPwd.png" />
|
||||
</view>
|
||||
<view>{{selectWifi.ssid}}</view>
|
||||
</view>
|
||||
<view>
|
||||
<view>密码</view>
|
||||
<view>
|
||||
<block wx:if="{{type}}">
|
||||
<input
|
||||
password="{{true}}"
|
||||
value="{{selectWifiPWD}}"
|
||||
bindinput="passwordInput"
|
||||
placeholder="输入您的wi-fi密码"
|
||||
placeholder-class="placeholderClass" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<input
|
||||
password="{{false}}"
|
||||
value="{{selectWifiPWD}}"
|
||||
bindinput="passwordInput"
|
||||
placeholder="输入您的wi-fi密码"
|
||||
placeholder-class="placeholderClass" />
|
||||
</block>
|
||||
</view>
|
||||
<view bind:tap="inputTypeChange">
|
||||
<image src="/images/configureDevice/{{type ? 'open' : 'close'}}.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="progress1_btn" bind:tap="setWifiPWD">连接</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:if="{{progress === 2}}">
|
||||
<view class="progress2">
|
||||
<view>
|
||||
<image src="/images/configureDevice/configureDevice_3_icon.png" />
|
||||
</view>
|
||||
<view>设备正在配对网络中,请稍等...</view>
|
||||
<view>请持续站在秤上,耐心等待</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -1,226 +0,0 @@
|
||||
.configureDevice3 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.progress0 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.progress0_title {
|
||||
width: 100%;
|
||||
padding: 0 60rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.progress0_title>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.progress0_title>view:nth-of-type(2) {
|
||||
color: #B6B6B6;
|
||||
width: 100%;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
|
||||
.nullData {
|
||||
width: 100%;
|
||||
padding: 200rpx 0 250rpx;
|
||||
}
|
||||
|
||||
.nullData>view:first-of-type {
|
||||
width: 230rpx;
|
||||
height: 160rpx;
|
||||
margin: 0 auto 15rpx;
|
||||
}
|
||||
|
||||
.nullData>view:last-of-type {
|
||||
color: #B6B6B6;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress0_content {
|
||||
width: 100%;
|
||||
height: calc(100% - 166rpx);
|
||||
}
|
||||
|
||||
.scrollView {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.scrollViewContent {
|
||||
width: 100%;
|
||||
padding: 0 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.scrollViewContent>view {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.scrollViewContent>view>view:nth-of-type(1) {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.scrollViewContent>view>view:nth-of-type(2) {
|
||||
color: #252535;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 80rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
|
||||
.progress1 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 60rpx 30rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.progress1_title {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.progress1_form {
|
||||
width: 100%;
|
||||
margin-bottom: 64rpx;
|
||||
}
|
||||
|
||||
.progress1_form>view {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx;
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
.progress1_form>view:first-of-type {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.progress1_form>view>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
width: 100rpx;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.progress1_form>view:first-of-type>view:nth-of-type(1) {
|
||||
padding: 24rpx 45rpx 24rpx 7rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.progress1_form>view>view:nth-of-type(2) {
|
||||
color: #252535;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.progress1_form>view>view:nth-of-type(2) input {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.placeholderClass {
|
||||
color: #B6B6B6;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.progress1_form>view>view:nth-of-type(3) {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
}
|
||||
|
||||
.progress1_btn {
|
||||
color: #FFFFFF;
|
||||
width: 580rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 88rpx;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-radius: 44rpx;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
|
||||
|
||||
.progress2 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 90rpx 62rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.progress2>view:nth-of-type(1) {
|
||||
width: 565rpx;
|
||||
height: 500rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.progress2>view:nth-of-type(2) {
|
||||
color: #1385FA;
|
||||
width: 100%;
|
||||
height: 36rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.progress2>view:nth-of-type(3) {
|
||||
color: #808080;
|
||||
width: 100%;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
Component({
|
||||
data: {},
|
||||
|
||||
methods: {
|
||||
bindOk() {
|
||||
this.triggerEvent('deviceEvent', { status: true });
|
||||
},
|
||||
|
||||
// 开始 OTA 升级
|
||||
startOtaUpgrade() {
|
||||
const ppScale = app.globalData.ppScale;
|
||||
const activeProtocol = ppScale.activeProtocol;
|
||||
|
||||
if (!activeProtocol) {
|
||||
wx.showToast({ title: '设备未连接,请重新连接', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const res = ppScale.device.version;
|
||||
// 解析固件版本号:格式 "006.005.004.305" → [mcu, ble, wifi, res]
|
||||
const [mcuVer, bleVer, wifiVer, resVer] = (res.firmwareRevision || "").split(".");
|
||||
|
||||
$.ajax("weighingScale/v2/firmware/version", {
|
||||
type: res.modelNumber
|
||||
}, "GET", false, "").then(serverRes => {
|
||||
if (serverRes.result) {
|
||||
/**
|
||||
* 判断服务端版本是否大于设备端版本(需要升级)
|
||||
* @param {string} deviceVer - 设备端单段版本,如 "006"
|
||||
* @param {string} serverVer - 服务端完整版本,如 "0.0.6"
|
||||
* @returns {boolean} true 表示服务端版本更新,需要升级
|
||||
*/
|
||||
const isServerNewer = (deviceVer, serverVer) => {
|
||||
// 设备端单段数字化(去前导零),如 "006" → 6
|
||||
const deviceNum = parseInt(deviceVer, 10);
|
||||
// 服务端版本各段累乘1000合并为整数,如 "0.0.6" → 6,"1.0.2" → 1002
|
||||
const serverNum = (serverVer || "").split(".").map(v => parseInt(v, 10)).reduce((acc, v) => acc * 1000 + v, 0);
|
||||
return serverNum > deviceNum;
|
||||
};
|
||||
|
||||
const needUpdate = isServerNewer(mcuVer, serverRes.result.mcuVersion) || isServerNewer(bleVer, serverRes.result.bleVersion) || isServerNewer(wifiVer, serverRes.result.wifiVersion) || isServerNewer(resVer, serverRes.result.resVersion);
|
||||
|
||||
if (needUpdate) {
|
||||
// status: false = 成功,true = 失败
|
||||
activeProtocol.codeOtaUpdate((status) => {
|
||||
console.log("OTA 升级结果:", status);
|
||||
});
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
wx.showToast({ title: '获取最新版本失败', icon: 'none' });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<view class="configureDevice4">
|
||||
<view class="icon">
|
||||
<view>
|
||||
<image src="/images/configureDevice/configureDevice_4_icon.png" />
|
||||
</view>
|
||||
<view>绑定成功</view>
|
||||
</view>
|
||||
|
||||
<view class="describe">随时随地同步测量数据</view>
|
||||
|
||||
<view class="btn" bind:tap="bindOk">完成</view>
|
||||
</view>
|
||||
@@ -1,102 +0,0 @@
|
||||
.configureDevice4 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 105rpx 55rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 100%;
|
||||
margin-bottom: 400rpx;
|
||||
}
|
||||
|
||||
.icon>view:first-of-type {
|
||||
width: 360rpx;
|
||||
height: 295rpx;
|
||||
margin: 0 auto 50rpx;
|
||||
}
|
||||
|
||||
.icon>view:last-of-type {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 40rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.describe {
|
||||
color: #B6B6B6;
|
||||
width: 100%;
|
||||
height: 26rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 46rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #FFFFFF;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 88rpx;
|
||||
text-align: center;
|
||||
border-radius: 44rpx;
|
||||
margin-bottom: 45rpx;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
|
||||
.ota {
|
||||
color: #1385FA;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 86rpx;
|
||||
text-align: center;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #1385FA;
|
||||
}
|
||||
|
||||
/* OTA 升级进度样式 */
|
||||
.ota-progress-container {
|
||||
width: 100%;
|
||||
margin-bottom: 30rpx;
|
||||
padding: 20rpx;
|
||||
background-color: #F5F5F5;
|
||||
border-radius: 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ota-message {
|
||||
color: #252535;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 15rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
width: 100%;
|
||||
height: 8rpx;
|
||||
background-color: #E0E0E0;
|
||||
border-radius: 4rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background-color: #1385FA;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
color: #1385FA;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
data: {
|
||||
wifiList: []
|
||||
},
|
||||
|
||||
// 生命周期方法
|
||||
lifetimes: {
|
||||
attached() {
|
||||
|
||||
},
|
||||
detached() {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
getWiFiList() {
|
||||
wx.showLoading({
|
||||
title: "正在获取Wi-Fi列表...",
|
||||
mask: true
|
||||
});
|
||||
const activeProtocol = app.globalData.ppScale.activeProtocol;
|
||||
if (!activeProtocol) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
console.log("connectedDevice ===》dataFindSurroundDevice", res);
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiList: Array.isArray(res) ? res : [] });
|
||||
});
|
||||
},
|
||||
|
||||
selectDevice(e) {
|
||||
this.triggerEvent('wifiEvent', {
|
||||
status: true,
|
||||
data: e.currentTarget.dataset.item
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<view class="replaceNetwork1">
|
||||
<view class="title">
|
||||
<view>可用Wi-Fi</view>
|
||||
<view>网络列表(设备暂不支持5GWi-Fi网络)</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<scroll-view class="scrollView" scroll-y>
|
||||
<view class="scrollViewContent">
|
||||
<block wx:for="{{wifiList}}" wx:key="index">
|
||||
<view data-item="{{item}}" bind:tap="selectDevice" class="~arrowAfter">
|
||||
<view>
|
||||
<image src="/images/replaceNetwork/wifi.png" />
|
||||
</view>
|
||||
<view>{{item.ssid}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,71 +0,0 @@
|
||||
.replaceNetwork1 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
padding: 0 60rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.title>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.title>view:nth-of-type(2) {
|
||||
color: #B6B6B6;
|
||||
width: 100%;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
height: calc(100% - 166rpx);
|
||||
}
|
||||
|
||||
.scrollView {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.scrollViewContent {
|
||||
width: 100%;
|
||||
padding: 0 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.scrollViewContent>view {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.scrollViewContent>view>view:nth-of-type(1) {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.scrollViewContent>view>view:nth-of-type(2) {
|
||||
color: #252535;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 80rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
ssid: {
|
||||
type: String,
|
||||
value: ""
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
type: true,
|
||||
|
||||
ssid: "",
|
||||
password: ""
|
||||
},
|
||||
|
||||
// 生命周期方法
|
||||
lifetimes: {
|
||||
attached() {
|
||||
|
||||
},
|
||||
detached() {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
setWiFiName() {
|
||||
this.setData({
|
||||
ssid: this.properties.ssid,
|
||||
type: true,
|
||||
})
|
||||
},
|
||||
|
||||
passwordInput(e) {
|
||||
this.setData({
|
||||
password: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
inputTypeChange() {
|
||||
this.setData({
|
||||
type: !this.data.type
|
||||
})
|
||||
},
|
||||
|
||||
setWifiPWD() {
|
||||
this.triggerEvent('wifiEvent', {
|
||||
status: true,
|
||||
data: this.data.password
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,36 +0,0 @@
|
||||
<view class="replaceNetwork2">
|
||||
<view class="title">输入Wi-Fi密码</view>
|
||||
<view class="form">
|
||||
<view>
|
||||
<view>
|
||||
<image src="/images/replaceNetwork/wifiPwd.png" />
|
||||
</view>
|
||||
<view>{{ssid}}</view>
|
||||
</view>
|
||||
<view>
|
||||
<view>密码</view>
|
||||
<view>
|
||||
<block wx:if="{{type}}">
|
||||
<input
|
||||
password="{{true}}"
|
||||
value="{{password}}"
|
||||
bindinput="passwordInput"
|
||||
placeholder="输入您的wi-fi密码"
|
||||
placeholder-class="placeholderClass" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<input
|
||||
password="{{false}}"
|
||||
value="{{password}}"
|
||||
bindinput="passwordInput"
|
||||
placeholder="输入您的wi-fi密码"
|
||||
placeholder-class="placeholderClass" />
|
||||
</block>
|
||||
</view>
|
||||
<view bind:tap="inputTypeChange">
|
||||
<image src="/images/replaceNetwork/{{type ? 'open' : 'close'}}.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn" bind:tap="setWifiPWD">连接</view>
|
||||
</view>
|
||||
@@ -1,95 +0,0 @@
|
||||
.replaceNetwork2 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 60rpx 30rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.form {
|
||||
width: 100%;
|
||||
margin-bottom: 64rpx;
|
||||
}
|
||||
|
||||
.form>view {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx;
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
.form>view:first-of-type {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.form>view>view:nth-of-type(1) {
|
||||
color: #252535;
|
||||
width: 100rpx;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form>view:first-of-type>view:nth-of-type(1) {
|
||||
padding: 24rpx 45rpx 24rpx 7rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form>view>view:nth-of-type(2) {
|
||||
color: #252535;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.form>view>view:nth-of-type(2) input {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.placeholderClass {
|
||||
color: #B6B6B6;
|
||||
height: 96rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 96rpx;
|
||||
}
|
||||
|
||||
.form>view>view:nth-of-type(3) {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #FFFFFF;
|
||||
width: 580rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 88rpx;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-radius: 44rpx;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
ssid: {
|
||||
type: String,
|
||||
value: ""
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
value: ""
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
// 生命周期方法
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.setNerwork();
|
||||
},
|
||||
detached() {
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
setNerwork() {
|
||||
let ssid = this.properties.ssid;
|
||||
let password = this.properties.password;
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: ssid,
|
||||
password: password
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
this.netWorkCallBack(res);
|
||||
});
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: ssid,
|
||||
password: password,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6"
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
this.netWorkCallBack(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
netWorkCallBack(res) {
|
||||
if(res === 23) {
|
||||
app.globalData.ppScale.wifi.ssid = this.properties.ssid;
|
||||
app.globalData.ppScale.wifi.password = this.properties.password;
|
||||
|
||||
let scaleDeviceId = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
if(scaleDeviceId) {
|
||||
let params = {
|
||||
equipmentCode: scaleDeviceId,
|
||||
wifiName: this.properties.ssid
|
||||
};
|
||||
$.ajax("weighingScale/edit/device", params, "POST").then((res) => {
|
||||
this.triggerEvent('wifiEvent', {
|
||||
status: true
|
||||
});
|
||||
})
|
||||
}
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配网失败,错误码:" + res
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.triggerEvent('wifiEvent', {
|
||||
status: false
|
||||
});
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
<view class="replaceNetwork3">
|
||||
<view>
|
||||
<image src="/images/configureDevice/configureDevice_3_icon.png" />
|
||||
</view>
|
||||
<view>设备正在配对网络中,请稍等...</view>
|
||||
<view>请持续站在秤上,耐心等待</view>
|
||||
</view>
|
||||
@@ -1,32 +0,0 @@
|
||||
.replaceNetwork3 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 90rpx 62rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.replaceNetwork3>view:nth-of-type(1) {
|
||||
width: 565rpx;
|
||||
height: 500rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.replaceNetwork3>view:nth-of-type(2) {
|
||||
color: #1385FA;
|
||||
width: 100%;
|
||||
height: 36rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.replaceNetwork3>view:nth-of-type(3) {
|
||||
color: #808080;
|
||||
width: 100%;
|
||||
height: 30rpx;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
// 生命周期方法
|
||||
lifetimes: {
|
||||
attached() {
|
||||
|
||||
},
|
||||
detached() {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 组件的方法
|
||||
methods: {
|
||||
replaceNetworkOk() {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
<view class="replaceNetwork4">
|
||||
<view class="icon">
|
||||
<view>
|
||||
<image src="/images/configureDevice/configureDevice_4_icon.png" />
|
||||
</view>
|
||||
<view>Wi-Fi 切换成功</view>
|
||||
</view>
|
||||
|
||||
<view class="describe">随时随地同步测量数据</view>
|
||||
|
||||
<view class="btn" bind:tap="replaceNetworkOk">完成</view>
|
||||
</view>
|
||||
@@ -1,49 +0,0 @@
|
||||
.replaceNetwork4 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 105rpx 55rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 100%;
|
||||
margin-bottom: 475rpx;
|
||||
}
|
||||
|
||||
.icon>view:first-of-type {
|
||||
width: 360rpx;
|
||||
height: 295rpx;
|
||||
margin: 0 auto 50rpx;
|
||||
}
|
||||
|
||||
.icon>view:last-of-type {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 40rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.describe {
|
||||
color: #B6B6B6;
|
||||
width: 100%;
|
||||
height: 26rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 46rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #FFFFFF;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 88rpx;
|
||||
text-align: center;
|
||||
border-radius: 44rpx;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 561 B |
|
Before Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 976 B |
|
Before Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,2 @@
|
||||
export { checkOpenIdLogin, getUserInfoByIdCard, updateUser } from './user'
|
||||
export type { UserInfo, LoginResult } from './user'
|
||||
@@ -0,0 +1,53 @@
|
||||
import { get, post, put } from '../utils/request/index'
|
||||
|
||||
export interface UserInfo {
|
||||
id: string
|
||||
userId: string
|
||||
parentUserId: string | null
|
||||
scaleDeviceId: string
|
||||
deviceId: string | null
|
||||
deviceType: string
|
||||
dataType: number
|
||||
userType: string | null
|
||||
idCard: string
|
||||
height: number
|
||||
weight: number
|
||||
birthday: string
|
||||
sex: number
|
||||
avatar: string | null
|
||||
phone: string | null
|
||||
thirdId: string
|
||||
realname: string
|
||||
bmi: number
|
||||
createBy: string
|
||||
createTime: string
|
||||
updateBy: string | null
|
||||
updateTime: string | null
|
||||
delFlag: number
|
||||
sn: string | null
|
||||
workNo: string | null
|
||||
secondDepart: string | null
|
||||
thirdDepart: string | null
|
||||
remark: string | null
|
||||
relationType: string | null
|
||||
sex_dictText: string
|
||||
connectDeviceInfo: string
|
||||
flag?: number | null
|
||||
}
|
||||
|
||||
export interface LoginResult {
|
||||
user: UserInfo | null
|
||||
token: string
|
||||
}
|
||||
|
||||
/** OpenID 登录 */
|
||||
export const checkOpenIdLogin = (code: string) =>
|
||||
post<LoginResult>('weighingScale/v2/checkOpenIdLogin', { code })
|
||||
|
||||
/** 根据身份证号查询用户信息 */
|
||||
export const getUserInfoByIdCard = (params: { sn?: string; idCard: string; realname: string }) =>
|
||||
get<UserInfo | null>('weighingScale/v6/getUserInfoByIdcard', params, { loading: true, loadingTitle: '正在查询用户信息' })
|
||||
|
||||
/** 更新当前登录微信用户信息 */
|
||||
export const updateUser = (data: Record<string, any>) =>
|
||||
put<UserInfo>('weighingScale/v6/update/user', data)
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/login/login",
|
||||
"pages/supplementPersonal/supplementPersonal",
|
||||
"pages/connectedDevice/connectedDevice",
|
||||
"pages/connectedWifi/connectedWifi",
|
||||
"pages/home/home",
|
||||
"pages/detailedReport/detailedReport",
|
||||
"pages/equipment/equipment",
|
||||
"pages/userManagement/userManagement",
|
||||
"pages/addUser/addUser",
|
||||
"pages/data/data",
|
||||
"pages/my/my",
|
||||
"pages/personalInformation/personalInformation",
|
||||
"pages/helpCenter/helpCenter",
|
||||
"pages/questionDetails/questionDetails"
|
||||
],
|
||||
"usingComponents": {
|
||||
"empty-data": "/components/emptyData/emptyData"
|
||||
},
|
||||
"window": {},
|
||||
"tabBar": {
|
||||
"color": "#808080",
|
||||
"selectedColor": "#1385FA",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"text": "首页",
|
||||
"iconPath": "images/tabBar/home_default.png",
|
||||
"selectedIconPath": "images/tabBar/home.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/equipment/equipment",
|
||||
"text": "设备",
|
||||
"iconPath": "images/tabBar/equipment_default.png",
|
||||
"selectedIconPath": "images/tabBar/equipment.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/data/data",
|
||||
"text": "数据",
|
||||
"iconPath": "images/tabBar/data_default.png",
|
||||
"selectedIconPath": "images/tabBar/data.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/my/my",
|
||||
"text": "我的",
|
||||
"iconPath": "images/tabBar/my_default.png",
|
||||
"selectedIconPath": "images/tabBar/my.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "v2",
|
||||
"rendererOptions": {
|
||||
"skyline": {
|
||||
"defaultDisplayBlock": true,
|
||||
"disableABTest": true,
|
||||
"sdkVersionBegin": "3.0.0",
|
||||
"sdkVersionEnd": "15.255.255"
|
||||
}
|
||||
},
|
||||
"componentFramework": "glass-easel",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents",
|
||||
"plugins": {
|
||||
"ppScale-plugin": {
|
||||
"version": "0.0.32",
|
||||
"provider": "wx0826af4e4908f524"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "您的位置信息将用于发现附近的蓝牙设备,以便连接蓝牙秤。"
|
||||
}
|
||||
},
|
||||
"requiredPrivateInfos": [
|
||||
"getLocation"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
page {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
/* 需要页面标准边距的业务容器,在 WXML 根节点使用 */
|
||||
.page-container {
|
||||
padding-left: 30rpx;
|
||||
padding-right: 30rpx;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* 全局 scroll-view 通用样式:同时兼容两种结构
|
||||
* - page 内直接放 scroll-view:靠 height: 100% 撑满
|
||||
* - page 内为 flex 列布局(header + scrollView + footer):靠 flex: 1 撑满剩余空间
|
||||
*/
|
||||
.scrollView {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
right: 24rpx;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
content: "";
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
border-left: 4rpx solid #b6b6b6;
|
||||
border-top: 4rpx solid #b6b6b6;
|
||||
transform: rotate(135deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { leFuService } from './lefu/index'
|
||||
|
||||
App<IAppOption>({
|
||||
globalData: {
|
||||
operationsEngineer: false,
|
||||
wasConnected: false
|
||||
},
|
||||
|
||||
onLaunch() {
|
||||
// 已登录则跳过登录页
|
||||
const token = wx.getStorageSync('token') || null;
|
||||
const userInfo = wx.getStorageSync('userInfo') || null;
|
||||
// const userInfo = true;
|
||||
if (token && userInfo) {
|
||||
wx.reLaunch({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onHide() {
|
||||
// 切后台:记录连接状态,挂起(断开但保留缓存设备,回前台可重连)
|
||||
const wasConnected = leFuService.isConnected
|
||||
this.globalData.wasConnected = wasConnected
|
||||
if (wasConnected) {
|
||||
leFuService.suspend()
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 回前台:如果之前连接过,自动重连
|
||||
if (this.globalData.wasConnected) {
|
||||
this.globalData.wasConnected = false
|
||||
leFuService.autoConnect()
|
||||
}
|
||||
},
|
||||
|
||||
getWxLoginCode(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
resolve(res.code)
|
||||
} else {
|
||||
reject(new Error('获取登录凭证失败'))
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error(err.errMsg || '获取登录凭证失败'))
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-top: 80rpx;
|
||||
|
||||
.empty-icon {
|
||||
width: 193rpx;
|
||||
height: 138rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: #808080;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// emptyData.ts
|
||||
Component({
|
||||
properties: {
|
||||
text: {
|
||||
type: String,
|
||||
value: '暂无数据'
|
||||
},
|
||||
iconSrc: {
|
||||
type: String,
|
||||
value: '/images/emptyData.png'
|
||||
},
|
||||
containerStyle: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
textStyle: {
|
||||
type: String,
|
||||
value: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
<view class="empty" style="{{containerStyle}}">
|
||||
<view class="empty-icon">
|
||||
<image src="{{iconSrc}}" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="empty-text" style="{{textStyle}}">{{text}}</view>
|
||||
</view>
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
.equipment-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(37, 37, 53, 0.6);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.equipment-panel {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 560rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 24rpx;
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 64rpx 40rpx 56rpx;
|
||||
|
||||
.equipment-spinner {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border: 8rpx solid rgba(19, 133, 250, 0.2);
|
||||
border-top-color: #1385FA;
|
||||
border-radius: 50%;
|
||||
animation: equipment-spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.equipment-title {
|
||||
color: #252535;
|
||||
height: 32rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 32rpx;
|
||||
text-align: center;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.equipment-content {
|
||||
color: #808080;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
text-align: center;
|
||||
margin-top: 24rpx;
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes equipment-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Component({
|
||||
properties: {
|
||||
/** 是否显示弹框 */
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
/** 标题 */
|
||||
title: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
/** 副标题(支持 \n 换行) */
|
||||
content: {
|
||||
type: String,
|
||||
value: ''
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 点击遮罩关闭 */
|
||||
onTapMask() {
|
||||
this.triggerEvent('close')
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
<block wx:if="{{ show }}">
|
||||
<view class="equipment-mask" bind:tap="onTapMask"></view>
|
||||
<view class="equipment-panel">
|
||||
<view class="equipment-spinner"></view>
|
||||
<view class="equipment-title">{{ title }}</view>
|
||||
<view class="equipment-content">{{ content }}</view>
|
||||
</view>
|
||||
</block>
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {},
|
||||
"multipleSlots": true
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
.nav-spacer {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-wrap {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.nav-left {
|
||||
height: 100%;
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 60rpx;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.back-arrow {
|
||||
width: 18rpx;
|
||||
height: 18rpx;
|
||||
border-left: 4rpx solid #252535;
|
||||
border-bottom: 4rpx solid #252535;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.nav-center {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
color: #252535;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { getNavBarLayout } from '../../utils/navBar/index';
|
||||
|
||||
Component({
|
||||
options: {
|
||||
multipleSlots: true,
|
||||
},
|
||||
|
||||
properties: {
|
||||
title: { type: String, value: '' },
|
||||
back: { type: String, value: 'auto' },
|
||||
fixed: { type: Boolean, value: false },
|
||||
zIndex: { type: Number, value: 100 },
|
||||
bgColor: { type: String, value: 'transparent' },
|
||||
color: { type: String, value: '#252535' },
|
||||
arrowColor: { type: String, value: '#252535' },
|
||||
},
|
||||
|
||||
data: {
|
||||
statusBarHeight: 0,
|
||||
navBarHeight: 44,
|
||||
totalNavHeight: 0,
|
||||
navPaddingRight: 0,
|
||||
_showBack: false,
|
||||
_spacerHeight: 'auto',
|
||||
_navStyle: '',
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
const layout = getApp<IAppOption>().globalData.navBarLayout || getNavBarLayout();
|
||||
this._applyLayout(layout);
|
||||
},
|
||||
},
|
||||
|
||||
observers: {
|
||||
'fixed, back, zIndex'(_fixed: boolean, _back: string, _zIndex: number) {
|
||||
const layout = getApp<IAppOption>().globalData.navBarLayout || getNavBarLayout();
|
||||
this._applyLayout(layout);
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
_applyLayout(layout: ReturnType<typeof getNavBarLayout>) {
|
||||
const { fixed, back, zIndex } = this.properties;
|
||||
const _showBack = back === 'show' || (back === 'auto' && getCurrentPages().length > 1);
|
||||
|
||||
this.setData({
|
||||
...layout,
|
||||
_showBack,
|
||||
_spacerHeight: fixed ? layout.totalNavHeight + 'px' : 'auto',
|
||||
_navStyle: fixed
|
||||
? `position: fixed; top: 0; left: 0; right: 0; z-index: ${zIndex};`
|
||||
: '',
|
||||
});
|
||||
},
|
||||
|
||||
onBack() {
|
||||
wx.navigateBack({ delta: 1 });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
<view class="nav-spacer" style="height: {{_spacerHeight}}; {{_navStyle}}">
|
||||
<view class="nav-wrap" style="background-color: {{bgColor}};">
|
||||
<view style="height: {{statusBarHeight}}px;"></view>
|
||||
<view class="nav-content" style="height: {{navBarHeight}}px; padding-right: {{navPaddingRight}}px;">
|
||||
<view class="nav-left">
|
||||
<block wx:if="{{_showBack}}">
|
||||
<view class="back-btn" bind:tap="onBack">
|
||||
<view class="back-arrow" style="border-left-color: {{arrowColor}}; border-bottom-color: {{arrowColor}};"></view>
|
||||
</view>
|
||||
</block>
|
||||
<slot name="left" />
|
||||
</view>
|
||||
<view class="nav-center">
|
||||
<text class="nav-title" style="color: {{color}};">{{title}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/* 遮罩层 */
|
||||
.drawer-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(37, 37, 53, 0.6);
|
||||
z-index: 100;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
&--visible {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 抽屉面板 */
|
||||
.drawer-panel {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 85vh;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.3s ease;
|
||||
|
||||
&--visible {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 拖拽把手 */
|
||||
.drawer-handle {
|
||||
width: 72rpx;
|
||||
height: 6rpx;
|
||||
background-color: #77849E;
|
||||
border-radius: 3rpx;
|
||||
margin: 32rpx auto 0;
|
||||
}
|
||||
|
||||
/* 标题栏 */
|
||||
.drawer-header {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
border-bottom: 2rpx solid #EAEDF1;
|
||||
|
||||
.drawer-icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
color: #252535;
|
||||
height: 40rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bolder;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
/* 关闭按钮 */
|
||||
.drawer-close {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.drawer-close-icon {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
position: relative;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
height: 3rpx;
|
||||
background-color: #252535;
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
|
||||
&::before {
|
||||
transform: translate(-50%, -50%) rotate(45deg);
|
||||
}
|
||||
|
||||
&::after {
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 用户滚动列表 */
|
||||
.drawer-user-list {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scrollViewContent {
|
||||
width: 100%;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
/* 用户行 */
|
||||
.member-item {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 2rpx solid #EAEDF1;
|
||||
|
||||
/* 纯色占位头像 */
|
||||
.member-avatar-placeholder {
|
||||
width: 90rpx;
|
||||
height: 90rpx;
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
|
||||
/* 姓名 + 副标题 */
|
||||
.member-info {
|
||||
flex: 1;
|
||||
height: 78rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
margin-left: 23rpx;
|
||||
|
||||
.member-name {
|
||||
color: #333333;
|
||||
height: 32rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
line-height: 32rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.member-sub {
|
||||
color: #77849E;
|
||||
height: 34rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 34rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.member-type {
|
||||
height: 40rpx;
|
||||
flex-shrink: 0;
|
||||
|
||||
.member-type-tag {
|
||||
height: 40rpx;
|
||||
padding: 0 14rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.member-type-tag--self {
|
||||
color: #1385FA;
|
||||
background-color: rgba(19, 133, 250, 0.12);
|
||||
}
|
||||
|
||||
.member-type-tag--employee {
|
||||
color: #10B981;
|
||||
background-color: rgba(16, 185, 129, 0.12);
|
||||
}
|
||||
|
||||
.member-type-tag--family {
|
||||
color: #F59E0B;
|
||||
background-color: rgba(245, 158, 11, 0.12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
import { get } from '../../utils/request/index'
|
||||
import { leFuService } from '../../lefu/index'
|
||||
import { calcAge } from '../../utils/idCard/index'
|
||||
|
||||
/** GET /weighingScale/v5/select/addMembers/user 返回的单条结构 */
|
||||
interface AddMemberApiItem {
|
||||
id: string
|
||||
realname: string
|
||||
sex_dictText: '男' | '女'
|
||||
birthday: string
|
||||
height: number
|
||||
weight: number
|
||||
idCard: string | null
|
||||
avatar: string | null
|
||||
dataType?: number
|
||||
relationType?: number | string | null
|
||||
}
|
||||
|
||||
/** GET /weighingScale/v3/select/history/user 返回的单条结构 */
|
||||
interface HistoryApiItem {
|
||||
id: string
|
||||
userId: string
|
||||
realname: string
|
||||
sex: number
|
||||
height: number
|
||||
birthday: string
|
||||
avatar: string | null
|
||||
relationType: number | string | null
|
||||
dataType?: number
|
||||
}
|
||||
|
||||
/** 抽屉内部用户项(含回填所需全量字段) */
|
||||
interface ExistingMember {
|
||||
id: string
|
||||
name: string
|
||||
gender: '男' | '女'
|
||||
age: number
|
||||
height: number
|
||||
weight: number
|
||||
idCard: string
|
||||
avatar?: string
|
||||
selected?: boolean
|
||||
/** history 模式额外携带,供页面构建 userInfo */
|
||||
userId?: string
|
||||
sex?: number
|
||||
birthday?: string
|
||||
relationType?: number | string | null
|
||||
/** 0=员工 1=家庭成员 */
|
||||
dataType?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择已有用户抽屉组件
|
||||
* Properties: show(控制显示)、source(数据来源:addMember/history)、excludeUserId(排除用户)
|
||||
* Events: close(关闭), select(选中用户,携带 ExistingMember)
|
||||
*/
|
||||
Component({
|
||||
properties: {
|
||||
/** 是否显示抽屉 */
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
/** 数据来源模式:addMember=新增用户选择 / history=历史数据切换用户 */
|
||||
source: {
|
||||
type: String,
|
||||
value: 'addMember'
|
||||
},
|
||||
/** 需要排除的用户 ID(history 模式下排除当前查看的用户) */
|
||||
excludeUserId: {
|
||||
type: String,
|
||||
value: ''
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
/** 控制 wx:if,DOM 是否存在 */
|
||||
innerShow: false,
|
||||
/** 控制 --visible 类,触发 CSS transition */
|
||||
animVisible: false,
|
||||
/** 用户列表(组件内部拉取) */
|
||||
members: [] as ExistingMember[]
|
||||
},
|
||||
|
||||
observers: {
|
||||
/**
|
||||
* 监听外部 show 变化:
|
||||
* 打开时先拉数据再展示抽屉;关闭时移除动画类后移除 DOM
|
||||
*/
|
||||
show(val: boolean) {
|
||||
if (val) {
|
||||
this._fetchMembers()
|
||||
this.setData({ innerShow: true })
|
||||
setTimeout(() => {
|
||||
this.setData({ animVisible: true })
|
||||
}, 20)
|
||||
} else {
|
||||
this.setData({ animVisible: false })
|
||||
setTimeout(() => {
|
||||
this.setData({ innerShow: false })
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 调接口获取可选用户列表,根据 source 调不同接口 */
|
||||
_fetchMembers() {
|
||||
const userInfo = wx.getStorageSync('userInfo') as { userId?: string } | null
|
||||
const userId = userInfo?.userId ?? ''
|
||||
|
||||
wx.showLoading({ title: '加载中...', mask: true })
|
||||
|
||||
if (this.properties.source === 'history') {
|
||||
const params: Record<string, string> = { userId }
|
||||
if (this.properties.excludeUserId) {
|
||||
params.userIdExclude = this.properties.excludeUserId
|
||||
}
|
||||
get<HistoryApiItem[]>('weighingScale/v3/select/history/user', params, { loading: false })
|
||||
.then((res: any) => {
|
||||
const members: ExistingMember[] = (res.result ?? []).map((item: HistoryApiItem) => ({
|
||||
id: item.id,
|
||||
name: item.realname,
|
||||
gender: item.sex === 1 ? '男' : '女',
|
||||
age: calcAge(item.birthday),
|
||||
height: item.height,
|
||||
weight: 0,
|
||||
idCard: '',
|
||||
avatar: item.avatar ?? '',
|
||||
userId: item.userId,
|
||||
sex: item.sex,
|
||||
birthday: item.birthday,
|
||||
relationType: item.relationType,
|
||||
dataType: item.dataType,
|
||||
}))
|
||||
this.setData({ members })
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error('[selectMemberDrawer] 加载成员失败:', err)
|
||||
wx.showToast({ title: err?.msg || err?.message || '加载失败', icon: 'none' })
|
||||
})
|
||||
.finally(() => {
|
||||
wx.hideLoading()
|
||||
})
|
||||
} else {
|
||||
const sn = leFuService.deviceInfo?.serialNumber ?? ''
|
||||
get<AddMemberApiItem[]>('weighingScale/v5/select/addMembers/user', { userId, sn }, { loading: false })
|
||||
.then((res: any) => {
|
||||
const members: ExistingMember[] = (res.result ?? []).map((item: AddMemberApiItem) => ({
|
||||
id: item.id,
|
||||
name: item.realname,
|
||||
gender: item.sex_dictText,
|
||||
age: calcAge(item.birthday),
|
||||
height: item.height,
|
||||
weight: item.weight,
|
||||
idCard: item.idCard ?? '',
|
||||
avatar: item.avatar ?? '',
|
||||
relationType: item.relationType,
|
||||
dataType: item.dataType,
|
||||
}))
|
||||
this.setData({ members })
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error('[selectMemberDrawer] 加载成员失败:', err)
|
||||
wx.showToast({ title: err?.msg || err?.message || '加载失败', icon: 'none' })
|
||||
})
|
||||
.finally(() => {
|
||||
wx.hideLoading()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/** 点击遮罩关闭 */
|
||||
onTapMask() {
|
||||
this.triggerEvent('close')
|
||||
},
|
||||
|
||||
/** 点击关闭按钮 */
|
||||
onTapClose() {
|
||||
this.triggerEvent('close')
|
||||
},
|
||||
|
||||
/** 点击用户行,触发 select 事件 */
|
||||
onTapMember(e: WechatMiniprogram.TouchEvent) {
|
||||
const member = e.currentTarget.dataset.member as ExistingMember
|
||||
this.triggerEvent('select', member)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,61 @@
|
||||
<!-- 选择已有用户抽屉 -->
|
||||
<block wx:if="{{ innerShow }}">
|
||||
<!-- 遮罩 -->
|
||||
<view class="drawer-mask {{ animVisible ? 'drawer-mask--visible' : '' }}" bind:tap="onTapMask"></view>
|
||||
|
||||
<!-- 抽屉面板 -->
|
||||
<view class="drawer-panel {{ animVisible ? 'drawer-panel--visible' : '' }}">
|
||||
<!-- 顶部拖拽把手 -->
|
||||
<view class="drawer-handle"></view>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<view class="drawer-header">
|
||||
<view class="drawer-icon"></view>
|
||||
<view class="drawer-title">选择本人添加的用户</view>
|
||||
<view class="drawer-close" bind:tap="onTapClose">
|
||||
<view class="drawer-close-icon"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<view class="drawer-user-list">
|
||||
<block wx:if="{{ members.length }}">
|
||||
<scroll-view class="~scrollView" scroll-y>
|
||||
<view class="scrollViewContent">
|
||||
<block wx:for="{{ members }}" wx:key="id">
|
||||
<view class="member-item" bind:tap="onTapMember" data-member="{{ item }}">
|
||||
<!-- 头像 -->
|
||||
<view class="member-avatar-placeholder">
|
||||
<image src="{{ item.gender === '女' ? '/images/woman.png' : '/images/man.png' }}" mode="aspectFit" />
|
||||
</view>
|
||||
|
||||
<!-- 姓名 + 性别·年龄 -->
|
||||
<view class="member-info">
|
||||
<view class="member-name">{{ item.name }}</view>
|
||||
<view class="member-sub">{{ item.gender }}·{{ item.age }}岁 丨 {{ item.height }}cm</view>
|
||||
</view>
|
||||
|
||||
<view class="member-type">
|
||||
<block wx:if="{{ item.relationType == 1 }}">
|
||||
<view class="member-type-tag member-type-tag--self">本人</view>
|
||||
</block>
|
||||
<block wx:elif="{{ item.dataType === 0 }}">
|
||||
<view class="member-type-tag member-type-tag--employee">员工</view>
|
||||
</block>
|
||||
<block wx:elif="{{ item.dataType === 1 }}">
|
||||
<view class="member-type-tag member-type-tag--family">家庭用户</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
|
||||
<!-- 无用户:占位 -->
|
||||
<block wx:else>
|
||||
<empty-data text="暂无用户" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
.confirm-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
&.anim-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
position: relative;
|
||||
width: 660rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
transform: scale(0.9);
|
||||
opacity: 0;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&.anim-visible {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding-top: 50rpx;
|
||||
width: 100%;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.modal-title {
|
||||
width: 100%;
|
||||
height: 36rpx;
|
||||
font-weight: bolder;
|
||||
font-size: 36rpx;
|
||||
color: #252535;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.modal-sub-title {
|
||||
width: 100%;
|
||||
height: 32rpx;
|
||||
font-weight: 400;
|
||||
font-size: 32rpx;
|
||||
color: #1385FA;
|
||||
line-height: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 0 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.modal-body-box {
|
||||
width: 100%;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx;
|
||||
background-color: #F6F6F6;
|
||||
|
||||
.info-row {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
padding: 10rpx 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
border-bottom: 1px solid #EAECF1;
|
||||
|
||||
.info-label {
|
||||
color: #77849E;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: #252535;
|
||||
height: 80rpx;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
width: 100%;
|
||||
height: 110rpx;
|
||||
display: flex;
|
||||
border-top: 1rpx solid #EAECF1;
|
||||
|
||||
.modal-btn {
|
||||
flex: 1;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
font-size: 36rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-btn-cancel {
|
||||
color: #77849E;
|
||||
border-right: 1rpx solid #EAECF1;
|
||||
}
|
||||
|
||||
.modal-btn-confirm {
|
||||
color: #1385FA;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 用户信息确认弹框组件
|
||||
* Properties: show(控制显示), userInfo(用户信息)
|
||||
* Events: confirm(确认), cancel(取消)
|
||||
*/
|
||||
Component({
|
||||
properties: {
|
||||
/** 是否显示弹框 */
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
/** 用户信息数据 */
|
||||
userInfo: {
|
||||
type: Object,
|
||||
value: {}
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
/** 控制 wx:if,DOM 是否存在 */
|
||||
innerShow: false,
|
||||
/** 控制 --visible 类,触发 CSS transition */
|
||||
animVisible: false
|
||||
},
|
||||
|
||||
observers: {
|
||||
/**
|
||||
* 监听外部 show 变化:
|
||||
* 打开时先展示弹框再执行动画;关闭时移除动画类后移除 DOM
|
||||
*/
|
||||
show(val: boolean) {
|
||||
if (val) {
|
||||
this.setData({ innerShow: true })
|
||||
setTimeout(() => {
|
||||
this.setData({ animVisible: true })
|
||||
}, 20)
|
||||
} else {
|
||||
this.setData({ animVisible: false })
|
||||
setTimeout(() => {
|
||||
this.setData({ innerShow: false })
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 点击遮罩关闭 */
|
||||
onTapMask() {
|
||||
this.triggerEvent('cancel')
|
||||
},
|
||||
|
||||
/** 点击取消按钮 */
|
||||
onTapCancel() {
|
||||
this.triggerEvent('cancel')
|
||||
},
|
||||
|
||||
/** 点击确认按钮 */
|
||||
onTapConfirm() {
|
||||
this.triggerEvent('confirm')
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,42 @@
|
||||
<view class="confirm-modal" wx:if="{{ innerShow }}">
|
||||
<view class="modal-mask {{ animVisible ? 'anim-visible' : '' }}" bind:tap="onTapMask"></view>
|
||||
|
||||
<view class="modal-content {{ animVisible ? 'anim-visible' : '' }}">
|
||||
<view class="modal-header">
|
||||
<view class="modal-title">当前身份证号已存在</view>
|
||||
<view class="modal-sub-title">是否直接复用信息?</view>
|
||||
</view>
|
||||
|
||||
<block wx:if="{{ userInfo }}">
|
||||
<view class="modal-body">
|
||||
<view class="modal-body-box">
|
||||
<view class="info-row">
|
||||
<view class="info-label">姓名:</view>
|
||||
<view class="info-value">{{ userInfo.realname }}</view>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<view class="info-label">身份证号:</view>
|
||||
<view class="info-value">{{ userInfo.idCard }}</view>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<view class="info-label">性别:</view>
|
||||
<view class="info-value">{{ userInfo.sex_dictText }}</view>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<view class="info-label">身高:</view>
|
||||
<view class="info-value">{{ userInfo.height }}cm</view>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<view class="info-label">体重:</view>
|
||||
<view class="info-value">{{ userInfo.weight }}kg</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="modal-footer">
|
||||
<view class="modal-btn modal-btn-cancel" bind:tap="onTapCancel">取消</view>
|
||||
<view class="modal-btn modal-btn-confirm" bind:tap="onTapConfirm">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
}
|
||||