123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- const app = getApp()
- Page({
- data: {
- spinShow: false,
- userInfo:{},
- info: {}
- },
- onLoad: function(options) {
- app.checkLogin( this.loadUserInfo )
- },
- loadUserInfo( userInfo ) {
- this.setData( {userInfo} )
- },
- userInfoHandler(e){
- console.log( e.detail.userInfo )
- let param = {
- "displayName": e.detail.userInfo.nickName,
- "avatarUrl":e.detail.userInfo.avatarUrl,
- }
- app.formPost('User.updateInfo', param ).then(res => {
- if( res.code == 200){
- this.setData( {userInfo: res.data})
- app.setUserInfo( res.data )
- }
- })
- },
- getPhoneNumber (e) {
- this.bindPhone(e)
- },
- bindPhone(e){
- if( e.detail.errMsg =="getPhoneNumber:ok"){
- let param = {
- "iv": e.detail.iv,
- "encryptedData":e.detail.encryptedData,
- }
- app.formPost( "User.bindphone", param).then( (res)=>{
- if( res.code == 200){
- this.setData( {userInfo: res.data})
- app.setUserInfo( res.data )
- }
- })
- }else{
- app.message("绑定失败", 'error')
- }
- },
- logOut() {
- wx.setStorageSync('userId', '')
- wx.setStorageSync('token', '')
- app.reLogin( this.loadUserInfo )
- }
- })
|