In the development of uniCloud, how to use the mini-program WeChat login nui-id module

1. Let's take a look at the official explanation first

Follow the documentation first, if you encounter a problem, you will find a solution

1 HBuilderX 3.1.0+
2 The plug-in market imports the uni-id public module uni_modules version, the plug-in market uni-id
3 Modify the required parameters in config.json under the public module uni-id (please refer to the description of config.json below)
4 Upload uni - id module under cloudfunctions/
common
verify-codes is the verification code table. You can use db_init.json in the sample project to initialize, or you can select these table modules when creating a new table in the web console)

1. HBuilderX 3.1.0+

(uni_modules version) For better experience, it is recommended to upgrade HBuilderX to version 3.1 or above

2. uni-id plugin import

Click this link
. The plugin in the link can be imported directly into your own project, the uni-modules directory will be generated, and the corresponding public modules will also be generated.

3. Configuration of config.json

  • In the current version, cloudfunctions/common does not have a config.json configuration file. According to the official statement, uni-config-center cannot find the corresponding configuration.
  • Then manually configure it . Click here to download config.json for free
  • Remember to change the appid and appsecret in the file
    insert image description here
  • Put the modified file in the uni-id directory

insert image description here

4. Upload the uni-id module

Just select it directly, and cloudfunction uploads all.
Note: Every time you modify the cloud function, you need to upload it again. In addition, the console.log() in the cloud function is printed in the log of the cloud function.
insert image description here

5. Add dependencies

Right-click the cloud function you created, manage dependencies, and select uni-id to confirm

Cannot find module 'uni-id' The error in the cloud function is that this step is not performed

insert image description here

2. WeChat applet authorized login

If the user information cannot be obtained by writing the login authorization, add a link description

Guess you like

Origin blog.csdn.net/wakaka112233/article/details/115428144