ソースを参照

feat 碳积分

anxiaoxia 1 年間 前
コミット
ae05f6ea9d

+ 27 - 0
src/packagesEnv/api/personalCenter.js

@@ -0,0 +1,27 @@
+import $http from '@/common/request.js'
+import config from '@/config'
+import store from '@/store/index.js'
+function getProjectId() {
+  const projectId = store.state.user.userInfo.projectId
+  return projectId
+}
+//  设置设备
+function customerservice() {
+  let params = {
+    'criteria': {
+      'projectId': getProjectId(),
+      'state': 1
+    }
+  }
+  return $http({
+    serverSp: config.brsgServer.duoduoUrl,
+    url: `/server/duoduoenv/customerservice/query`,
+    method: 'POST',
+    isNotShowErrorToast: true,
+    errorSave: true,
+    data: JSON.stringify(params)
+  })
+}
+export {
+    customerservice
+}

+ 6 - 10
src/packagesEnv/api/portrait.js

@@ -3,21 +3,17 @@ import config from '@/config'
 import store from '@/store/index.js'
 /* 使用统计 */
 function storeUser() {
-//   return store.state.user.userInfo;
+  const userInfo = store.state.user.userInfo
   return {
-    tag: '20247ac1b24e82760a733485969ef7ee',
-    userId: '9a1ecfbacb6b4f249bf2dd3ec7793ead',
-    phone: '17611228068',
-    userName: '安小霞'
+    userId: userInfo.userId,
+    phone: userInfo.phone,
+    userName: userInfo.name
   }
 }
 
 function getProjectId() {
-//   return (
-//     store.state.company.companyConfig &&
-//     store.state.company.companyConfig.sagacareProjectId
-//   )
-  return 'Pj1101080259'
+  const projectId = store.state.user.userInfo.projectId
+  return projectId
 }
 
 function commonParams() {

+ 82 - 85
src/packagesEnv/pages/common.js

@@ -1,5 +1,5 @@
-import config from '@/config';
-import uma from 'umtrack-wx';
+import config from '@/config'
+import uma from 'umtrack-wx'
 
 function umaInit() {
   config.appKey &&
@@ -13,66 +13,66 @@ function umaInit() {
       autoGetOpenid: false
       // debug: true, // 是否打开调试模式
       // uploadUserInfo: true // 自动上传用户信息,设为false取消上传,默认为false
-    });
+    })
 }
 
-const SliderUnit = 0.5; // 一个色块代表0.5个小时
-const TimeStart = 0;
-const TimeEnd = 24;
+const SliderUnit = 0.5 // 一个色块代表0.5个小时
+const TimeStart = 0
+const TimeEnd = 24
 
 function generateTimeSliders(openStartTime, openEndTime, disabledPast = true) {
   let start = TimeStart,
-    end = TimeEnd;
-  let duration = end - start;
-  let times = [];
-  let { juggeValue } = getNowTime();
+    end = TimeEnd
+  let duration = end - start
+  let times = []
+  let { juggeValue } = getNowTime()
   for (let i = 0; i < duration / SliderUnit; i++) {
-    let value = start + i * SliderUnit;
-    let values = value.toString().split('.');
-    let status = '';
-    let label = '';
+    let value = start + i * SliderUnit
+    let values = value.toString().split('.')
+    let status = ''
+    let label = ''
     if (values.length == 1) {
       // 代表是整数
       label =
-        parseInt(values[0]) < 10 ? '0' + values[0] + ':00' : values[0] + ':00';
+        parseInt(values[0]) < 10 ? '0' + values[0] + ':00' : values[0] + ':00'
     } else {
       // 代表是有分钟
-      let mniuts = SliderUnit * 60; // 转化分钟;
+      let mniuts = SliderUnit * 60 // 转化分钟;
       label =
         parseInt(values[0]) < 10
           ? '0' + values[0] + ':' + mniuts
-          : values[0] + ':' + mniuts;
+          : values[0] + ':' + mniuts
     }
     if (disabledPast && value < juggeValue) {
-      status = 'past'; // 过去时间
+      status = 'past' // 过去时间
     }
 
     if (openEndTime && value >= openStartTime && value <= openEndTime) {
-      status = 'unOpened'; // 不在开放时间内
+      status = 'unOpened' // 不在开放时间内
     }
 
     times.push({
       value,
       label,
       status
-    });
+    })
   }
