List of applet applications

Small program Z basic version

Address of self – use scaffold

Leave a message if you have any questions

authorization

The authorization of applets is generally judged in onLauch, but only synchronous operations are supported. If there are asynchronous operations, sequence problems will be caused, which I have encountered at present

  1. Set a global variable and add a root page. For all the pages forwarded in, enter the root. WXML page first, and then call the login interface to determine whether they have been registered on the platform. SetInterval is used to wait

  2. The second method, which is the most brutal, is to judge the cache directly and go to the login registration page if there is no userId, and is suitable for many template applets

  3. Personally, I prefer to modify the Page object of the Page, initialize it before the onload of the Page, get the route and parameters of the Page in the app.js Page and store them in Seeion. After registering authorization, perform corresponding operations. The convenience of this operation lies in that many redundant codes can be optimized, such as page burying point, login detection, specific page supporting tourist mode, specific page need to call corresponding wechat API, etc. When I first started writing small programs, I always looked forward to this way of writing, because I saw that Vue had similar operations, and small programs did not, so I longed for a long time.

  4. Change the check_login_page array of init.js to copy the route to the page that needs to be checked for login

const check_login_page = ["pages/sharePage/sharePage"."pages/index/index"];

Copy the code

miniappPromise

  1. I won’t bother writing promisification of common apis

utils

  1. Storage of common tool classes

component

  1. For common components of the package, such as Canvas IMG and video upload, popup,step and so on

style

  1. For the project style specification, including margin,padding,font-size font-color background, etc

api

  1. Encapsulation of Ajax

Final conclusion

Small program I think there is no place too difficult, nearly half a year, including optimization and some code architecture problems have been solved, such as a long list and some dog blood API operation, my heart also have the bottom, now do small program basic also can not get too big promotion. Ready to dig deeper into Vue, although I enjoy vuE-Admin’s mature projects on Github, I still want to build my own to deepen my understanding