소스 검색

fix: 长按返回上一页

chenzhen2 2 년 전
부모
커밋
5fd576c1fa
3개의 변경된 파일67개의 추가작업 그리고 21개의 파일을 삭제
  1. 8 3
      src/styles/index.scss
  2. 21 16
      src/views/envmonitor/components/workOvertime/index.vue
  3. 38 2
      src/views/envmonitor/index.vue

+ 8 - 3
src/styles/index.scss

@@ -16,6 +16,8 @@ body {
   height: 100%;
   overflow: hidden;
   font-family: 'Noto Sans SC';
+  -webkit-touch-callout: none !important;
+  -webkit-user-select: none;
 
 }
 
@@ -162,14 +164,17 @@ div:focus {
 .main-left {
   width: calc(100% - 375px);
 }
+
 .main-right {
   width: 375px;
 }
+
 .popup-content {
   height: 100%;
-  width:500px;
+  width: 500px;
   padding: 3.33vh 20px;
 }
+
 .van-switch--on {
-  background: $elActiveColor !important;
-}
+  background: $elActiveColor  !important;
+}

+ 21 - 16
src/views/envmonitor/components/workOvertime/index.vue

@@ -107,7 +107,7 @@ export default defineComponent({
     let myTimeArr: any = [];
     let timerArr: any = getTimers();
     let nowTimerArr: any = [];
-    let nowData: any = [];
+    let nowData: any = {};
     let redUrl: any = `${parseImgUrl("ipdImages", "time-check.svg")}`;
     let bgRed: any = `linear-gradient(0deg, rgba(255, 0, 0, 0.2), rgba(255, 0, 0, 0.2)), url(${redUrl})`;
     const userInfo: any = getUserInfo();
@@ -685,14 +685,12 @@ export default defineComponent({
             timerArr: timerArr,
           });
         }
-        if (!(proxyData.nowData && proxyData.nowData.length)) {
-          proxyData.dateArr.map((item: any, index: any) => {
-            if (item.week === "今天") {
-              proxyData.checkDate(item, index);
-              return;
-            }
-          });
-        }
+        proxyData.dateArr.map((item: any, index: any) => {
+          if (index === proxyData.activeIndex) {
+            proxyData.checkDate(item, index);
+            return;
+          }
+        });
       },
       clearTimerBoxStyle() {
         proxyData.dateArr.map((elItem: any) => {
@@ -709,33 +707,39 @@ export default defineComponent({
       /**
        * 切换日期
        */
+      activeIndex: 0,
       checkDate(item: any, index: any) {
         proxyData.clearTimerBoxStyle();
         item.isActive = true;
+        proxyData.activeIndex = index;
         proxyData.nowTimerArr = proxyData.dateArr[index].timerArr;
         proxyData.nowData = proxyData.dateArr[index];
-        // dom元素宽高调整
         nextTick(() => {
           proxyData.setOptionnalTime(proxyData.nowTimerArr);
-          console.log(item);
-          let index: any = proxyData.getNowIndex();
-          proxyData.setPastTime(index);
+          let nowIndex: any = proxyData.getNowIndex();
+          proxyData.setPastTime(nowIndex);
           // // 已经被选择的时间
           proxyData.setCheckTimeStyle();
           // // 固定服务时间
           proxyData.setServiceTimerStyle();
-          if (proxyData.nowData.week === "今天") {
-            proxyData.changeEl();
-          }
+          // dom元素宽高调整
+          proxyData.changeEl();
         });
       },
       /**
        * dom的滚动功能设置
        */
+      flag: false,
       changeEl() {
         proxyData.setScreennWidth();
         proxyData.sliderSwiper();
         proxyData.endBoxSwiper();
+        // if (!proxyData.flag) {
+        //   proxyData.setScreennWidth();
+        //   proxyData.sliderSwiper();
+        //   proxyData.endBoxSwiper();
+        //   proxyData.flag = true;
+        // }
       },
       // 加班数据格式化=》后台需要的数据结构(添加加班逻辑)
       formateAddTimer() {
@@ -994,6 +998,7 @@ export default defineComponent({
     watch(props, (newProps: any) => {
       proxyData.workkArr = newProps.workkArr;
       proxyData.projectId = newProps.projectId;
+      // proxyData.setWorkTimeList();
       // proxyData.getWorkTimeList();
     });
     onMounted(() => {

+ 38 - 2
src/views/envmonitor/index.vue

@@ -17,7 +17,13 @@
       </div>
       <div class="left-space">
         <div class="text">
-          <div>{{ officeData.localName }}</div>
+          <div
+            @touchstart="gtouchstart"
+            @touchmove="gtouchmove()"
+            @touchend="showDeleteButton"
+          >
+            {{ officeData.localName }}
+          </div>
           <div>
             <img :src="parseImgUrl('ipdImages', 'vector.svg')" />
             <span>无人</span>
@@ -262,6 +268,7 @@ export default defineComponent({
     let spaceInfo: any = {};
     const projectId: string = store.state.user.projectId;
     const sceneDetail: any = {};
+    const timeOutEvent: any = {};
     const headerInfo: {
       headImg: any;
       headScene: string;
@@ -1008,7 +1015,7 @@ export default defineComponent({
           lodingText: item.lodingText,
           sceneName: item.sceneName,
         };
-        console.log(proxyData.secenaroStatus)
+        console.log(proxyData.secenaroStatus);
       },
       closeDailog() {
         proxyData.isShowMetting = false;
@@ -1499,6 +1506,35 @@ export default defineComponent({
         proxyData.init();
         item.active = true;
       },
+      timeOutEvent: timeOutEvent,
+      gtouchstart() {
+        proxyData.timeOutEvent = setTimeout(function () {
+          proxyData.longPress();
+        }, 500); //这里设置定时器,定义长按500毫秒触发长按事件
+        return false;
+      },
+      //手释放,如果在500毫秒内就释放,则取消长按事件,此时可以执行onclick应该执行的事件
+      showDeleteButton() {
+        clearTimeout(proxyData.timeOutEvent); //清除定时器
+        if (proxyData.timeOutEvent != 0) {
+        }
+        return false;
+      },
+      //如果手指有移动,则取消所有事件,此时说明用户只是要移动而不是长按
+      gtouchmove() {
+        clearTimeout(this.timeOutEvent); //清除定时器
+        proxyData.timeOutEvent = 0;
+      },
+      //真正长按后应该执行的内容
+      longPress() {
+        proxyData.timeOutEvent = 0;
+        //执行长按要执行的内容,如弹出菜单
+        // console.log("长按");
+        router.push({
+          name: "choiceSpace",
+          query: { id: proxyData.projectId },
+        });
+      },
     });
     nextTick(() => {
       // proxyData.envmonitorMove()