Brief summary of WeChat applets (I)
wx.login
Get a request code via wx.login
Request a third-party server login url, the requested url needs to have a request code
The third-party server accesses https://api.weixin.qq.comsomewhere down the lineurl getsession_key harmonyopenid based on the obtained request code, and the applet's AppID and SECRET combination. session_key is the key for valence signing of the data, and openid is a unique identifier for the current user.
( selectable) The third-party server needs to generate its ownsession_id( perhaps othertoken etc.), And use thissession_id act askey,session_key harmonyopenid act asvalue, Save to a third-party serversession Or...redis in, It's best to set a relatively short expiry time, Because most of the cases just use microsoft data, Long-term use is not required。
(Optional) Save the session_id or token returned by the third party to local, and bring this parameter when needed, so that the third party server can get the session_key and openid according to this parameter.
wx.checkSession
The request code is usually checked for expiration before each use, and if it expires, you need to call wx.login again to get a new request code.
Obtaining user information
Through wx.getUserInfo can get the user's information, by the time there is part of the sensitive data and can not see, this time it is necessary, we get the encrypted data as a request sent to a third-party server, the third-party server using session_key decryption, you can get part of the sensitive data, the user according to their own needs for processing.
microsoft payment
Steps of WeChat payment
place a unified order
Data signing by the 5 fields appid, nonceStr, package, signType and timeStamp
Initiate a payment request using the wx.requestPayment method
The basic process is the WeChat applet using wx.request method call, the third-party server url, this url in the server side through https://api.mch.weixin.qq.com/pay/unifiedorder place an order, this url needs to pass a lot of information, such as the applet id, merchant good, amount, etc. (https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1), if the order is successful, will return package, and then the package will be returned to the applet, and finally call wx.requestPayment to initiate a payment request, if the initiation of the payment request is successful, it will directly open the payment function of WeChat, asking for the payment password, if the password is correct, will pay successfully.
disposition
Horizontal alignment display:flex ,flex-direction:row horizontal fold line need to add flex-wrap:wrap,
Vertical alignment display:flex,flex-direction:column vertical fold need to add flex-wrap:wrap
Horizontal alignment alignment using justify-content:(many properties, configure yourself as appropriate, e.g. flex-start)
Vertical alignment alignment uses the align-items property (there are many properties, configure them yourself as appropriate, e.g. flex-end)
Horizontal equal spacing set justify-content:space-between
Horizontal equidistant alignment with margins justify-content:space-around
other
More basic reference WeChat small program official website