Home WeChat Applet Mini Program Development How to connect the mini program to WIFI

How to connect the mini program to WIFI

Mar 21, 2020 pm 12:24 PM
Applets Connect to wifi

This article mainly introduces the WeChat applet to realize the WiFi connection function, and analyzes the module initialization, configuration, connection and other related operation skills of the WeChat applet to operate WiFi connection in the form of examples. Friends in need can refer to the following

How to connect the mini program to WIFI

How to connect to WIFI with a small program

When the wifi account and wifi password are known, the following process is generally used to connect to wifi.

Recommended learning: Small program developmentTutorial

Wi-Fi interface call:

1, Android

 startWifi —> connectWifi —> onWifiConnected
Copy after login

2. iOS (only supported by iOS 11 and above):

startWifi —> connectWifi —> onWifiConnected
Copy after login

The steps are as follows:

1. Get the model number of the phone:

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 == &#39;android&#39; && system < 6) {
                wx.showToast({
                    title: &#39;手机版本不支持&#39;,
                })
                return
            }
            if (res.platform == &#39;ios&#39; && system < 11.2) {
                wx.showToast({
                    title: &#39;手机版本不支持&#39;,
                })
                return
            }
            //2.初始化 Wi-Fi 模块
            that.startWifi();
        }
    })
},
//初始化 Wi-Fi 模块
startWifi: function() {
    var that=this
    wx.startWifi({
        success: function() {
            //请求成功连接Wifi
            that.Connected();
        },
        fail: function(res) {
            this.setData({
                wx.showToast({
                    title: &#39;接口调用失败&#39;,
                })
            });
        }
    })
},
Copy after login

2. Connect to known Wifi

Connected: function() {
    var that=this
    wx.connectWifi({
        SSID: that.data.accountNumber,
        BSSID: that.data.bssid,
        password: that.data.password,
        success: function(res) {
            wx.showToast({
                title: &#39;wifi连接成功&#39;,
            })
        },
        fail: function(res) {
            wx.showToast({
                title: &#39;wifi连接失败&#39;,
            })
        }
    })
},
//使用的参数
data:{
    accountNumber: &#39;&#39;,//Wi-Fi 的SSID,即账号
    bssid: &#39;&#39;,//Wi-Fi 的ISSID
    password: &#39;&#39;,//Wi-Fi 的密码
}
Copy after login

3. .wxml connection button

<button bindtap="connectWifi"></button>
Copy after login

PHP Chinese website , a large number of MySQL video tutorials, welcome to learn online for free!

The above is the detailed content of How to connect the mini program to WIFI. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to connect Xiaoai speakers to wifi? Detailed steps for connecting Xiaoai speakers to wifi network! How to connect Xiaoai speakers to wifi? Detailed steps for connecting Xiaoai speakers to wifi network! Mar 15, 2024 pm 07:28 PM

Are you curious about how to connect Xiaoai speakers to wifi? Xiaoai Speaker is a very comprehensive smart speaker software. Users can control and configure your AI speaker on their mobile phones, such as adjusting volume, playing music, voice wake-up, etc. Are there any friends who are using it for the first time and don’t know how to set up the wifi connection of Xiaoai speakers? The editor has now compiled the detailed steps for connecting Xiaoai speakers to the wifi network to share with you! If it is helpful to you, please download the software and experience it! 1. How to connect Xiaoai speakers to wifi? Detailed steps for connecting Xiaoai speakers to wifi network! 1. Open the latest version of Xiaoai Speaker app downloaded from this site. The latest version of Xiaoai Speaker app Category: Convenient life Download the latest version of Xiaoai Speaker app is a very convenient smart home service software that can

Steps on how to connect HP 136w printer to wifi. Must read: HP printer wireless connection tutorial Steps on how to connect HP 136w printer to wifi. Must read: HP printer wireless connection tutorial Feb 26, 2024 am 11:19 AM

In fact, it is LAN printer sharing. The method is as follows: 1. Set the IP for the printer. First, plug the network from the router or switch to the printer. 2. Then click Printer Settings - Network Configuration - Wireless Menu. It is best to set a fixed IP for the printer there. Next, download and install the printer driver on your computer. When installing the driver, select the network installation option, so that the computer will automatically search for printers connected to the shared network. Once the installation is complete, the driver will show that the printer has been successfully shared wirelessly. How to connect the printer through a wireless network: 1. Right-click the WiFi icon under the desktop and select "Open Network and Sharing Center". 2. Click the name of the WiFi you are connected to, and a pop-up will appear.

Develop WeChat applet using Python Develop WeChat applet using Python Jun 17, 2023 pm 06:34 PM

With the popularity of mobile Internet technology and smartphones, WeChat has become an indispensable application in people's lives. WeChat mini programs allow people to directly use mini programs to solve some simple needs without downloading and installing applications. This article will introduce how to use Python to develop WeChat applet. 1. Preparation Before using Python to develop WeChat applet, you need to install the relevant Python library. It is recommended to use the two libraries wxpy and itchat here. wxpy is a WeChat machine

Can small programs use react? Can small programs use react? Dec 29, 2022 am 11:06 AM

Mini programs can use react. How to use it: 1. Implement a renderer based on "react-reconciler" and generate a DSL; 2. Create a mini program component to parse and render DSL; 3. Install npm and execute the developer Build npm in the tool; 4. Introduce the package into your own page, and then use the API to complete the development.

Implement card flipping effects in WeChat mini programs Implement card flipping effects in WeChat mini programs Nov 21, 2023 am 10:55 AM

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: &lt;!--index.wxml--&gt;&l

How to connect Xiaomi speaker to wifi network_Steps to connect Xiaomi speaker to wifi network How to connect Xiaomi speaker to wifi network_Steps to connect Xiaomi speaker to wifi network Mar 25, 2024 am 11:16 AM

1. Plug in the Xiaoai speaker and turn it on. 2. Log in to the Xiaoai Speaker APP with your mobile phone and automatically search for your speakers. 3. Click to start network configuration, select WiFi, enter the password, and click to connect.

How to connect Xiaoai speaker to wifi network 'Detailed explanation: Xiaoai classmate cannot connect to the network' How to connect Xiaoai speaker to wifi network 'Detailed explanation: Xiaoai classmate cannot connect to the network' Feb 06, 2024 pm 03:43 PM

I believe everyone is familiar with Xiaoai. It has brought us a lot of convenience and happiness in life, and many friends will not be unable to connect to the Internet for a long time when they are busy. Let's demonstrate it in a simple and convenient way. If your phone is of the Xiaomi brand, you only need to open the settings, find Xiaoai classmates, and click Check for Updates. If your phone is of another brand, you need to download the Xiaoai Audio APP. Then open and click on me in the lower right corner. Click Upgrade. As shown in Figure 3, click Detect Updates. If you still cannot connect to the network, try restarting the router. Xiaoai speakers support connecting to wireless networks (Wi-Fi), and some models also support 5G frequency bands. The steps for connecting Xiaoai speakers to Wi-Fi are as follows: Step 1: Plug in the power adapter of the newly purchased Xiaoai speaker and turn it on.

Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Oct 31, 2023 pm 09:25 PM

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

See all articles