-  return times;
+  return times
 }
 function getNowTime() {
-  let now = new Date();
-  let hour = now.getHours();
-  let minuts = now.getMinutes();
+  let now = new Date()
+  let hour = now.getHours()
+  let minuts = now.getMinutes()
   // let hour = 16;
   // let minuts = 30;
-  let minutsValue = 0;
+  let minutsValue = 0
   if (minuts < 30) {
     // 在30分钟内,都可以预约当前小时,故取0
-    minutsValue = 0;
+    minutsValue = 0
   } else {
-    minutsValue = 0.5; // 在30分钟-59分钟内,都可以预约当前小时+半小时之后,故取0.5
+    minutsValue = 0.5 // 在30分钟-59分钟内,都可以预约当前小时+半小时之后,故取0.5
   }
-  let juggeValue = hour + minutsValue;
+  let juggeValue = hour + minutsValue
 
   return {
     juggeValue,
@@ -80,110 +80,110 @@ function getNowTime() {
       hour,
       minuts
     }
-  };
+  }
 }
 
 function getNowDate(date) {
-  let now = new Date();
-  return getDate(now);
+  let now = new Date()
+  return getDate(now)
 }
 
 function getDate(now) {
-  let year = now.getFullYear();
-  let month = now.getMonth() + 1;
-  let date = now.getDate();
-  return [year, getTowNum(month), getTowNum(date)].join('');
+  let year = now.getFullYear()
+  let month = now.getMonth() + 1
+  let date = now.getDate()
+  return [year, getTowNum(month), getTowNum(date)].join('')
 }
 
 function getTowNum(num) {
-  num = parseInt(num);
-  return num < 10 ? '0' + num : num;
+  num = parseInt(num)
+  return num < 10 ? '0' + num : num
 }
 
 function formateTimeValue(timeValue) {
-  let value = parseFloat(timeValue);
-  let hour = parseInt(timeValue);
-  let minits = (value - hour) * 60;
-  return `${getTowNum(hour)}${getTowNum(minits)}00`;
+  let value = parseFloat(timeValue)
+  let hour = parseInt(timeValue)
+  let minits = (value - hour) * 60
+  return `${getTowNum(hour)}${getTowNum(minits)}00`
 }
 
 function formateDateValue(dateValue) {
-  return dateValue.replace(/-/g, '');
+  return dateValue.replace(/-/g, '')
 }
 
 function formateTimeToValue(time) {
-  if (time === '') return 0;
-  let hours = time.substring(0, 2);
-  let mins = time.substring(2, 4);
-  let hoursValue = parseInt(hours);
-  let mintusValue = parseInt(mins) / 60;
-  return hoursValue + mintusValue;
+  if (time === '') return 0
+  let hours = time.substring(0, 2)
+  let mins = time.substring(2, 4)
+  let hoursValue = parseInt(hours)
+  let mintusValue = parseInt(mins) / 60
+  return hoursValue + mintusValue
 }
 
 function formateTimeToColon(time) {
-  let hours = time.substring(0, 2);
-  let mins = time.substring(2, 4);
-  return `${hours}:${mins}`;
+  let hours = time.substring(0, 2)
+  let mins = time.substring(2, 4)
+  return `${hours}:${mins}`
 }
 
 function endtimeToUnitTime(time) {
-  let hours = time.substring(0, 2);
-  let mins = time.substring(2, 4);
+  let hours = time.substring(0, 2)
+  let mins = time.substring(2, 4)
   if (mins < 30) {
-    mins = '00';
+    mins = '00'
   } else {
-    mins = '30';
+    mins = '30'
   }
-  return `${hours}${mins}00`;
+  return `${hours}${mins}00`
 }
 function startimeToUnitTime(time) {
-  let hours = time.substring(0, 2);
-  let mins = time.substring(2, 4);
+  let hours = time.substring(0, 2)
+  let mins = time.substring(2, 4)
   if (mins < 30 && mins !== '00') {
-    mins = '30';
+    mins = '30'
   } else if (mins > 30) {
-    mins = '00';
-    hours = parseInt(hours) + 1;
+    mins = '00'
+    hours = parseInt(hours) + 1
     hours = hours < 10 ? `0${hours}` : hours
   } else {
   }
-  return `${hours}${mins}00`;
+  return `${hours}${mins}00`
 }
 
 function formateBookedList(bookedList) {
-  let list = {};
+  let list = {}
   if (!bookedList || (bookedList && bookedList.length == 0)) {
-    return list;
+    return list
   }
 
   bookedList.forEach((item) => {
-    let { startTime, endTime, startDate } = item;
-    let key = startDate;
+    let { startTime, endTime, startDate } = item
+    let key = startDate
     let data = {
       start: formateTimeToValue(endtimeToUnitTime(startTime)),
       end: formateTimeToValue(startimeToUnitTime(endTime)),
       ...item
-    };
+    }
     if (!list[key]) {
-      list[key] = [data];
+      list[key] = [data]
     } else {
-      list[key].push(data);
+      list[key].push(data)
     }
-  });
-  return list;
+  })
+  return list
 }
 
 function dateToDate(val) {
-  const year = val.slice(0, 4);
-  const month = val.slice(4, 6);
-  const day = val.slice(6, 8);
-  return `${year}-${month}-${day}`;
+  const year = val.slice(0, 4)
+  const month = val.slice(4, 6)
+  const day = val.slice(6, 8)
+  return `${year}-${month}-${day}`
 }
 
 function getWeekDay(date) {
-  let week = date.getDay();
-  let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
-  return weekday[week];
+  let week = date.getDay()
+  let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
+  return weekday[week]
 }
 function checkSpaceControl(val) {
   if (!val) {
@@ -191,18 +191,15 @@ function checkSpaceControl(val) {
       title: '您没有权限!',
       icon: 'none',
       duration: 1500
-    });
-    return false;
+    })
+    return false
   } else {
     return true
   }
 }
 
 function carbonCredit(projectId) {
-  if (projectId === 'Pj1101020007') {
-    return '碳积分';
-  }
-  return '节能分';
+  return '碳积分'
 }
 
 function carbonCreditExplain(params) {
@@ -298,4 +295,4 @@ export {
   TimeEnd,
   TimeStart,
   SliderUnit
-};
+}

