Record of developing WeChat applet using java language

coldplay.xixi
Release: 2021-04-30 11:29:57
forward
2338 people have browsed it

Record of developing WeChat applet using java language

Register Mini Program

To develop, you naturally need to have an account first. Search "WeChat Public Platform" in your browser, or visit https://mp.weixin.qq.com/ directly. You can see that accounts are divided into three categories: service account, subscription account and mini program. Not much to say about the first two here, just click on the mini program to register.

Related free learning recommendations: WeChat applet development

Configuration server

The applet itself Many interfaces have been provided to meet most of the needs of developers. But if there is already an implemented service, then you only need to call the service interface in the applet (you can even use a web page that has already been written). If you happen to have this need, you first need to make relevant configurations in the mini program console

  1. appid and secret key

Enter the menu Settings——》Development Settings.
First, you can get the appID and secret key (AppSecret) in Developer ID. appid is the unique identifier of the mini program and needs to be used during development.

  1. Server domain name

Enter the menu Settings——》Development Settings.
Make relevant configurations in server domain name. Among them, request legal domain name is the server domain name deployed by the Java service interface. If there are special needs such as uploading and downloading files, you can also configure the corresponding server. My applet uses the referenced web-view, so the business domain name is also configured. If you are in a test environment, you can use ngrok to map a domain name. However, it should be noted that the domain names of WeChat official accounts and mini programs must use the https protocol, so whether you generate it yourself or purchase it, you must install an SSL certificate.

For the operation of generating an SSL certificate, you can read my other article (also reprinted from others), you can click here

Association Settings

Settings——》Association Settings You can bind mini programs to public accounts and open platforms. Of course, this makes sense. For example, the official account supports jumping to the mini program in the menu, and the mini program can also jump to the official account. The most important reason is the usage mechanism of WeChat's unionid. If you want to obtain the user's unionid, you must bind the official account and mini program to the open platform. Here I want to talk about a problem I encountered, that is, if the user only uses your mini program and does not follow your official account, then the unionid is still not available.

Assist in development

If you need a team, you need to ensure that the members have development permissions. Enter the mini program homepage and click User Identity to add user members. Just give it the relevant permissions. Under normal circumstances, granting the following should be enough. Developer Tools, you can download and install it directly. You can directly read the official documentation to install developer tools here.

Project structure

Create a simple small program according to this link, and then you can take a look at the structure of the project. Specific details can be found in the documentation. Here are just a few points that I personally think are worth noting.

project.config.json file

    According to the document, this file saves some personalized settings, among which
  1. appid

    This attribute is the appid mentioned above. According to this thing, after the project is completed, the identity of the project, that is, which account it belongs to, will only be known when it is uploaded from the development tool to the mini program console. Of course, if this value is changed, the developer will not be able to open the project at all.

app.json file

    All pages must be written into the pages array, be careful not to write suffixes. Because the developer does not create a wxml file, js, json and wxss files will be automatically generated, so the elements in the pages array will find these four different types of files just based on the file names.
  1. The tabBar object is the defined navigation menu, and the click-oriented page needs to be defined in the list array.

app.js file


    This file has a globalData object, which defines the global variables of the mini program and can be used on any page. For example, you may need to define baseurl here, or public data such as user information. It should be noted that if you want to use the content defined by app.js, you first need to obtain the application instance const app = getApp() on the page you are using, and then you can use usage such as
  1. app.globleData.global variable name

    .

Related free learning recommendations:

WeChat Mini Program Development Tutorial

The above is the detailed content of Record of developing WeChat applet using java language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template