uniapp的uni.login实现登录功能~

1、uni.login实现登录功能

// 保存
onSubmit() {
// 这里做一次赋值是为了解决this点不到data中的数据
var that = this
// 登录
uni.login({
provider: 'weixin', //使用微信登录
onlyAuthorize: true, // 微信登录仅请求授权认证
success: function(e) {
	console.log(e);
	const {code} = e
    console.log(that.userName, that.avatarUrl)
	// 判断头像以及昵称不为空 再上传
	if (that.userName && that.avatarUrl) {
		getLoging(
			that.userName, that.avatarUrl
		).then(res => {
			console.log('res', res)
		})
		console.log("登录成功")
        uni.switchTab({
		    url: '/pages/mainfist/mainfist'
	    });
	} else {
		uni.showToast({
			icon: 'none',
			title: '请上传头像并填写昵称'
		})
		return false;
	}
},
fail: function(err) {
	console.log('err', err);
    }
 })
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值