+ 132 - 0
src/packagesEnv/pages/personalCenter/component/custome-service-panel.wpy

@@ -0,0 +1,132 @@
+<style lang="less">
+.custome-service-panel {
+    position: fixed;
+    top: 0;
+    bottom: 0;
+    right: 0;
+    left: 0;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    z-index: 2;
+    &.show {
+        display: flex;
+    }
+    &.hide {
+        display: none;
+    }
+    .panel-mask {
+        position: absolute;
+        top: 0;
+        right: 0;
+        left: 0;
+        bottom: 0;
+        background: rgba(0, 0, 0, 0.2);
+    }
+    .content {
+        position: absolute;
+        bottom: 0px;
+        text-align: center;
+        border-radius: 16px 16px 0px 0px;
+        background: #ffffff;
+        width: 100%;
+        height: 296rpx;
+
+        .sp-text {
+            height: 100rpx;
+            color: #1db1b2;
+            font-family: PingFang SC;
+            font-size: 32rpx;
+            font-weight: 400;
+            line-height: 100rpx;
+        }
+        .dir {
+            height: 16rpx;
+            background: #f1f4f6;
+        }
+        .text {
+            color: #8b949e;
+            font-family: PingFang SC;
+            font-size: 32rpx;
+            font-weight: 400;
+            line-height: 100rpx;
+        }
+    }
+}
+</style>
+
+<template>
+    <cover-view
+        class="{{'custome-service-panel '+(show?'show':'hide')}}"
+        v-on:touchmove.stop="stopProgration"
+    >
+        <cover-view
+            class="panel-mask"
+            v-on:click="closePanel"
+        ></cover-view>
+        <cover-view class="content">
+            <cover-view>
+                <cover-view
+                    class="sp-text"
+                    @click="callPhone"
+                >
+                    呼叫 {{ phone }}
+                </cover-view>
+                <cover-view class="dir"></cover-view>
+                <cover-view
+                    class="text"
+                    v-on:click="closePanel"
+                >取消</cover-view>
+            </cover-view>
+        </cover-view>
+    </cover-view>
+</template>
+
+<script>
+import wepy from '@wepy/core'
+import config from '@config'
+import { mapState } from '@wepy/x'
+import store from '@/store'
+
+wepy.component({
+  store,
+  data: {
+    h5StaticPath: config.h5StaticPath,
+    h5Origin: config.h5Origin,
+    showLink: `${config.h5Origin}/#/wx-external-link`
+  },
+  props: {
+    show: Boolean,
+    phone: String
+
+  },
+  computed: {
+    ...mapState({ userInfo: state => state.user.userInfo })
+  },
+  created() {
+
+  },
+  methods: {
+    callPhone() {
+      let _this = this
+      wx.makePhoneCall({
+        phoneNumber: this.phone,
+        complete() {
+          _this.$emit('custome-service-close', false)
+        }
+      })
+    },
+    closePanel() {
+      this.$emit('custome-service-close', false)
+    },
+    stopProgration() { }
+  }
+})
+</script>
+
+
+<config>
+{
+  
+}
+</config>

