第一版
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name: "",
|
||||
deviceSelect: null
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
let name = app.globalData.ppScale.device.name;
|
||||
let deviceSelect = app.globalData.ppScale.device.connection;
|
||||
this.setData({
|
||||
name: name ? name : deviceSelect.name,
|
||||
deviceSelect: deviceSelect
|
||||
})
|
||||
|
||||
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||
console.log('connectedDevice ===》deviceConnect', res);
|
||||
|
||||
app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
|
||||
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||
|
||||
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||
console.log("connectedDevice ===》codeUpdateMTU", res);
|
||||
|
||||
app.globalData.ppScale.activeProtocol.codeFetchBindingState((res) => {
|
||||
console.log("connectedDevice ===》codeFetchBindingState", res);
|
||||
|
||||
wx.hideLoading();
|
||||
if (res === 1) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前设备已被绑定,你确定要覆盖绑定吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||
console.log("deviceInfo === codeClearDeviceData", res);
|
||||
|
||||
let scaleDeviceId = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentCode: scaleDeviceId,
|
||||
};
|
||||
$.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: res.message,
|
||||
})
|
||||
let pages = getCurrentPages();
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({
|
||||
getDeviceSetting: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1500);
|
||||
});
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.device.name = this.data.name;
|
||||
wx.navigateTo({
|
||||
url: "/pages/connectionSuccessful/connectionSuccessful"
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
nameInput(e) {
|
||||
this.setData({
|
||||
name: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
// 配对
|
||||
openConnectionSuccessful() {
|
||||
let deviceSelect = this.data.deviceSelect;
|
||||
if (deviceSelect) {
|
||||
let name = this.data.name;
|
||||
if (name) {
|
||||
wx.showLoading({
|
||||
title: "蓝牙配对中...",
|
||||
mask: true
|
||||
});
|
||||
app.globalData.ppScale.plugin.Blue.createBLEConnection(deviceSelect);
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "设备名称不能为空"
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配对设备不能为空"
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "设备命名",
|
||||
"disableScroll": true
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<view class="equipmentModel">型号:{{deviceSelect.name}}</view>
|
||||
|
||||
<view class="equipmentIcon">
|
||||
<image src="/images/connectedDevice/device.png" />
|
||||
</view>
|
||||
|
||||
<view class="equipmentName arrowAfter">
|
||||
<view>设备名称</view>
|
||||
<view>
|
||||
<input type="text" value="{{name}}" bindinput="nameInput" placeholder="请输入设备名称" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn" bind:tap="openConnectionSuccessful">配对</view>
|
||||
@@ -0,0 +1,68 @@
|
||||
page {
|
||||
padding: 50rpx 60rpx 0;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.equipmentModel {
|
||||
color: #252535;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.equipmentIcon {
|
||||
width: 320rpx;
|
||||
height: 320rpx;
|
||||
margin: 0 auto 40rpx;
|
||||
}
|
||||
|
||||
.equipmentName {
|
||||
width: 100%;
|
||||
height: 126rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding-right: 35rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 550rpx;
|
||||
justify-content: space-between;
|
||||
border-bottom: 1rpx solid #EAECF1;
|
||||
}
|
||||
|
||||
.equipmentName>view:first-of-type {
|
||||
color: #252535;
|
||||
height: 126rpx;
|
||||
line-height: 126rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.equipmentName>view:last-of-type {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 126rpx;
|
||||
}
|
||||
|
||||
.equipmentName>view:last-of-type input {
|
||||
color: #808080;
|
||||
width: 100%;
|
||||
height: 126rpx;
|
||||
text-align: right;
|
||||
font-size: 36rpx;
|
||||
line-height: 126rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #FFFFFF;
|
||||
width: 580rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
margin: 0 auto;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
border-radius: 44rpx;
|
||||
text-align: center;
|
||||
background-color: #1385FA;
|
||||
}
|
||||
Reference in New Issue
Block a user