qingyiay
2023-10-30 0978691dc9047c7090dca64406f5d0ac027e8df4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<template>
    <!-- 打卡 -->
    <view class="punchTheClock">
        <!-- 打卡按钮 -->
        <view class="punchTheClock_container">
            <view class="punchTheClock_btn"
                @click="arrive">
                <view>
                    <p>{{ coalStatus == 2 ? '已签到' : '签到/打卡' }}</p>
                    <p>{{ nowTime }}</p>
                </view>
            </view>
        </view>
        <view class="entrance-apply">
            <view class="entrance-apply_block">
                <u-button text="更换预约时间"
                    @click="entranceApply"></u-button>
            </view>
        </view>
    </view>
</template>
 
<script>
    import { todayDate } from '@/utils/util.js';
    export default {
        data() {
            return {
                nowTime: '',
                coalStatus: 0,
                punchTheClockObj: {
                    tmcoa: null,
                    latA: null,
                    latB: null
                },
                timeout: '2', //'1' 是超时 '2' 是未超时
                entranceApplyParams: {
                    takeCoalId: '',
                    filedId: '',
                    deptId: '',
                    sendDate: '',
                    yyId: ''
                },
                yuYueSection: '', //预约时间段
            };
        },
        onLoad(params) {
            this.punchTheClockObj.tmcoa = params.tmId;
            this.coalStatus = params.coalStatus;
            this.timeout = params.timeout
            this.entranceApplyParams.takeCoalId = params.orderPlanId
            this.entranceApplyParams.filedId = params.filedId
            this.entranceApplyParams.deptId = params.deptId
            this.entranceApplyParams.sendDate = params.sendDate
            this.entranceApplyParams.yyId = params.yyId
            this.yuYueSection = params.yuYueSection
            this.getSetting(); //获取授权
            this.getFuzzyLocation(); //获取位置
            this.todayDate(); //当前时间
        },
        methods: {
            getSetting() {
                // 获取权限信息
                wx.getSetting({
                    success(res) {
                        if (!res.authSetting['scope.userFuzzyLocation']) {
                            wx.authorize({
                                scope: 'scope.userFuzzyLocation',
                                success(res) {
                                    uni.showToast({
                                        title: '授权成功!'
                                    });
                                }
                            });
                        }
                    },
                    fail() {
                        console.log('获取失败');
                    }
                });
            },
            getFuzzyLocation() {
                let that = this;
                wx.getFuzzyLocation({
                    type: 'wgs84',
                    success(res) {
                        console.log(res, '获取位置', that);
                        that.punchTheClockObj.latB = res.latitude;
                        that.punchTheClockObj.latA = res.longitude;
                    }
                });
            },
            todayDate() {
                setInterval(() => {
                    this.nowTime = todayDate('hms');
                }, 1000);
            },
            // 签到
            arrive() {
                if (this.punchTheClockObj.latA && this.punchTheClockObj.latB) {
                    console.log(this.punchTheClockObj);
                    this.$reqPost('arrive', this.punchTheClockObj, 'params').then(res => {
                        console.log(res, '签到');
                        if (res.code == 0) {
                            this.$u.toast('签到成功');
                            setTimeout(() => {
                                uni.navigateBack({
                                    delta: 1
                                });
                            }, 1000);
                        } else {
                            this.$u.toast(res.msg ? res.msg : '签到失败');
                        }
                    });
                } else {
                    this.$u.toast('暂获取不到到当前位置');
                }
            },
            entranceApply() {
                if (this.coalStatus !== 2) {
                    this.$u.toast('请先签到')
                    return
                }
                if (this.timeout === '2') {
                    this.$u.toast('未超出预约时间,无需更换');
                    return
                }
                uni.navigateTo({
                    url: `/pages/driver-page/appointment/appointment?type=入场申请&takeCoalId=${this.entranceApplyParams.takeCoalId}&yyId=${this.entranceApplyParams.yyId}&filedId=${this.entranceApplyParams.filedId}&deptId=${
                        this.entranceApplyParams.deptId
                    }&sendDate=${this.entranceApplyParams.sendDate}&yuYueSection=${this.yuYueSection}`
                });
            }
        }
    };
</script>
 
<style lang="scss"
    scoped>
    .punchTheClock {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
 
        .punchTheClock_container {
            .punchTheClock_btn {
                width: vww(240);
                height: vww(240);
                color: #ffffff;
                font-size: vww(20);
                border-radius: 50%;
                background-color: #36d4e5;
                display: flex;
                justify-content: center;
                align-items: center;
 
                p {
                    text-align: center;
                }
            }
 
            .punchTheClock_text {
                display: flex;
                justify-content: center;
                margin-top: vww(20);
                color: #b8b8b8;
 
                .text {
                    margin-left: vww(5);
                }
            }
        }
 
        .entrance-apply {
            width: 100%;
            display: flex;
            justify-content: center;
            position: fixed;
            bottom: vww(50);
 
            &_block {
                width: 50%;
 
                /deep/.u-button {
                    font-size: 28rpx;
                    font-weight: 300;
                    color: #ffffff !important;
                    background: #497bfb !important;
                    letter-spacing: 4rpx;
                    border-radius: 37rpx 37rpx 37rpx 37rpx !important;
                    box-shadow: 2rpx 3rpx 13rpx 0rpx rgba(43, 98, 239, 0.5), 0rpx 0rpx 9rpx 0rpx rgba(247, 250, 253, 0.29);
                }
            }
        }
    }
</style>