小程序一键链接WIFI

1.小程序一键链接WIFI

wx 复制代码
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() {
						//请求成功连接Wifi
						that.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";// 系统运行商配置拒绝链接Wifi
						if (res.errCode == "12010") errMsg = "wifi连接失败";// 未知错误,请联系系统管理员
						if (res.errCode == "12011") errMsg = "wifi连接失败";应用在后台无法配置Wifi
						if (res.errCode == "12013") errMsg = "wifi连接失败";// 查不到账号,请联系系统管理员
						if (res.errCode == "12014") errMsg = "wifi连接失败";
						
						wx.showToast({
							title: errMsg
						});
					}
				});
			},
相关推荐
weixin_lynhgworld1 小时前
抽取类盲盒小程序的五条合规红线意味着什么?
小程序
现任明教教主~2 小时前
运营级多门店洗车贴膜汽车在线核销保养服务系统洗车预约洗车系统消费分佣扫码核销系统
微信小程序·小程序·汽车
小小王app小程序开发3 小时前
盲盒微信小程序开发实战:架构、核心难点与实现方案
小程序
MoonMoonLee6 天前
小程序配置
小程序
2501_916007476 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
JQweryuiop6 天前
中小型游戏陪练工作室数字化管理实践:基于七彩屋电竞护航小程序订单、履约与绩效系统的落地复盘
大数据·游戏·小程序·架构
Ai-_Man6 天前
您您这可以把Mistral AI的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。
人工智能·ai·小程序·电脑
2501_916008896 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
微擎应用市场6 天前
简单拼车小程序系统:实现出行与物流资源的高效精准匹配
小程序
2501_916008896 天前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview