|
@@ -6,11 +6,26 @@ import store from '../../utils/store';
|
|
|
import { BtCmd } from '../../devices/bluetooth/bt_cmd';
|
|
|
Page({
|
|
|
data: {
|
|
|
+ navbarData: {
|
|
|
+ showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
|
|
+ title: '猫王音箱 - WI-FI配置', //导航栏 中间的标题
|
|
|
+ // callback: true,
|
|
|
+ },
|
|
|
wifiName: '',
|
|
|
wifiPassword: '',
|
|
|
_otaUrl: "",
|
|
|
+ eyeIconSrc: '../../img/yj0.png',
|
|
|
+ passwordType: true,
|
|
|
+ _onNavigateBack: false,
|
|
|
+
|
|
|
},
|
|
|
+ callback() {
|
|
|
+ console.log("返回");
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ });
|
|
|
|
|
|
+ },
|
|
|
getConnectedWifi: function () {
|
|
|
const that = this;
|
|
|
let wifiDic = store.getStore("wifiInfo")
|
|
@@ -62,6 +77,17 @@ Page({
|
|
|
wifiPassword: e.detail.value
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+ togglePasswordVisibility: function () {
|
|
|
+ const passwordType = !this.data.passwordType;
|
|
|
+ // const newType = currentType === 'password' ? 'text' : 'password';
|
|
|
+ const newIconSrc = passwordType ? '../../img/yj0.png' : '../../img/yj1.png';
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ passwordType: passwordType,
|
|
|
+ eyeIconSrc: newIconSrc
|
|
|
+ });
|
|
|
+ },
|
|
|
sendWiFiInfo(wifiName, pwd) {
|
|
|
// [0x22, (wifiList.length + pwdList.length + 6), 0x33, (wifiList.length), (wifiList), 0x44, (pwdList)];
|
|
|
|
|
@@ -72,7 +98,9 @@ Page({
|
|
|
wx.hideLoading()
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'wifi连接中',
|
|
|
+ })
|
|
|
let result = BtCmd.sendWiFiInfo(wifiName, pwd)
|
|
|
|
|
|
// _ble.send({ cmd: result });
|
|
@@ -112,6 +140,18 @@ Page({
|
|
|
}
|
|
|
}, _this)
|
|
|
},
|
|
|
+ wifiPageSuccess() {
|
|
|
+ this.data._onNavigateBack = true
|
|
|
+ },
|
|
|
+ // 获取保存的 Wi-Fi 账号和密码
|
|
|
+ getSavedWiFiInfo() {
|
|
|
+ const wifiName = wx.getStorageSync('wifiName') || '';
|
|
|
+ const wifiPassword = wx.getStorageSync('wifiPassword') || '';
|
|
|
+ this.setData({
|
|
|
+ wifiName: wifiName,
|
|
|
+ wifiPassword: wifiPassword
|
|
|
+ });
|
|
|
+ },
|
|
|
onLoad: function (options) {
|
|
|
let param = options.param ?? "{}";
|
|
|
let url = JSON.parse(param).url ?? "";
|
|
@@ -120,6 +160,9 @@ Page({
|
|
|
this.addNotification()
|
|
|
},
|
|
|
onUnload() {
|
|
|
+ if (!this.data._onNavigateBack) {
|
|
|
+ BtHelper.getInstance().otaCmd(2)
|
|
|
+ }
|
|
|
EventManager.removeNotification(CmdEvent.eventName)
|
|
|
},
|
|
|
});
|