瀏覽代碼

上下班

seimin 3 年之前
父節點
當前提交
084c195b37
共有 1 個文件被更改,包括 13 次插入29 次删除
  1. 13 29
      src/views/my.vue

+ 13 - 29
src/views/my.vue

@@ -2,8 +2,8 @@
2 2
   <div class="bgColor">
3 3
     <div class="head">
4 4
       <template v-if="!isWorkLoading">
5
-        <div class="img" @click="getLocation(loginUser.online)" v-show="isWorkOnline">
6
-          {{ loginUser.online == 1 ? "下班" : "上班" }}
5
+        <div class="img" @click="getLocation(online)" v-show="isWorkOnline">
6
+          {{ online == 1 ? "上班" : "下班" }}
7 7
         </div>
8 8
         <div class="name">{{ loginUser.name }}</div>
9 9
       </template>
@@ -121,7 +121,6 @@
121 121
 let sdk = new jssdk(3, "https://wx2.zuel.edu.cn"); // 域名更换为对应环境域名, 204 更换为对应环境wid
122 122
 sdk.config(0); //1表示调试模式,生产环境传0
123 123
 import "./../../static/css/iconfont.js";
124
-import { formatDate } from "./../components/js/date.js";
125 124
 export default {
126 125
   data() {
127 126
     return {
@@ -135,6 +134,7 @@ export default {
135 134
       toast: null,
136 135
       isWorkOnline:false,//当前用户是否可以上下班
137 136
       isWorkLoading:false,//当前用户是否可以上下班loading
137
+      online:0,//1是上班,0是下班
138 138
     };
139 139
   },
140 140
   methods: {
@@ -149,6 +149,9 @@ export default {
149 149
         }).show()
150 150
         return;
151 151
       }
152
+      // 本地测试
153
+      // this.goToWork(online, '123');
154
+      // return;
152 155
       let _this = this;
153 156
       this.toast = this.$createToast({
154 157
         time: 0,
@@ -180,14 +183,12 @@ export default {
180 183
     },
181 184
     // 上下班
182 185
     goToWork(online, address) {
183
-      online = online == 1 ? 0 : 1;
184 186
       this.$http
185
-        .post("service/auth/online", { online: online, address })
187
+        .post("service/auth/online", { online, address })
186 188
         .then(res => {
187
-          this.toast.hide();
189
+          this.toast.hide();//本地测试
188 190
           if (res.data.status == 200) {
189
-            this.loginUser.online = online;
190
-            localStorage.setItem("loginUser", JSON.stringify(this.loginUser));
191
+            this.online = online;
191 192
             const t = this.$createToast({
192 193
               type: "txt",
193 194
               txt: online == 1 ? "上班成功" : "下班成功"
@@ -222,12 +223,11 @@ export default {
222 223
                 });
223 224
                 this.toast.show();
224 225
                 this.$http
225
-                .post("service/auth/online", { online: online, address, confirm:'ok' })
226
+                .post("service/auth/online", { online, address, confirm:'ok' })
226 227
                 .then(res => {
227 228
                   this.toast.hide();
228 229
                   if (res.data.status == 200) {
229
-                    this.loginUser.online = online;
230
-                    localStorage.setItem("loginUser", JSON.stringify(this.loginUser));
230
+                    this.online = online;
231 231
                     const t = this.$createToast({
232 232
                       type: "txt",
233 233
                       txt: online == 1 ? "上班成功" : "下班成功"
@@ -301,28 +301,12 @@ export default {
301 301
             let userList = res.data.list[0].userList.map(v=>v.id);//用户id列表
302 302
             this.isWorkOnline = userList.includes(this.loginUser.id);
303 303
             if(this.isWorkOnline){
304
-              let now = formatDate(new Date(), "yyyy-MM-dd");
305 304
               this.$http
306
-                .post("service/auth/onlineInfo/"+now, {"idx":0,"sum":1000})
305
+                .post("service/auth/showOnlineBtn", {})
307 306
                 .then((res) => {
308 307
                   this.isWorkLoading = false;
309 308
                   if(res.data.status == 200){
310
-                    console.log(res.data)
311
-                    const {unOnlineList,unOfflineList} = res.data;//上班记录未打卡,下班记录未打卡
312
-                    let unOnlineList1 = unOnlineList.map(v=>v.userId);
313
-                    let unOfflineList1 = unOfflineList.map(v=>v.userId);
314
-                    let flag1 = unOnlineList1.includes(this.loginUser.id);
315
-                    let flag2 = unOfflineList1.includes(this.loginUser.id);
316
-                    if(flag1 && flag2){
317
-                      //上班未打卡,下班未打卡
318
-                      this.isWorkOnline = true;
319
-                    }else if(!flag1 && flag2){
320
-                      //上班打卡,下班未打卡
321
-                      this.isWorkOnline = true;
322
-                    }else if(!flag1 && !flag2){
323
-                      //上班打卡,下班打卡
324
-                      this.isWorkOnline = false;
325
-                    }
309
+                    this.online = res.data.online;
326 310
                   }
327 311
                 });
328 312
             }