浏览代码

上下班

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

+ 13 - 29
src/views/my.vue

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