更换WIFI

This commit is contained in:
17792275749
2025-05-29 13:43:16 +08:00
parent 3caf082c24
commit 1eb129e3bd
41 changed files with 1314 additions and 50 deletions
@@ -122,6 +122,6 @@
<view class="btn">
<view bind:tap="setUserInfo">下一步</view>
</view>
<view class="describe">请填写和完善您家人的健康信息(填写数据同时,踩亮蓝牙秤并与其保持连接),将用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。</view>
<view class="describe">请认真填写和完善您家人的健康信息用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。<text>(填写数据同时,踩亮蓝牙秤并与其保持连接)。</text></view>
</view>
</view>
@@ -151,4 +151,8 @@ input {
width: 100%;
font-size: 24rpx;
line-height: 40rpx;
}
.describe text {
color: #F24439;
}
@@ -0,0 +1,37 @@
const app = getApp();
Component({
data: {
wifiList: []
},
// 生命周期方法
lifetimes: {
attached() {
},
detached() {
}
},
// 组件的方法
methods: {
getWiFiList() {
app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => {
console.log("connectedDevice ===》dataFindSurroundDevice", res);
this.setData({
wifiList: res
})
})
},
selectDevice(e) {
this.triggerEvent('wifiEvent', {
status: true,
data: e.currentTarget.dataset.item
});
}
}
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,20 @@
<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>
@@ -0,0 +1,71 @@
.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;
}
@@ -0,0 +1,56 @@
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
});
}
}
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,36 @@
<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>
@@ -0,0 +1,95 @@
.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;
}
@@ -0,0 +1,131 @@
const app = getApp();
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;
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
domain: app.globalData.ppScale.domain,
ssid: ssid,
password: password
}, (res) => {
console.log("setNetwork.js dataConfigNetWork", res);
if(res === 23) {
app.globalData.ppScale.wifi.ssid = ssid;
app.globalData.ppScale.wifi.password = password;
this.triggerEvent('wifiEvent', {
status: true
});
// let mac = app.globalData.ppScale.device.mac;
// let deviceId = app.globalData.ppScale.device.connection.deviceId;
// if(mac && deviceId) {
// let scaleDeviceId = mac.replace(/:/g, '');
// let params = {
// equipmentName: app.globalData.ppScale.device.name,
// scaleDeviceId: scaleDeviceId,
// deviceId: deviceId
// };
// $.ajax("weighingScale/binding/device", params, "POST").then(res => {
// if (res.success) {
// app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
// console.log("setNetwork.js codeSetBindingState", res);
// if(res == 0) {
// this.triggerEvent('deviceEvent', {
// status: true
// });
// } else {
// app.globalData.ppScale.plugin.Blue.disconnect();
// wx.showToast({
// title: "绑定失败,请重试。",
// icon: "none"
// })
// setTimeout(() => {
// wx.navigateBack({
// delta: 2
// })
// }, 1500)
// }
// })
// } else {
// app.globalData.ppScale.plugin.Blue.disconnect();
// wx.showToast({
// icon: "none",
// title: res.message
// })
// setTimeout(() => {
// wx.navigateBack({
// delta: 2
// })
// }, 1500)
// }
// }).catch(err => {
// app.globalData.ppScale.plugin.Blue.disconnect();
// wx.showToast({
// icon: "none",
// title: err.message
// })
// setTimeout(() => {
// wx.navigateBack({
// delta: 2
// })
// }, 1500)
// })
// } else {
// app.globalData.ppScale.plugin.Blue.disconnect();
// wx.showToast({
// icon: "none",
// title: "Mac 地址与 deviceId 获取失败,请重新绑定"
// })
// setTimeout(() => {
// wx.navigateBack({
// delta: 2
// })
// }, 1500)
// }
} else {
app.globalData.ppScale.plugin.Blue.disconnect();
wx.showToast({
icon: "none",
title: "配网失败,错误码:" + res
})
setTimeout(() => {
this.triggerEvent('wifiEvent', {
status: false
});
}, 1500)
}
})
}
}
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,7 @@
<view class="replaceNetwork3">
<view>
<image src="/images/configureDevice/configureDevice_3_icon.png" />
</view>
<view>设备正在配对网络中,请稍等...</view>
<view>请持续站在秤上,耐心等待</view>
</view>
@@ -0,0 +1,32 @@
.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;
}
@@ -0,0 +1,26 @@
const app = getApp();
Component({
data: {
},
// 生命周期方法
lifetimes: {
attached() {
},
detached() {
}
},
// 组件的方法
methods: {
replaceNetworkOk() {
wx.navigateBack({
delta: 1
})
}
}
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,12 @@
<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>
@@ -0,0 +1,49 @@
.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;
}