Brief summary of WeChat applets (I)


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.


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 place an order, this url needs to pass a lot of information, such as the applet id, merchant good, amount, etc. (, 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.


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


More basic reference WeChat small program official website

1、Singapores Cyber Security Agency officially launched to tackle cyber security threats
2、Reinforcement learning to handle adaptive code stream playback Aiki AI recommendations boost viewing rate by 15
3、IndustryHow to reach the top 2 of the Kaggle competition Heres a feature exploration experience post
4、Introduction to the Dockerregistry working mechanism
5、Types of arguments accepted by switch primary

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送