Practical development tutorial for gas station membership management applet 12

In the previous article, we introduced the development of member data sources. In this section, we introduce the member registration function.

First of all, let's sort out the business logic of member registration. If the user is logging in for the first time, he must have not submitted any information to our applet. Then we will show him a registration button on my page. If he has already registered, then the member information will be displayed normally, and he can use subsequent functions.

If we want to display according to conditions, we can control it through variables. We can define a global variable to control whether the currently logged-in person has registered.

In the application editor, click Variables to create a Boolean global variable isRegister

insert image description here
insert image description here
After we have the variable, we need to initialize it in the global lifecycle function. If the current user’s openid exists in the membership table, it means that it has been registered. If it does not exist, it means that it has not been registered.

First, we need to obtain the user's login information

var a=await app.utils.getWXContext(

Guess you like