


Summarize and share some practical knowledge in small program development
This article summarizes and shares with you some practical knowledge in small program development. I hope it will be helpful to everyone!
Understand the rendering principle of the mini program
Background
In web development, since js is single-threaded, scripts sometimes run for a long time, causing the page to lose response. There are currently three ways to render pages:
- Pure client-side native technology rendering
- Pure web technology rendering
- Hybrid rendering, that is, a combination of web and native rendering Method
In the mini program, the Hybrid rendering method is selected, the logic layer and the view layer are separated, and run using dual threads. WebView is used to render the interface of the view layer, and the logic layer runs in JSCore.
Dual-thread model of mini program:
- Logic layer: Create a separate thread to execute javascript. All code related to the business logic of the mini program is executed here, responsible for the logic Processing, data requests, interface calls.
- View layer: Interface rendering is executed in the webView thread, and which interfaces are controlled through the logic layer code
- jsBridge: Enables small programs to use native functions through the API
Do you really understand the connection between appId, uniId and openId
openID
openID is assigned uniformly to users by the WeChat public platform. As we all know, WeChat mini programs and WeChat public accounts are maintained on the WeChat public platform. In order to distinguish users, each public account and mini program provides a unique ID for each user. Each user generates a unique openID
UnionID
UnionID is the ID assigned to WeChat users by the WeChat open platform. For applications under the same open platform, WeChat users will have a unique UnionID
For example: your company has two applications, mini program A and WeChat official account B, user information of A and B is required By opening up, two applications A and B can be bound to the same open platform. The WeChat open platform will generate a unique UnionID for WeChat users. After authorized login and registration, the UnionID will be stored in the user table, and will be opened from the same open platform in the future. After other applications under the platform are authorized to log in and get the UnionID, they can directly return the user information,
AppID
AppID is the unique identifier of different applications
For example: your company has one mini program, one official account and two applications, AppId is the unique identifier of these two applications
Take you to summarize the jumping ability of the mini program, so that you can accept leadership inspection at any time
A friend today He complained to me that he is currently working in a small and medium-sized company. The bosses are having a meeting in the conference room. The big boss has a question about mini program jump. A leader A, who didn't know which part he was responsible for, came out and first asked about operation and maintenance, and then asked about back-end Java. Java boss said that this belongs to the front-end category, and they were more clear. After hearing this, leader A directly said, what does the front-end know? Then he walked into the conference room and gave feedback to the big boss. No one knew. He told me before that their company’s front-end status is low. This is really low.
h5 Jump Mini Program
Product: Xiaoyang , our official account needs to jump to a certain applet by clicking this button. This function must be implemented
Okay, now that we have the requirements, let’s start with the plan
- Option 1: Click the button, give a pop-up box, and put it in the pop-up box A QR code. Guide users to long press to identify the
- operation process field, the user conversion rate is low, and most users are basically too lazy to operate
- Option 2: Use WeChat’s open label wx -open-launch-weapp
- You can jump to any legal and compliant mini program (I feel there will be more restrictions on this function later)
Passed After discussing with the product, the second option is more suitable. Start with:
Steps:
- Certified service account, bind the service account to the "js interface security domain name" Web pages under "can use this tag to jump to any legal and compliant mini program
- Introduce js files https://res.wx.qq.com/open/js/jweixin-1.6.0.js
- Inject permission configuration through the config interface, and apply for the required open tags through the openTagList field
wx.config({ debug: false, appId: '', // 公众号唯一标识 timestamp: '', // 生成签名的时间戳 nonceStr: '', // 生成签名的随机串 signature: '', // 签名 jsApiList: ["wx-open-launch-weapp"], openTagList: ["wx-open-launch-weapp"] // 微信开放标签 小程序跳转按钮:<wx-open-launch-weapp> }); // 通过ready处理成功验证 wx.ready(function () { console.log('ready') }) // 处理失败验证 wx.error(function(error) { console.error("err", error); }); <wx-open-launch-weapp id="launch-btn" username="gh_xxxxxxxx" path="pages/home/index?user=123&action=abc" > <script type="text/wxtag-template"> <style>.btn { padding: 12px }</style> <button class="btn">打开小程序</button> </script> </wx-open-launch-weapp>
The WeChat customer service message contains a jump applet link
文本内容....<a href='' data-miniprogram-appid='{{appid}}' data-miniprogram-path='pages/index/index'>点击跳小程序</a>
- data-miniprogram-appid填写小程序链接,表示跳转小程序
- data-miniprogram-path 小程序路径,可带参数
- 公众号必须和小程序相关联
- 链接中的各个属性值必须使用单引号
小程序跳转小程序
wx.navigateToMiniProgram({ envVersion: 'release', // 要打开的小程序版本,develop: 开发版,trial:体验版,release:正式版。仅在当前小程序为开发版或体验版时此参数有效。 appId: ’‘, // 跳转appid path: ’‘ // 跳转路径 })
- 需要用户手动触发
- 需要用户确认跳转
【相关学习推荐:小程序开发教程】
The above is the detailed content of Summarize and share some practical knowledge in small program development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor