liukangdong
2024-07-30 1a6905045d38bb50b0c6554c3440bdfd339c8d23
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() {
@@ -56,7 +69,6 @@
    })
    editMember({
      ...addr,
      imgurl: imgurl || '',
      name: name || '',
      nickname: nickname || '',
      phone: phone || '',
@@ -65,6 +77,7 @@
      longitude: longitude || '',
      district: district || '',
      housearea: housearea || '',
      imgurl: imgurl || null,
      housetype: houseType.val1 + '-' + houseType.val2 + '-' + houseType.val3 + '-' + houseType.val4 + '-' + houseType.val5
    }).then(res => {
      wx.setStorageSync('member', res.data)
@@ -72,6 +85,9 @@
        title: '保存成功',
        icon: 'none'
      })
      setTimeout(() => {
        wx.navigateBack()
      }, 500)
    })
  },
  initData() {
@@ -126,15 +142,10 @@
      areaName: names[2],
    }
    this.setData({ addr })
  },
  bindRegionChange(e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    const temp = e.detail.value
    this.setData({
      region: e.detail.value
    })
    console.log('addr', this.data.addr);
  },
  getBindchooseavatar(e) {
    console.log('e', e);
    var that = this
    if (e.detail.avatarUrl) {
      wx.uploadFile({
@@ -150,23 +161,38 @@
            imgurl: data.data.imgaddr,
            imgurlFull: data.data.url,
          })
          console.log('imgurlFull', this.data);
        }
      })
    }
  },
  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 })
    this.setData({ nickname: e.detail.value })
  },
  changeAddr() {
    // console.log('点击了');
    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);
      }
    })
  },