{"action":"opened","issue":{"url":"https://api.github.com/repos/binsee/padchat-sdk/issues/16","repository_url":"https://api.github.com/repos/binsee/padchat-sdk","labels_url":"https://api.github.com/repos/binsee/padchat-sdk/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/binsee/padchat-sdk/issues/16/comments","events_url":"https://api.github.com/repos/binsee/padchat-sdk/issues/16/events","html_url":"https://github.com/binsee/padchat-sdk/issues/16","id":320269524,"number":16,"title":"使用wxdata+token登录失败","user":{"login":"keithchi","id":38396286,"avatar_url":"https://avatars2.githubusercontent.com/u/38396286?v=4","gravatar_id":"","url":"https://api.github.com/users/keithchi","html_url":"https://github.com/keithchi","followers_url":"https://api.github.com/users/keithchi/followers","following_url":"https://api.github.com/users/keithchi/following{/other_user}","gists_url":"https://api.github.com/users/keithchi/gists{/gist_id}","starred_url":"https://api.github.com/users/keithchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithchi/subscriptions","organizations_url":"https://api.github.com/users/keithchi/orgs","repos_url":"https://api.github.com/users/keithchi/repos","events_url":"https://api.github.com/users/keithchi/events{/privacy}","received_events_url":"https://api.github.com/users/keithchi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-04T13:11:40Z","updated_at":"2018-05-04T13:11:40Z","closed_at":null,"author_association":"NONE","body":"代码基本就是你写的那个demo，我第一次使用的时候没有问题，大概几个小时后退出再登录的时候出现了这个问题，然后我试着换新的token，但是还是失败，之后就再也没有成功过。\r\n\r\nasync function run_wechat(){\r\n    wx\r\n    .on('open', async () => {\r\n        let login_wxdata = await dp.query(\"select value from back_control where name='wxdata'\");\r\n        login_wxdata = login_wxdata[0]['value'];\r\n        let login_token = await dp.query(\"select value from back_control where name='token'\");\r\n        login_token = login_token[0]['value'];\r\n        let ret;\r\n        ret = await wx.init();\r\n        if (!ret.success) {\r\n            console.error('初始化失败! ret:', ret);\r\n            return\r\n        }\r\n        console.log('初始化成功! ret:', ret);\r\n        // ret = await wx.login();\r\n        ret = await wx.login('request',{wxData:login_wxdata,token:login_token});\r\n        if (!ret.success) {\r\n            console.error('请求登录失败! ret:', ret);\r\n            return\r\n        }\r\n        console.log('请求登录成功! ret:', ret);\r\n    })\r\n    .on('qrcode', data => {\r\n        if (data.url) {\r\n            console.log('登陆二维码url: %s ,请扫码登陆：', data.url);\r\n            qrcode.generate(data.url);\r\n            return\r\n        } else if (data.qrCode) {\r\n            console.log('登陆二维码图片数据，请输出到文件扫码。');\r\n            return\r\n        }\r\n        console.error('没有发现二维码数据!')\r\n    })\r\n    .on('scan', data => {\r\n        switch (data.status) {\r\n            case 0:\r\n                console.log('等待扫码...', data);\r\n                break;\r\n            case 1:\r\n                console.log('已扫码，请在手机端确认登陆...', data);\r\n                break;\r\n            case 2:\r\n                switch (data.subStatus) {\r\n                    case 0:\r\n                        console.log('扫码成功！登陆成功！', data);\r\n                        break;\r\n                    case 1:\r\n                        console.log('扫码成功！登陆失败！', data);\r\n                        break;\r\n                    default:\r\n                        console.log('扫码成功！未知状态码！', data);\r\n                        break;\r\n                }\r\n                break;\r\n            case 3:\r\n                console.log('二维码已过期', data);\r\n                break;\r\n            case 4:\r\n                console.log('手机端已取消登陆！', data);\r\n                break;\r\n            default:\r\n                break;\r\n        }\r\n    })\r\n    .on('login', async() => {\r\n        console.log('登陆成功!');\r\n        let get_token = await wx.getLoginToken();\r\n        let sql = \"update back_control set value=? where name = 'token'\";\r\n        await dp.query(sql,get_token.data.token)\r\n    })\r\n    .on('loaded', () => {\r\n        console.log('载入通讯录完成!')\r\n    })\r\n    .on('push', async(data)=> {\r\n        room_id =  await search_room();\r\n        if(data.mType===1 && data.fromUser === room_id) {\r\n    });\r\n\r\n }"}}
{"actor":{"display_login":"keithchi"}}