odc.xiaohui
2023-03-20 190f42003ed5f96f285e8ff9517dbfbe70ef0ba5
用户登录
1个文件已修改
78 ■■■■■ 已修改文件
miniprogram/pages/index/index.ts 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
miniprogram/pages/index/index.ts
@@ -72,47 +72,59 @@
            success: (res) => {
                console.log("code", res.code)
                wx.request({
                    url: app.globalData.url+"/wx/login",
                    url:app.globalData.url+"/wx/checkIdentity",
                    data: {
                        "code": res.code,
                        "phoneNumberCode": e.detail.code
                    },
                    method: "GET",
                    success: (res) => {
                    success:(res)=>{
                        console.log(res);
                        //  如果用户已经注册直接进入  未注册进入宣传   role == 0用户  1警员
                        wx.setStorageSync('token', res.data.data.token)
                        wx.setStorageSync('role', res.data.data.role)
                        wx.setStorageSync('id', res.data.data.id)
                        wx.setStorageSync('card',res.data.data.time)
                        console.log(res.data.data.id)
                        if (res.data.data.role == 0) {
                            var info=wx.getStorageSync('card')
                            if (info) {
                                wx.redirectTo(
                                    {
                                        url: '../user/index'
                                    }
                                )
                            } else {
                                wx.redirectTo(
                                    {
                                          url: '../user/pubulicty/index'
                                        // url: '../user/loginInfo/index'
                                    }
                                )
                            }
                        }
                        if (res.data.data.role == 1) {
                            wx.redirectTo(
                                {
                                    url: '../manager/index'
                                }
                            )
                        }
                    }
                })
                // wx.request({
                //     url: app.globalData.url+"/wx/login",
                //     data: {
                //         "code": res.code,
                //         "phoneNumberCode": e.detail.code
                //     },
                //     method: "GET",
                //     success: (res) => {
                //         console.log(res);
                //         //  如果用户已经注册直接进入  未注册进入宣传   role == 0用户  1警员
                //         wx.setStorageSync('token', res.data.data.token)
                //         wx.setStorageSync('role', res.data.data.role)
                //         wx.setStorageSync('id', res.data.data.id)
                //         wx.setStorageSync('card',res.data.data.time)
                //         console.log(res.data.data.id)
                //         if (res.data.data.role == 0) {
                //             var info=wx.getStorageSync('card')
                //             if (info) {
                //                 wx.redirectTo(
                //                     {
                //                         url: '../user/index'
                //                     }
                //                 )
                //             } else {
                //                 wx.redirectTo(
                //                     {
                //                           url: '../user/pubulicty/index'
                //                         // url: '../user/loginInfo/index'
                //                     }
                //                 )
                //             }
                //         }
                //         if (res.data.data.role == 1) {
                //             wx.redirectTo(
                //                 {
                //                     url: '../manager/index'
                //                 }
                //             )
                //         }
                //     }
                // })
            }
        })
    },