小程序登录界面到底怎么写,把我的代码直接拿走吧(附源码)
⼩程序登录界⾯到底怎么写,把我的代码直接拿⾛吧(附
源码)
01 js
Page({
data:{
userInfo:''
},
幼儿园安全预案onLoad(){
let StorageSync('user')
console.log('进⼊⼩程序的页⾯获取缓存',user)
this.setData({
userInfo:user
})胡列娜最后怎么死的
},
//授权登录
login(){
desc: '⽤于完善会员资料',//声明获取⽤户个⼈信息后的⽤途,后续会展⽰在弹窗中
success:res =>{
let user = res.userInfo
//把⽤户信息缓存到本地
wx.setStorageSync('user', user)
三本院校
console.log("⽤户信息",user)
this.setData({
userInfo:user
})
},
fail: res=>{
console.log('授权失败',res)
预祝2020高考顺利的话
}
})
},
//退出登录
loginOut(){
this.setData({
userInfo:''
})
wx.setStorageSync('user', null)
}
})
02 xwml
<button wx:if="{{!userInfo}}" bindtap="login">授权登录</button><!--授权登录-->
<view wx:else class="root">
<image class="touxiang" src="{{userInfo.avatarUrl}}"></image>
<text class="nicheng">{{userInfo.nickName}}</text>
<button  bindtap="loginOut">退出登录</button><!--退出登录-->
</view>
03 wxss
.root{
display: flex;
flex-direction: column;  align-items: center;选调生
经济学考研}
.touxiang{
width: 200rpx;
height: 200rpx;
border-radius: 50%;  margin-top: 30rpx;
margin-bottom: 10rpx; }

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。