小程序一键链接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
						});
					}
				});
			},
相关推荐
说私域2 小时前
“开源AI智能名片链动2+1模式S2B2C商城小程序”在县级市场的应用与挑战分析
人工智能·小程序·开源
千寻技术帮3 小时前
50024_基于微信小程序的食品购商城
小程序·源码·项目·文档·ppt
说私域9 小时前
定制开发AI智能名片S2B2C预约服务小程序的定制开发与优势分析
大数据·人工智能·小程序
云起SAAS18 小时前
名字姓名起名打分评分抖音快手微信小程序看广告流量主开源
微信小程序·小程序·ai编程·看广告变现轻·名字姓名起名打分评分
说私域18 小时前
从裂变能力竞争到技术水平竞争:开源AI智能名片链动2+1模式S2B2C商城小程序对微商企业竞争格局的重塑
人工智能·小程序·开源
开发加微信:hedian11621 小时前
短剧小程序开发全攻略:技术选型与实现思路
微信·小程序·架构·aigc·交互
2501_9159184121 小时前
移动端 HTTPS 抓包实战,多工具组合分析与高效排查指南
数据库·网络协议·ios·小程序·https·uni-app·iphone
星光一影1 天前
陪诊陪检系统源码,陪诊小程序,陪诊APP,陪诊服务,家政上门系统,居家护理陪护源码
mysql·小程序·uni-app·php
阿奇__1 天前
uniapp h5 app 小程序获取当前定位
小程序·uni-app
2501_915106321 天前
iOS性能调优的系统化实践,从架构分层到多工具协同的全流程优化指南(开发者深度版)
android·ios·小程序·架构·uni-app·iphone·webview