更换wifi添加loading
This commit is contained in:
@@ -18,9 +18,14 @@ Component({
|
|||||||
// 组件的方法
|
// 组件的方法
|
||||||
methods: {
|
methods: {
|
||||||
getWiFiList() {
|
getWiFiList() {
|
||||||
|
wx.showLoading({
|
||||||
|
title: "正在获取Wi-Fi列表...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => {
|
app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => {
|
||||||
console.log("connectedDevice ===》dataFindSurroundDevice", res);
|
console.log("connectedDevice ===》dataFindSurroundDevice", res);
|
||||||
|
|
||||||
|
wx.hideLoading();
|
||||||
this.setData({
|
this.setData({
|
||||||
wifiList: res
|
wifiList: res
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ Page({
|
|||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.checkBluetoothPermissionAndInit();
|
this.checkBluetoothPermissionAndInit();
|
||||||
|
|
||||||
|
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("devicesModel", (res) => {
|
app.globalData.ppScale.plugin.bus.subscribe("devicesModel", (res) => {
|
||||||
console.log("searchDevice ===》devicesModel", res);
|
console.log("searchDevice ===》devicesModel", res);
|
||||||
app.globalData.ppScale.device.mac = res.deviceMac;
|
app.globalData.ppScale.device.mac = res.deviceMac;
|
||||||
@@ -35,9 +34,10 @@ Page({
|
|||||||
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||||
console.log("connectedDevice ===》codeUpdateMTU", res);
|
console.log("connectedDevice ===》codeUpdateMTU", res);
|
||||||
|
|
||||||
|
|
||||||
app.globalData.ppScale.device.name = this.data.device.name;
|
app.globalData.ppScale.device.name = this.data.device.name;
|
||||||
app.globalData.ppScale.device.connection = this.data.device;
|
app.globalData.ppScale.device.connection = this.data.device;
|
||||||
|
|
||||||
|
wx.hideLoading();
|
||||||
this.selectComponent('#replaceNetwork1Component').getWiFiList();
|
this.selectComponent('#replaceNetwork1Component').getWiFiList();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -58,23 +58,24 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
checkBluetoothPermissionAndInit() {
|
checkBluetoothPermissionAndInit() {
|
||||||
this.setData({
|
wx.showLoading({
|
||||||
initText: "正在检查蓝牙权限..."
|
title: "正在检查蓝牙权限...",
|
||||||
|
mask: true
|
||||||
});
|
});
|
||||||
wx.getSetting({
|
wx.getSetting({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.authSetting['scope.bluetooth']) {
|
if (res.authSetting['scope.bluetooth']) {
|
||||||
|
wx.hideLoading();
|
||||||
this.openBluetoothAdapter();
|
this.openBluetoothAdapter();
|
||||||
} else {
|
} else {
|
||||||
wx.authorize({
|
wx.authorize({
|
||||||
scope: 'scope.bluetooth',
|
scope: 'scope.bluetooth',
|
||||||
success: () => {
|
success: () => {
|
||||||
|
wx.hideLoading();
|
||||||
this.openBluetoothAdapter();
|
this.openBluetoothAdapter();
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
this.setData({
|
wx.hideLoading();
|
||||||
initText: "蓝牙权限被拒绝。"
|
|
||||||
});
|
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '您拒绝了蓝牙权限,将无法连接蓝牙秤。是否前往设置开启?',
|
content: '您拒绝了蓝牙权限,将无法连接蓝牙秤。是否前往设置开启?',
|
||||||
@@ -104,35 +105,32 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
this.setData({
|
wx.hideLoading();
|
||||||
initText: "获取权限设置失败。"
|
|
||||||
});
|
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '获取权限设置失败',
|
title: '获取权限设置失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
|
setTimeout(() => {
|
||||||
wx.navigateBack({
|
wx.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
});
|
});
|
||||||
|
}, 1500)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
openBluetoothAdapter() {
|
openBluetoothAdapter() {
|
||||||
this.setData({
|
wx.showLoading({
|
||||||
initText: "正在初始化蓝牙..."
|
title: "正在初始化蓝牙...",
|
||||||
|
mask: true
|
||||||
});
|
});
|
||||||
wx.openBluetoothAdapter({
|
wx.openBluetoothAdapter({
|
||||||
success: () => {
|
success: () => {
|
||||||
this.setData({
|
wx.hideLoading();
|
||||||
initText: "蓝牙初始化成功"
|
|
||||||
});
|
|
||||||
this.getDeviceSettingList();
|
this.getDeviceSettingList();
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
this.setData({
|
wx.hideLoading();
|
||||||
initText: "蓝牙初始化失败。"
|
|
||||||
});
|
|
||||||
if (err.errCode === 10001) {
|
if (err.errCode === 10001) {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
@@ -174,9 +172,11 @@ Page({
|
|||||||
getDeviceSettingList() {
|
getDeviceSettingList() {
|
||||||
let params = {};
|
let params = {};
|
||||||
$.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => {
|
$.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => {
|
||||||
this.setData({
|
wx.showLoading({
|
||||||
initText: "设备搜索中..."
|
title: "正在寻找设备...",
|
||||||
})
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
app.globalData.ppScale.device.list = [];
|
app.globalData.ppScale.device.list = [];
|
||||||
let seviceList = app.globalData.ppScale.device.setting.find((item) => {
|
let seviceList = app.globalData.ppScale.device.setting.find((item) => {
|
||||||
return item.deviceName === res.result[0].type
|
return item.deviceName === res.result[0].type
|
||||||
@@ -189,6 +189,11 @@ Page({
|
|||||||
let fIndex = res_.findIndex(item => item.deviceId === res.result[0].deviceId);
|
let fIndex = res_.findIndex(item => item.deviceId === res.result[0].deviceId);
|
||||||
if (fIndex >= 0) {
|
if (fIndex >= 0) {
|
||||||
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showLoading({
|
||||||
|
title: "正在连接设备...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
this.setData({
|
this.setData({
|
||||||
device: res_[fIndex]
|
device: res_[fIndex]
|
||||||
})
|
})
|
||||||
@@ -243,6 +248,7 @@ Page({
|
|||||||
|
|
||||||
// 卸载事件监听
|
// 卸载事件监听
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
app.globalData.ppScale.plugin.Blue.disconnect();
|
||||||
if (this._connectStateWatcher) {
|
if (this._connectStateWatcher) {
|
||||||
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ Page({
|
|||||||
|
|
||||||
app.globalData.ppScale.device.name = this.data.device.name;
|
app.globalData.ppScale.device.name = this.data.device.name;
|
||||||
app.globalData.ppScale.device.connection = this.data.device;
|
app.globalData.ppScale.device.connection = this.data.device;
|
||||||
this.selectComponent('#replaceNetwork1Component').getWiFiList();
|
|
||||||
|
wx.hideLoading();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -229,9 +230,15 @@ Page({
|
|||||||
recentData: [],
|
recentData: [],
|
||||||
}, (res) => {
|
}, (res) => {
|
||||||
if(res == 0) {
|
if(res == 0) {
|
||||||
this.triggerEvent('deviceEvent', {
|
wx.showToast({
|
||||||
status: true
|
title: "用户信息更新成功。",
|
||||||
});
|
icon: "none"
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
})
|
||||||
|
}, 1500)
|
||||||
} else {
|
} else {
|
||||||
console.log("dataSyncUserInfo", res)
|
console.log("dataSyncUserInfo", res)
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
@@ -410,6 +417,10 @@ Page({
|
|||||||
|
|
||||||
// 点击设备重连
|
// 点击设备重连
|
||||||
connectedDevice() {
|
connectedDevice() {
|
||||||
|
wx.showLoading({
|
||||||
|
title: "正在重新连接设备...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
let device = this.data.device;
|
let device = this.data.device;
|
||||||
if(device) {
|
if(device) {
|
||||||
app.globalData.ppScale.plugin.Blue.createBLEConnection(device);
|
app.globalData.ppScale.plugin.Blue.createBLEConnection(device);
|
||||||
|
|||||||
Reference in New Issue
Block a user