From d41f1f707dc643b726a42b9d2a63b186dd9e4f28 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 06 八月 2024 16:12:38 +0800
Subject: [PATCH] ll

---
 wechat_jiaxuan/pages/userinfo/index.js |   90 +++++++++++++++++++++++++++++++++------------
 1 files changed, 66 insertions(+), 24 deletions(-)

diff --git a/wechat_jiaxuan/pages/userinfo/index.js b/wechat_jiaxuan/pages/userinfo/index.js
index fbe9364..34e0e04 100644
--- a/wechat_jiaxuan/pages/userinfo/index.js
+++ b/wechat_jiaxuan/pages/userinfo/index.js
@@ -2,7 +2,8 @@
   uploadUrl,
   editMember,
   getMemberInfo,
-  getArea
+  getArea,
+  getWxMiniPhone
 } from '../../api/index'
 Page({
 
@@ -21,6 +22,7 @@
     district: '',
     housearea: '',
     
+    addrValues: [],
     addr: {},
     areaData: [],
 
@@ -33,7 +35,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 +70,6 @@
     })
     editMember({
       ...addr,
-      imgurl: imgurl || '',
       name: name || '',
       nickname: nickname || '',
       phone: phone || '',
@@ -65,8 +78,10 @@
       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)
       wx.showToast({
         title: '淇濆瓨鎴愬姛',
         icon: 'none'
@@ -97,6 +112,7 @@
         longitude: res.data.longitude || '',
         district: res.data.district || '',
         housearea: res.data.housearea || '',
+        addrValues: [res.data.provinceCode, res.data.cityCode, res.data.areaCode],
         addr: {
           provinceCode: res.data.provinceCode,
           provinceName: res.data.provinceName,
@@ -112,28 +128,39 @@
       this.setData({ areaData: res.data })
     })
   },
-  positionChange (e) {
-    console.log(e.detail.value)
-    const names = e.detail.value
-    const codes = e.detail.code
-    let addr = {
-      provinceCode: codes[0] + '00',
-      provinceName: names[0],
-      cityCode: codes[1] + '00',
-      cityName: names[1],
-      areaCode: codes[2] + '00',
-      areaName: names[2],
-    }
-    this.setData({ addr })
+  regionChange(e) {
+    console.log(e) 
+    if(e.detail.value &&e.detail.value.length ==3){
+      var tn = e.detail.label.split("-")
+      const addr = {
+        provinceCode: e.detail.value[0] ,
+        provinceName: tn[0],
+        cityCode:  e.detail.value[1] ,
+        cityName:  tn[1],
+        areaCode: e.detail.value[2] ,
+        areaName:  tn[2]
+      }
+      this.setData({ addr, showAreaList: false })
+      console.log('selectedOptions', addr);
+    } 
   },
-  bindRegionChange(e) {
-    console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
-    const temp = e.detail.value
-    this.setData({
-      region: e.detail.value
-    })
-  },
+  // positionChange (e) {
+  //   console.log(e.detail.value)
+  //   const names = e.detail.value
+  //   const codes = e.detail.code
+  //   let addr = {
+  //     provinceCode: codes[0] + '00',
+  //     provinceName: names[0],
+  //     cityCode: codes[1] + '00',
+  //     cityName: names[1],
+  //     areaCode: codes[2] + '00',
+  //     areaName: names[2],
+  //   }
+  //   this.setData({ addr })
+  //   console.log('addr', this.data.addr);
+  // },
   getBindchooseavatar(e) {
+    console.log('e', e);
     var that = this
     if (e.detail.avatarUrl) {
       wx.uploadFile({
@@ -149,23 +176,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);
       }
     })
   },

--
Gitblit v1.9.3