1.小程序一键链接WIFI
connectWifi: function() {var that = this;//检测手机型号wx.getSystemInfo({success: function(res) {var system = '';if (res.platform == 'android') system = parseInt(res.system.substr(8));if (res.platform == 'ios') system = parseInt(res.system.substr(4));if (res.platform == 'android' && system < 6) {wx.showToast({title: '手机版本不支持'});return;}if (res.platform == 'ios' && system < 11.2) {wx.showToast({title: '手机版本不支持'});return;}//2.初始化 Wi-Fi 模块that.startWifi();}});},//初始化 Wi-Fi 模块startWifi: function() {var that = this;wx.startWifi({success: function() {//请求成功连接Wifithat.Connected();},fail: function(res) {wx.showToast({title: '接口调用失败'});}});},Connected: function() {var that = this;wx.connectWifi({SSID: this.GetShop.wifi,// wifi名称// BSSID: '10-F6-0A-99-E0-35',password: this.GetShop.wifimima,// wifi密码success: function(res) {wx.showToast({title: 'wifi连接成功'});setTimeout(()=>{this.showWifi();},2000)},fail: function(res) {let errMsg = 'wifi连接失败';if (res.errCode == "12001") errMsg = "wifi连接失败";// 当前系统不支持相关能力if (res.errCode == "12002") errMsg = "wifi连接失败";// 查不到账号,请联系系统管理员if (res.errCode == "12003") errMsg = "wifi连接失败";// 请确认是否在组织Wifi覆盖范围内if (res.errCode == "12004") errMsg = "重复连接Wifi";if (res.errCode == "12005") errMsg = "未打开Wifi开关";if (res.errCode == "12006") errMsg = "未打开GPS定位开关";if (res.errCode == "12007") errMsg = "用户拒绝授权链接Wifi";if (res.errCode == "12008") errMsg = "wifi连接失败";// 查不到账号,请联系系统管理员if (res.errCode == "12009") errMsg = "系统运行商配置拒绝链接Wifi";// 系统运行商配置拒绝链接Wifiif (res.errCode == "12010") errMsg = "wifi连接失败";// 未知错误,请联系系统管理员if (res.errCode == "12011") errMsg = "wifi连接失败";应用在后台无法配置Wifiif (res.errCode == "12013") errMsg = "wifi连接失败";// 查不到账号,请联系系统管理员if (res.errCode == "12014") errMsg = "wifi连接失败";wx.showToast({title: errMsg});}});},