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

feat:更新页面调整代码

jinx 4 лет назад
Родитель
Сommit
1280b6fdcc

+ 12 - 10
apps/RealtorEasier/components/detail-components/detail-banner/detail-banner.js

@@ -8,7 +8,9 @@ Component({
   properties: {
     imglist: Array,
     vrLink: String,
-    isAgency:Boolean
+    isAgency: Boolean,
+    avatar: String
+
   },
 
   /**
@@ -17,32 +19,32 @@ Component({
   data: {
     currentIndex: 0,
     preIndex: 1,
-   
+
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
-    swiperchange (e) {
+    swiperchange(e) {
       this.setData({
         preIndex: e.detail.current + 1
       })
     },
-    HandleImgClick (e) {
-      
+    HandleImgClick(e) {
+
     },
-    onlineWatch () {
+    onlineWatch() {
       this.triggerEvent('onlineWatch')
     },
-    toVrHouse () {
+    toVrHouse() {
       this.triggerEvent('toVrHouse')
     },
-    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,
@@ -55,4 +57,4 @@ Component({
       })
     }
   }
-})
+})

+ 17 - 0
apps/RealtorEasier/pages/index/index.js

@@ -1,4 +1,5 @@
 import houseApi from '../../apis/house'
+import loginFn from '../../utils/login'
 import {
     encryption
 } from '../../utils/encryption'
@@ -234,5 +235,21 @@ Page({
             imageUrl: 'https://4d-tjw.oss-cn-shenzhen.aliyuncs.com/4dHouse/share.png', // 分享的封面图
         }
     },
+    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,
+          })
+          // this.getHouseFocusStatus().then(res => {
+          //   if (!res) {
+          //     this.changeFocusStatus()
+          //   }
+          // })
+        })
+      }
 
 });

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

@@ -11,6 +11,7 @@
         <view>{{ fetcherData.city }}</view>
     </view>
 </view>
+<!-- <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}}">

+ 2 - 2
apps/RealtorEasier/pages/web/web.js

@@ -46,8 +46,8 @@ Page({
     }
     this.setData({
       socketOpts: opts,
-      url: `${vr_link}&room_id=${opts.roomId}${options.is_auto? `&vr=1` : ''}`,
-      // url: `http://192.168.0.207:8080/realtor-easier.html?m=t-LloMBfU&appname=realtor-easier&role=customer&room_id=10507db19f478ed5f551621558258956&user_id=10021912303a282f2a41620886147753&room_id=10507db19f478ed5f551621558258956`,
+      // url: `${vr_link}&room_id=${opts.roomId}${options.is_auto? `&vr=1` : ''}`,
+      url: `http://192.168.0.77:8081/realtor-easier.html?m=t-LloMBfU&appname=realtor-easier&role=customer&room_id=10507db19f478ed5f551621558258956&user_id=10021912303a282f2a41620886147753&room_id=10507db19f478ed5f551621558258956`,
       room_id: opts.roomId,
       house_id: options.house_id || '',
       vr_link: vr_link,

+ 1 - 1
apps/RealtorEasier/utils/login.js

@@ -166,7 +166,7 @@ export default function Login(phone_data, code, isAgency) {
   
 // }
 
-
+// 修復微信登录用戶信息缺失
 export async function loginByUserInfo () {
   // wx.showLoading('登录中')
   let UserProfile  = await getUserProfile()

+ 51 - 7
apps/agent/components/detail-components/detail-scroll/detail-scroll.js

@@ -70,6 +70,46 @@ Component({
         value: '',
         name: 'house_usage'
       },
+    ],
+
+    new_detailItems: [
+      {
+        label: '建设年份',
+        value: '2009',
+        name: 'build_time',
+        format: fotmatDate
+      },
+      {
+        label: '浴室个数',
+        value: '1',
+        name: 'bathRoom_num',
+        // format: fotmatDate
+      },
+      {
+        label: '卧室数量',
+        value: '3',
+        name: 'bedRomm_num'
+      },
+      {
+        label: '单位价格',
+        value: '3',
+        name: 'unit_price'
+      },
+      {
+        label: '物业编号',
+        value: '12321321',
+        name: 'unit_number'
+      },
+      {
+        label: '建筑面积',
+        value: '123',
+        name: 'build_area'
+      },
+      {
+        label: '土地面积',
+        value: '123',
+        name: 'land_area'
+      },
     ]
   },
   pageLifetimes: {
@@ -89,17 +129,20 @@ Component({
     this.getHouseDetail(this.properties.house_id)
     this.fetchRecommendHouseList()
     this.msgManager = new MsgManager(this)
+  
     if (!this.data.loginStatus) {
-      wx.login({
-        success: (res) => {
-          this.setData({
-            user_code: res.code
-          })
-        }
-      })
+      // wx.login({
+      //   success: (res) => {
+      //     this.setData({
+      //       user_code: res.code
+      //     })
+      //   }
+      // })
     } else {
+     
       this.getHouseFocusStatus()
     }
+    
   },
   /**
    * 组件的方法列表
@@ -289,6 +332,7 @@ Component({
       return getApp().getIMHandler().newFriendSendMsg({content: defaultContent})
     },
     toVrHouse (room_id, isAuto) {
+      // console.log(app.globalData)
       if (typeof room_id !== 'string') room_id = ''
       
       this.postDataToOpen(room_id).then(res => {

+ 68 - 38
apps/agent/components/detail-components/detail-scroll/detail-scroll.wxml

@@ -1,29 +1,35 @@
-<detail-banner imglist="{{house.detail_images}}" vrLink="{{house.vrLink}}" bind:onlineWatch="onlineWatch" bind:toVrHouse="toVrHouse" />
+<detail-banner imglist="{{house.detail_images}}" vrLink="{{house.vrLink}}" bind:onlineWatch="onlineWatch"
+    bind:toVrHouse="toVrHouse" />
 <scroll-view class="contanerbox" scroll-y="true" wx:if="{{house.house_id}}">
     <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" > 满两年 </view>
+            <view class="tab-item" > 随时可看 </view> -->
         </view>
         <view class="follow-status-w">
-          <button class="follow-status" open-type="getPhoneNumber" bindgetphonenumber="bindgetphonenumber" wx:if="{{ !loginStatus && app_type !== 'user' }}">
-            <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
-            关注
-          </button>
-          <button class="follow-status" data-action="changeFocusStatus" open-type="getUserInfo" bindgetuserinfo="bindgetuserinfo" wx:elif="{{ !loginStatus && app_type === 'user' }}">
-            <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
-            关注
-          </button>
-          <view class="follow-status" wx:elif="{{ !isFocused }}" bindtap="changeFocusStatus">
-            <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
-            关注
-          </view>
-          <view class="follow-status" wx:elif="{{ isFocused }}" bindtap="cancleFocusStatus">
-            <image class="follow-icon" src="/image/4Dage/detail/icon-follow-active.svg" />
-            已关注
-          </view>
+            <button class="follow-status" open-type="getPhoneNumber" bindgetphonenumber="bindgetphonenumber"
+                wx:if="{{ !loginStatus && app_type !== 'user' }}">
+                <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
+                关注
+            </button>
+            <button class="follow-status" data-action="changeFocusStatus" open-type="getUserInfo"
+                bindtap="bindgetuserinfo" wx:elif="{{ !loginStatus && app_type === 'user' }}">
+                <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
+                关注
+            </button>
+            <view class="follow-status" wx:elif="{{ !isFocused }}" bindtap="changeFocusStatus">
+                <image class="follow-icon" src="/image/4Dage/detail/icon-follow.svg" />
+                关注
+            </view>
+            <view class="follow-status" wx:elif="{{ isFocused }}" bindtap="cancleFocusStatus">
+                <image class="follow-icon" src="/image/4Dage/detail/icon-follow-active.svg" />
+                已关注
+            </view>
         </view>
         <view class="house-name ">{{ house.title }}</view>
-        <view class="contact-user">房源负责人:{{ agent_user.name }}<view class="icon-idcard" bind:tap="toAgentDetail"></view></view>
+        <view class="contact-user">房源负责人:{{ agent_user.name }}<view class="icon-idcard" bind:tap="toAgentDetail"></view>
+        </view>
         <view class="house-parameter">
             <view class="parameter-item">
                 <view class="price">{{ house.price / 10000 }}万</view>
@@ -34,14 +40,18 @@
                 <view class="parameter-name">房型</view>
             </view>
             <view class="parameter-item">
-                <view class="price">{{ house.area ? house.area + 'm²' : '暂无数据' }}</view>
+                <view class="price">{{ house.area ? house.area + 'ft²' : '暂无数据' }}</view>
                 <view class="parameter-name">建筑面积</view>
             </view>
         </view>
         <view class="house-detail">
-            <view class="detail-item" wx:for="{{detailItems}}" wx:key="name">
+            <view class="detail-item" wx:for="{{new_detailItems}}" wx:key="name">
                 <text class="label">{{ item.label }}:</text>
-                <text class="value">{{ item.value }}</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=='unit_price' }}">万</text>
+                <text class="value" wx:if="{{item.name=='build_area' ||item.name=='land_area' }}">平方英尺</text>
             </view>
         </view>
         <view class="vr-tip" wx:if="{{!isAgency && house.vrLink}}">
@@ -60,34 +70,54 @@
                 <text class="location-label">位置:</text>
                 <text class="location-value">{{ house.city + house.estate_name }}</text>
             </view>
-            <view class="location-item"  wx:if="{{!isAgency}}">
+            <view class="location-item" wx:if="{{!isAgency}}">
                 <text class="location-label">学校信息:</text>
                 <text class="location-link" bindtap="sendSchoolMsg">咨询经纪人中小学情况</text>
             </view>
         </view>
     </view>
     <view class="map-w">
-      <map
-      id="map"
-      class="detail-map"
-      longitude="{{markers[0].longitude}}" 
-      latitude="{{markers[0].latitude}}"
-      enable-scroll="{{ false }}"
-      enable-zoom="{{ false }}"
-      markers="{{markers}}"
-      show-location>
-      </map>
-      <view class="cover" bindtap="toMap"></view>
+        <map id="map" class="detail-map" longitude="{{markers[0].longitude}}" latitude="{{markers[0].latitude}}"
+            enable-scroll="{{ false }}" enable-zoom="{{ false }}" markers="{{markers}}" show-location>
+        </map>
+        <view class="cover" bindtap="toMap"></view>
     </view>
-    
-    <view class=" padding-container" bind:tap="toMoreIntro">
+
+    <!-- <view class=" padding-container" bind:tap="toMoreIntro"> -->
+    <view class=" padding-container">
         <view class="location-text-info border-btn">
-            <view class="detail-title">房源介绍
-                <view class="arrow-right fr"></view>
+            <!-- <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>
+        </view>
+    </view>
+
+    <!-- 配套设施 -->
+    <view class=" padding-container">
+        <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>
+                <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 class="detail-text">{{ house.remarks }}</view>
         </view>
     </view>
+
+
     <view class="padding-container">
         <view class="detail-title m-t-32">推荐房源({{recommendList.length}})</view>
         <view class="house-list">

+ 30 - 3
apps/agent/components/detail-components/detail-scroll/detail-scroll.wxss

@@ -6,7 +6,7 @@
   position: relative;
 }
 .contanerbox {
-  margin-top: 48rpx;
+  margin-top: 34rpx;
   padding-bottom: 160rpx;
 }
 
@@ -77,8 +77,18 @@
   line-height: 42rpx;
   margin-bottom: 12rpx;
 }
+.detail-item:nth-of-type(n+5){
+  /* display: inline-block; */
+  width: 100%;
+  /* font-size: 30rpx;
+  color: #79868F;
+  font-weight: 400;
+  line-height: 42rpx;
+  margin-bottom: 12rpx; */
+}
 .detail-item .value {
   color: #111;
+  font-weight: bold;
 }
 
 .vr-tip {
@@ -120,6 +130,23 @@
   font-size: 30rpx;
   padding-bottom: 30rpx;
 }
+.detail-tag{
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  justify-content: flex-start;
+}
+.tag-item{
+  padding: 0 20rpx;
+  height: 72rpx;
+  background: #E8F8FE;
+  font-size: 28rpx;
+  color: #79868F;
+  display:block;
+  line-height: 72rpx;
+  margin-right: 12rpx;
+  margin-bottom: 12rpx;
+}
 .m-t-32 {
   margin-top: 32rpx;
 }
@@ -141,9 +168,9 @@
   word-break: break-all;
   font-size: 30rpx;
   line-height: 42rpx;
-  display:-webkit-box;
+  /* display:-webkit-box;
   -webkit-box-orient:vertical;
-  -webkit-line-clamp: 5;
+  -webkit-line-clamp: 5; */
 }
 .location-item {
   margin-bottom: 2rpx;

+ 7 - 0
apps/agent/components/drop-down/drop-down.js

@@ -86,6 +86,13 @@ Component({
           maxjushi: ''
         }
       }
+      if (type === 'yushi') {
+        obj = {
+          selectObj:Object.assign(this.data.selectObj,tmp),
+          minyushi: '',
+          maxyushi: ''
+        }
+      }
       Object.keys(this.data.selectObj).forEach(item=>{
         let i =this.data.selectObj[item]
         i.name = i.name.replace('不限','')

+ 2 - 2
apps/agent/components/drop-down/drop-down.wxml

@@ -22,8 +22,8 @@
     <view class="filter {{item.filter==='浴室'?'':'hidden'}}">
         <text>自定义{{item.filter}}:</text>
         <input class="hidden" />
-        <input type="number" value="{{minjushi}}" placeholder="最小" bindinput="bindInput" data-key="{{'min'+item.id}}"></input>
-        <input type="number" value="{{maxjushi}}" placeholder="最大" bindinput="bindInput" data-key="{{'max'+item.id}}"></input>
+        <input type="number" value="{{minyushi}}" placeholder="最小" bindinput="bindInput" data-key="{{'min'+item.id}}"></input>
+        <input type="number" value="{{maxyushi}}" placeholder="最大" bindinput="bindInput" data-key="{{'max'+item.id}}"></input>
         <input class="hidden" />
       <view data-type="{{item.id}}" bindtap="comfirm" class="btn">确定</view>
     </view>

+ 5 - 4
apps/agent/components/house-item/house-item.wxml

@@ -12,12 +12,13 @@
         <view class="text-black address" >{{ house.district }}/{{ house.address }}</view>
       </view>
       <view class="tap-list" >
-        <view class="tap-item" wx:if="{{house.vrLink}}">云看房</view>
-        <view class="tap-item" wx:if="{{house.vrLink}}">随时可看</view>
+      <view class="tap-item" >{{house.house_type}}</view>
+        <!-- <view class="tap-item" wx:if="{{house.vrLink}}">{{云看房}}</view> -->
+        <!-- <view class="tap-item" wx:if="{{house.vrLink}}">随时可看</view> -->
       </view>
     <view class="price-w">
-        <text class="price text-bold">{{ house.price/10000 }}万</text>
-        <text class="price-tip">{{ house.unit_price }}元/平</text>
+        <text class="price text-bold">${{ house.price/10000 }}万</text>
+        <!-- <text class="price-tip">{{ house.unit_price }}元/平</text> -->
       </view>
     </view>
   </view>

+ 2 - 1
apps/agent/components/login-pannel/login-pannel.wxml

@@ -5,6 +5,7 @@
     <cover-image class="login-logo" src="/image/4Dage/login-logo.png" mode="heightFix"></cover-image>
     <cover-view class="logo-bottom-tips">四维时代网络科技有限公司申请获取以下权限</cover-view>
     <cover-view class="tips">·获得您的公开信息(昵称、头像等)</cover-view>
-    <button class="login-btn" open-type="getUserInfo" bindgetuserinfo="bindgetuserinfo">微信授权登录</button>
+    <!-- <button class="login-btn" open-type="getUserInfo" bindgetuserinfo="bindgetuserinfo">微信授权登录</button> -->
+    <button class="login-btn" open-type="getUserInfo" bindtap="bindgetuserinfo">微信授权登录</button>
   </cover-view>
 </cover-view>

+ 6 - 6
apps/agent/components/tabs-house-list/tabs-house-list.wxml

@@ -1,11 +1,11 @@
-<van-tabs active="{{ active }}" line-width="20" color="#1FE4DC" bind:change="onChange">
-  <van-tab title="{{ tabs.name }}" wx:for="{{tabs}}" wx:for-item="tabs" wx:key="index">
+<!-- <van-tabs active="{{ active }}" line-width="20" color="#1FE4DC" bind:change="onChange">
+  <van-tab title="{{ tabs.name }}" wx:for="{{tabs}}" wx:for-item="tabs" wx:key="index"> -->
     <view >
       <view class="no-data" wx:if="{{tabs.house_list.length === 0}}">暂无数据</view>
       <view class="house-list" wx:else>
-        <house-item wx:for="{{ tabs.house_list }}" house="{{ item }}" wx:key="id" />
+        <house-item wx:for="{{ tabs[0].house_list }}" house="{{ item }}" wx:key="id" />
       </view>
-      <no-more-bar wx:if="{{tabs.house_list.length !== 0}}" />
+      <no-more-bar wx:if="{{tabs[0].house_list.length !== 0}}" />
     </view>
-  </van-tab>
-</van-tabs>
+  <!-- </van-tab>
+</van-tabs> -->

+ 3 - 3
apps/agent/pages/add-client/add-client.js

@@ -182,9 +182,9 @@ Page({
         })
 
         let params = this.data.params
-        if (!params['user_id']) {
-            return app.ShowModel('提示',`请输入电话号码后选择用户信息`);
-        }
+        // if (!params['user_id']) {
+        //     return app.ShowModel('提示',`请输入电话号码后选择用户信息`);
+        // }
         let NONULL = [{
            name:'手机号码',
            id: 'user_phone'

+ 2 - 1
apps/agent/pages/add-client/add-client.wxml

@@ -18,7 +18,8 @@
 
     <view class="add-item">
       <text>手机号码</text>
-      <input placeholder="请输入手机号码" disabled="{{ is_edit }}" value="{{ params.user_phone }}" bindblur="getUserList" bindinput="bindInput" data-key="params.user_phone"></input>
+      <!-- <input placeholder="请输入手机号码" disabled="{{ is_edit }}" value="{{ params.user_phone }}" bindblur="getUserList" bindinput="bindInput" data-key="params.user_phone"></input> -->
+      <input placeholder="请输入手机号码" disabled="{{ is_edit }}" value="{{ params.user_phone }}"  bindinput="bindInput" data-key="params.user_phone"></input>
     </view>
 
     <view class="add-item">

+ 5 - 2
apps/agent/pages/index/index.js

@@ -126,7 +126,8 @@ Page({
             saleState: 1,
             district:'',
             price_s:'',
-            rooms:''
+            rooms:'',
+            bothRooms:'',
         },
         has_next: true,
         navbarInitTop: 80,
@@ -203,7 +204,8 @@ Page({
         let fetData = this.data.fetcherData
         let tmp = Object.assign(fetData,{
             price_s:data.jiage||fetData.price||'',
-            room_s:data.jushi||''
+            room_s:data.jushi||'',
+            bathRoom_s:data.yushi||''
         })
         this.closeTypeActive()
         this.setData({
@@ -224,6 +226,7 @@ Page({
             district:selectObj.didian.name,
             price_s:selectObj.jiage?selectObj.jiage.id:'',
             rooms:selectObj.jushi?selectObj.jushi.id:'',
+            bothRooms:selectObj.jushi?selectObj.yushi.id:'',
             city: selectObj.quyu.name.replace('市', '')
         })
         this.setData({

+ 17 - 8
apps/agent/pages/login/login.js

@@ -1,4 +1,7 @@
-import loginFn from './../../utils/login'
+import {
+  loginFn,
+  loginByUserInfo
+} from './../../utils/login'
 //获取应用实例
 const app = getApp()
 Page({
@@ -7,10 +10,10 @@ Page({
     navUrl: '',
     code: '',
     login_img: "/image/4Dage/login-bg.svg",
-    login_logo: "/image/4Dage/login-logo.svg"    
+    login_logo: "/image/4Dage/login-logo.svg"
   },
 
-  onLoad: function(options) {
+  onLoad: function (options) {
     wx.login({
       success: (res) => {
         if (res.code) {
@@ -21,21 +24,27 @@ Page({
       }
     });
   },
-  onReady: function() {
+  onReady: function () {
     // 页面渲染完成
   },
-  onShow: function() {
+  onShow: function () {
     // 页面显示
   },
-  onHide: function() {
+  onHide: function () {
     // 页面隐藏
   },
-  onUnload: function() {
+  onUnload: function () {
     // 页面关闭
   },
   bindgetphonenumber(e) {
     loginFn(e, this.data.code, true).then(() => {
       wx.navigateBack()
     })
-  }
+  },
+  bindgetuserinfo() {
+    loginByUserInfo().then(res => {
+      // this.triggerEvent('loginSuccess')
+      wx.navigateBack()
+    })
+  },
 })

+ 2 - 1
apps/agent/pages/login/login.wxml

@@ -12,5 +12,6 @@
     <view>四维时代网络科技有限公司申请获得以下权限</view>
     <view>· 获得您的公开信息(昵称、头像等)</view>
   </view>
-  <button  wx:if="{{canIUse}}" class='btn_login' open-type="getPhoneNumber" bindgetphonenumber="bindgetphonenumber">授权登录</button>
+  <!-- <button  wx:if="{{canIUse}}" class='btn_login' open-type="getPhoneNumber" bindgetphonenumber="bindgetphonenumber">授权登录</button> -->
+  <button  wx:if="{{canIUse}}" class='btn_login' open-type="bindgetuserinfo" bindtap="bindgetuserinfo">授权登录</button>
 </view>

+ 58 - 26
apps/agent/pages/my/my.js

@@ -1,6 +1,8 @@
-import login from '../../utils/login'
+import {login,loginByUserInfo } from '../../utils/login'
 import Toast from '../../components/vant-ui/toast/toast';
-import { subcribe } from '../../utils/utils'
+import {
+    subcribe
+} from '../../utils/utils'
 const app = getApp();
 Page({
     options: {
@@ -10,18 +12,33 @@ Page({
      * 页面的初始数据
      */
     data: {
-        cu_items: [
-            { title: '我关注的房源', icon: 'house', value: '/pages/follow-list/follow-list'},
-            { title: '关于我们', icon: 'about', value: '/pages/about/about' },
-            { title: '消息订阅', icon: 'guanzhu', action: 'dingyue', value: 'null'}
+        cu_items: [{
+                title: '我关注的房源',
+                icon: 'house',
+                value: '/pages/follow-list/follow-list'
+            },
+            {
+                title: '关于我们',
+                icon: 'about',
+                value: '/pages/about/about'
+            },
+            {
+                title: '消息订阅',
+                icon: 'guanzhu',
+                action: 'dingyue',
+                value: 'null'
+            }
         ],
         user_code: '',
         isLogined: app.globalData.token ? true : false,
         userinfo: app.globalData.userinfo
     },
 
-    Navigator_to(e){
-        const { value, action } = e.currentTarget.dataset
+    Navigator_to(e) {
+        const {
+            value,
+            action
+        } = e.currentTarget.dataset
         if (value) {
             if (action === 'dingyue') {
                 this.subscribeMessage()
@@ -32,12 +49,12 @@ Page({
             })
         }
     },
-    toModifyUser () {
+    toModifyUser() {
         if (!this.data.isLogined) {
             return
         }
         wx.navigateTo({
-          url: '/pages/user-info/user-info',
+            url: '/pages/user-info/user-info',
         })
     },
     /**
@@ -54,45 +71,60 @@ Page({
         })
     },
     onShow: function () {
-        
+
         this.setData({
             isLogined: app.globalData.token ? true : false,
             userinfo: app.globalData.userinfo
         });
     },
-    bindgetphonenumber (e) {
-        login(e, this.data.user_code, true).then(res => {
+    bindgetphonenumber(e) {
+        // login(e, this.data.user_code, true).then(res => {
+        loginByUserInfo(e, this.data.user_code, true).then(res => {
             this.setData({
                 isLogined: app.globalData.token ? true : false,
                 userinfo: app.globalData.userinfo
             })
         })
     },
-    getSubscribeStatus () {
+    getSubscribeStatus() {
         wx.getSetting({
             withSubscriptions: true,
             success: (setting) => {
                 if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings['GApxDrE3tPhysRxHEmGHRn-0mvNJXqtZ4znZ8PJnQ8Q']) {
                     this.setData({
-                        cu_items: [
-                            { title: '我关注的房源', icon: 'house', value: '/pages/follow-list/follow-list'},
-                            { title: '关于我们', icon: 'about', value: '/pages/about/about' }
+                        cu_items: [{
+                                title: '我关注的房源',
+                                icon: 'house',
+                                value: '/pages/follow-list/follow-list'
+                            },
+                            {
+                                title: '关于我们',
+                                icon: 'about',
+                                value: '/pages/about/about'
+                            }
                         ]
                     })
                 }
             },
         })
     },
-    subscribeMessage () {
+    subscribeMessage() {
         subcribe().then(res => {
             wx.getSetting({
                 withSubscriptions: true,
                 success: (setting) => {
                     if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings[res.subId]) {
                         this.setData({
-                            cu_items: [
-                                { title: '我关注的房源', icon: 'house', value: '/pages/follow-list/follow-list'},
-                                { title: '关于我们', icon: 'about', value: '/pages/about/about' }
+                            cu_items: [{
+                                    title: '我关注的房源',
+                                    icon: 'house',
+                                    value: '/pages/follow-list/follow-list'
+                                },
+                                {
+                                    title: '关于我们',
+                                    icon: 'about',
+                                    value: '/pages/about/about'
+                                }
                             ]
                         })
                         return
@@ -103,10 +135,10 @@ Page({
                 },
             })
         })
-        
-        
-        
-        
+
+
+
+
         return
     }
-})
+})

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

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

+ 57 - 6
apps/agent/utils/login.js

@@ -67,6 +67,26 @@ function tips (res) {
   }
 }
 
+//获取用户信息接口
+function getUserProfile() {
+  return new Promise((resovle, reject) => {
+    wx.getUserProfile({
+      desc: "用于完善用户资料", 
+      //异步请求:回调函数中调用下一个函数
+      success (res)  {
+        resovle(res)
+      },
+      fail(err) {
+        wx.showModal({
+          title: "登录失败",
+          content: "网络异常,请重试",
+        })
+        reject(err)
+      },
+    });
+    
+  })
+}
 export default function Login(phone_data, code, isAgency) {
   const { encryptedData, iv } = phone_data.detail
   if (!encryptedData || !iv) {
@@ -95,23 +115,55 @@ 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({
+//       withCredentials: true,
+//       success (res) {
+//         console.log(res)
+//         res.wx_code = code
+//         UserApi.loginByUserInfo(res).then(loginRes => {
+//           const data = loginRes.data
+//           data.user = data.user || data.agency
+//           data.user.user_id = data.user.user_id || data.user.agency_user_id
+//           saveToken(data.token)
+//           saveUserInfo(data.user)
+//           getApp().globalData.token = data.token
+//           getApp().globalData.userinfo = data.user
+//           EventEmitter.emit('login')
+//           wx.hideLoading()
+//           resolve(res)
+//         })
+//       },
+//       fail (err) {
+//         wx.hideLoading()
+//         reject(err)
+//       }
+//     })
+//   })
+  
+// }
 export async function loginByUserInfo () {
-  wx.showLoading('登录中')
+  // wx.showLoading('登录中')
+  let UserProfile  = await getUserProfile()
   return new Promise(async (resolve, reject) => {
     let code = await wxLogin()
     wx.getUserInfo({
       withCredentials: true,
       success (res) {
-        console.log(res)
         res.wx_code = code
         UserApi.loginByUserInfo(res).then(loginRes => {
           const data = loginRes.data
           data.user = data.user || data.agency
-          data.user.user_id = data.user.user_id || data.user.agency_user_id
+          UserProfile.userInfo.user_id = data.user.user_id || data.user.agency_user_id
           saveToken(data.token)
-          saveUserInfo(data.user)
           getApp().globalData.token = data.token
-          getApp().globalData.userinfo = data.user
+          UserProfile.userInfo.name = UserProfile.userInfo.name || UserProfile.userInfo.nickName
+          UserProfile.userInfo.avatar = UserProfile.userInfo.avatar || UserProfile.userInfo.avatarUrl
+          getApp().globalData.userinfo =UserProfile.userInfo
+          saveUserInfo(UserProfile.userInfo)
           EventEmitter.emit('login')
           wx.hideLoading()
           resolve(res)
@@ -123,5 +175,4 @@ export async function loginByUserInfo () {
       }
     })
   })
-  
 }