2022-11-15 10:03:13 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view class="pad-x120">
|
|
|
|
|
<!-- 头部 -->
|
|
|
|
|
<status-nav :ifReturn="false" navBarTitle="打卡小程序" :titleColor="titleColor" :backgroudColor="backgroudColor"></status-nav>
|
|
|
|
|
<view class="content">
|
|
|
|
|
<!-- 打卡 -->
|
|
|
|
|
<view class="sign-top font24 color-white" :style="{'padding-top':statusHeight+50+'px'}">
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<image src="/static/sign-bg.jpg" mode="aspectFill"></image>
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<view class="sign-time">
|
|
|
|
|
<text>{{currentDate}}</text>
|
|
|
|
|
<text>{{currentWeek}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="sign-btn" :class="finish?'finish':''" @tap="signEv">
|
|
|
|
|
<text class="font56">{{finish?'已打卡':'打卡'}}</text>
|
|
|
|
|
<text>{{currenTime}}</text>
|
|
|
|
|
</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<view class="sign-site" v-if="isLoding">
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<view class="name">{{siteInfo.name}}</view>
|
|
|
|
|
<view class="position">
|
|
|
|
|
<view class="warning" v-if="!siteInfo.name">
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<image src="/static/icon/icon-warning.png" mode="aspectFit"></image>
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<text class="color-yellow">不在范围内</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="position-btn" @tap="getLocationEv(1)">
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<image src="/static/icon/icon-position.png" mode="aspectFit"></image>
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<text>重新定位</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<view class="sign-type bg-yellow font26" @tap="changeSignType" :style="{'top':statusHeight+50+'px'}">{{signType=='in'?'上班':'下班'}}</view>
|
2022-11-15 10:03:13 +00:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 打卡记录 -->
|
|
|
|
|
<view class="sign-record bg-white">
|
|
|
|
|
<view class="title">
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<image src="/static/icon/icon-sign.png" mode="aspectFit"></image>
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<text class="color-blue font28">今日打卡记录</text>
|
|
|
|
|
</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<view class="item font26" v-for="(item,index) in signList" :key="index">
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<view class="info">
|
|
|
|
|
<text>{{item.type_text}}打卡:{{item.created_at.substr(item.created_at.length-8)}}</text>
|
|
|
|
|
<text>打卡工地:{{item.worksite_name}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="state" :class="item.state==1?'color-blue':''">{{item.status_text}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 安全公告 -->
|
|
|
|
|
<view class="pop-up-bg" v-if="!isRead && safetyBulletin!==''">
|
|
|
|
|
<view class="safety-bulletin bg-white">
|
|
|
|
|
<view class="title font34">安全公告</view>
|
|
|
|
|
<view class="txt font24">{{safetyBulletin}}</view>
|
|
|
|
|
<view class="close-btn font30 color-66" @tap="closeSafetyBulletin">关闭</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 注册工人信息 -->
|
|
|
|
|
<view class="pop-up-bg" v-if="userInfo.checking==0 && userInfo.role==0">
|
|
|
|
|
<view class="register-information font24 bg-white">
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">姓名</view>
|
|
|
|
|
<input class="input" type="text" v-model="registerObj.real_name">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">电话号码</view>
|
|
|
|
|
<input class="input" type="number" v-model="registerObj.mobile">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">身份证</view>
|
|
|
|
|
<input class="input" type="text" v-model="registerObj.card_number">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">技术岗位</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<picker class="input" mode="selector" :range="positionList" @change="choicePosition" :value="positionIndex" :range-key="'name'">
|
|
|
|
|
<view class="name">
|
2022-11-15 10:03:13 +00:00
|
|
|
|
<text>{{positionList[positionIndex].name}}</text>
|
|
|
|
|
<image src="/static/icon/icon-arrow-01.png" mode="aspectFit"></image>
|
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">工资</view>
|
|
|
|
|
<input class="input" type="number" v-model="registerObj.pay">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">紧急联系人</view>
|
|
|
|
|
<input class="input" type="text" v-model="registerObj.emergency_contact">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">联系人电话</view>
|
|
|
|
|
<input class="input" type="number" v-model="registerObj.emergency_phone">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">银行卡户名</view>
|
|
|
|
|
<input class="input" type="text" v-model="registerObj.bank_card_name">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">银行卡号</view>
|
|
|
|
|
<input class="input" type="number" v-model="registerObj.bank_card_number">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
|
|
|
|
<view class="title">开户行</view>
|
|
|
|
|
<input class="input" type="text" v-model="registerObj.bank_name">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="submit-btn bg-blue color-white font30" @tap="submitRegister">提交</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 尾部 -->
|
|
|
|
|
<tabbar :userType="userType"></tabbar>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import tabbar from '@/components/tabbar/tabbar';
|
|
|
|
|
export default {
|
|
|
|
|
components:{
|
|
|
|
|
tabbar
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
|
|
|
|
|
userType:'worker', //账户类型 工人:worker 负责人:director
|
|
|
|
|
frontColor:'#ffffff', //状态栏文字颜色
|
|
|
|
|
backgroudColor:'none', //导航栏背景
|
|
|
|
|
titleColor:'#ffffff', //导航栏颜色
|
|
|
|
|
signType:'in', //打卡分类 in:上班 out:下班
|
|
|
|
|
currentDate:'', //当前日期
|
|
|
|
|
currentWeek:'', //当前星期几
|
|
|
|
|
currenTime:'', //实时时间
|
|
|
|
|
siteInfo:{}, //定位工地
|
|
|
|
|
signList:[], //打卡记录
|
|
|
|
|
safetyBulletin:'', //安全公告
|
|
|
|
|
isRead:true, //是否已读安全公告
|
|
|
|
|
userInfo:{
|
|
|
|
|
checking:-1,
|
|
|
|
|
role:-1
|
|
|
|
|
}, //用户信息
|
|
|
|
|
registerObj:{
|
|
|
|
|
real_name:'',
|
|
|
|
|
mobile:'',
|
|
|
|
|
card_number:'',
|
|
|
|
|
pay:'',
|
|
|
|
|
position:-1,
|
|
|
|
|
emergency_contact:'',
|
|
|
|
|
emergency_phone:'',
|
|
|
|
|
bank_card_name:'',
|
|
|
|
|
bank_card_number:'',
|
|
|
|
|
bank_name:'',
|
|
|
|
|
worksite_id:-1
|
|
|
|
|
}, //工人注册信息
|
|
|
|
|
positionList:[], //技术岗位
|
|
|
|
|
positionIndex:0, //当前技术岗位
|
|
|
|
|
finish:false, //是否完成打卡
|
|
|
|
|
flag:true, //是否能提交
|
2022-11-16 10:20:26 +00:00
|
|
|
|
isLoding:false, //是否加载完成
|
2022-11-15 10:03:13 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onPageScroll(object){
|
|
|
|
|
if(object.scrollTop >= 5){
|
|
|
|
|
this.frontColor = '#000000';
|
|
|
|
|
this.backgroudColor = '#ffffff';
|
|
|
|
|
this.titleColor = '#3333333';
|
|
|
|
|
// 改变状态栏
|
|
|
|
|
this.changeStatusNav();
|
|
|
|
|
}
|
|
|
|
|
if(object.scrollTop <= 0){
|
|
|
|
|
this.frontColor = '#ffffff';
|
|
|
|
|
this.backgroudColor = 'none';
|
|
|
|
|
this.titleColor = '#ffffff';
|
|
|
|
|
// 改变状态栏
|
|
|
|
|
this.changeStatusNav();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
// 改变状态栏
|
|
|
|
|
this.changeStatusNav();
|
|
|
|
|
|
|
|
|
|
// 获取位置信息
|
|
|
|
|
this.getLocationEv(0);
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
// 获取打卡信息
|
|
|
|
|
this.getSignInfo();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 改变状态栏
|
|
|
|
|
changeStatusNav(){
|
|
|
|
|
wx.setNavigationBarColor({
|
|
|
|
|
frontColor: this.frontColor,
|
|
|
|
|
backgroundColor: 'none',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
getUserInfo(){
|
|
|
|
|
this.$requst.post('/api/v1/user/info').then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
console.log(res,'用户信息');
|
|
|
|
|
this.userInfo = res.data;
|
|
|
|
|
if(this.userInfo.checking==0 && this.userInfo.role==0){
|
|
|
|
|
// 获取技术岗位
|
|
|
|
|
this.getPositionList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 授权位置信息
|
|
|
|
|
getLocationEv(type){
|
|
|
|
|
uni.getLocation({
|
|
|
|
|
type: 'wgs84',
|
|
|
|
|
success: (res)=>{
|
|
|
|
|
console.log(res,'位置信息');
|
|
|
|
|
if(type=='1'){
|
|
|
|
|
this.$toolAll.tools.showToast('重新定位成功');
|
|
|
|
|
}
|
|
|
|
|
//获取工地列表
|
|
|
|
|
this.getSiteEv(res.longitude,res.latitude);
|
|
|
|
|
// 判断是否查看安全公告
|
|
|
|
|
if(uni.getStorageSync('isRead')){
|
|
|
|
|
this.isRead = uni.getStorageSync('isRead');
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
this.getUserInfo();
|
|
|
|
|
}else{
|
|
|
|
|
this.isRead = false;
|
|
|
|
|
// 获取安全公告
|
|
|
|
|
this.getSafetyBulletin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//获取工地列表
|
|
|
|
|
getSiteEv(lng,lat){
|
|
|
|
|
this.$requst.get('/api/v1/common/get-current-worksite',{lng:lng,lat:lat}).then(res=>{
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
console.log(res,'定位工地信息');
|
|
|
|
|
this.siteInfo = res.data;
|
|
|
|
|
this.registerObj.worksite_id = res.data.id;
|
2022-11-16 10:20:26 +00:00
|
|
|
|
this.isLoding = true;
|
2022-11-15 10:03:13 +00:00
|
|
|
|
}else{
|
|
|
|
|
this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取安全公告
|
|
|
|
|
getSafetyBulletin(){
|
|
|
|
|
if(!this.isRead){
|
|
|
|
|
this.$requst.get('/api/v1/index/safe-notice').then(res=>{
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
console.log(res,'安全公告');
|
|
|
|
|
this.safetyBulletin = '安全告知员工手册公告信息安全告知,员工手册,公告信息安全告知,员工手册,公告信息安全告知,员工手册,公告信息安全告知,员工手册公告信息安全告知员工手册,公告信息安全告知,员工手册,公告信息安全告知,员工手册,公告信息安全告知,员工手册公告信息安全告知,员工手册,公告信息安全告知员二十大受权发布党的二十大主席团举行第二次会议习近平主持会议聚焦初心永不褪色 使命历久弥新';
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 关闭安全公告
|
|
|
|
|
closeSafetyBulletin(){
|
|
|
|
|
this.isRead = true;
|
|
|
|
|
// 缓存是否已读
|
|
|
|
|
uni.setStorageSync('isRead',this.isRead);
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
this.getUserInfo();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取技术岗位
|
|
|
|
|
getPositionList(){
|
|
|
|
|
this.$requst.get('/api/v1/common/position-list').then(res=>{
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
console.log(res,'技术岗位');
|
|
|
|
|
this.positionList = res.data.list;
|
|
|
|
|
this.registerObj.position = res.data.list[this.positionIndex].id;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 选择技术岗位
|
|
|
|
|
choicePosition(e){
|
|
|
|
|
this.positionIndex = e.detail.value;
|
|
|
|
|
this.registerObj.position = this.positionList[e.detail.value].id;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 提交注册信息
|
|
|
|
|
submitRegister(){
|
|
|
|
|
if(this.checkEmpty() && this.flag){
|
|
|
|
|
this.flag = false;
|
|
|
|
|
let params = this.registerObj;
|
|
|
|
|
this.$requst.post('/api/v1/worker/register',params).then(res=>{
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
this.$toolAll.tools.showToast('提交成功');
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
this.getUserInfo();
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.flag = true;
|
|
|
|
|
},2000)
|
|
|
|
|
}else{
|
|
|
|
|
this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.flag = true;
|
|
|
|
|
},2000)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 验证电话号
|
|
|
|
|
checkEmpty(){
|
|
|
|
|
let result = false;
|
|
|
|
|
if(this.$toolAll.tools.isPhone(this.registerObj.mobile)) {
|
|
|
|
|
this.$toolAll.tools.showToast('请正确填写电话号码');
|
|
|
|
|
} else {
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取打卡信息
|
|
|
|
|
getSignInfo(){
|
|
|
|
|
this.$requst.get('/api/v1/user/sign-info').then(res=>{
|
|
|
|
|
if(res.code == 0){
|
|
|
|
|
console.log(res,'打卡信息');
|
|
|
|
|
// 获取日期
|
|
|
|
|
this.currentDate = res.data.info.today;
|
|
|
|
|
// 获取星期几
|
|
|
|
|
this.currentWeek = res.data.info.week;
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
this.currenTime = res.data.info.now;
|
|
|
|
|
// 服务端时间处理
|
|
|
|
|
setInterval(()=>{
|
|
|
|
|
let nowArr = this.currenTime.split(':');
|
|
|
|
|
let hour = parseInt(nowArr[0]);
|
|
|
|
|
let minute = parseInt(nowArr[1]);
|
|
|
|
|
let second = parseInt(nowArr[2]);
|
|
|
|
|
if(second<59){
|
|
|
|
|
second++;
|
|
|
|
|
if(second<10){
|
|
|
|
|
second = '0'+second;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
second = '00';
|
|
|
|
|
if(minute<59){
|
|
|
|
|
minute++;
|
|
|
|
|
if(minute<10){
|
|
|
|
|
minute = '0'+minute;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
minute = '00';
|
|
|
|
|
if(hour<23){
|
|
|
|
|
hour++;
|
|
|
|
|
if(hour<10){
|
|
|
|
|
hour = '0'+hour;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
hour = '00';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.currenTime = `${hour}:${minute}:${second}`;
|
|
|
|
|
},1000)
|
|
|
|
|
// 获取打卡记录列表
|
|
|
|
|
this.signList = res.data.list;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 改变上下班打卡
|
|
|
|
|
changeSignType(){
|
|
|
|
|
if(this.signType == 'in'){
|
|
|
|
|
this.signType = 'out';
|
|
|
|
|
}else{
|
|
|
|
|
this.signType = 'in';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 打卡
|
|
|
|
|
signEv(){
|
|
|
|
|
let params = {
|
|
|
|
|
type:this.signType,
|
|
|
|
|
lat:this.siteInfo.lat,
|
|
|
|
|
lng:this.siteInfo.lng,
|
|
|
|
|
worksite_id:this.siteInfo.id
|
|
|
|
|
}
|
|
|
|
|
this.$requst.post('/api/v1/worker/sign',params).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.finish = true;
|
|
|
|
|
// 获取打卡信息
|
|
|
|
|
this.getSignInfo();
|
|
|
|
|
// 延时改变打卡状态
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.finish = false;
|
|
|
|
|
},10000)
|
|
|
|
|
}else{
|
|
|
|
|
this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|