From b2d360d9113b6955287108ca9e90d76a1f3c1419 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期日, 29 九月 2024 15:05:11 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia

---
 wechat_jiaxuan/pages/userinfo/index.js |  126 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 104 insertions(+), 22 deletions(-)

diff --git a/wechat_jiaxuan/pages/userinfo/index.js b/wechat_jiaxuan/pages/userinfo/index.js
index ab3fa95..18074ca 100644
--- a/wechat_jiaxuan/pages/userinfo/index.js
+++ b/wechat_jiaxuan/pages/userinfo/index.js
@@ -1,7 +1,8 @@
 import {
   uploadUrl,
   editMember,
-  getMemberInfo
+  getMemberInfo,
+  getWxMiniPhone
 } from '../../api/index'
 Page({
 
@@ -19,8 +20,10 @@
     longitude: '',
     district: '',
     housearea: '',
-    // 鍩庡競銆傚湴鍧�
-    region: [],
+    
+    addrValues: [],
+    addr: {},
+    areaData: [],
 
     showHouseType: false,
     houseType: {
@@ -31,7 +34,19 @@
       val5: '',
     }
   },
-  onLoad(options) {
+  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() {
@@ -45,14 +60,15 @@
       longitude,
       district,
       housearea,
-      houseType
+      houseType,
+      addr
     } = this.data
     if (!nickname) return wx.showToast({
       title: '璇疯緭鍏ユ樀绉�',
       icon: 'none'
     })
     editMember({
-      imgurl: imgurl || '',
+      ...addr,
       name: name || '',
       nickname: nickname || '',
       phone: phone || '',
@@ -61,8 +77,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'
@@ -93,26 +111,100 @@
         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,
+          cityCode: res.data.cityCode,
+          cityName: res.data.cityName,
+          areaCode: res.data.areaCode,
+          areaName: res.data.areaName,
+        }
+
       })
     })
+  },
+  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);
+    } 
+  },
+  // 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({
+        url: uploadUrl,
+        filePath: e.detail.avatarUrl,
+        formData: {
+          folder: "member"
+        },
+        name: 'file',
+        success (res) {
+          let data = JSON.parse(res.data)
+          that.setData({
+            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({ 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);
       }
-    })
-  },
-  bindRegionChange(e) {
-    console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
-    this.setData({
-      region: e.detail.value
     })
   },
   openHouse() {
@@ -167,22 +259,12 @@
               imgurl: data.data.imgaddr,
               imgurlFull: data.data.url,
             })
-            setTimeout(() => {
-              console.log('imgurlFull', this.data.imgurlFull);
-            }, 1000)
           }
         })
       }
     })
   },
   onReady() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
-   */
-  onShow() {
 
   },
 

--
Gitblit v1.9.3