Let me first describe this problem in detail:
1. WeChat Mini Programs needs to first call Mini Program"s network request interface (if the network is not good, remind the user that the network status is not good), and request user authorization (pop-up authorization window);
2. According to the results of user authorization, it is divided into the following two cases:
a.;
b.3;
3. After the user is authorized, send a request for user information:
a.;
b.4;
4. According to the openid, send a request to the backend (if the network is not good, you should still remind the user that the network status is not good), and check whether the user is bound to a mobile phone:
a.
b.
as you can see, every network request in this process needs to take into account
1. If there is a problem with the network status, if you can"t connect to the network, you should prompt the user
2. When each request is initiated, it has to wait for the actual result of the previous request to respond: whether to jump to the page or initiate the request
how can this requirement be written to make it maintainable? Would you please give me a tip, provide an idea, or a general code flow? I have thought about using promise, but this series of requests, each reject will be catch, that how to divide ah, there is no good idea, but also ask you to help, learn one.