小程序一键链接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
						});
					}
				});
			},
相关推荐
克里斯蒂亚诺更新7 小时前
微信小程序使用vant4 weapp自定义菜单 但是弹出层却被菜单遮挡的解决办法
微信小程序·小程序·notepad++
小羊Yveesss11 小时前
2026年微信小程序制作工具怎么选?
微信小程序·小程序
河北清兮网络科技13 小时前
深度解析:2026石家庄短视频APP开发真实成本、隐性开销与避坑方案
大数据·小程序·app·短剧app·广告联盟
微擎应用13 小时前
宠物门店系统 - 连锁宠物医院多门店小程序+公众号双端管理系统
小程序·宠物
2501_9159214314 小时前
uni-app 上架 iOS 的完整流程(无需依赖 Mac)
android·macos·ios·小程序·uni-app·iphone·webview
前端 贾公子15 小时前
使用 wxappUnpacker 工具进行 MAC 微信小程序反编译
macos·微信小程序·小程序
CRMEB系统商城1 天前
CRMEB多商户系统(Java)v2.3公测版发布
java·开发语言·人工智能·小程序·开源·php
嫂子的姐夫2 天前
050-wx小程序合肥住房
爬虫·python·小程序·逆向
Geek_Vison2 天前
政务一网通APP如何引入AI能力,通过一个AI助手就能够调用所有的功能,实现对话即办事
人工智能·ai·小程序·uni-app·小程序容器
黄华SJ520it2 天前
跨境分销小程序:全球市场新机遇
小程序·系统开发