jiangping
2024-07-30 b022834cf81ea67a6f28d31cc057d494ac6dc8ed
wechat_jiaxuan/pages/userinfo/index.js
@@ -2,7 +2,8 @@
  uploadUrl,
  editMember,
  getMemberInfo,
  getArea
  getArea,
  getWxMiniPhone
} from '../../api/index'
Page({
@@ -33,7 +34,19 @@
      val5: '',
    }
  },
  onShow() {
  onLoad() {
    wx.getUserInfo({
      success: function(res) {
        console.log('res', res);
        var userInfo = res.userInfo
        var nickName = userInfo.nickName
        var avatarUrl = userInfo.avatarUrl
        var gender = userInfo.gender //性别 0:未知、1:男、2:女
        var province = userInfo.province
        var city = userInfo.city
        var country = userInfo.country
      }
    })
    this.initData()
  },
  onSubmit() {
@@ -67,10 +80,14 @@
      housearea: housearea || '',
      housetype: houseType.val1 + '-' + houseType.val2 + '-' + houseType.val3 + '-' + houseType.val4 + '-' + houseType.val5
    }).then(res => {
      wx.setStorageSync('member', res.data)
      wx.showToast({
        title: '保存成功',
        icon: 'none'
      })
      setTimeout(() => {
        wx.navigateBack()
      }, 500)
    })
  },
  initData() {
@@ -153,6 +170,18 @@
      })
    }
  },
  getPhoneNumber (e) {
    const data = { ...e.detail }
    getWxMiniPhone({
      encryptedData: data.encryptedData,
      iv: data.iv,
      sessionKey: wx.getStorageSync('sessionKey') || data.iv,
    }).then(res => {
      this.setData({
        phone: res.data
      })
    })
  },
  getNickName(e) {
    this.setData({ nikname: e.detail.value })
  },
@@ -161,11 +190,13 @@
    wx.chooseLocation({
      type: 'wgs84',
      success: (res) => {
        console.log('res', res);
        this.setData({
          longitude: res.longitude,
          latitude: res.latitude,
          address: res.address,
        })
        console.log('address', this.data.address);
      }
    })
  },