|
@@ -1,92 +1,144 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="Clockln-box">
|
3
|
3
|
<div class="box1">
|
4
|
|
- <img src="../assets/userImag/userImag.jpg" alt />
|
5
|
|
- <div class="box1-title">{{title}}</div>
|
|
4
|
+ <div class="box-item box1-avatar">
|
|
5
|
+ <avatar />
|
|
6
|
+ </div>
|
|
7
|
+ <div class="box-item box1-title">{{signInfo.name}}</div>
|
6
|
8
|
<div class="box1-time">签到结束时间</div>
|
7
|
|
- <div class="box1-time">{{parseTime(endTime, '{y}年{m}月{d}日 {h}:{i}')}}</div>
|
|
9
|
+ <div class="box1-time">{{endTimeStr}}</div>
|
8
|
10
|
</div>
|
9
|
|
- <div :class="{'myDIV':true, 'disabled':ok}" @click="goSign">
|
10
|
|
- <div>上课打卡</div>
|
11
|
|
- <span>{{SignInTime(nowTime)}}</span>
|
|
11
|
+ <div :class="{ 'myDIV': true }" @click="goSign">
|
|
12
|
+ <div>{{signText}}</div>
|
|
13
|
+ <span>{{currentTimeStr}}</span>
|
12
|
14
|
</div>
|
13
|
15
|
|
14
|
|
- <img src="../assets/basemap.png" alt width="100%" />
|
|
16
|
+ <img src="~@/assets/basemap.png" alt width="100%" />
|
15
|
17
|
</div>
|
16
|
18
|
</template>
|
17
|
19
|
|
18
|
20
|
<script>
|
19
|
|
-import { getSignInInfof, getSignIn } from '../util/api'
|
20
|
|
-import query from '../util/query'
|
21
|
|
-import { parseTime, SignInTime } from '../util/formattingData'
|
|
21
|
+import { getSignInInfo, postSignIn } from '@/util/api'
|
|
22
|
+import { parseTime } from '@/util/formattingData'
|
|
23
|
+import { mapState } from 'vuex'
|
|
24
|
+
|
22
|
25
|
export default {
|
|
26
|
+ components: {
|
|
27
|
+ avatar: () => import('@/components/Avatar/index.vue')
|
|
28
|
+ },
|
23
|
29
|
data() {
|
24
|
30
|
return {
|
25
|
|
- signId: '',
|
26
|
|
- phone: '',
|
27
|
|
- ok: false,
|
28
|
|
- endTime: '',
|
29
|
|
- title: '',
|
30
|
|
- nowTime: new Date()
|
|
31
|
+ signInfo: {},
|
|
32
|
+ canSign: false,
|
|
33
|
+ noSignErr: '',
|
|
34
|
+ shortErr: '',
|
|
35
|
+ ticker: null,
|
|
36
|
+ now: new Date()
|
|
37
|
+ }
|
|
38
|
+ },
|
|
39
|
+ computed: {
|
|
40
|
+ ...mapState({
|
|
41
|
+ person: s => s.user
|
|
42
|
+ }),
|
|
43
|
+ endTimeStr() {
|
|
44
|
+ if (!this.signInfo.endTime) return '未知';
|
|
45
|
+
|
|
46
|
+ return parseTime(this.signInfo.endTime, '{y}年{m}月{d}日 {h}:{i}')
|
|
47
|
+ },
|
|
48
|
+ currentTimeStr() {
|
|
49
|
+ return parseTime(this.now, '{h}:{i}:{s}')
|
|
50
|
+ },
|
|
51
|
+ signText() {
|
|
52
|
+ return this.canSign ? '签 到' : this.shortErr
|
|
53
|
+ }
|
|
54
|
+ },
|
|
55
|
+ watch: {
|
|
56
|
+ '$route.query.signId': {
|
|
57
|
+ handler(v) {
|
|
58
|
+ if (v) {
|
|
59
|
+ this.onLoadSinInfo(v)
|
|
60
|
+ }
|
|
61
|
+ },
|
|
62
|
+ immediate: true
|
31
|
63
|
}
|
32
|
64
|
},
|
|
65
|
+ created() {
|
|
66
|
+ this.ticker = setInterval(() => {
|
|
67
|
+ this.now = new Date()
|
|
68
|
+ }, 1000)
|
|
69
|
+ },
|
33
|
70
|
mounted() {
|
34
|
|
- this.signId = query('signId')
|
35
|
|
- this.phone = this.$store.state.user.phone
|
36
|
|
-
|
37
|
|
- this.onLoadSinInO()
|
38
|
|
- let that = this
|
39
|
|
- this.timer = setInterval(function () {
|
40
|
|
- that.nowTime = new Date().toLocaleString()
|
41
|
|
- })
|
|
71
|
+ const {phone} = this.person || {}
|
|
72
|
+
|
|
73
|
+ if (!phone) {
|
|
74
|
+ this.$dialog.alert({
|
|
75
|
+ message: '请先维护您的个人信息',
|
|
76
|
+ }).then(() => {
|
|
77
|
+ this.$router.push({ name: 'SetUser' })
|
|
78
|
+ })
|
|
79
|
+ }
|
42
|
80
|
},
|
43
|
|
- //离开当前页面后执行
|
44
|
|
- destroyed: function () {
|
45
|
|
- // 销毁时清除计时器
|
46
|
|
- this.beforeDestroy()
|
|
81
|
+ beforeDestroy() {
|
|
82
|
+ if (this.ticker) {
|
|
83
|
+ clearInterval(this.ticker)
|
|
84
|
+ }
|
47
|
85
|
},
|
|
86
|
+
|
48
|
87
|
methods: {
|
49
|
|
- SignInTime,
|
50
|
88
|
parseTime,
|
51
|
|
- // 销毁时清除计时器
|
52
|
|
- beforeDestroy: function () {
|
53
|
|
- console.log('销毁时清除计时器')
|
54
|
|
- if (this.timer) {
|
55
|
|
- clearInterval(this.timer)
|
56
|
|
- }
|
57
|
|
- },
|
58
|
89
|
//首先判断他有没有资格
|
59
|
90
|
// this.$toast.success('修改成功!')
|
60
|
|
- onLoadSinInO() {
|
61
|
|
- getSignInInfof().then((e) => {
|
62
|
|
- const { canSign, endTime, startTime, isSigned, name } = e
|
63
|
|
- this.endTime = endTime
|
64
|
|
- this.title = name
|
65
|
|
-
|
66
|
|
- let starDtat = new Date(startTime) - new Date()
|
67
|
|
- let endDtat = new Date(endTime) - new Date()
|
68
|
|
-
|
69
|
|
- if (this.phone) {
|
70
|
|
- if (canSign) {
|
71
|
|
- if (starDtat < 0) {
|
72
|
|
- if (endDtat < 0) {
|
73
|
|
- if (!isSigned) {
|
74
|
|
- this.ok = true
|
75
|
|
- } else {
|
76
|
|
- this.$toast.fail('您已签到过')
|
77
|
|
- }
|
78
|
|
- }
|
79
|
|
- } else {
|
80
|
|
- this.$toast.fail('未到签到时间')
|
81
|
|
- }
|
82
|
|
- }
|
83
|
|
- } else {
|
84
|
|
- this.$toast.fail('请维护手机号')
|
|
91
|
+ onLoadSinInfo(id) {
|
|
92
|
+ getSignInInfo(id).then((e) => {
|
|
93
|
+ this.signInfo = e
|
|
94
|
+
|
|
95
|
+ // 必须属于签到池人员
|
|
96
|
+ if (!this.signInfo.canSign) {
|
|
97
|
+ this.canSign = false;
|
|
98
|
+ this.noSignErr = '当前活动您未参与';
|
|
99
|
+ this.shortErr = '未参与';
|
|
100
|
+ return;
|
85
|
101
|
}
|
|
102
|
+
|
|
103
|
+ if (this.signInfo.isSigned) {
|
|
104
|
+ this.canSign = false;
|
|
105
|
+ this.noSignErr = '您已签到';
|
|
106
|
+ this.shortErr = '已签到';
|
|
107
|
+ return;
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ // 必须是签到时间
|
|
111
|
+ const isGtStart = (this.now - new Date(this.signInfo.startTime)) > 0
|
|
112
|
+ const isLtEnd = (this.now - new Date(this.signInfo.endTime)) < 0
|
|
113
|
+ if (!isGtStart) {
|
|
114
|
+ this.canSign = false;
|
|
115
|
+ this.noSignErr = '签到未开始';
|
|
116
|
+ this.shortErr = '未开始';
|
|
117
|
+ return;
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ if (!isLtEnd) {
|
|
121
|
+ this.canSign = false;
|
|
122
|
+ this.noSignErr = '签到已结束';
|
|
123
|
+ this.shortErr = '已结束';
|
|
124
|
+ return;
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ this.canSign = true;
|
|
128
|
+ this.noSignErr = '';
|
|
129
|
+ this.shortErr = '';
|
|
130
|
+
|
|
131
|
+ }).catch(e => {
|
|
132
|
+ this.$toast(e.message)
|
86
|
133
|
})
|
87
|
134
|
},
|
88
|
135
|
goSign() {
|
89
|
|
- getSignIn().then((e) => {
|
|
136
|
+ if (!this.canSign) {
|
|
137
|
+ this.$toast(this.noSignErr);
|
|
138
|
+ return;
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ postSignIn(this.$route.query.signId).then((e) => {
|
90
|
142
|
console.log(e)
|
91
|
143
|
this.$toast('签到成功')
|
92
|
144
|
})
|
|
@@ -100,21 +152,27 @@ export default {
|
100
|
152
|
background-color: #fff;
|
101
|
153
|
height: 100%;
|
102
|
154
|
width: 100vw;
|
|
155
|
+ padding-top: 60px;
|
|
156
|
+
|
|
157
|
+ .box-item {
|
|
158
|
+ & + .box-item {
|
|
159
|
+ margin-top: 3em;
|
|
160
|
+ }
|
|
161
|
+ }
|
103
|
162
|
.box1 {
|
104
|
163
|
width: 100%;
|
105
|
|
- > img {
|
106
|
|
- width: 80px;
|
107
|
|
- border-radius: 50%;
|
108
|
|
- margin: 0 auto;
|
109
|
|
- display: block;
|
110
|
|
- padding: 35px 0 20px 0;
|
|
164
|
+
|
|
165
|
+ &-avatar {
|
|
166
|
+ display: flex;
|
|
167
|
+ justify-content: center;
|
111
|
168
|
}
|
|
169
|
+
|
112
|
170
|
&-title {
|
113
|
171
|
width: 90%;
|
114
|
172
|
margin: 0 auto;
|
115
|
173
|
text-align: center;
|
116
|
174
|
color: #000;
|
117
|
|
- font-size: 17px;
|
|
175
|
+ font-size: 18px;
|
118
|
176
|
font-weight: 700;
|
119
|
177
|
margin-bottom: 30px;
|
120
|
178
|
}
|
|
@@ -147,6 +205,7 @@ export default {
|
147
|
205
|
font-size: 19px;
|
148
|
206
|
margin-bottom: 10px;
|
149
|
207
|
font-weight: 600;
|
|
208
|
+ letter-spacing: 2px;
|
150
|
209
|
}
|
151
|
210
|
|
152
|
211
|
> span {
|