Browse Source

fix: 会议室有人和无人的样式修改

chenzhen2 2 years ago
parent
commit
fc87ae8b1e

+ 6 - 1
components/spacecard/index.wxml

@@ -15,7 +15,12 @@
 			<view class="card_name">
 				<view class="nametxt">
 					<text>{{cardDate.localName}}</text>
-                    <text wx:if="{{cardDate.isPassengerPassShow}}" class="peoplestate {{cardDate.isPassengerPass=='有人'?'activepeople':''}}">{{cardDate.isPassengerPass}}</text>
+                    <view wx:if="{{cardDate.isPassengerPassShow}}" 
+					class="peoplestate {{cardDate.isPassengerPass=='有人'?'activepeople':''}}">
+					<image wx:if="{{cardDate.isPassengerPass=='有人'}}"  src="../../static/images/person-active.svg"></image>
+					<image wx:else src="../../static/images/person.svg"></image>		
+					 <text>{{cardDate.isPassengerPass}}</text>
+					</view>
 				</view>
 				<view class="imgbox">
 					<view  class="lottie {{canvashidden?'':lottiehidden}}" wx:if="{{canvashidden}}">

+ 21 - 6
components/spacecard/index.wxss

@@ -64,16 +64,31 @@
 .nametxt .peoplestate{
   display: inline-block;
   box-sizing: border-box;
-  padding: 1px 7px;
   margin-left: 10px;
-  background: #34c724;
+  background: #EDF1F5;
   vertical-align: middle;
-  color: #ffffff;
-  border-radius: 12px;
-  font-size: 20rpx;
+  width:90rpx;
+  height:32rpx;
+  color: #626C78;
+  border-radius: 8px;
+  font-size: 0px;
+  text-align:center;
+
+}
+.nametxt .peoplestate image {
+  width:20rpx;
+  height:20rpx;
+  margin-right:4rpx;
+  display: inline-block;
+  vertical-align: middle;
+}
+.nametxt .peoplestate text {
+  display: inline-block;
+  font-size:20rpx;
+  line-height:32rpx;
 }
 .nametxt .activepeople{
-  background: #f54e45;
+  background: #EDF1F5;
 }
 .imgbox text{
   color: #80838F;

+ 39 - 13
pages/adjust/index.js

@@ -3,6 +3,7 @@ import router from "./../../utils/router";
 import { getSetting, getLocation } from "./../../utils/auth";
 const AUTH = require("../../utils/auth");
 import icons from "../../utils/icon";
+import { getUrlParams } from '../../utils/util'
 import {
     getPropertyData,
     submitAdjust,
@@ -18,6 +19,7 @@ import {
     getSpacedetail,
     openSpace,
     workLeave,
+    comfirmCodeLogin,
     contactTenant,
 } from "../../requests/api";
 let refreshTimer = null;
@@ -168,8 +170,8 @@ Page({
     goBack() {
         router.pop();
     },
-     // 获取扫码结果
-     getScancode: function () {
+    // 获取扫码结果
+    getScancode: function () {
         // if (!$.storage.get('logined')) {
         //   router.push('auth');
         //   return
@@ -190,14 +192,17 @@ Page({
             },
         });
     },
-     // 检查二维码
-     async checkCode(value) {
+    // 检查二维码
+    async checkCode(value) {
+        // debugger
         console.log(value, 381);
         let scanArr = value.split("?");
         let domain = scanArr[0];
+        let type = getUrlParams(scanArr[1], 'type')
         let qualifiedUrl = [
             "http://meos.sagacloud.cn/scan",
             "https://duoduoenv.sagacloud.cn/scan",
+            "http://192.168.17.121:9999/borui/home"
         ];
         if (qualifiedUrl.includes(domain)) {
             let md = scanArr[1].split("=") || [];
@@ -205,11 +210,32 @@ Page({
             console.log("扫码了====")
             // router.push("adjust", { md1 });
             // debugger
-            router.push("ipdauth",{ spaceid: this.data.spaceDetail.id})
+            if (type === 'ipad') {
+                this.confirmLogin(scanArr[1])
+            } else {
+                router.push("ipdauth", { spaceid: this.data.spaceDetail.id })
+            }
         } else {
             Toast.fail("无效的二维码");
         }
     },
+    confirmLogin(value) {
+        let id = getUrlParams(value, 'id')
+        let mac = getUrlParams(value, 'mac')
+        let projectId = $.store.get("projectId") || $.storage.get("projectId")
+        let param = {
+            qrCodeId: id,
+            macAddress: mac,
+            status: 1,  // 0-未扫码 1-已扫描 2-已确认 3-已经失效
+            projectId: projectId,
+            spaceId: this.data.spaceDetail.id
+        }
+        comfirmCodeLogin(param).then(res => {
+            router.push("ipdauth", { 'id': id, 'mac': mac, spaceId: this.data.spaceDetail.id })
+        }).catch(() => {
+            router.push("ipdauth", { 'id': id, 'mac': mac, spaceId: this.data.spaceDetail.id })
+        })
+    },
     changeMode() {
         if (this.data.spaceDetail.isClose.toString() !== "true") {
             this.setData({ StandardMode: !this.data.StandardMode }, () => {
@@ -286,9 +312,9 @@ Page({
                 showCancel: false,
                 confirmText: "我知道了", //默认是“确定”
                 // confirmColor: 'skyblue',//确定文字的颜色
-                success: function (res) {},
-                fail: function (res) {}, //接口调用失败的回调函数
-                complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
+                success: function (res) { },
+                fail: function (res) { }, //接口调用失败的回调函数
+                complete: function (res) { }, //接口调用结束的回调函数(调用成功、失败都会执行)
             });
             return;
         }
@@ -420,9 +446,9 @@ Page({
                 showCancel: false,
                 confirmText: "我知道了", //默认是“确定”
                 // confirmColor: 'skyblue',//确定文字的颜色
-                success: function (res) {},
-                fail: function (res) {}, //接口调用失败的回调函数
-                complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
+                success: function (res) { },
+                fail: function (res) { }, //接口调用失败的回调函数
+                complete: function (res) { }, //接口调用结束的回调函数(调用成功、失败都会执行)
             });
             return;
         }
@@ -685,7 +711,7 @@ Page({
                 targetTemp = parseInt(
                     (value[index].temperatureMax +
                         value[index].temperatureMin) /
-                        2
+                    2
                 );
                 this.setData({
                     targetTemp: targetTemp,
@@ -859,7 +885,7 @@ Page({
             title: "提示",
             content: "非工作时间如需使用空调,或遇特殊问题,请联系环境管理员",
             showCancel: false,
-            success: function (res) {},
+            success: function (res) { },
         });
     },
     chartChange(e) {

+ 5 - 1
pages/adjust/index.wxml

@@ -39,7 +39,11 @@
             <view class="msg_left">
                 <view class="msg_left_text">
                   <text class="spacename">{{spaceDetail.localName}}</text>
-                <text wx:if="{{spaceDetail.isPassengerPassShow}}" class="peoplestate {{spaceDetail.isPassengerPass=='有人'?'activepeople':''}}">{{spaceDetail.isPassengerPass}}</text>
+                <view wx:if="{{spaceDetail.isPassengerPassShow}}" class="peoplestate {{spaceDetail.isPassengerPass=='有人'?'activepeople':''}}">
+                   <image wx:if="{{spaceDetail.isPassengerPass=='有人'}}"  src="../../static/images/person-active.svg"></image>
+				   <image wx:else src="../../static/images/person.svg"></image>	
+                   <text>{{spaceDetail.isPassengerPass}}</text>
+                </view>
                 <image class="scan_img" bindtap="getScancode"  src="../../static/images/scan.svg"></image>
                 </view>
                 <view class="spacestate flex_row">

+ 23 - 6
pages/adjust/index.wxss

@@ -149,16 +149,33 @@ page {
 .adjust_main .space_msg .msg_left .peoplestate {
   display: inline-block;
   box-sizing: border-box;
-  padding: 1px 7px;
   margin-left: 10px;
-  background: #34c724;
+  background: #EDF1F5;
   vertical-align: middle;
-  color: #ffffff;
-  border-radius: 12px;
-  font-size: 20rpx;
+  width:90rpx;
+  height:32rpx;
+  color: #626C78;
+  font-size:0px;
+  border-radius: 8px;
+  text-align:center;
+}
+.space_msg .msg_left .peoplestate  image {
+  width:20rpx;
+  height:20rpx;
+  margin-right:4rpx;
+  display: inline-block;
+  vertical-align: middle;
+}
+.space_msg .msg_left .peoplestate text {
+  display: inline-block;
+  font-size:20rpx;
+  vertical-align: middle;
+  height:32rpx;
+  line-height:32rpx;
 }
+
 .adjust_main .space_msg .msg_left .activepeople {
-  background: #f54e45;
+  background: #EDF1F5;
 }
 .adjust_main .space_msg .msg_left .spacestate {
   font-size: 30rpx;

+ 30 - 3
pages/index/index.js

@@ -8,9 +8,11 @@ import {
 } from "../../utils/auth";
 const AUTH = require("../../utils/auth");
 import icons from "../../utils/icon";
+import { getUrlParams } from '../../utils/util'
 import Toast from "../../vant-weapp/dist/toast/toast";
 import {
     getopenId,
+    comfirmCodeLogin,
     userCheck,
     getSpaceAdjustList,
     spaceTop,
@@ -503,6 +505,7 @@ Page({
                 }
             },
             success: (res) => {
+                // let result = res.result
                 this.checkCode(res.result);
             },
             fail: (res) => {
@@ -516,24 +519,48 @@ Page({
     },
     // 检查二维码
     async checkCode(value) {
+        // debugger
         console.log(value, 381);
         let scanArr = value.split("?");
         let domain = scanArr[0];
         let qualifiedUrl = [
             "http://meos.sagacloud.cn/scan",
             "https://duoduoenv.sagacloud.cn/scan",
+            "http://192.168.17.121:9999/borui/home"
         ];
+        let type = getUrlParams(scanArr[1], 'type')
+        // debugger
         if (qualifiedUrl.includes(domain)) {
             let md = scanArr[1].split("=") || [];
             let md1 = md[1];
             console.log("扫码了====")
             // router.push("adjust", { md1 });
             // debugger
-            router.push("ipdauth")
+            if (type === 'ipad') {
+                this.confirmLogin(scanArr[1])
+            } else {
+                router.push("adjust", { md1 });
+            }
         } else {
             Toast.fail("无效的二维码");
         }
     },
+    confirmLogin(value) {
+        let id = getUrlParams(value, 'id')
+        let mac = getUrlParams(value, 'mac')
+        let projectId = $.store.get("projectId") || $.storage.get("projectId")
+        let param = {
+            qrCodeId: id,
+            macAddress: mac,
+            status: 1,  // 0-未扫码 1-已扫描 2-已确认 3-已经失效
+            projectId: projectId
+        }
+        comfirmCodeLogin(param).then(res => {
+            router.push("ipdauth", { 'id': id, 'mac': mac })
+        }).catch(() => {
+            router.push("ipdauth", { 'id': id, 'mac': mac })
+        })
+    },
     async userLogin() {
         let that = this;
         let isLogined = await checkHasLogined();
@@ -648,10 +675,10 @@ Page({
     /**
      * 页面上拉触底事件的处理函数
      */
-    onReachBottom: function () {},
+    onReachBottom: function () { },
 
     /**
      * 用户点击右上角分享
      */
-    onShareAppMessage: function () {},
+    onShareAppMessage: function () { },
 });

+ 28 - 13
pages/ipdauth/index.js

@@ -1,33 +1,48 @@
 import $ from "./../../utils/Tool";
+import {
+  comfirmCodeLogin
+} from "../../requests/api";
+import router from "../../utils/router";
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    spaceId:'',
-    projectId:''
+    qrCodeId: "",
+    macAddress: '',
+    projectId: '',
+    spaceId: ''
   },
   // 确认登录
-  confirmLogin(){
-    let projectId=$.store.get("projectId") || $.storage.get("projectId")
-    console.log("获取项目id")
-    console.log(projectId)
+  confirmLogin() {
+    let param = {
+      qrCodeId: this.data.qrCodeId,
+      macAddress: this.data.macAddress,
+      status: 2,  // 0-未扫码 1-已扫描 2-已确认 3-已经失效
+      projectId: this.data.projectId,
+      spaceId: this.data.spaceId
+    }
+    comfirmCodeLogin(param).then(res => {
+      // if (res.result === 'success') {
+      //   // Toast.success("已确认");
+      // }
+      router.pop();
+    })
   },
   // 取消登录
-  cancelLoginn(){
-
+  cancelLoginn() {
+    router.pop();
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
     options = JSON.parse(decodeURIComponent(JSON.stringify(options)))
-    let {spaceid} = options
-    let projectId=$.store.get("projectId") || $.storage.get("projectId")
-    this.setData({spaceId:spaceid,projectId:projectId})
-    console.log("projectid==="+projectid)
-    console.log("spaceid===="+spaceid)
+    // debugger
+    let { id, mac, spaceId } = options
+    let projectId = $.store.get("projectId") || $.storage.get("projectId")
+    this.setData({ qrCodeId: id, macAddress: mac, projectId: projectId, spaceId: spaceId })
   },
 
   /**

+ 8 - 12
project.config.json

@@ -5,7 +5,7 @@
     "include": []
   },
   "setting": {
-    "urlCheck": true,
+    "urlCheck": false,
     "es6": true,
     "enhance": true,
     "postcss": true,
@@ -22,7 +22,6 @@
     "checkSiteMap": true,
     "uploadWithSourceMap": true,
     "compileHotReLoad": false,
-    "lazyloadPlaceholderEnable": false,
     "useMultiFrameRuntime": true,
     "useApiHook": true,
     "useApiHostProcess": true,
@@ -33,15 +32,12 @@
     },
     "enableEngineNative": false,
     "useIsolateContext": true,
+    "useCompilerModule": true,
+    "userConfirmedUseCompilerModuleSwitch": false,
     "userConfirmedBundleSwitch": false,
     "packNpmManually": false,
     "packNpmRelationList": [],
-    "minifyWXSS": true,
-    "disableUseStrict": false,
-    "showES6CompileOption": false,
-    "useCompilerPlugins": false,
-    "minifyWXML": true,
-    "useStaticServer": true
+    "minifyWXSS": true
   },
   "compileType": "miniprogram",
   "libVersion": "2.11.1",
@@ -49,6 +45,10 @@
   "projectname": "env-pc",
   "simulatorType": "wechat",
   "simulatorPluginLibVersion": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  },
   "condition": {
     "miniprogram": {
       "list": [
@@ -90,9 +90,5 @@
         }
       ]
     }
-  },
-  "editorSetting": {
-    "tabIndent": "insertSpaces",
-    "tabSize": 2
   }
 }

+ 79 - 74
requests/api.js

@@ -1,133 +1,137 @@
-import {http} from './http'
+import { http } from './http'
 //是否为测试环境
 const test = false;
 //  需要先调用远程权限的接口
-function getopenId(code){
-  return http.get('/duoduo-service/wechat-service/wechat/app/getOpenId',{code:code})
+function getopenId(code) {
+  return http.get('/duoduo-service/wechat-service/wechat/app/getOpenId', { code: code })
 }
 
-function getuserPhone(data){
-  return  http.get('/duoduo-service/wechat-service/wechat/app/getUserInfo',data)
+function getuserPhone(data) {
+  return http.get('/duoduo-service/wechat-service/wechat/app/getUserInfo', data)
 }
 
-function userCheck(data){
-  return  http.get('/server/user/check',data)
+function userCheck(data) {
+  return http.get('/server/user/check', data)
 }
 
-function userSave(data){
-  return http.post('/server/user/save',data)
+function userSave(data) {
+  return http.post('/server/user/save', data)
 }
 
-function userQuery(data){
-  return http.post('/server/user/query',data)
+function userQuery(data) {
+  return http.post('/server/user/query', data)
 }
 
-function userUpdate(data){
-  return http.post('/server/user/update',data)
+function userUpdate(data) {
+  return http.post('/server/user/update', data)
 }
 
-function spaceProperty(data){
-  return  http.get('/server/custom/spaceProperty',data,test)
+function spaceProperty(data) {
+  return http.get('/server/custom/spaceProperty', data, test)
 }
 
-function queryChart(data){
-  return  http.get('/server/space/queryPeriodData',data)
+function queryChart(data) {
+  return http.get('/server/space/queryPeriodData', data)
 }
 
-function queryAllspace(data){
-  return http.post('/server/space/queryAll',data,test)
+function queryAllspace(data) {
+  return http.post('/server/space/queryAll', data, test)
 }
 
-function queryFollowspace(data){
-  return http.post('/server/space/querySubscribe',data)
+function queryFollowspace(data) {
+  return http.post('/server/space/querySubscribe', data)
 }
 
 
-function powerCheck(data){
-  return http.post('/server/custom/check',data,test)
+function powerCheck(data) {
+  return http.post('/server/custom/check', data, test)
 }
 
-function workLeave(data){
-  return http.post('/server/custom/leave',data,test)
+function workLeave(data) {
+  return http.post('/server/custom/leave', data, test)
 }
 
-function nextOpen(data){
-  return http.post('/server/custom/nextOpenTime',data,test)
+function nextOpen(data) {
+  return http.post('/server/custom/nextOpenTime', data, test)
 }
 
-function getfeedBack(data){
-  return http.post('/server/custom/feedbackCreate',data,test)
+function getfeedBack(data) {
+  return http.post('/server/custom/feedbackCreate', data, test)
 }
 
-function getSpacedetail(data){
-  return http.post('/server/space/property',data,test)
+function getSpacedetail(data) {
+  return http.post('/server/space/property', data, test)
 }
 
-function openSpace(data){
-  return http.post('/server/custom/recover',data,test)
+function openSpace(data) {
+  return http.post('/server/custom/recover', data, test)
 }
 
-function getEquipmentAction(data){
-  return http.post('/server/custom/getEquipmentAction',data,test)
+function comfirmCodeLogin(data) {
+  return http.post('/server/padLogin/confirmPadLogin', data,'test')
 }
 
-function getSpaceAdjustList(data){
-  return http.post('/server/spaceAdjust/getSpaceAdjustList',data,test)
+function getEquipmentAction(data) {
+  return http.post('/server/custom/getEquipmentAction', data, test)
 }
-function getPropertyData(data){
-  return http.get('/server/spaceAdjust/queryPropertyData',data,test)
+
+function getSpaceAdjustList(data) {
+  return http.post('/server/spaceAdjust/getSpaceAdjustList', data, test)
+}
+function getPropertyData(data) {
+  return http.get('/server/spaceAdjust/queryPropertyData', data, test)
 }
-function getFeedbackList(data){
-  return http.post('/server/custom/adjustSpaceList',data,test)
+function getFeedbackList(data) {
+  return http.post('/server/custom/adjustSpaceList', data, test)
 }
-function getfeedbackSeason(data){
-  return http.post('/server/feedbackSeason/query',data,test)
+function getfeedbackSeason(data) {
+  return http.post('/server/feedbackSeason/query', data, test)
 }
-function getSpaceNum(data){
-  return http.post('/server/spaceAdjust/getSpaceNum',data,test)
+function getSpaceNum(data) {
+  return http.post('/server/spaceAdjust/getSpaceNum', data, test)
 }
-function spaceTop(data){
-  return http.post('/server/spaceAdjust/pcSaveAndUpdate',data,test)
+function spaceTop(data) {
+  return http.post('/server/spaceAdjust/pcSaveAndUpdate', data, test)
 }
-function deleteSpaceAdjust(data){
-  return http.get('/server/spaceAdjust/delete',data,test)
+function deleteSpaceAdjust(data) {
+  return http.get('/server/spaceAdjust/delete', data, test)
 }
-function gethouseKeeper(data){
-  return http.get('/server/duoduoenv/customerservice/queryCustomer',data,test)
+function gethouseKeeper(data) {
+  return http.get('/server/duoduoenv/customerservice/queryCustomer', data, test)
 }
-function getSeasonType(data){
-  return http.get('/duoduo-service/custom-service/custom/getSeasonType',data,test)
+function getSeasonType(data) {
+  return http.get('/duoduo-service/custom-service/custom/getSeasonType', data, test)
 }
-function getWeather(data){
-  return http.get('/duoduo-service/object-service/weather/getCurrentWeather',data,test)
+function getWeather(data) {
+  return http.get('/duoduo-service/object-service/weather/getCurrentWeather', data, test)
 }
-function submitFeedback(data){
-  return http.post('/server/feedbackSuggest/save',data,test)
+function submitFeedback(data) {
+  return http.post('/server/feedbackSuggest/save', data, test)
 }
-function submitAdjust(data){
-  return http.post('/server/custom/custormPlan',data,test)
+function submitAdjust(data) {
+  return http.post('/server/custom/custormPlan', data, test)
 }
-function getCurrentSeason(data){
-  return http.get('/duoduo-service/custom-service/custom/getSeasonType',data,test)
+function getCurrentSeason(data) {
+  return http.get('/duoduo-service/custom-service/custom/getSeasonType', data, test)
 }
-function contactTenant(data){
-  return http.post('/server/spaceAdjust/adjustSpace',data,test)
+function contactTenant(data) {
+  return http.post('/server/spaceAdjust/adjustSpace', data, test)
 }
 
-function getTransfrom(data){
-  return http.get('/duoduo-service/custom-service/custom/getSeasonBySeasonDate',data,test)
+function getTransfrom(data) {
+  return http.get('/duoduo-service/custom-service/custom/getSeasonBySeasonDate', data, test)
 }
-function queryQuestion(data){
-  return http.post('/server/question/queryQuestion',data,test)
+function queryQuestion(data) {
+  return http.post('/server/question/queryQuestion', data, test)
 }
-function queryUseranswer(data){
-  return http.post('/server/question/queryShowQuestion',data,test)
+function queryUseranswer(data) {
+  return http.post('/server/question/queryShowQuestion', data, test)
 }
-function submitAnswer(data){
-  return http.post('/server/question/saveUserQuestion',data,test)
+function submitAnswer(data) {
+  return http.post('/server/question/saveUserQuestion', data, test)
 }
-function notShowQuestion(data){
-  return http.post('/server/question/notShowQuestion',data,test)
+function notShowQuestion(data) {
+  return http.post('/server/question/notShowQuestion', data, test)
 }
 module.exports = {
   getopenId, // 获取到openId
@@ -148,7 +152,7 @@ module.exports = {
   openSpace, // 下班后开启调节
   getEquipmentAction, // 查询反馈后设备动作
   getSpaceAdjustList, //获取用户调节空间
-  getPropertyData ,//获取各参数数据
+  getPropertyData,//获取各参数数据
   getFeedbackList, // 获取调节记录
   getfeedbackSeason, // 获取季节调节记录
   getSpaceNum, //调节空间次数和数量
@@ -166,4 +170,5 @@ module.exports = {
   queryUseranswer, //查询用户是否要填写问卷
   submitAnswer,  //提交问卷答案
   notShowQuestion, //不再展示问卷
+  comfirmCodeLogin // 二维码登录
 }

+ 1 - 1
requests/http.js

@@ -1,6 +1,6 @@
 import $ from "../utils/Tool.js";
 import errorRequest from "./errorRequest.js";
-// const test = "http://192.168.12.20:50009"; //192.168.12.20 172.16.36.245
+const test = "http://192.168.0.47:52015"; //192.168.12.20 172.16.36.245
 const API_BASE_URL = "https://duoduoenv.sagacloud.cn";
 function get(url, data = {}, testenv) {
     let _url;

File diff suppressed because it is too large
+ 3 - 0
static/images/person-active.svg


File diff suppressed because it is too large
+ 3 - 0
static/images/person.svg


+ 53 - 53
utils/router.js

@@ -1,64 +1,64 @@
 const pages = {
-    home: '/pages/index/index',
-    adjust: '/pages/adjust/index',
-    detail:'/pages/detail/index',
-    auth:'/pages/auth/index',
-    search:'/pages/search/index',
-    projectlist:'/pages/projectlist/index',
-    usercenter:'/pages/usercenter/index',
-    feedback:'/pages/feedback/index',
-    spacelist:'/pages/spacelist/index',
-    search:'/pages/search/index',
-    adjustlog:'/pages/adjustlog/index',
-    spacelog:'/pages/spacelog/index',
-    ipdauth:'/pages/ipdauth/index'
-  }
+  home: '/pages/index/index',
+  adjust: '/pages/adjust/index',
+  detail: '/pages/detail/index',
+  auth: '/pages/auth/index',
+  search: '/pages/search/index',
+  projectlist: '/pages/projectlist/index',
+  usercenter: '/pages/usercenter/index',
+  feedback: '/pages/feedback/index',
+  spacelist: '/pages/spacelist/index',
+  search: '/pages/search/index',
+  adjustlog: '/pages/adjustlog/index',
+  spacelog: '/pages/spacelog/index',
+  ipdauth: '/pages/ipdauth/index'
+}
 
-  function to(page, data) {
-    if (!pages[page]) { throw new Error(`${page} is not exist!`) }
-    const _result = []
-    for (const key in data) {
-      const value = data[key]
-      if (['', undefined, null].includes(value)) {
-        continue
-      }
-      if (value.constructor === Array) {
-        value.forEach(_value => {
-          _result.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(_value))
-        })
-      } else {
-        _result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value))
-      }
+function to(page, data) {
+  if (!pages[page]) { throw new Error(`${page} is not exist!`) }
+  const _result = []
+  for (const key in data) {
+    const value = data[key]
+    if (['', undefined, null].includes(value)) {
+      continue
     }
-    const url = pages[page] + (_result.length ? `?${_result.join('&')}` : '')
-    return url
-  }
-
-  class Router {
-    push(page, param = {}, events = {}, callback = () => {}) {
-      wx.navigateTo({
-        url: to(page, param),
-        events,
-        success: callback
+    if (value.constructor === Array) {
+      value.forEach(_value => {
+        _result.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(_value))
       })
+    } else {
+      _result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value))
     }
+  }
+  const url = pages[page] + (_result.length ? `?${_result.join('&')}` : '')
+  return url
+}
 
-    pop(delta) {
-      wx.navigateBack({ delta })
-    }
+class Router {
+  push(page, param = {}, events = {}, callback = () => { }) {
+    wx.navigateTo({
+      url: to(page, param),
+      events,
+      success: callback
+    })
+  }
 
-    redirectTo(page, param) {
-      wx.redirectTo({ url: to(page, param) })
-    }
+  pop(delta) {
+    wx.navigateBack({ delta })
+  }
 
-    reLaunch() {
-      wx.reLaunch({ url: pages.home })
-    }
+  redirectTo(page, param) {
+    wx.redirectTo({ url: to(page, param) })
+  }
 
-    toHome() {
-      this.reLaunch()
-      // if (getCurrentPages().length > 1) { this.pop() } else { this.reLaunch() }
-    }
+  reLaunch() {
+    wx.reLaunch({ url: pages.home })
+  }
+
+  toHome() {
+    this.reLaunch()
+    // if (getCurrentPages().length > 1) { this.pop() } else { this.reLaunch() }
   }
+}
 
-  export default new Router()
+export default new Router()

+ 141 - 123
utils/util.js

@@ -1,74 +1,74 @@
 const formatTime = date => {
-  const year = date.getFullYear()
-  const month = date.getMonth() + 1
-  const day = date.getDate()
-  const hour = date.getHours()
-  const minute = date.getMinutes()
-  const second = date.getSeconds()
+	const year = date.getFullYear()
+	const month = date.getMonth() + 1
+	const day = date.getDate()
+	const hour = date.getHours()
+	const minute = date.getMinutes()
+	const second = date.getSeconds()
 
-  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
+	return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
 }
 
 const formatNumber = n => {
-  n = n.toString()
-  return n[1] ? n : '0' + n
+	n = n.toString()
+	return n[1] ? n : '0' + n
 }
 
 // 格式化时间// 20180101101010  => 2018-01-01 10:10:10
 function formatDate(time) {
-  return `${time.substring(8,10)}:${time.substring(10,12)}`
+	return `${time.substring(8, 10)}:${time.substring(10, 12)}`
 }
 /** 检测是否有定位权限BY 小程序 **/
 function checkHasLocationPermissionByMP() {
-  return new Promise(function (resolve, reject) {
-    wx.getSetting({
-      success(sd) {
-        if (!sd.authSetting['scope.userLocation']) {
-          wx.authorize({
-            scope: 'scope.userLocation',
-            success(e) {
-              resolve(e)
-            },
-            fail(e) {
-              reject()
-            }
-          })
-        } else {
-          resolve(sd)
-        }
-      }
-    })
-  })
+	return new Promise(function (resolve, reject) {
+		wx.getSetting({
+			success(sd) {
+				if (!sd.authSetting['scope.userLocation']) {
+					wx.authorize({
+						scope: 'scope.userLocation',
+						success(e) {
+							resolve(e)
+						},
+						fail(e) {
+							reject()
+						}
+					})
+				} else {
+					resolve(sd)
+				}
+			}
+		})
+	})
 }
-function picInit(value){
-	let baseUrl="../../static/images/"
+function picInit(value) {
+	let baseUrl = "../../static/images/"
 	value = value || '';
 	return baseUrl + "room.png"
-	if(value.startsWith("300")||value.startsWith("310")||value.startsWith("311")){
+	if (value.startsWith("300") || value.startsWith("310") || value.startsWith("311")) {
 		return baseUrl + "ic311.png"
-	}else if(value.startsWith("312")){
+	} else if (value.startsWith("312")) {
 		return baseUrl + "ic312.png"
-	}else if(value.startsWith("313")){
+	} else if (value.startsWith("313")) {
 		return baseUrl + "ic313.png"
-	}else if(value.startsWith("314")){
+	} else if (value.startsWith("314")) {
 		return baseUrl + "ic314.png"
-	}else if(value.startsWith("315")){
+	} else if (value.startsWith("315")) {
 		return baseUrl + "ic315.png"
-	}else if(value.startsWith("320")||value.startsWith("321")){
+	} else if (value.startsWith("320") || value.startsWith("321")) {
 		return baseUrl + "ic321.png"
-	}else if(value.startsWith("322")){
+	} else if (value.startsWith("322")) {
 		return baseUrl + "ic322.png"
-	}else if(value.startsWith("323")){
+	} else if (value.startsWith("323")) {
 		return baseUrl + "ic323.png"
-	}else if(value.startsWith("33")){
+	} else if (value.startsWith("33")) {
 		return baseUrl + "ic331.png"
-	}else{
+	} else {
 		return baseUrl + "ic313.png"
 	}
 }
 // 前面补零
 function PrefixZero(num, n = 2) {
-  return (Array(n).join(0) + num).slice(-n);
+	return (Array(n).join(0) + num).slice(-n);
 }
 function formatMsgTime(dateStr) {
 	// let dateObj = dateStr.replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '').replace(/(-)/g, '/')
@@ -97,7 +97,7 @@ function formatMsgTime(dateStr) {
 		timeSpanStr = Math.round(milliseconds / (1000 * 60 * 60 * 24)) + '天前';
 	}
 	else if (milliseconds > 1000 * 60 * 60 * 24 * 15 && year == nowDate.getFullYear()) {
-		timeSpanStr = month + '.' + day + ' ' + (hour<10?`0${hour}`:hour) + ':' +(minute<10?`0${minute}`:minute) ;
+		timeSpanStr = month + '.' + day + ' ' + (hour < 10 ? `0${hour}` : hour) + ':' + (minute < 10 ? `0${minute}` : minute);
 	} else {
 		timeSpanStr = year + '-' + month + '-' + day;
 	}
@@ -106,51 +106,51 @@ function formatMsgTime(dateStr) {
 
 
 function buildTree(value) {
-  let list = JSON.parse(JSON.stringify(value));
-  // let temp = {};
-  let tree = [];
-  list.forEach(item => {
-    let temp = {};
-    let children = {};
-    temp.projectId = item.projectId;
-    temp.projectName = item.projectName;
-    temp.children = [];
-    tree.push(temp)
-  });
-  let hash = {};
-  tree = tree.reduce((item, next) => {
-    hash[next.projectId] ? '' : hash[next.projectId] = true && item.push(next);
-    return item;
-  }, []);
-  value.forEach((item) => {
-    tree.forEach(items => {
-      if (item.projectId === items.projectId) {
-        // items.children=[];
-        let children = {};
-        children.tenantId = item.tenantId;
-        children.projectId = item.projectId;
-        children.tenantName = item.tenantName;
-        children.remote = item.remote;
-        items.children.push(children);
-      }
-    })
-  })
-  return tree;
+	let list = JSON.parse(JSON.stringify(value));
+	// let temp = {};
+	let tree = [];
+	list.forEach(item => {
+		let temp = {};
+		let children = {};
+		temp.projectId = item.projectId;
+		temp.projectName = item.projectName;
+		temp.children = [];
+		tree.push(temp)
+	});
+	let hash = {};
+	tree = tree.reduce((item, next) => {
+		hash[next.projectId] ? '' : hash[next.projectId] = true && item.push(next);
+		return item;
+	}, []);
+	value.forEach((item) => {
+		tree.forEach(items => {
+			if (item.projectId === items.projectId) {
+				// items.children=[];
+				let children = {};
+				children.tenantId = item.tenantId;
+				children.projectId = item.projectId;
+				children.tenantName = item.tenantName;
+				children.remote = item.remote;
+				items.children.push(children);
+			}
+		})
+	})
+	return tree;
 }
 //  base64解码
 var Base64 = {
-  // 转码表
-  tables: [
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
-    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
-    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
-    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
-    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
-    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
-    'w', 'x', 'y', 'z', '0', '1', '2', '3',
-    '4', '5', '6', '7', '8', '9', '+', '/'
-  ],
-  UTF16ToUTF8 : function (str) {
+	// 转码表
+	tables: [
+		'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+		'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+		'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+		'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+		'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+		'w', 'x', 'y', 'z', '0', '1', '2', '3',
+		'4', '5', '6', '7', '8', '9', '+', '/'
+	],
+	UTF16ToUTF8: function (str) {
 		let results = [], len = str.length;
 		for (let i = 0; i < len; i++) {
 			let code = str.charCodeAt(i);
@@ -200,7 +200,7 @@ var Base64 = {
 
 		return results.join('');
 	},
-	UTF8ToUTF16 : function (str) {
+	UTF8ToUTF16: function (str) {
 		let results = [], len = str.length;
 		let i = 0;
 		for (let i = 0; i < len; i++) {
@@ -241,11 +241,11 @@ var Base64 = {
 
 		return results.join('');
 	},
-	encode : function (str) {
+	encode: function (str) {
 		if (!str) {
 			return '';
 		}
-		let utf8    = this.UTF16ToUTF8(str); // 转成UTF-8
+		let utf8 = this.UTF16ToUTF8(str); // 转成UTF-8
 		let i = 0; // 遍历索引
 		let len = utf8.length;
 		let results = [];
@@ -274,47 +274,65 @@ var Base64 = {
 
 		return results.join('');
 	},
-  decode: function (str) {
-    //判断是否为空
-    if (!str) {
-      return '';
-    }
+	decode: function (str) {
+		//判断是否为空
+		if (!str) {
+			return '';
+		}
 
-    let len = str.length;
-    let i = 0;
-    let results = [];
-    //循环解出字符数组
-    while (i < len) {
-      let code1 = this.tables.indexOf(str.charAt(i++));
-      let code2 = this.tables.indexOf(str.charAt(i++));
-      let code3 = this.tables.indexOf(str.charAt(i++));
-      let code4 = this.tables.indexOf(str.charAt(i++));
+		let len = str.length;
+		let i = 0;
+		let results = [];
+		//循环解出字符数组
+		while (i < len) {
+			let code1 = this.tables.indexOf(str.charAt(i++));
+			let code2 = this.tables.indexOf(str.charAt(i++));
+			let code3 = this.tables.indexOf(str.charAt(i++));
+			let code4 = this.tables.indexOf(str.charAt(i++));
 
-      let c1 = (code1 << 2) | (code2 >> 4);
-      results.push(String.fromCharCode(c1));
+			let c1 = (code1 << 2) | (code2 >> 4);
+			results.push(String.fromCharCode(c1));
 
-      if (code3 != -1) {
-        let c2 = ((code2 & 0xF) << 4) | (code3 >> 2);
-        results.push(String.fromCharCode(c2));
-      }
-      if (code4 != -1) {
-        let c3 = ((code3 & 0x3) << 6) | code4;
-        results.push(String.fromCharCode(c3));
-      }
+			if (code3 != -1) {
+				let c2 = ((code2 & 0xF) << 4) | (code3 >> 2);
+				results.push(String.fromCharCode(c2));
+			}
+			if (code4 != -1) {
+				let c3 = ((code3 & 0x3) << 6) | code4;
+				results.push(String.fromCharCode(c3));
+			}
+
+		}
 
-    }
+		return this.UTF8ToUTF16(results.join(''));
+	}
+}
 
-    return this.UTF8ToUTF16(results.join(''));
-  }
+// 解析参数
+function getUrlParams(url, key) {
+	// debugger
+	// let url = url //获取url中"?"符后的字串
+	let theRequest = {}
+	url = "?" + url
+	if (url.indexOf('?') != -1) {
+		let str = url.substr(1)
+		let strs = str.split('&')
+		for (var i = 0; i < strs.length; i++) {
+			theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1]
+		}
+	}
+	let value = theRequest[key] || ''
+	return value
 }
 
 module.exports = {
-  formatTime: formatTime,
-  formatDate: formatDate,
-  checkHasLocationPermissionByMP: checkHasLocationPermissionByMP,
-  PrefixZero: PrefixZero,
-  buildTree: buildTree,
-	Base64:Base64,
-	picInit:picInit,
-	formatMsgTime:formatMsgTime,
+	formatTime: formatTime,
+	formatDate: formatDate,
+	checkHasLocationPermissionByMP: checkHasLocationPermissionByMP,
+	PrefixZero: PrefixZero,
+	buildTree: buildTree,
+	Base64: Base64,
+	getUrlParams,
+	picInit: picInit,
+	formatMsgTime: formatMsgTime,
 }