流程改版

This commit is contained in:
17792275749
2025-05-29 08:45:04 +08:00
parent ba54f14735
commit f9c22f1da4
83 changed files with 1831 additions and 2603 deletions
@@ -0,0 +1,157 @@
const app = getApp();
import $ from "../../utils/request";
Component({
data: {
progress: 0,
wifiList: [],
selectWifi: null,
type: true,
selectWifiPWD: ""
},
lifetimes: {
attached() {
this.initWifi();
},
detached() {
// 在组件实例被从页面节点树移除时执行
console.log('MyComponent detached!');
}
},
// 组件的方法
methods: {
initWifi() {
wx.showLoading({
title: "正在获取Wi-Fi列表...",
mask: true
});
app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => {
wx.hideLoading();
this.setData({
wifiList: res
})
})
},
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
})
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
domain: app.globalData.ppScale.domain,
ssid: this.data.selectWifi.ssid,
password: this.data.selectWifiPWD
}, (res) => {
console.log("setNetwork.js dataConfigNetWork", res);
if(res === 23) {
app.globalData.ppScale.wifi.ssid = this.data.selectWifi.ssid;
app.globalData.ppScale.wifi.password = this.data.selectWifiPWD;
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(() => {
wx.navigateBack({
delta: 2
})
}, 1500)
}
})
}
}
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,62 @@
<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">
<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>
</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>
<input
password="{{type}}"
value="{{selectWifiPWD}}"
bindinput="passwordInput"
placeholder="输入您的wi-fi密码"
placeholder-class="placeholderClass" />
</view>
<view bind:tap="inputTypeChange">
<image src="/images/configureDevice/open.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>
@@ -0,0 +1,207 @@
.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;
}
.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;
}