Просмотр исходного кода

feat:更新获取手机号以及登录授权传用户信息

jinx 4 лет назад
Родитель
Сommit
65c7727280

+ 6 - 1
apps/RealtorEasier/apis/user.js

@@ -17,11 +17,16 @@ export default {
       str += `${item}=${data[item]}&`
     })
     
-    return request.post(`user/login${str}`, data)
+    // return request.post(`user/login${str}`, data)
+    return request.post(`user/getPhoneNum${str}`, data)
   },
   loginByUserInfo (data) {
     return request.post(`user/login`, data)
   },
+  loginPostUserInfo (data) {
+ 
+    return request.post(`user/updateUserInfo`, data)
+  },
   loginByPhoneCodeAgency (data) {
     let str = '?'
     Object.keys(data).forEach(item => {

+ 6 - 5
apps/RealtorEasier/pages/index/index.js

@@ -20,7 +20,7 @@ Page({
      * 组件的属性列表
      */
     data: {
-        token:app.globalData.token,
+        token: app.globalData.token,
         tabList: [],
         show_empty: false,
         houses: [],
@@ -85,7 +85,7 @@ Page({
         }
     },
     onShow: function () {
-  
+
         var that = this;
         var city = app.globalData.city;
         if (city !== this.data.fetcherData.city) {
@@ -236,10 +236,10 @@ Page({
             imageUrl: 'https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/share.png', // 分享的封面图
         }
     },
-    getPhoneNumber (e) {
+    getPhoneNumber(e) {
         this.triggerEvent('toVrHouse')
         loginFn(e, app.globalData.user_code, this.properties.isAgency ? true : false).then(res => {
-         
+
           this.setData({
             loginStatus: app.globalData.token ? true : false,
             userinfo: app.globalData.userinfo,
@@ -250,6 +250,7 @@ Page({
           //   }
           // })
         })
-      }
+      
+    }
 
 });

+ 1 - 1
apps/RealtorEasier/pages/index/index.wxml

@@ -12,7 +12,7 @@
     </view>
 </view>
 
-<!-- <button class="getPhoneNum" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">测试获取手机号</button>  -->
+<button class="getPhoneNum" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">测试获取手机号</button> 
 <!-- 屏蔽栏目 -->
 <!-- <view class="icon-list {{ isFixedTop ? 'fixed' : ''}}">
     <view wx:for="{{icon_list}}" class="icon-item {{ fetcherData.saleType === item.type ? 'is-active' : ''}}"  wx:key bindtap="changeListType" data-type="{{item.type}}">

+ 37 - 21
apps/RealtorEasier/utils/login.js

@@ -1,7 +1,13 @@
 import UserApi from "../apis/user"
-import { saveToken, saveUserInfo ,removeUserCode,saveUserCode} from './storage'
+import {
+  saveToken,
+  saveUserInfo,
+  removeUserCode,
+  saveUserCode
+} from './storage'
 import EventEmitter from './eventEmitter'
 const app = getApp()
+
 function wxLogin() {
   return new Promise((resovle, reject) => {
     wx.login({
@@ -9,7 +15,7 @@ function wxLogin() {
         getApp().globalData.user_code = res.code
         console.log(res)
         saveUserInfo(res.code)
-        removeUserCode()//先删除再存入
+        removeUserCode() //先删除再存入
         saveUserCode(res.code)
         resovle(res.code)
       },
@@ -52,7 +58,7 @@ function loginByPhone(data, isAgency) {
   })
 }
 
-function tips (res) {
+function tips(res) {
   console.log(res)
   if (res.data.code == 3032) {
     wx.showToast({
@@ -74,12 +80,12 @@ function tips (res) {
 
 
 //获取用户信息接口
- function getUserProfile() {
+function getUserProfile() {
   return new Promise((resovle, reject) => {
     wx.getUserProfile({
-      desc: "用于完善用户资料", 
+      desc: "用于完善用户资料",
       //异步请求:回调函数中调用下一个函数
-      success (res)  {
+      success(res) {
         resovle(res)
       },
       fail(err) {
@@ -90,7 +96,7 @@ function tips (res) {
         reject(err)
       },
     });
-    
+
   })
   // await wx.getUserProfile({
   //   desc: "用于完善用户资料", 
@@ -110,16 +116,23 @@ function tips (res) {
 }
 
 export default function Login(phone_data, code, isAgency) {
-  const { encryptedData, iv } = phone_data.detail
+  const {
+    encryptedData,
+    iv
+  } = phone_data.detail
   console.log(phone_data)
-  
+
   if (!encryptedData || !iv) {
     return new Promise((_, reject) => reject())
   }
   return new Promise((resolve, reject) => {
     checkSession()
       .then(() => {
-        return loginByPhone({ phone_num: encryptedData, iv, wx_code: code }, isAgency).then(res => {
+        return loginByPhone({
+          phone_num: encryptedData,
+          iv,
+          wx_code: code
+        }, isAgency).then(res => {
           resolve(res)
         })
       })
@@ -127,7 +140,11 @@ export default function Login(phone_data, code, isAgency) {
         // 登陆失败可能是code失效,故重新wx.login重新获取code
         tips(err)
         wxLogin().then((code) => {
-          loginByPhone({ phone_num: encryptedData, iv, wx_code: code }, isAgency).then(res => {
+          loginByPhone({
+            phone_num: encryptedData,
+            iv,
+            wx_code: code
+          }, isAgency).then(res => {
             resolve(res)
           }).catch(err => {
             console.log(err, 'err')
@@ -141,7 +158,7 @@ export default function Login(phone_data, code, isAgency) {
 // 修復微信用戶信息 详情请看以下同名方法
 // export async function loginByUserInfo () {
 //   wx.showLoading('登录中')
-  
+
 //   return new Promise(async (resolve, reject) => {
 //     let code = await wxLogin()
 //     wx.getUserInfo({
@@ -167,20 +184,21 @@ export default function Login(phone_data, code, isAgency) {
 //       }
 //     })
 //   })
-  
+
 // }
 
 // 修復微信登录用戶信息缺失
-export async function loginByUserInfo () {
+export async function loginByUserInfo() {
   // wx.showLoading('登录中')
-  let UserProfile  = await getUserProfile()
+  let UserProfile = await getUserProfile()
   return new Promise(async (resolve, reject) => {
     let code = await wxLogin()
     wx.getUserInfo({
       withCredentials: true,
-      success (res) {
+      success(res) {
         console.log(res)
         res.wx_code = code
+        res.userInfo = UserProfile.userInfo
         UserApi.loginByUserInfo(res).then(loginRes => {
           const data = loginRes.data
           data.user = data.user || data.agency
@@ -189,19 +207,17 @@ export async function loginByUserInfo () {
           getApp().globalData.token = data.token
           UserProfile.userInfo.name = UserProfile.userInfo.name || UserProfile.userInfo.nickName
           UserProfile.userInfo.avatar = UserProfile.userInfo.avatar || UserProfile.userInfo.avatarUrl
-          getApp().globalData.userinfo =UserProfile.userInfo
+          getApp().globalData.userinfo = UserProfile.userInfo
           saveUserInfo(UserProfile.userInfo)
           EventEmitter.emit('login')
           wx.hideLoading()
           resolve(res)
         })
       },
-      fail (err) {
+      fail(err) {
         wx.hideLoading()
         reject(err)
       }
     })
   })
-}
-
-
+}

+ 2 - 1
apps/agent/apis/user.js

@@ -28,7 +28,8 @@ export default {
       str += `${item}=${data[item]}&`
     })
     
-    return request.post(`agency/login${str}`, data)
+    // return request.post(`agency/login${str}`, data)
+    return request.post(`agency/getPhoneNum${str}`, data)
   },
   // 分享历史
   fetchSharedHistory (data) {

+ 2 - 1
apps/agent/app.json

@@ -1,8 +1,9 @@
 {
   "pages": [
+    "pages/my/my",
+
     "pages/index/index",
     "pages/detail/detail",
-    "pages/my/my",
     "pages/city/city",
     "pages/web/web",
     "pages/chat-list/chat-list",

+ 101 - 67
apps/agent/components/detail-components/detail-scroll/detail-scroll.js

@@ -1,11 +1,18 @@
-
 import HouseApi from '../../../apis/house'
-import { fotmatDate } from '../../../utils/date'
+import {
+  fotmatDate
+} from '../../../utils/date'
 import loginFn from '../../../utils/login'
 import MsgManager from '../../../pages/chat/msg-manager'
-import { randomString } from './../../../utils/tools'
-import { saveViewHistory } from '../../../utils/storage'
-import { loginByUserInfo } from '../../../utils/login'
+import {
+  randomString
+} from './../../../utils/tools'
+import {
+  saveViewHistory
+} from '../../../utils/storage'
+import {
+  loginByUserInfo
+} from '../../../utils/login'
 const app = getApp();
 Component({
   /**
@@ -28,8 +35,7 @@ Component({
     user_code: '',
     markers: [],
     house: getApp().globalData.lastHouse,
-    detailItems: [
-      {
+    new_detailItems: [{
         label: '单价',
         value: '',
         name: 'unit_price'
@@ -72,23 +78,22 @@ Component({
       },
     ],
 
-    new_detailItems: [
-      {
+    detailItems: [{
         label: '建设年份',
         value: '2009',
-        name: 'build_time',
-        format: fotmatDate
+        name: 'constructionYear',
+        // format: fotmatDate
       },
       {
         label: '浴室个数',
         value: '1',
-        name: 'bathRoom_num',
+        name: 'showerroomAmount',
         // format: fotmatDate
       },
       {
         label: '卧室数量',
         value: '3',
-        name: 'bedRomm_num'
+        name: 'bedroomAmount'
       },
       {
         label: '单位价格',
@@ -98,22 +103,22 @@ Component({
       {
         label: '物业编号',
         value: '12321321',
-        name: 'unit_number'
+        name: 'propertyNumber'
       },
       {
         label: '建筑面积',
         value: '123',
-        name: 'build_area'
+        name: 'buildingArea'
       },
       {
         label: '土地面积',
         value: '123',
-        name: 'land_area'
+        name: 'floorSpace'
       },
     ]
   },
   pageLifetimes: {
-    show () {
+    show() {
       this.setData({
         loginStatus: app.globalData.token ? true : false,
         userinfo: app.globalData.userinfo,
@@ -121,7 +126,9 @@ Component({
       })
     }
   },
-  ready () {
+  ready() {
+
+
     this.setData({
       loginStatus: app.globalData.token ? true : false,
       userinfo: app.globalData.userinfo,
@@ -129,7 +136,7 @@ Component({
     this.getHouseDetail(this.properties.house_id)
     this.fetchRecommendHouseList()
     this.msgManager = new MsgManager(this)
-  
+
     if (!this.data.loginStatus) {
       // wx.login({
       //   success: (res) => {
@@ -139,22 +146,22 @@ Component({
       //   }
       // })
     } else {
-     
+
       this.getHouseFocusStatus()
     }
-    
+
   },
   /**
    * 组件的方法列表
    */
   methods: {
-    toMap () {
+    toMap() {
       const house = this.data.house
       wx.navigateTo({
         url: `/pages/map/map?longitude=${house.longitude}&latitude=${house.latitude}&housename=${house.district || ''} ${house.estate_name || ''}${this.properties.isAgency ? '' : `&agency_id=${this.properties.agent_user.agency_user_id}&agency_name=${this.properties.agent_user.name}&phone=${this.properties.agent_user.phone}`}`
       })
     },
-    sendSchoolMsg () {
+    sendSchoolMsg() {
       if (!getApp().globalData.token) {
         wx.navigateTo({
           url: '/pages/login/login',
@@ -167,12 +174,14 @@ Component({
         })
       })
     },
-    getHouseDetail(house_id){
+    getHouseDetail(house_id) {
       wx.showLoading({
         title: '加载数据中'
       })
       HouseApi.houseDetail(house_id).then(res => {
-        let { detailItems } = this.data
+        let {
+          detailItems
+        } = this.data
         let house = res.data
         detailItems.forEach(item => {
           if (house[item.name]) {
@@ -186,24 +195,24 @@ Component({
           }
         })
         house.tags = JSON.parse(house.tags || "[]")
-        house.remarks = JSON.parse(house.remarks || "[]")[0].text
+        house.ancillaryFacility = JSON.parse(house.ancillaryFacility || "[]")
+        // house.remarks = JSON.parse(house.remarks || "[]")[0].text
+        house.remarks = JSON.parse(house.remarks || "[]")
         res.data.detail_images = JSON.parse(res.data.detail_images)
         res.data.detail_images = res.data.detail_images.map(item => `${item}?x-oss-process=image/resize,w_750,limit_0/quality,q_75`)
-        let markers = [
-          {
-            longitude: house.longitude,
-            latitude: house.latitude,
-            housename: house.title,
-            iconPath: "/image/4Dage/location-cycle.png",
-            zIndex: -1,
-            callout: {
-              content: `${house.district || ''} ${house.estate_name || ''}`,
-              display: 'ALWAYS',
-              padding: 15,
-              anchorY: 10
-            }
+        let markers = [{
+          longitude: house.longitude,
+          latitude: house.latitude,
+          housename: house.title,
+          iconPath: "/image/4Dage/location-cycle.png",
+          zIndex: -1,
+          callout: {
+            content: `${house.district || ''} ${house.estate_name || ''}`,
+            display: 'ALWAYS',
+            padding: 15,
+            anchorY: 10
           }
-        ]
+        }]
         this.setData({
           house: res.data,
           detailItems: detailItems,
@@ -217,8 +226,10 @@ Component({
         wx.hideLoading()
       })
     },
-    getHouseFocusStatus () {
-      const { loginStatus } = this.data
+    getHouseFocusStatus() {
+      const {
+        loginStatus
+      } = this.data
       if (!loginStatus) {
         return
       }
@@ -232,7 +243,7 @@ Component({
         return res.data
       })
     },
-    bindgetphonenumber (e) {
+    bindgetphonenumber(e) {
       loginFn(e, this.data.user_code, this.properties.isAgency ? true : false).then(res => {
         this.setData({
           loginStatus: app.globalData.token ? true : false,
@@ -245,7 +256,7 @@ Component({
         })
       })
     },
-    changeFocusStatus () {
+    changeFocusStatus() {
       const is_valid = this.data.isFocused ? 0 : 1
       HouseApi.focusHouse({
         is_valid,
@@ -256,14 +267,16 @@ Component({
         })
       })
     },
-    cancleFocusStatus () {
-      return HouseApi.cancleFocusHouse({house_id: this.properties.house_id}).then(() => {
+    cancleFocusStatus() {
+      return HouseApi.cancleFocusHouse({
+        house_id: this.properties.house_id
+      }).then(() => {
         this.setData({
           isFocused: 0
         })
       })
     },
-    fetchRecommendHouseList () {
+    fetchRecommendHouseList() {
       const fetchData = {
         city: app.globalData.city,
         saleState: 1,
@@ -275,16 +288,18 @@ Component({
         })
       })
     },
-    toMoreIntro () {
+    toMoreIntro() {
       wx.navigateTo({
         url: `/pages/detail-intro/detail-intro?house_id=${this.properties.house_id}`
       })
     },
-    addReadHistory () {
-      HouseApi.addReadHistory({ house_id: this.properties.house_id })
+    addReadHistory() {
+      HouseApi.addReadHistory({
+        house_id: this.properties.house_id
+      })
     },
     // 发送带看
-    onlineWatch () {
+    onlineWatch() {
       if (!this.data.loginStatus) {
         wx.navigateTo({
           url: '/pages/login/login'
@@ -301,8 +316,10 @@ Component({
       this.toVrHouse(room_id, true)
     },
     // 发送房屋卡片
-    sendVrMsg (room_id, is_vr_invite) {
-      const { house } = this.data
+    sendVrMsg(room_id, is_vr_invite) {
+      const {
+        house
+      } = this.data
       let content = {
         house_name: house.title,
         image_url: house.detail_images[0],
@@ -313,13 +330,22 @@ Component({
         vr_link: is_vr_invite ? `${house.vrLink}${encodeURIComponent(`&room_id=${room_id}`)}` : '',
         house_id: house.house_id
       }
-      return this.sendMsg({content, msgType: 'vr'})
+      return this.sendMsg({
+        content,
+        msgType: 'vr'
+      })
     },
     // 发送文字
-    sendTextMsg (content) {
-      return this.sendMsg({content, msgType: 'text'})
+    sendTextMsg(content) {
+      return this.sendMsg({
+        content,
+        msgType: 'text'
+      })
     },
-    sendMsg ({content, msgType}) {
+    sendMsg({
+      content,
+      msgType
+    }) {
       let defaultContent = {
         fromId: app.globalData.userinfo.user_id,
         fromName: app.globalData.userinfo.phone,
@@ -329,30 +355,38 @@ Component({
         msgType,
         content: content
       }
-      return getApp().getIMHandler().newFriendSendMsg({content: defaultContent})
+      return getApp().getIMHandler().newFriendSendMsg({
+        content: defaultContent
+      })
     },
-    toVrHouse (room_id, isAuto) {
+    toVrHouse(room_id, isAuto) {
       // console.log(app.globalData)
       if (typeof room_id !== 'string') room_id = ''
-      
+
       this.postDataToOpen(room_id).then(res => {
         const vr_link = res.data.vrLink
         wx.navigateTo({
           url: `/pages/web/web?room_id=${res.data.roomId}&vr_link=${encodeURIComponent(vr_link)}&house_id=${this.properties.house_id}${isAuto ? `&is_auto=${isAuto}` : ''}`
         })
       })
-      
+
     },
-    postDataToOpen (room_id) {
-      return HouseApi.postDataToOpen({house_id: this.properties.house_id, room_id, type: 'customer'})
+    postDataToOpen(room_id) {
+      return HouseApi.postDataToOpen({
+        house_id: this.properties.house_id,
+        room_id,
+        type: 'customer'
+      })
     },
-    toAgentDetail () {
+    toAgentDetail() {
       wx.navigateTo({
         url: `/pages/agent-detail/agent-detail?agency_id=${this.properties.agent_user.agency_user_id}`,
       })
     },
-    bindgetuserinfo (e) {
-      const { action } = e.currentTarget.dataset
+    bindgetuserinfo(e) {
+      const {
+        action
+      } = e.currentTarget.dataset
       loginByUserInfo().then(res => {
         this.setData({
           loginStatus: app.globalData.token ? true : false,
@@ -363,4 +397,4 @@ Component({
       })
     }
   }
-})
+})

+ 26 - 18
apps/agent/components/detail-components/detail-scroll/detail-scroll.wxml

@@ -4,6 +4,7 @@
     <view class="house-info padding-container">
         <view class="tab-list">
             <view class="tab-item" wx:for="{{house.tags}}" wx:key="index">{{ item }}</view>
+            <!-- <view class="tab-item" wx:for="{{house.tags}}" wx:key="index">{{ item }}</view> -->
             <!-- <view class="tab-item" > 满两年 </view>
             <view class="tab-item" > 随时可看 </view> -->
         </view>
@@ -32,26 +33,29 @@
         </view>
         <view class="house-parameter">
             <view class="parameter-item">
-                <view class="price">{{ house.price / 10000 }}万</view>
+                <!-- <view class="price">${{ house.price / 10000 }}万</view> -->
+                <view class="price">${{ house.price/10000 }}万</view>
                 <view class="parameter-name">售价</view>
             </view>
             <view class="parameter-item">
-                <view class="price">{{ house.house_type || '暂无数据' }}</view>
+                <!-- <view class="price">{{ house.house_type || '暂无数据' }}</view> -->
+                <view class="price">{{house.bedroomAmount+'卧'+house.showerroomAmount+'卫' || '暂无数据' }}</view>
                 <view class="parameter-name">房型</view>
             </view>
             <view class="parameter-item">
-                <view class="price">{{ house.area ? house.area + 'ft²' : '暂无数据' }}</view>
+                <!-- <view class="price">{{ house.area ? house.area + 'm²' : '暂无数据' }}</view> -->
+                <view class="price">{{ house.buildingArea ? house.buildingArea + 'ft²' : '暂无数据' }}</view>
                 <view class="parameter-name">建筑面积</view>
             </view>
         </view>
         <view class="house-detail">
-            <view class="detail-item" wx:for="{{new_detailItems}}" wx:key="name">
+            <view class="detail-item" wx:for="{{detailItems}}" wx:key="name">
                 <text class="label">{{ item.label }}:</text>
                 <text class="value"> <text class="value" wx:if="{{item.name=='unit_price' }}"> $</text>{{ item.value
                     }}</text>
-                <text class="value" wx:if="{{item.name=='bedRomm_num' ||item.name=='bathRoom_num' }}">个</text>
+                <text class="value" wx:if="{{item.name=='bedroomAmount' ||item.name=='bathRoom_num' }}">个</text>
                 <text class="value" wx:if="{{item.name=='unit_price' }}">万</text>
-                <text class="value" wx:if="{{item.name=='build_area' ||item.name=='land_area' }}">平方英尺</text>
+                <text class="value" wx:if="{{item.name=='buildingArea' ||item.name=='floorSpace' }}">平方英尺</text>
             </view>
         </view>
         <view class="vr-tip" wx:if="{{!isAgency && house.vrLink}}">
@@ -68,7 +72,8 @@
             <view class="detail-title">位置及周边配套</view>
             <view class="location-item">
                 <text class="location-label">位置:</text>
-                <text class="location-value">{{ house.city + house.estate_name }}</text>
+                <!-- <text class="location-value">{{ house.city + house.estate_name }}</text> -->
+                <text class="location-value">{{ house.city + house.address }}</text>
             </view>
             <view class="location-item" wx:if="{{!isAgency}}">
                 <text class="location-label">学校信息:</text>
@@ -84,35 +89,38 @@
     </view>
 
     <!-- <view class=" padding-container" bind:tap="toMoreIntro"> -->
-    <view class=" padding-container">
+    <view class=" padding-container" wx:if="{{!( house.remarks.length == 1 &&house.remarks[0].title == '' &&house.remarks[0].text == '') }}">
+
         <view class="location-text-info border-btn">
             <!-- <view class="detail-title">房源介绍 -->
             <view class="detail-title">物业特色
                 <!-- <view class="arrow-right fr"></view> -->
             </view>
-            <!-- <view class="detail-text">{{ house.remarks }}</view> -->
-            <view class="detail-text">
-                位于美国佐治亚州Suwanee的房产,其为一座优雅的乡村风格小屋,拥有独特的定制装饰和高质量手工工艺。优雅与天然在这座壮丽住宅内完美相融。该住宅共设有5间卧室、6间全浴卫生间和3间半浴室,可以看到格雷格·诺曼高尔夫球场(Greg
-                Norman Golf
-                Course)、一个池塘和葱郁树林。5间卧室中有2间卧室为业主套房。后院设有带热水浴缸的泳池、瀑布和火坑,供您日常享受;还有2间厨房、6台壁炉、带桑拿浴室的露台水疗区、蒸汽淋浴间、按摩室、健身室和有氧室;更有3间洗衣房、电梯,并铺设有宽木板手刮胡桃木地板。
+            <view wx:for="{{house.remarks}}" :key="name">
+                <view class="detail-text">{{item.title}}</view>
+                <view class="detail-text">
+                    {{item.text}}
+                </view>
             </view>
+
         </view>
     </view>
 
     <!-- 配套设施 -->
-    <view class=" padding-container">
+    <view class=" padding-container" wx:if="{{house.ancillaryFacility.length>0}}">
         <view class="location-text-info border-btn">
             <view class="detail-title m-t-32">配套设施
             </view>
             <view class="detail-tag">
-                <text class="tag-item">壁炉</text>
-                <text class="tag-item">大理石</text>
+                <view class="tag-item" wx:for="{{house.ancillaryFacility}}" wx:key="index">{{item}}</view>
+                <!-- <text class="tag-item">壁炉</text> -->
+                <!-- <text class="tag-item">大理石</text>
                 <text class="tag-item">微波炉</text>
                 <text class="tag-item">洗碗机</text>
                 <text class="tag-item">浴缸</text>
                 <text class="tag-item">食品储蓄室</text>
-                <text class="tag-item">藏书师</text>
-                
+                <text class="tag-item">藏书师</text> -->
+
             </view>
         </view>
     </view>

+ 0 - 1
apps/agent/pages/chat-list/chat-list.js

@@ -24,7 +24,6 @@ Page({
         let app = getApp()
         getApp().autoSubcrebe && getApp().autoSubcrebe()
         let item = e.currentTarget.dataset.item;
-        console.log(item)
         app.globalData.unViewMsg = app.globalData.unViewMsg - item.unReadNum
         console.log(item.unread, app.globalData.unViewMsg, e)
         delete item.latestMsg;

+ 11 - 2
apps/agent/pages/my/my.js

@@ -1,4 +1,5 @@
-import {login,loginByUserInfo } from '../../utils/login'
+import {loginByUserInfo ,Login}from './../../utils/login'
+console.log(Login)
 import Toast from '../../components/vant-ui/toast/toast';
 import {
     subcribe
@@ -77,7 +78,15 @@ Page({
             userinfo: app.globalData.userinfo
         });
     },
-    bindgetphonenumber(e) {
+    getPhoneNumber(e) {
+        Login(e, this.data.user_code, true).then(res => {
+            this.setData({
+                isLogined: app.globalData.token ? true : false,
+                userinfo: app.globalData.userinfo
+            })
+        })
+    },
+    bindgetuserinfo(e) {
         // login(e, this.data.user_code, true).then(res => {
         loginByUserInfo(e, this.data.user_code, true).then(res => {
             this.setData({

+ 2 - 2
apps/agent/pages/my/my.wxml

@@ -8,8 +8,8 @@
         点击注册 / 登录
         
     </view>
-    <!-- <button wx:if="{{ !isLogined }}" open-type="getPhoneNumber" bindgetphonenumber="bindgetphonenumber">获取手机号</button> -->
-    <button wx:if="{{ !isLogined }}" open-type="getUserInfo" bindtap="bindgetphonenumber">获取手机号</button>
+    <!-- <button wx:if="{{ !isLogined }}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取手机号</button> -->
+    <button wx:if="{{ !isLogined }}" open-type="getUserInfo" bindtap="bindgetuserinfo">获取手机号</button>
     <image src="https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/miniprogram/my-header-bg.png" class="header-bg"></image>
 </view>
 

+ 2 - 1
apps/agent/utils/login.js

@@ -87,7 +87,7 @@ function getUserProfile() {
     
   })
 }
-export default function Login(phone_data, code, isAgency) {
+export  function Login(phone_data, code, isAgency) {
   const { encryptedData, iv } = phone_data.detail
   if (!encryptedData || !iv) {
     return new Promise((_, reject) => reject())
@@ -154,6 +154,7 @@ export async function loginByUserInfo () {
       withCredentials: true,
       success (res) {
         res.wx_code = code
+        res.userInfo = UserProfile.userInfo
         UserApi.loginByUserInfo(res).then(loginRes => {
           const data = loginRes.data
           data.user = data.user || data.agency