uniCloud云开发----5、uni-id-pages的使用

前言

在开发过程中,会发现微信小程序的登录方式不断地更新和变化,这样导致我们在开发过程中非常的困难,uni-id-pages直接集成的页面和数据库来实现就很方便了

1、下载uni-id-pages插件

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
安装完成后如果报错重启可以解决

2、查看登录页面

在这里插入图片描述
http://localhost:8080/#/uni_modules/uni-id-pages/pages/login/login-withpwd
在这里插入图片描述
说明安装成功

3、配置项

云端配置config.json

在这里插入图片描述
创建config.json文件
在这里插入图片描述

将文档中的json代码粘过来并删除注释

{
    
    
  "passwordSecret": [
    {
    
    
      "type": "hmac-sha256",
      "version": 1
    }
  ], 
  "passwordStrength": "medium", 
  "tokenSecret": "", 
  "requestAuthSecret": "", 
  "tokenExpiresIn": 7200, 
  "tokenExpiresThreshold": 3600, 
  "passwordErrorLimit": 6, 
  "passwordErrorRetryTime": 3600, 
  "autoSetInviteCode": false, 
  "forceInviteCode": false, 
  "app": {
    
     
    "tokenExpiresIn": 2592000,
    "tokenExpiresThreshold": 864000,
    "oauth": {
    
    
      "weixin": {
    
    
        "appid": "",
        "appsecret": ""
      },
      "qq": {
    
    
        "appid": "",
        "appsecret": ""
      },
      "apple": {
    
     
        "bundleId": ""
      }
    }
  },
  "web": {
    
     
    "tokenExpiresIn": 7200,
    "tokenExpiresThreshold": 3600,
    "oauth": {
    
    
      "weixin-h5": {
    
     
        "appid": "",
        "appsecret": ""
      },
      "weixin-web": {
    
     
        "appid": "",
        "appsecret": ""
      }
    }
  },
  "mp-weixin": {
    
    
    "tokenExpiresIn": 259200,
    "tokenExpiresThreshold": 86400,
    "oauth": {
    
    
      "weixin": {
    
    
        "appid": "",
        "appsecret": ""
      }
    }
  },
  "mp-qq": {
    
    
    "tokenExpiresIn": 259200,
    "tokenExpiresThreshold": 86400,
    "oauth": {
    
    
      "qq": {
    
    
        "appid": "",
        "appsecret": ""
      }
    }
  },
  "mp-alipay": {
    
    
    "tokenExpiresIn": 259200,
    "tokenExpiresThreshold": 86400,
    "oauth": {
    
    
      
      "alipay": {
    
    
        "appid": "",
        "privateKey": "", 
        "keyType": "PKCS8" 
      }
    }
  },
  "service": {
    
    
    "sms": {
    
    
      "name": "", 
      "codeExpiresIn": 180, 
      "smsKey": "", 
      "smsSecret": "", 
      "scene": {
    
    
        "bind-mobile-by-sms": {
    
     
          "templateId": "", 
          "codeExpiresIn": 240 
        }
      }
    },
    "univerify": {
    
    
      "appid": "", 
      "apiKey": "", 
      "apiSecret": ""
    }
  }
}

在这里插入图片描述
这两项必填然后注册登录在浏览器缓存中可以看到用户数据
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_50207524/article/details/128511174
今日推荐