+ 24 - 13
src/packagesEnv/pages/personalCenter/footer.wpy

@@ -29,10 +29,10 @@
         justify-content: center;
         width: 272rpx;
         height: 88rpx;
-        padding: 20rpx 48rpx 20rpx 48rpx;
         border-radius: 40px;
         background: #ffffff;
         .text {
+            margin-left: 16rpx;
             font-family: PingFang SC;
             font-size: 28rpx;
             font-weight: 400;
@@ -52,10 +52,11 @@
         <div
             class="btn-box"
             v-if="IsShowPhone"
+            @click="callPhone"
         >
             <image
                 class="imgSt"
-                src="/static/icon-phone.svg"
+                src="{{ h5StaticPath }}/icon-phone.svg"
             />
             <span class="text">客服电话</span>
         </div>
@@ -74,26 +75,36 @@
 <script>
 
 import wepy from '@wepy/core'
-// import config from '@/config';
+import config from '@/config'
+import { customerservice } from '../../api/personalCenter.js'
 wepy.component({
   name: 'Footer',
   props: {
-    IsShowPhone: Boolean
   },
   data: {
+    h5StaticPath: config.h5StaticPath + '/page-personalCenter',
+    IsShowPhone: true,
+    phone: null
 
   },
   computed: {},
-  methods: {
-
+  ready() {
+    this.getPhone()
   },
-    // 生命周期 - 创建完成(可以访问当前this实例)
-  created() {
-
-  },
-    // 生命周期 - 挂载完成(可以访问DOM元素)
-  mounted() {
-
+  methods: {
+    callPhone() {
+      this.$emit('callPhone', this.phone)
+    },
+    getPhone() {
+      customerservice().then(res => {
+        let phone = null
+        if (res.count) {
+          phone = res.content[0].phone
+        }
+        this.phone = phone
+      })
+    }
   }
+
 })
 </script>

+ 17 - 2
src/packagesEnv/pages/personalCenter/index.wpy

@@ -192,7 +192,13 @@ page {
 
             </div>
         </div>
-        <footer :IsShowPhone="IsShowPhone"></footer>
+        <footer @callPhone="openPhonePanel"></footer>
+        <custome-service-panel 
+         :show="visiblePhone" 
+         :phone="phone"
+         @custome-service-close="closePhonePanel"
+         >
+        </custome-service-panel>
         <add-miniprogram-to-desk-panel
             :show="isShowAddminiProgramToDesk"
             @component-add-miniprogram-to-desk-panel-close="handleAdd(false)"
@@ -208,10 +214,11 @@ wepy.page({
   components: {},
   props: {},
   data: {
+    visiblePhone: false,
+    phone: '',
     h5StaticPath: config.h5StaticPath + '/page-personalCenter',
     h5Static: config.h5StaticPath,
     isShowAddminiProgramToDesk: false,
-    IsShowPhone: true,
     arr: [
             // { name: '问题反馈', icon: 'icon-message.svg', url: '' },
             { name: '操作指引', icon: 'icon-guid.svg', url: '/packagesEnv/pages/personalCenter/operating' },
@@ -220,6 +227,13 @@ wepy.page({
   },
   computed: {},
   methods: {
+    openPhonePanel(val) {
+      this.phone = val
+      this.visiblePhone = true
+    },
+    closePhonePanel(val) {
+      this.visiblePhone = val
+    },
     handleAdd(val) {
       this.isShowAddminiProgramToDesk = val
     },
@@ -253,6 +267,7 @@ wepy.page({
     usingComponents: {
         'page-top-bar': '~@/components/common/page-top-bar', 
         'add-miniprogram-to-desk-panel': './component/add-miniprogram-to-desk-panel', 
+        'custome-service-panel': './component/custome-service-panel', 
         'footer':'./footer'     
     },
     "componentPlaceholder": {

+ 1 - 31
src/packagesEnv/pages/portrait/pointExplain.wpy

@@ -63,7 +63,7 @@ page {
 <template>
     <div>
         <page-top-bar
-            icon="{{h5StaticPath+'/topBar/return-icon.svg'}}"
+            icon="{{h5StaticPath+'/page-top-bar/return-icon.svg'}}"
         ></page-top-bar>
         <div class="page-container">
             <div class="energyHead">
@@ -71,7 +71,6 @@ page {
             </div>
             <div
                 class="pointExplain"
-                v-if="projectId === 'Pj1101020007'"
             >
                 <div :class="{'item':true,'carbonItem':true}" 
                 style="{{ item.sty }}"
@@ -80,35 +79,6 @@ page {
                     <div class="cont" style="line-height: 48rpx;">{{item.text}}</div>
                 </div>
             </div>
-            <div
-                class="pointExplain"
-                v-else
-            >
-                <div class="item">
-                    <div class="order">1、</div>
-                    <div class="cont">加班的时候设置加班时间,积分1</div>
-                </div>
-                <div class="item">
-                    <div class="order">2、</div>
-                    <div class="cont">办公中暂时不需要<span v-if="portraitModule.light">照明&</span><span v-if="portraitModule.airConditioner">空调</span>,持续时间大于等<br>于0.5,小于1小时无任何开启,积分0.5</div>
-                </div>
-                <div class="item">
-                    <div class="order">3、</div>
-                    <div class="cont">办公中暂时不需要<span v-if="portraitModule.light">照明&</span><span v-if="portraitModule.airConditioner">空调</span>,持续时间大于等<br>于1,小于2小时无任何开启,积分1</div>
-                </div>
-                <div class="item">
-                    <div class="order">4、</div>
-                    <div class="cont">办公中暂时不需要<span v-if="portraitModule.light">照明&</span><span v-if="portraitModule.airConditioner">空调</span>,持续时间大于等<br>于2小时无任何开启,积分2</div>
-                </div>
-                <div class="item">
-                    <div class="order">5、</div>
-                    <div class="cont">供冷季,调节至室内温度大于等于26℃,积分1</div>
-                </div>
-                <div class="item">
-                    <div class="order">6、</div>
-                    <div class="cont">供暖季,调节至室内温度小于等于20℃,积分1</div>
-                </div>
-            </div>
 
         </div>
     </div>