小程序一键链接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
						});
					}
				});
			},
相关推荐
云迈科技-软件定制开发11 小时前
2026年湖南长沙软件定制开发公司怎么选?本地企业做APP、小程序、管理系统的合作参考
小程序
小码哥0682 天前
从三甲综合医院到连锁诊所:医院管理小程序的场景化突围逻辑(陪诊系统-陪诊APP-陪诊小程序)
小程序·医院管理系统·陪诊小程序·陪诊系统·陪诊app
2501_916007472 天前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
正在走向自律2 天前
用豆包Seed Evolving打造全功能【AI智能记账】小程序,开源可落地
人工智能·小程序·开源·智能记账
小羊Yveesss3 天前
模板建站哪个平台好?模板数量之外还要比较编辑与SEO能力
大数据·人工智能·小程序
2501_916007473 天前
深入理解HTTPS对称与非对称加密机制及Charles抓包实践
网络协议·http·ios·小程序·https·uni-app·iphone
郑州光合科技余经理3 天前
家政O2O平台解析:从0搭建上门预约小程序解决方案
android·java·开发语言·前端·小程序·架构·php
维双云3 天前
小程序商城制作一个需要多少钱?2026报价明细与成本拆解
小程序
郑州光合科技余经理3 天前
家政预约小程序后端源码深度剖析:支付回调实战
java·开发语言·前端·git·小程序·架构·php
电商API_180079052473 天前
导购比价小程序场景|京东联盟商品详情对接方案|多规格图文拉取技术实操
网络·小程序·网络爬虫