Browse Source

Merge branch 'master' of http://39.106.8.246:3003/sagacloud/sagacloud-sagacare-weChat

zhaojing 1 năm trước cách đây
mục cha
commit
c22cc86e15

+ 2 - 2
src/api/user.js

@@ -53,7 +53,7 @@ function getCompanyByPhone(params) {
 }
 
 // 根据code获取手机号
-function getPhoneNumber(code) {
+function getHttpPhoneNumber(code) {
   return $http({
     url: `${config.duoduoenvService}userNew/wechat/getPhoneNumber?code=${code}`,
     method: 'get'
@@ -72,7 +72,7 @@ function refreshToken(refreshToken) {
 export {
   getCompmayUsers,
   getUserInfo,
-  getPhoneNumber,
+  getHttpPhoneNumber,
   getCompanyByPhone,
   register,
   login,

+ 5 - 5
src/common/request.js

@@ -37,7 +37,7 @@ function commonParams() {
     url = url + `&userId=${storeUser().userId}`
   }
   if (storeToken()) {
-    url = url + `&saga_token=${storeToken()}`
+    // url = url + `&saga-token=${storeToken()}`
   }
   return url;
 }
@@ -65,9 +65,9 @@ export default function (info) {
 
   const token = store.state.user.token;
   if (token) {
-    info.header = Object.assign(
-      { 'saga_token': token }
-      , info.header)
+    // info.header = Object.assign(
+    //   { 'saga-token': token }
+    //   , info.header)
   }
 
   info.timeout = info.timeout || 10 * 1000; // 默认超时为10s
@@ -96,7 +96,7 @@ export default function (info) {
         if (res.statusCode === 401) {
           if (checkTokenIsValid() == 2) { // 登录过期后重新从首页刷新进入
             // store.commit('clearToken','');
-            wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
+            // wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
           }
         } else if (res.statusCode >= 400) {
           reject(res.errMsg);

+ 1 - 34
src/common/utils.js

@@ -5,47 +5,14 @@ import {
 import moment from 'moment';
 
 export default {
-  genId,
-  getGenderDesc,
-  getTwoNum,
-  getFutureDayList,
-  getWeekDesc,
-  getHourList,
-  getHourObj,
-  payItemsC2S,
-  payItemsS2C,
-  invitationS2C,
   formateTime,
-  getHour12Desc,
-  addUrlVersion,
-  addUrlParams,
-  getPeriodTimeDesc,
-  getDateSimpleDesc,
-  getDateDesc,
   debounce,
-  formatepmValueToStatusText,
-  getPmfromHttpResult,
   getUrlParams,
-  // 刷新接口
-  refreshCode,
   // 轮训获取
   getQrcode,
   formateEnvIndicatorValue,
   random,
-  getTextHcho,
-  getTextCO2,
-  getTextHumidity,
-  getTextPM,
-  getEnvIndectorDesc,
-  formatePassLinkToText,
-  formatePassLinkItemToText,
-  generateImgRandomStr,
-  getSearchRegEx,
-  formateInvitationPassLink,
-  formateDateDurationTime,
-  transformColorHex2Rgba,
-  isDeepColor,
-  previewAgreement
+  getSearchRegEx
 };
 
 let seed = 0;

+ 9 - 23
src/packagesEnv/pages/intelligentControl/components/floor/floor.wpy

@@ -96,45 +96,31 @@
 
 <template>
   <!-- && selectedFloor == item.id -->
+  <!-- :class="{'selected' :selectedBuilding == item.id}" -->
   <div class="{{'component-floor '+status}}">
     <div class="component-wrapper">
       <div class="building-wrapper">
-      <div class="building-item" 
-      :key="index+'building-map'"
-      :class="{'selected' :selectedBuilding == item.id}"
-      v-if="status=='expand' || (status=='fold' && selectedBuilding == item.id)"
-      v-for="(item,index) in buildings">
-      {{item.localName}}
-      </div>
-    </div>
+        <div class="building-item" 
+        :key="index+'building-map'"
+        v-for="(item,index) in buildings">
+        {{item.localName}}
+        </div>
+     </div>
 
+     <!-- :class="{'selected' :selectedFloor == item.id}" -->
       <div class="floor-wrapper">
         <div
           class="floor-item"
-          :class="{'selected' :selectedFloor == item.id}"
           :key="index+'map'"
           v-for="(item,index) in floors"
           v-on:click.stop="changeFloor(item.id)"
           v-if="status=='expand' || (status=='fold' && selectedFloor == item.id)"
         >
         {{item.localName}}
-      </div>
+       </div>
 
       </div>
     </div>
-    <div class="icon-arrow" 
-         wx:if="{{status=='expand'}}">
-         <div class="icon-arrow-box">
-          <label>收起</label>
-          <image
-            mode="scaleToFill"
-            class="icon"
-            src="{{h5StaticPath+ 'icon-floor-arrow.svg'}}"
-            v-on:click.stop="flodFloor"
-          />
-         </div>
-         
-  </div>
   </div>
 </template>
 

+ 137 - 23
src/packagesEnv/pages/intelligentControl/home2.wpy

@@ -10,6 +10,65 @@
     background: #f7f8fa;
   }
 }
+.tool-box {
+  position: fixed;
+  bottom: 272rpx;
+  right: 40rpx;
+  z-index: 333;
+  .search-btn-box {
+    overflow: hidden;
+    text-align: right;
+    image {
+      float: right;
+      width: 88rpx;
+      height: 88rpx;
+    }
+  }
+  .search-btn {
+    margin-bottom: 16rpx;
+    width: 88rpx;
+    height: 88rpx;
+    display: block;
+    border-radius: 16rpx;
+  }
+  .now-floor {
+    box-sizing: border-box;
+    padding: 20rpx 0;
+    background: #ffffff;
+    border-radius: 16rpx;
+    box-shadow: 0px 4px 12px 0px #00000008;
+    .select-building {
+      display: inline-block;
+      vertical-align: middle;
+      padding-left: 28rpx;
+      padding-right: 24rpx;
+      font-family: PingFang SC;
+      font-size: 32rpx;
+      font-weight: 500;
+      line-height: 44rpx;
+      text-align: center;
+    }
+
+    .line {
+      display: inline-block;
+      vertical-align: middle;
+      height: 36rpx;
+      width: 1px;
+      background: #e1e5eb;
+    }
+    .select-floor {
+      display: inline-block;
+      vertical-align: middle;
+      padding: 0 24rpx;
+      font-family: PingFang SC;
+      font-size: 32rpx;
+      font-weight: 500;
+      line-height: 44rpx;
+      text-align: center;
+      background: #fff;
+    }
+  }
+}
 
 .page-intelligent-control .map-contanier {
   //   height: 100%;
@@ -21,30 +80,16 @@
 }
 
 .page-intelligent-control .location-wrapper {
-  position: absolute;
-  bottom: 36rpx;
-  right: 32rpx;
+  position: fixed;
+  bottom: 272rpx;
+  right: 40rpx;
+  z-index: 444;
   &.fold {
   }
   &.building {
   }
 }
 
-.search-btn-box {
-  display: flex;
-  justify-content: flex-end;
-}
-.page-intelligent-control .location-wrapper .search-btn {
-  // position: absolute;
-  // right: 0;
-  margin-bottom: 16rpx;
-  width: 96rpx;
-  height: 96rpx;
-  display: block;
-  background: #ffffff;
-  border-radius: 16rpx;
-}
-
 .page-intelligent-control .location-wrapper.expand {
   bottom: 658rpx;
 }
@@ -207,6 +252,36 @@ movable-view {
     border-radius: 60rpx;
   }
 }
+.icon-arrow {
+  text-align: right;
+  .icon-arrow-box {
+    margin-top: 8rpx;
+    box-sizing: border-box;
+    padding: 22rpx;
+    border-radius: 8px;
+    display: inline-block;
+    height: 44px;
+    line-height: 44px;
+    width: 60px;
+    background: #fff;
+    box-shadow: 0px 4px 12px 0px #00000008;
+    label {
+      display: inline-block;
+      vertical-align: middle;
+      font-family: PingFang SC;
+      font-size: 32rpx;
+      font-weight: 500;
+      letter-spacing: 0px;
+    }
+    image {
+      display: inline-block;
+      vertical-align: middle;
+      margin-left: 16rpx;
+      width: 24rpx;
+      height: 24rpx;
+    }
+  }
+}
 </style>
 <template>
   <div class="page-intelligent-control" v-on:click="flodFloorFun">
@@ -278,15 +353,25 @@ movable-view {
                 />
           </div>
         </movable-view>
-        <div class="{{'location-wrapper ' + foldStatus}}">
+
+        <div class="tool-box" v-if="foldStatus!=='expand'">
           <div class="search-btn-box">
             <image
             v-on:click="toSearchPage"
             class="search-btn"
             src="{{h5StaticPath}}icon-search-big.svg"
             />
+         </div>
+         <div class="now-floor" 
+             v-on:click="changeBuilding">
+            <div class="select-building">东南栋</div>
+            <div class="line"></div>
+            <div class="select-floor">F1</div>
           </div>
-          
+        </div>
+        
+        <div v-if="foldStatus=='expand'" class="location-wrapper">
+          <!--楼层和建筑数据-->
           <floor
             status="{{floorStatus}}"
             :floors="floors"
@@ -297,6 +382,19 @@ movable-view {
             @component-floor-change="changeFloorFun($event)"
             @component-floor-click="toggleFloorStatus"
           ></floor>
+
+         <!--查看更多 -->
+        <div class="icon-arrow">
+         <div class="icon-arrow-box">
+          <label>收起</label>
+          <image
+            mode="scaleToFill"
+            class="icon"
+            src="{{h5StaticPath+ 'icon-floor-arrow.svg'}}"
+            v-on:click.stop="flodFloor"
+          />
+         </div> 
+         </div>
         </div>
       </movable-area>
     </div>
@@ -423,6 +521,10 @@ wepy.component({
       this.projectId = 'Pj1101080259';
       this.getPageBuildingList();
     },
+    // 展开建筑
+    changeBuilding() {
+      this.foldStatus = 'expand';
+    },
     //获取建筑数据
     getPageBuildingList() {
       let params = {
@@ -431,7 +533,20 @@ wepy.component({
         }
       };
       getBuildingList(params).then(res => {
-        this.buildingData = res.content || [];
+        // this.buildingData = res.content || [];
+        this.buildingData = [
+          {
+            id: 1,
+            localName: '冬暖冬冬'
+          },
+          {
+            id: 2,
+            localName: '冬暖冬冬暖冬冬暖冬'
+          },
+          {
+            localName: '冬暖冬冬暖冬冬暖冬冬暖冬冬暖冬冬暖冬'
+          }
+        ];
         this.buildingItem = this.buildingData[0];
         this.selectedBuilding = this.buildingItem.id;
         this.getFloorList();
@@ -684,8 +799,7 @@ wepy.component({
       });
     },
     toSearchPage() {
-      wx.uma.trackEvent('officeHome_map-find', { key: '环境调节-地图-找找' });
-
+      console.log('被点击了');
       wx.navigateTo({
         url: `/packagesEnv/pages/intelligentControl/search/search?canSearchPerson=${
           this.canSearchPerson

+ 10 - 9
src/pages/auth/index.wpy

@@ -90,7 +90,7 @@ import { mapState } from '@wepy/x';
 import store from '@/store';
 import config from '@/config';
 import { setAvatar, setUserInfoByAuth } from '@/service/user';
-import { getCompanyByPhone } from '@/api/user';
+import { getHttpPhoneNumber } from '@/api/user';
 let defaultAvatarUrl =
   config.h5StaticPath + '/page-bind-tenant/default_avatar.svg';
 wepy.page({
@@ -136,16 +136,17 @@ wepy.page({
     },
     // 手机号认证
     phonenumberAuth(e) {
-      console.log(e);
-      // this.goBindTenant();
       let detail = e.$wx.detail;
       let code = detail.code;
-      let errMsg = detail.errMsg;
-      console.log(detail);
-      store.commit('setUserPhone', 15321277745);
-      // wx.setStorage('userPhone', 15321277745);
-      wx.navigateTo({
-        url: '/pages/bindTenant/index'
+      this.getHttpPhoneNumber(code);
+    },
+    // code 换取手机号
+    getHttpPhoneNumber(code) {
+      getHttpPhoneNumber(code).then(res => {
+        let data = res.data || {};
+        let phoneNumber = data.purePhoneNumber;
+        store.commit('setUserPhone', phoneNumber);
+        this.goBindTenant();
       });
     },
     goBindTenant() {

+ 4 - 0
src/pages/index.wpy

@@ -81,6 +81,7 @@ wepy.page({
     goBindTenant() {
       this.goAuth();
     },
+    // 判断用户是否认证过
     checkTenantRegist() {
       wxLogin(1)
         .then(res => {
@@ -111,6 +112,9 @@ wepy.page({
       wx.navigateTo({
         url: '/packagesEnv/pages/home/index'
       });
+      // wx.navigateTo({
+      //   url: '/pages/auth/index'
+      // });
     },
     goAuth() {
       console.log('被点击了');

+ 32 - 22
src/service/user.js

@@ -176,28 +176,38 @@ function getCompanyDataByPhone() {
 
 // 登录续约
 function refreshTokenPage() {
-  refreshToken().then(res => {
-    if (res.result == 'success') {
-      let data = res.data || []
-      let tokenInfo = {
-        expireTime: data.expireTime,
-        startTime: data.startTime,
-        refreshTokenExpireTime: data.refreshTokenExpireTime,
-        refreshToken: data.refreshToken
-      };
-      store.commit('setToken', data.token);
-      store.commit('setActivated', data.isActivated);
-      store.commit('setTokenInfo', tokenInfo);
-      if (data.isActivated && data.isActivated == 1) {
-        store.commit('setUserInfo', data.tokenUser);
-      } else {
-        wx.redirectTo({ url: '/pages/index' });
-        store.commit('setUserInfo', {});
+  return new Promise((resolve, reject) => {
+    refreshToken().then(res => {
+      if (res.result == 'success') {
+        let data = res.data || []
+        let tokenInfo = {
+          expireTime: data.expireTime,
+          startTime: data.startTime,
+          refreshTokenExpireTime: data.refreshTokenExpireTime,
+          refreshToken: data.refreshToken
+        };
+        store.commit('setToken', data.token);
+        store.commit('setActivated', data.isActivated);
+        store.commit('setTokenInfo', tokenInfo);
+        if (data.isActivated && data.isActivated == 1) {
+          store.commit('setUserInfo', data.tokenUser);
+          resolve(data)
+        } else {
+          store.commit('setToken', '')
+          // store.commit('setUserInfo', {});
+          wx.redirectTo({ url: '/pages/index' });
+          resolve(data)
+        }
       }
-    }
-  }).catch(() => {
-    wxLogin()
+    }).catch(() => {
+      resolve("续约失败")
+      store.commit('setToken', '')
+      wx.redirectTo({ url: '/pages/index' });
+      // store.commit('setUserInfo', {});
+      // wxLogin()
+    })
   })
+
 }
 // 检查是否登录过以及过期
 function checkLoginNew() {
@@ -207,9 +217,9 @@ function checkLoginNew() {
   } else {
     let flag = checkTokenIsValid()
     if (flag == 1) {
-      refreshTokenPage(); // 续约
+      return refreshTokenPage(); // 续约
     } else if (flag == 2) { // 重新登录
-      wxLogin();
+      return wxLogin();
     } else if (flag == 3) {  // 后续补定时器定时续约逻辑
 
     }

+ 22 - 2
src/utils/index.js

@@ -1,4 +1,4 @@
-
+import store from '@/store';
 function getMiniProgram() {
     const miniProgram = wx.getAccountInfoSync();
     return miniProgram;
@@ -21,10 +21,30 @@ function getTimeStamp() {
     return timeStamp;
 }
 
+// http请求通用参数
+function commonParams() {
+    // openid=${storeUser().openId}&
+    let url = `pubname=${config.brsgServer.pubname}`
+    if (storeUser().projectId) {
+        url = url + `&projectId=${storeUser().projectId}`
+    }
+    if (storeUser().userName) {
+        url = url + `&userName=${storeUser().userName}`
+    }
+    if (storeUser().userId) {
+        url = url + `&userId=${storeUser().userId}`
+    }
+    if (storeToken()) {
+        url = url + `&saga-token=${storeToken()}`
+    }
+    return url;
+}
+
 
 export {
     getAppId,
     getVersion,
     getTimeStamp,
-    getMiniProgram
+    getMiniProgram,
+    commonParams
 }