补充图片

This commit is contained in:
17792275749
2025-04-24 19:59:00 +08:00
parent 4ad8d2a841
commit 230490b995
15 changed files with 178 additions and 102 deletions
+37
View File
@@ -68,8 +68,12 @@ Page({
},
onShow() {
let token = wx.getStorageSync("token") || null;
let userInfo = wx.getStorageSync("userInfo") || null;
let deviceSelect = app.globalData.ppScale.device.connection;
this.setData({
token: token,
userInfo: userInfo,
name: deviceSelect.name,
deviceSelect: deviceSelect
})
@@ -83,6 +87,27 @@ Page({
// 配对
openConnectionSuccessful() {
let token = this.data.token;
let userInfo = this.data.userInfo;
if (token && userInfo) {
this.starConnection();
} else {
wx.login({
success: (res) => {
if (res.code) {
this.checkOpenIdLogin(res.code);
} else {
wx.showToast({
icon: "none",
title: "登录失败,请稍后再试!",
})
}
}
})
}
},
starConnection() {
let deviceSelect = this.data.deviceSelect;
if (deviceSelect) {
let name = this.data.name;
@@ -106,4 +131,16 @@ Page({
})
}
},
// 微信一键登录
checkOpenIdLogin(code) {
let params = {
code: code
};
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
wx.setStorageSync("userInfo", res.result.user);
wx.setStorageSync("token", res.result.token);
this.starConnection();
})
},
})
+3 -1
View File
@@ -1,7 +1,9 @@
<view class="equipmentModel">型号:{{deviceSelect.name}}</view>
<view class="equipmentIcon">
<image src="/images/connectedDevice/device.png" />
<block wx:if="{{deviceSelect && deviceSelect.name}}">
<image src="/images/devices/{{deviceSelect.name}}.png" />
</block>
</view>
<view class="equipmentName arrowAfter">
+62 -62
View File
@@ -3,7 +3,7 @@ import $ from "../../utils/request";
Page({
data: {
deviceConnect: false,
// deviceConnect: false,
deviceInfo: null,
},
@@ -11,58 +11,58 @@ Page({
onLoad(options) {
this.getDevice();
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
console.log('deviceInfo ===》deviceConnect', res);
// app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
// console.log('deviceInfo ===》deviceConnect', res);
app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
// app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
// app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
console.log("deviceInfo ===》codeUpdateMTU", res);
// app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
// console.log("deviceInfo ===》codeUpdateMTU", res);
this.setData({
deviceConnect: true
})
});
});
// this.setData({
// deviceConnect: true
// })
// });
// });
},
// 初始化蓝牙
initBluetooth() {
wx.openBluetoothAdapter({
success: () => {
this.getDeviceSettingList();
},
fail: (err) => {
if (err.errCode === 10001) {
wx.showModal({
title: "提示",
content: "请打开手机蓝牙",
});
}
},
});
},
// initBluetooth() {
// wx.openBluetoothAdapter({
// success: () => {
// this.getDeviceSettingList();
// },
// fail: (err) => {
// if (err.errCode === 10001) {
// wx.showModal({
// title: "提示",
// content: "请打开手机蓝牙",
// });
// }
// },
// });
// },
getDeviceSettingList() {
let seviceList = [];
app.globalData.ppScale.device.setting.map(item => {
if(this.data.deviceInfo.type === item.deviceName) {
seviceList.push(item);
}
})
if(seviceList && seviceList.length) {
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false);
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId);
if (fIndex > -1) {
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]);
}
});
}
},
// getDeviceSettingList() {
// let seviceList = [];
// app.globalData.ppScale.device.setting.map(item => {
// if(this.data.deviceInfo.type === item.deviceName) {
// seviceList.push(item);
// }
// })
// if(seviceList && seviceList.length) {
// app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
// app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false);
// app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
// let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId);
// if (fIndex > -1) {
// app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
// app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]);
// }
// });
// }
// },
// 获取已经绑定的设备列表
getDevice() {
@@ -71,14 +71,14 @@ Page({
this.setData({
deviceInfo: res.result[0]
})
this.initBluetooth();
// this.initBluetooth();
})
},
delDevice() {
if(this.data.deviceConnect) {
app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
console.log("deviceInfo === codeClearDeviceData", res);
// if(this.data.deviceConnect) {
// app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
// console.log("deviceInfo === codeClearDeviceData", res);
let scaleDeviceId = this.data.deviceInfo.macAddress.replace(/:/g, '');
let params = {
@@ -95,18 +95,18 @@ Page({
})
}, 1500);
});
})
} else {
wx.showToast({
icon: "none",
title: "删除失败,请靠近设备并点亮后再试"
})
app.globalData.ppScale.plugin.Blue.stop();
this.getDeviceSettingList();
}
// })
// } else {
// wx.showToast({
// icon: "none",
// title: "删除失败,请靠近设备并点亮后再试"
// })
// app.globalData.ppScale.plugin.Blue.stop();
// this.getDeviceSettingList();
// }
},
onUnload() {
app.globalData.ppScale.plugin.Blue.stop();
}
// onUnload() {
// app.globalData.ppScale.plugin.Blue.stop();
// }
})
+5 -3
View File
@@ -1,6 +1,8 @@
<view class="device">
<view>
<image src="/images/deviceInfo/device.png" />
<block wx:if="{{deviceInfo && deviceInfo.type}}">
<image src="/images/devices/{{deviceInfo.type}}.png" />
</block>
</view>
<view>
<view>{{deviceInfo.equipmentName}}</view>
@@ -18,8 +20,8 @@
<view>{{deviceInfo.equipmentCode}}</view>
</view>
<view>
<view>配置Wi-Fi</view>
<view class="arrowAfter" style="padding-right: 30rpx;">{{deviceInfo.wifiName}}</view>
<view>Wi-Fi名称</view>
<view>{{deviceInfo.wifiName}}</view>
</view>
<view>
<view>成员</view>
+15 -9
View File
@@ -76,17 +76,23 @@ Page({
// 添加设备
openSearchDevice() {
let token = this.data.token;
let userInfo = this.data.userInfo;
if (token && userInfo) {
// let token = this.data.token;
// let userInfo = this.data.userInfo;
// if (token && userInfo) {
wx.navigateTo({
url: "/pages/searchDevice/searchDevice"
})
} else {
wx.showToast({
icon: "none",
title: "请先登录"
})
}
// } else {
// wx.showToast({
// icon: "none",
// title: "请先登录"
// })
// }
},
openDeviceInfo() {
wx.navigateTo({
url: "/pages/deviceInfo/deviceInfo"
})
}
})
+21 -16
View File
@@ -6,12 +6,7 @@
<view class="title">
<view>
<view>
<block wx:if="{{userInfo && userInfo.avatar}}">
<image src="{{userInfo.avatar}}" />
</block>
<block wx:else>
<image src="/images/home/user.png" />
</block>
<image src="/images/home/user.png" />
</view>
<block wx:if="{{userInfo && token}}">
<view>{{userInfo.realname}}</view>
@@ -24,14 +19,24 @@
<view>注重更好的健康生活品质</view>
<view></view>
</view>
<view class="device">
<view>请添加设备</view>
<view>添加设备后,解锁更多体验</view>
<block wx:if="{{userInfo && token}}">
<view bind:tap="openSearchDevice">添加设备</view>
</block>
<block wx:else>
<view bind:tap="openLoginOrReg">登录/注册</view>
</block>
</view>
<block wx:if="{{deviceList && deviceList.length}}">
<view class="device" bind:tap="openDeviceInfo">
<view>
<image src="/images/devices/{{deviceList[0].type}}.png" />
</view>
<view>设备名称:{{deviceList[0].equipmentName}}</view>
</view>
</block>
<block wx:else>
<view class="addDevice">
<view>请添加设备</view>
<view>添加设备后,解锁更多体验</view>
<!-- <block wx:if="{{userInfo && token}}"> -->
<view bind:tap="openSearchDevice">添加设备</view>
<!-- </block>
<block wx:else>
<view bind:tap="openLoginOrReg">登录/注册</view>
</block> -->
</view>
</block>
</view>
+23 -3
View File
@@ -80,11 +80,31 @@
}
.device {
width: 100%;
}
.device>view:nth-of-type(1) {
width: 500rpx;
height: 500rpx;
margin: 0 auto;
}
.device>view:nth-of-type(2) {
color: #ffffff;
width: 100%;
height: 32rpx;
font-weight: bold;
font-size: 32rpx;
line-height: 32rpx;
text-align: center;
}
.addDevice {
width: 580rpx;
margin: 0 auto;
}
.device>view:nth-of-type(1) {
.addDevice>view:nth-of-type(1) {
color: #FFFFFF;
width: 100%;
height: 36rpx;
@@ -95,7 +115,7 @@
margin-bottom: 30rpx;
}
.device>view:nth-of-type(2) {
.addDevice>view:nth-of-type(2) {
color: #FFFFFF;
width: 100%;
height: 30rpx;
@@ -105,7 +125,7 @@
margin-bottom: 80rpx;
}
.device>view:nth-of-type(3) {
.addDevice>view:nth-of-type(3) {
color: #FFFFFF;
width: 100%;
height: 106rpx;
+1 -5
View File
@@ -9,8 +9,4 @@
<view class="description">
<view>{{initText}}</view>
<view>请轻轻踩秤,保证屏幕亮起</view>
</view>
<block wx:for="{{devicesList}}" wx:key="index">
<view>{{item.name}}</view>
</block>
</view>
+9 -1
View File
@@ -2,8 +2,10 @@ const app = getApp();
Page({
data: {
type: true,
wifiInfo: null,
password: "mimahaojige8"
password: ""
},
onLoad(options) {
@@ -18,6 +20,12 @@ Page({
})
},
inputTypeChange() {
this.setData({
type: !this.data.type
})
},
// 打开配网
openSetNetwork() {
wx.navigateTo({
+2 -2
View File
@@ -9,13 +9,13 @@
<view>密码</view>
<view>
<input
type="password"
password="{{type}}"
value="{{password}}"
bindinput="passwordInput"
placeholder="8~16位密码"
placeholder-class="placeholderClass" />
</view>
<view>
<view bind:tap="inputTypeChange">
<image src="/images/setWifiPassword/open.png" />
</view>
</view>