c5454
c5454
  • 发布:2022-09-01 10:20
  • 更新:2024-03-14 12:51
  • 阅读:324

【报Bug】一键登录连接本地云函数,和连接云端云函数测试没问题,打包后无法一键登录

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win 11

HBuilderX类型: Alpha

HBuilderX版本号: 3.5.5

手机系统: Android

手机系统版本号: Android 12

手机厂商: 小米

手机机型: 红米 k50

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.login({
provider:'univerify',
univerifyStyle:{
"fullScreen":false,
"backgroundColor":"#ffffff",
"phoneNum":{
"color":"#2281F5"
},
"authButton":{
"normalColor":"#3479f5",
"highlightColor":"#2861c5",
"disabledColor":"#73aaf5",
"textColor":"#ffffff",
"title":"本机号码一键登录"
},
"otherLoginButton": {
"visible": false, // 是否显示其他登录按钮,默认值:true
}
},
success:(result)=> {
uniCloud.callFunction({
name:'univerify',
data:{
access_token:result.authResult.access_token,
openid:result.authResult.openid
},
success:(callRes)=> {
console.log(callRes);
if(callRes.result.code == 0){
let phone = callRes.result.phoneNumber; //手机号码

                                            let url = '/api/moblie.Login/getappnumber';  
                                            let param = {  
                                                _phoneNumber:phone  
                                            };  
                                            that.$mHttp.HttpRequst(url,param, null, 'POST',function(res){  
                                                if(typeof(res)=='string'){  
                                                    res = JSON.parse( res );  
                                                }  
                                                var myStatus = res.status;  
                                                if(myStatus == 200){  
                                                    that.$refs.popupData.componentName="success";  
                                                    that.$refs.popupData.title="登录成功";  
                                                    that.$refs.popupData.messages=res.msg;  
                                                    that.$refs.popupData.toggleShow();//第一次显示  

                                                    //插入cookie  
                                                    let user = {  
                                                        id:res.data.id,  
                                                        admin_id:res.data.admin_id,  
                                                        usename:res.data.account,  
                                                        token:res.data.token,  
                                                        examine:res.data.examine,  
                                                        pass_code:res.data.pass_code,  
                                                        status:res.data.status,  
                                                        nickname:res.data.account,  
                                                        user:res.data.user  
                                                    }  

                                                    that.$mStore.commit('login',user);  

                                                    _Cache.remove('activity');  
                                                    _Cache.remove('notice');  
                                                    _Cache.remove('problem');  

                                                    //#ifdef APP-PLUS  
                                                    that.pushCi(res.data.id);  
                                                    //#endif  

                                                    setTimeout(function(){  
                                                        uni.switchTab({  
                                                            url:'/pages/uCenter/index'  
                                                        })  
                                                    },2500);  

                                                }else if(myStatus == 10002){  
                                                    //欠费之中  
                                                    that.$refs.popupData.componentName="error";  
                                                    that.$refs.popupData.title="登录失败";  
                                                    that.$refs.popupData.messages=res.msg;  
                                                    that.$refs.popupData.toggleShow();//第一次显示  

                                                    //插入cookie  
                                                    let user = {  
                                                        admin_id:res.data.admin_id,  
                                                        usename:res.data.account,  
                                                        examine:res.data.examine,  
                                                        token:res.data.token,  
                                                        pass_code:res.data.pass_code,  
                                                        nickname:res.data.account  
                                                    }  

                                                    that.$mStore.commit('login',user);  

                                                    setTimeout(function(){  
                                                        uni.navigateTo({  
                                                            url:'/pagesA/payMembershipFee/index'  
                                                        })  
                                                    },3000);  

                                                }else if(myStatus == 10003){  
                                                    //审核之中..  
                                                    that.$refs.popupData.componentName="error";  
                                                    that.$refs.popupData.title="登录成功";  
                                                    that.$refs.popupData.messages=res.msg;  
                                                    that.$refs.popupData.toggleShow();//第一次显示  

                                                    //插入cookie  
                                                    let user = {  
                                                        id:res.data.id,  
                                                        admin_id:res.data.admin_id,  
                                                        usename:res.data.account,  
                                                        examine:res.data.examine,  
                                                        token:res.data.token,  
                                                        pass_code:res.data.pass_code,  
                                                        nickname:res.data.account,  
                                                        use:'ss',  
                                                        status:0  
                                                    }  
                                                    //console.log(user.id);  
                                                    //console.log("AA");  

                                                    that.$mStore.commit('login',user);  
                                                    //console.log("BB");  
                                                    setTimeout(function(){  
                                                        uni.switchTab({  
                                                            url:'/pages/uCenter/index'  
                                                        })  
                                                    },2000);  

                                                }else{  
                                                    that.$refs.popupData.componentName="error";  
                                                    that.$refs.popupData.title="登录失败";  
                                                    that.$refs.popupData.messages="一键登录失败,请用手机登录...";  
                                                    that.$refs.popupData.toggleShow();  

                                                    setTimeout(function(){  
                                                        uni.navigateTo({  
                                                            url:'/pages/public/moblie'  
                                                        });  
                                                    },2000);  
                                                }  
                                            });  

                                        }  
                                    },  
                                    fail:(callErr)=>{  
                                        console.log(callErr);  
                                        that.$refs.popupData.componentName="error";  
                                        that.$refs.popupData.title="登录失败";  
                                        that.$refs.popupData.messages="一键登录失败,请转手机登录...";  
                                        that.$refs.popupData.toggleShow();  

                                        // setTimeout(function(){  
                                        //  uni.navigateTo({  
                                        //      url:'/pages/public/moblie'  
                                        //  });  
                                        // },2000);  

                                        return;  
                                        //console.log('调用云函数失败'+ callErr);  

                                    },  
                                    complete() {  
                                        uni.closeAuthView();  
                                    }  
                                })  
                            },  
                            fail:(e)=> {  
                                console.log(e);  
                                if(e.code==30006){  
                                that.$refs.popupData.componentName="error";  
                                that.$refs.popupData.title="一键登录失败";  
                                that.$refs.popupData.messages="请开启数据流量,重试!或使用其他方式登录...";  
                                that.$refs.popupData.toggleShow();  
                                uni.closeAuthView();  

                                }  
                            }  
                        })

操作步骤:

上传云函数,重启打包还是一样,打包后无法一键登录,uniCloud.callFunction这一步失败

预期结果:

本地调试没问题,打包后有问题,本地也使用了连接云函数调试没有问题,就打包后运行云函数失败

实际结果:

本地调试没问题,打包后有问题,本地也使用了连接云函数调试没有问题,就打包后运行云函数失败

bug描述:

一键登录连接本地云函数,和连接云端云函数测试没问题,打包后无法一键登录

2022-09-01 10:20 负责人:无 分享
已邀请:
c5454

c5454 (作者) - uni-app 使用者

[HBuilder] 10:09:34.490 类型: Android自有证书(小米应用商店) 下载地址: https://ide.dcloud.net.cn/build/download/dfc1b650-2999-11ed-bd86-ab87ecd66f62

  • DCloud_uniCloud_WYQ

    卸载uni-app vue2编译插件,重新安装一下,然后再打包试试

    2022-09-01 11:02

c5454

c5454 (作者) - uni-app 使用者

有时候登录成功后还跳出一下界面,这又是什么情况

c5454

c5454 (作者) - uni-app 使用者

重新安装就可以了

1***@qq.com

1***@qq.com - 于小c

连接云函数调试有问题,怎么解决的

要回复问题请先登录注册