You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
8.0 KiB

2 years ago
//单位普通人员
<template>
<view style="background-color: #F3F3F3;min-height: 100vh;">
<u-sticky>
<view style="background-color: #3A71FF;height: 90px;">
2 years ago
<image :src="applet+'/close.png'" style="width: 35px;height: 35px;margin-top: 40px;margin-left: 10px;"
@tap="close"></image>
<view style="text-align: center;color: #fff;position: absolute;top: 49px;left: 40%;font-size: 17px;">
值班打卡</view>
2 years ago
</view>
</u-sticky>
2 years ago
<view
style="margin: 10px auto;border: 1px #b7b7b7 dashed;width: 80%;border-radius: 6px;padding: 10px;background-color: #eaeaea;">
<view style="margin-bottom: 10px;text-align: center;">打卡时间范围</view>
<view v-for="item in ruleList" style="font-size: 12px;text-align: center;margin-top: 10px;">
{{item.startTime}} ~ {{item.endTime}}</view>
2 years ago
</view>
2 years ago
<view style="margin-top: 30px;" @click="clickSign">
2 years ago
<view class="module CBlue">
<view class="text">打卡</view>
<view class="time">{{time}}</view>
</view>
2 years ago
<view style="margin: 10px 0;text-align: center;font-size: 12px;">提示打卡需要您上传中控室的自拍照片</view>
2 years ago
</view>
<view style="text-align: center;font-size: 12px;margin-top: 20px;">
2 years ago
<view v-for="item in ingDate" style="margin-top: 5px;">
<image :src="applet+'/success.png'" style="width: 14px;height: 14px;margin-right: 5px;"></image>
{{item.time}}已打卡
</view>
2 years ago
</view>
<view style="padding: 10px 10px;">
<view>
<text>打卡记录</text>
</view>
<uni-list class="custom-list">
2 years ago
<u-card class="custom-card" v-for="(val,index) in list" @click="previewOpen(val.picUrl)"
2 years ago
:show-foot="false" :show-head="false">
2 years ago
<view slot="body" class="u-body-item" style="display: flex;flex-wrap:nowrap;">
2 years ago
<view>
<image :src="val.picUrl" mode="aspectFill" style="width: 60px;height: 80px;"></image>
</view>
<view style="margin-left: 20px;line-height: 28px;margin-top: 11px;">
<view>打卡时间:</view>
<view>{{val.time}}</view>
</view>
2 years ago
</view>
</u-card>
</uni-list>
2 years ago
2 years ago
</view>
</view>
</template>
<script>
2 years ago
import {
formatterDateTime
} from "@/common/utils.js"
import config from "../../uni_modules/uview-ui/libs/config/config"
var interval = null
2 years ago
export default {
data() {
return {
2 years ago
pageInfo: {
page: 1,
limit: 20,
userId: uni.getStorageSync("user_id"),
unitId: uni.getStorageSync("dept_id")
2 years ago
},
2 years ago
applet: this.$url.data.applet,
2 years ago
time: formatterDateTime(new Date(), 'h:min:s'),
2 years ago
date: formatterDateTime(new Date(), 'Y-M-D'),
lnt: '',
ingDate: [],
list: [],
2 years ago
//ruleList:[{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'}]
2 years ago
ruleList: [],
serverTime: '',
form: {},
taskId: ''
2 years ago
}
},
onLoad() {
this.getTime()
2 years ago
this.initRuleList()
this.getRecordByToday()
this.loadData()
2 years ago
},
onHide() {
clearInterval(interval)
},
onShow() {
this.getTime()
},
methods: {
2 years ago
initRuleList() {
this.$http.get("/fire-customer/sign/getRuleByUnitIdAndDate", {
unitId: uni.getStorageSync("dept_id"),
date: this.date
}, {}).then(res => {
2 years ago
this.ruleList = res.data
2 years ago
})
},
2 years ago
getRecordByToday() {
2 years ago
//获取今天打卡记录
2 years ago
this.$http.get("/fire-customer/sign/getRecordByUserIdAndDate", {
userId: uni.getStorageSync("user_id"),
unitId: uni.getStorageSync("dept_id"),
date: this.date
}, {}).then(res => {
2 years ago
this.ingDate = res.data
2 years ago
this.ingDate.forEach(ingDate => {
this.ruleList.forEach((rule, index) => {
if (ingDate.taskId == rule.id) {
2 years ago
// this.ruleList[index].bb = true
rule.bb = true
}
})
2 years ago
})
})
},
2 years ago
loadData() {
this.$http.get("/fire-customer/sign/record/user/page", this.pageInfo, {}).then(res => {
2 years ago
this.list = this.list.concat(res.data.records)
})
},
2 years ago
clickSign() {
this.$http.get("/fire-customer/sign/getServerTime", {}, {}).then(res => {
2 years ago
this.serverTime = res.data
1 year ago
let n = new Date(res.data.replace(/-/g, '/')).getTime()
2 years ago
let bl = false
try {
2 years ago
this.ruleList.forEach((rule) => {
1 year ago
let s = new Date(rule.startTime.replace(/-/g, '/')).getTime()
let e = new Date(rule.endTime.replace(/-/g, '/')).getTime()
2 years ago
if (s <= n && n <= e) {
if (rule.bb) {
2 years ago
uni.showToast({
2 years ago
icon: 'none',
title: '该时间段已打卡,请勿重复打卡'
2 years ago
})
bl = true
return false
}
2 years ago
//rule.bb = true
2 years ago
this.taskId = rule.id
bl = true
this.getDw()
throw new Error("停止循环");
}
})
2 years ago
} catch (e) {
2 years ago
throw e;
2 years ago
}
if (!bl) {
2 years ago
uni.showToast({
2 years ago
icon: "none",
title: "不在打卡时间范围!请到点打卡!"
2 years ago
})
return false
}
2 years ago
})
2 years ago
},
2 years ago
getDw() {
2 years ago
this.getLocation()
this.getCam()
},
2 years ago
getCam() {
2 years ago
uni.chooseMedia({
2 years ago
count: 1,
mediaType: ['image'],
sourceType: ['camera'],
camera: 'front',
success: (e) => {
2 years ago
uni.showLoading({
title: "上传图片...",
mask: true
})
let te = e.tempFiles[0].tempFilePath
//"{"code":200,"success":true,"data":"https://keningfile.oss-cn-shenzhen.aliyuncs.com/knFire/image/20230724/20230724180751_446.jpg","msg":"操作成功"}"
2 years ago
this.$http.upload('/fire-customer/knAliOss/uploadVadioFile', te, {}).then(res => {
2 years ago
let ddd = JSON.parse(res.data)
this.form.picUrl = ddd.data
this.form.locate = this.lnt
this.form.time = this.serverTime
this.form.userId = uni.getStorageSync("user_id")
this.form.unitId = uni.getStorageSync("dept_id")
this.form.date = this.date
this.form.taskId = this.taskId
2 years ago
this.$http.post('/fire-customer/sign/addRecord', this.form, {}).then(
res => {
2 years ago
uni.hideLoading()
this.getRecordByToday()
this.pageInfo.page = 1;
this.list = [];
this.loadData();
})
2 years ago
}).catch(e => {
2 years ago
uni.hideLoading()
2 years ago
uni.showToast({
2 years ago
icon: 'error',
title: '请重试..'
2 years ago
})
2 years ago
})
2 years ago
2 years ago
}
})
},
getLocation() {
uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
geocode: true,
2 years ago
success: (res) => {
2 years ago
this.lnt = res.longitude + ',' + res.latitude;
}
2 years ago
})
},
getTime() {
2 years ago
interval = setInterval(() => {
2 years ago
this.time = formatterDateTime(new Date(), 'h:min:s')
}, 1000)
},
previewOpen(e) {
2 years ago
uni.previewImage({
urls: [e]
2 years ago
})
},
2 years ago
close() {
2 years ago
clearInterval(interval)
uni.removeStorageSync("token")
uni.redirectTo({
2 years ago
url: '/pages/login/index'
2 years ago
})
2 years ago
2 years ago
}
},
onPullDownRefresh() {
this.pageInfo.page = 1;
this.list = [];
this.loadData();
this.getRecordByToday()
//下拉刷新
uni.stopPullDownRefresh();
},
onReachBottom() {
this.pageInfo.page = this.pageInfo.page + 1;
this.loadData();
//加载更多
2 years ago
},
onUnload() {
clearInterval(interval)
}
}
</script>
<style scoped lang="scss">
.CBlue {
2 years ago
background-image: linear-gradient(#7cc9ff, #1771d7);
2 years ago
box-shadow: 0 8px 8px #b0d2f3;
}
.module {
overflow: hidden;
margin: 20upx auto;
width: 260upx;
height: 260upx;
border-radius: 50%;
color: #fff;
text-align: center;
}
.module .text {
font-size: 20px;
margin: 80upx auto 10upx;
}
2 years ago
2 years ago
.custom-list {
background: #f1f1f4;
2 years ago
2 years ago
.custom-card {
2 years ago
//margin: 12rpx 24rpx !important;
2 years ago
position: relative;
2 years ago
2 years ago
.card-nav {
position: absolute;
float: right;
top: 40%;
right: 35rpx;
}
}
}
2 years ago
2 years ago
.u-body-title {
font-size: 32rpx;
color: #333;
}
2 years ago
2 years ago
.u-body-item {
padding: 0rpx;
}
2 years ago
2 years ago
.u-body-item-desc {
font-size: 28rpx;
color: #555;
padding: 0rpx;
}
2 years ago
2 years ago
.u-body-item image {
width: 160rpx;
flex: 0 0 160rpx;
height: 120rpx;
border-radius: 8rpx;
margin-left: 0rpx;
margin-right: 12rpx;
}
2 years ago
2 years ago
.u-margin-right-12 {
margin-right: 12rpx;
border: 0;
}
2 years ago
</style>