search
HomeWeChat AppletMini Program DevelopmentSummarize 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!

Summarize and share some practical knowledge in small program development

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

Summarize and share some practical knowledge in small program development

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

Summarize and share some practical knowledge in small program development

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,

Summarize and share some practical knowledge in small program development

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

Summarize and share some practical knowledge in small program development

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(&#39;ready&#39;)

})
// 处理失败验证
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=&#39;&#39; data-miniprogram-appid=&#39;{{appid}}&#39; data-miniprogram-path=&#39;pages/index/index&#39;>点击跳小程序</a>
  • data-miniprogram-appid填写小程序链接,表示跳转小程序
  • data-miniprogram-path 小程序路径,可带参数
  • 公众号必须和小程序相关联
  • 链接中的各个属性值必须使用单引号

小程序跳转小程序

wx.navigateToMiniProgram({
    envVersion: &#39;release&#39;, // 要打开的小程序版本,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!

Statement
This article is reproduced at:掘金社区. If there is any infringement, please contact admin@php.cn delete
使用Python开发微信小程序使用Python开发微信小程序Jun 17, 2023 pm 06:34 PM

随着移动互联网技术和智能手机的普及,微信成为了人们生活中不可或缺的一个应用。而微信小程序则让人们可以在不需要下载安装应用的情况下,直接使用小程序来解决一些简单的需求。本文将介绍如何使用Python来开发微信小程序。一、准备工作在使用Python开发微信小程序之前,需要安装相关的Python库。这里推荐使用wxpy和itchat这两个库。wxpy是一个微信机器

小程序能用react吗小程序能用react吗Dec 29, 2022 am 11:06 AM

小程序能用react,其使用方法:1、基于“react-reconciler”实现一个渲染器,生成一个DSL;2、创建一个小程序组件,去解析和渲染DSL;3、安装npm,并执行开发者工具中的构建npm;4、在自己的页面中引入包,再利用api即可完成开发。

Java语言中的微信小程序开发介绍Java语言中的微信小程序开发介绍Jun 09, 2023 pm 10:40 PM

微信小程序是一种轻量级的应用程序,可以在微信平台上运行,不需要下载安装,方便快捷。Java语言作为一种广泛应用于企业级应用开发的语言,也可以用于微信小程序的开发。在Java语言中,可以使用SpringBoot框架和第三方工具包来开发微信小程序。下面是一个简单的微信小程序开发过程。创建微信小程序首先,需要在微信公众平台上注册一个小程序。注册成功后,可以获取到

用Python编写简单的聊天程序教程用Python编写简单的聊天程序教程May 08, 2023 pm 06:37 PM

实现思路x01服务端的建立首先,在服务端,使用socket进行消息的接受,每接受一个socket的请求,就开启一个新的线程来管理消息的分发与接受,同时,又存在一个handler来管理所有的线程,从而实现对聊天室的各种功能的处理x02客户端的建立客户端的建立就要比服务端简单多了,客户端的作用只是对消息的发送以及接受,以及按照特定的规则去输入特定的字符从而实现不同的功能的使用,因此,在客户端这里,只需要去使用两个线程,一个是专门用于接受消息,一个是专门用于发送消息的至于为什么不用一个呢,那是因为,只

PHP与小程序的地理位置定位与地图显示PHP与小程序的地理位置定位与地图显示Jul 04, 2023 pm 04:01 PM

PHP与小程序的地理位置定位与地图显示地理位置定位与地图显示在现代科技中已经成为了必备的功能之一。随着移动设备的普及,人们对于定位和地图显示的需求也越来越高。在开发过程中,PHP和小程序是常见的两种技术选择。本文将为大家介绍PHP与小程序中的地理位置定位与地图显示的实现方法,并附上相应的代码示例。一、PHP中的地理位置定位在PHP中,我们可以使用第三方地理位

教你如何在小程序中用公众号模板消息(附详细思路)教你如何在小程序中用公众号模板消息(附详细思路)Nov 04, 2022 pm 04:53 PM

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了如何在小程序中用公众号模板消息,下面一起来看一下,希望对大家有帮助。

小程序中文件上传的PHP实现方法小程序中文件上传的PHP实现方法Jun 02, 2023 am 08:40 AM

随着小程序的广泛应用,越来越多的开发者需要将其与后台服务器进行数据交互,其中最常见的业务场景之一就是上传文件。本文将介绍在小程序中实现文件上传的PHP后台实现方法。一、小程序中的文件上传在小程序中实现文件上传,主要依赖于小程序APIwx.uploadFile()。该API接受一个options对象作为参数,其中包含了要上传的文件路径、需要传递的其他数据以及

苏州健康码的小程序叫什么苏州健康码的小程序叫什么Oct 24, 2022 am 09:47 AM

苏州健康码的小程序叫“苏康码”,它是苏州市疫情防控指挥部指定的通行服务码,疫情防控期间在全市范围内通用,可以作为广大民众日常出行的重要凭证,同时作为防疫人员查验的主要依据;也是省内所有来苏逗苏人员以及在苏工作学习生活,旅游或临时停留人员申报的键康申报数据为基础,结合相关数据比对后动态生成的个人电子健康凭证。

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!