In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to scan code and even wifi in Mini Program", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to scan code with wifi on Mini Program".
Mini Program disadvantages: android6 version ios11 version
Code:
/ / pages/wifi/wifi.js
Page ({
Data: {
StartError:'', / / initialize error message
WifiListError: false, / / wifi list error display switch
WifiListErrorInfo:'', / / wifi list error details
System:'', / / version number
Platform:'', / / system android
Ssid: 'wifi account', / / wifi account (required)
Pass: 'wifi password', / / Wireless network password (required)
Bssid:'', / / device number is obtained automatically
EndError:''/ / the last hint to connect
}
OnLoad: function () {
Var _ this = this
/ / check the phone model
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) { _this.setData({ startError: '手机版本暂时不支持' }); return } if (res.platform == 'ios' && system < 11) { _this.setData({ startError: '手机版本暂时不支持' }); return } _this.setData({ platform: res.platform }); //初始化 Wi-Fi 模块 _this.startWifi(_this); } }) },//初始化 Wi-Fi 模块。 startWifi: function (_this) { wx.startWifi({ success: function () { _this.getList(_this); }, fail: function (res) { _this.setData({ startError: res.errMsg }); } }) }, getList: function (_this) { //安卓执行方法 if (_this.data.platform == 'android') { //请求获取 Wi-Fi 列表 wx.getWifiList({ success: function (res) { //安卓执行方法 _this.AndroidList(_this); }, fail: function (res) { _this.setData({ wifiListError: true }); _this.setData({ wifiListErrorInfo: res.errMsg }); } }) } //IOS执行方法 if (_this.data.platform == 'ios') { _this.IosList(_this); } }, AndroidList: function (_this) { //监听获取到 Wi-Fi 列表数据 wx.onGetWifiList(function (res) { //获取列表 if (res.wifiList.length) { // _this.setData({ // wifiList: res.wifiList // }); //循环找出信号最好的那一个(wifi存在多个) var ssid = _this.data.ssid; var signalStrength = 0; var bssid = ''; for (var i = 0; i < res.wifiList.length; i++) { if (res.wifiList[i]['SSID'] == ssid && res.wifiList[i]['signalStrength'] >SignalStrength) {
Bssid = res.wifiList [I] ['BSSID']
SignalStrength = res.wifiList [I] ['signalStrength']
}
}
If (! signalStrength) {
_ this.setData ({wifiListError: true})
_ this.setData ({wifiListErrorInfo: 'the set wifi'} was not found)
Return
}
_ this.setData ({bssid: bssid})
/ / execute the connection method
/ / Connect to wifi
_ this.Connected (_ this)
} else {
_ this.setData ({wifiListError: true})
_ this.setData ({wifiListErrorInfo: 'the set wifi'} was not found)
At this point, I believe that "Mini Program how to achieve scan code even wifi" have a deeper understanding, might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.