收藏
回答

checksession的完整流程是这样吗?

问题模块
API和组件
wx.checkSession({
                    success() {
                        console.log("checksession success")
                        wx.getStorage({
                            key: '3rd_session',
                            success: function (res) {
                                console.log(res)
                                var url = "url";
                                var data = res.data;
                                var method = "POST";
                                var header = { 'content-type': 'application/json' }
                                http.ajax(url, method, data, header)
                                    .then(function (res) {
                                        console.log(res)
 
                                    })
                                    .catch(function (err) {
 
                                    })
                            },
                        })
                    },
                    // 检查3rd_session失败
                    fail() {
                        // 登陆
                        wx.login({
                            success: res => {
                                // 发送 res.code 到后台换取 openId, sessionKey, unionId
                                console.log(res.code);

                                var url = "url";

                                var method = "POST"
                                var data = {
                                    code: res.code,
                                    nickName: nick,
                                    avatarUrl: avatar
                                };
                                var header = { 'content-type': 'application/json' };
                                http.ajax(url, method, data, header)
                                    .then(function (response) {
                                        console.log(response.data.token)
                                        wx.setStorage({
                                            key: '3rd_session',
                                            data: response.data.token,
                                        });
                                        
 
                                    })
                                    .catch(function (error) {
                                        console.log(error)
                                    })
 
                            }
                        })
                    }
                })

请问一下是否是这样的?




最后一次编辑于  2017-11-16  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