zoukankan      html  css  js  c++  java
  • wafer2的keng

    一、之前用wafer2开发的小程序,今天突然Error: 用户未登录过,请先使用 login() 登录?

    答:改用qcloud.login, 替换掉qcloud.loginWithCode (小程序代码)

    也有可能重新上传一次测试代码(勾上部署后自动安装依赖)就解决了。

    参考链接:https://blog.csdn.net/kfgauss/article/details/91046421

    二、小程序Cannot set property 'userInfo' of undefined

    //this.globalData.userInfo = res.userInfo;
    var app = getApp();
    app.globalData.userInfo = res.userInfo;

    Cannot set property 'userInfo' of undefined
    不要使用this

    参考链接:https://blog.51cto.com/lailai/2068184

    三、wafer2二次登录时,报:用户未登录过,请先使用 login() 登录

    request fail Error: 用户未登录过,请先使用 login() 登录
    at n.success (login.js:141)
    at Object.success (WAService.js:4)
    at s. (WAService.js:12)
    at s.emit (WAService.js:6)
    at Function. (WAService.js:12)
    at WAService.js:6
    at a (appservice?t=1528991705772:1048)
    at b. (appservice?t=1528991705772:1048)
    at b.emit (appservice?t=1528991705772:1048)
    at callback (appservice?t=1528991705772:1048)
    index.js:128 request complete

    Node.js SDK 更新了吗,需要配合 1.4.x 版本以上的 SDK

    参考链接:

    1. https://github.com/tencentyun/wafer2-quickstart-nodejs/issues/14

    2. https://github.com/tencentyun/wafer2-startup/issues/143

    四、Unexpected token o in JSON at position 1 报错原因

    解决方案就是去掉JSON.parse()这一层转换,因为你需要转换的数据本来就是一个json对象了,不需要在转换了。

    (我不知道,我重启就好了

    参考链接:

    1. https://blog.csdn.net/wxl1555/article/details/79184076

    2. https://blog.csdn.net/qq_41999617/article/details/83511002

    五、登陆失败,请允许获取您的公开信息

    根据微信公告,wx.getUserInfo 接口将不再弹窗,而改用 <button>。目前 Wafer2 的 Demo 已经切换,以下主要对 Wafer2 SDK 的实现进行说明。

    Wafer2 SDK 的授权登录模式改为:前端 <button> 弹出登录框,用户点击授权之后,SDK 调用 wx.login 和 wx.getUserInfo 获取用户信息,并解密,存储数据库。

    注意 2.0 版本以上的 Client SDK 需配合 1.4.x 以上版本的 Node.js SDK 或者 2.2.x 以上版本的 PHP SDK。

    // wxml
    <button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="doLogin">获取用户信息</button>
    
    // js
    doLogin: function () {
        const session = qcloud.Session.get()
    
        if (session) {
            // 第二次登录
            // 或者本地已经有登录态
            // 可使用本函数更新登录态
            qcloud.loginWithCode({
                success: res => {
                    this.setData({ userInfo: res, logged: true })
                    util.showSuccess('登录成功')
                },
                fail: err => {
                    console.error(err)
                    util.showModel('登录错误', err.message)
                }
            })
        } else {
            // 首次登录
            qcloud.login({
                success: res => {
                    this.setData({ userInfo: res, logged: true })
                    util.showSuccess('登录成功')
                },
                fail: err => {
                    console.error(err)
                    util.showModel('登录错误', err.message)
                }
            })
        }
    }

    参考链接:

    1. https://github.com/tencentyun/wafer2-client-sdk#%E7%99%BB%E5%BD%95

    2. https://github.com/tencentyun/wafer2-client-sdk/issues/28

    3. https://github.com/tencentyun/wafer2-quickstart/issues/10

    六、发起登录请求,返回Error: 响应错误,{"code":-1,"error":"ERR_REQUEST_PARAM"}

    你可以通过以下两种方式修复该问题:

    1. 关闭腾讯云代理登录,使用微信小程序 AppID 和 AppSecret 登录:

    修改 server/config.js 中的 useQcloudLogin 为 false,并填写上 appId 和 appSecret 字段(分别为微信小程序的 AppID 和 AppSecret),重新部署代码即可。

    2. 手动填写腾讯云云 API 密钥:

    登录腾讯云云 API 密钥控制台申请云 API 密钥,并在 server/config.js 的 CONF 中添加如下三个字段:

    qcloudAppId: '你的腾讯云 AppID',
    qcloudSecretId: '你的腾讯云 SecretId',
    qcloudSecretKey: '你的腾讯云 SecretKey',

    重新部署代码即可生效。

    参考链接:https://github.com/tencentyun/wafer2-quickstart/issues/13

  • 相关阅读:
    Path类
    C#集合
    阿里巴巴2013年实习生笔试题B
    阿里巴巴2013年实习生笔试题A
    腾讯2014年校园招聘笔试试题
    腾讯技术类校园招聘笔试试题
    腾讯2013年实习生笔试题
    腾讯2012年实习生笔试题
    hdu1505
    hdu1506
  • 原文地址:https://www.cnblogs.com/lfri/p/11909683.html
Copyright © 2011-2022 走看看