| wx.login({ | wx.login({ | ||||
| success: res => { | success: res => { | ||||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | // 发送 res.code 到后台换取 openId, sessionKey, unionId | ||||
| console.log(res) | |||||
| // console.log(res) | |||||
| wx.request({ | wx.request({ | ||||
| url: '', | url: '', | ||||
| data: { | data: { | ||||
| // 获取用户信息 | // 获取用户信息 | ||||
| wx.getSetting({ | wx.getSetting({ | ||||
| success: res => { | success: res => { | ||||
| console.log(res) | |||||
| // console.log(res) | |||||
| if (res.authSetting['scope.userInfo']) { | if (res.authSetting['scope.userInfo']) { | ||||
| // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | ||||
| wx.getUserInfo({ | wx.getUserInfo({ |
| data: { | data: { | ||||
| myTicketArrows: false, | myTicketArrows: false, | ||||
| historyTicketArrows: false, | historyTicketArrows: false, | ||||
| getUser:false, | |||||
| getUserArr:[], | |||||
| mydeg: -90, | mydeg: -90, | ||||
| historydeg: -90, | historydeg: -90, | ||||
| historyArr: [ | historyArr: [ | ||||
| wx.navigateTo({ | wx.navigateTo({ | ||||
| url: '../givePage/givePage', | url: '../givePage/givePage', | ||||
| }) | }) | ||||
| }, | |||||
| getUser:function(e){ | |||||
| console.log(e) | |||||
| this.setData({ | |||||
| getUserArr: e.detail.userInfo | |||||
| }) | |||||
| if (this.data.getUserArr){ | |||||
| this.setData({ | |||||
| getUser: true | |||||
| }) | |||||
| } | |||||
| console.log(this.data.getUserArr) | |||||
| } | } | ||||
| }) | }) |
| <image class="userCircle" src="../images/userCircle.png"></image> | <image class="userCircle" src="../images/userCircle.png"></image> | ||||
| <view class="userAll"> | <view class="userAll"> | ||||
| <view class="userHeader"> | <view class="userHeader"> | ||||
| <image src="../images/centerBg.png"></image> | |||||
| <image class="userImg" src="{{getUserArr.avatarUrl}}"></image> | |||||
| </view> | </view> | ||||
| <view class="userName">老门框用户</view> | |||||
| <view class="userPhone">12345678910</view> | |||||
| <button wx:if="{{!getUser}}" plain="true" size="mini" class="getUser" open-type="getUserInfo" bindgetuserinfo="getUser">登陆</button> | |||||
| <view class="userName">{{getUserArr.nickName}}</view> | |||||
| <view wx:if="{{getUser}}" class="userPhone">12345678910</view> | |||||
| </view> | </view> | ||||
| <view class="myTicketAll"> | <view class="myTicketAll"> |
| overflow: hidden; | overflow: hidden; | ||||
| border-radius: 50%; | border-radius: 50%; | ||||
| } | } | ||||
| .userImg{ | |||||
| width: 200rpx; | |||||
| height: 200rpx; | |||||
| } | |||||
| .userAll{ | .userAll{ | ||||
| text-align: center; | text-align: center; | ||||
| position:absolute; | position:absolute; | ||||
| font-size:40rpx; | font-size:40rpx; | ||||
| color:rgba(51,51,51,1); | color:rgba(51,51,51,1); | ||||
| font-weight:bold; | font-weight:bold; | ||||
| margin-top: 31rpx; | |||||
| /* margin-top: 31rpx; */ | |||||
| margin-bottom: 16rpx; | margin-bottom: 16rpx; | ||||
| } | } | ||||
| .userPhone{ | .userPhone{ | ||||
| .myTicketAll{ | .myTicketAll{ | ||||
| padding: 0 64rpx; | padding: 0 64rpx; | ||||
| /* margin-top: 80rpx; */ | |||||
| } | } | ||||
| .myTicketTop{ | .myTicketTop{ | ||||
| display: flex; | display: flex; | ||||
| font-family:SourceHanSansCN; | font-family:SourceHanSansCN; | ||||
| font-weight:bold; | font-weight:bold; | ||||
| color:rgba(235,97,0,1); | color:rgba(235,97,0,1); | ||||
| } | |||||
| .getUser{ | |||||
| } | } |