How does the WeChat applet determine whether it is the screen, return, or Home button operation?

Our company is working on an applet where the client and the applet control each other, both of which can control whether the user exits, because the first time the Android phone scans the code, the onload method will be triggered, but the second time the code is scanned into the applet, it will trigger the onload method. Going directly to the last exit interface will only trigger the onShow method. Now the requirement is to request the login interface only when the code is scanned in, and the bright screen operation does not request the interface, but the two operations cannot be distinguished at present. Point, it's a headache now.

I thought about identifying it by monitoring the return key before, but I didn't find a way to monitor the return key, and the Home key operation couldn't be identified (both the Home key and the return key can be considered as the need to scan the code to get the value in the option of the onload method. One type, the interest screen is another type);

later I thought of the getCurrentPages() method to judge his length, and the result was 1 in Android;

but later I stumbled upon a way, which is to adjust the onHide method in app.js For an interface, assign a value of 88 to the global variable mid in complete, and assign it to 55 in success. As a result, the mid value obtained in the background of the screen is 55, and the returned value is 88 (strangely, this interface does not have a print request in the background. It feels like it's not adjusted, but when I enter the applet again, the mid has changed), but I can't explain this situation clearly, so I don't dare to judge it. This is the only sign I can judge so far, but the boss thinks that I don't care for the obvious reason. . . (Mainly, the method of scanning the code for the second time on the Android phone is the same as that of opening the screen, so it is not easy to judge and handle)

A: Click the hidden stamp to close the applet (supported from the public library version 1.1.0): When the user scans a Scan, share and other entrances (scenario values ​​1007, 1008, 1011, 1025) enter the applet, and exit without the top applet, the applet will be destroyed.

Wechat had this problem before 6.5.7, but in version 6.5.7, no matter which page you exited from last time, the applet will only enter the specified page every time you scan the code to enter, and get the value in onload, so that you can distinguish the scan code Enter or keep the screen still or search to enter.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326200929&siteId=291194637
Recommended