clock.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. <template>
  2. <view>
  3. <view class="lock">
  4. <view class="lock_header">
  5. <view class="limgs">
  6. <image :src="juehg.avatar" alt="" v-if="juehg.avatar"></image>
  7. <image :src="headimg" alt="" v-else></image>
  8. </view>
  9. <view class="toptxt">
  10. <view class="tit">{{ juehg.nickName}}</view>
  11. <view class="txt">{{ kaTime }}</view>
  12. </view>
  13. <view class="topr" @click="getRecondFn">查看考勤记录 ></view>
  14. </view>
  15. <view class="bottom">
  16. <view class="olp mb24">
  17. <text>当前位置</text>
  18. <text @click="shuiux">点击刷新</text>
  19. </view>
  20. <view class="bott_nav">
  21. <image :src="adrimg"></image>
  22. <view>{{ address || '获取地址中' }}</view>
  23. </view>
  24. <!-- 休息 -->
  25. <!-- <view class="restbox">
  26. <image :src="restimg"></image>
  27. <view>今日休息</view>
  28. <view>无需打卡哟~</view>
  29. </view> -->
  30. <!-- 第二部分 -->
  31. <view class="lock_navebut">
  32. <block v-if="ruleflag">
  33. <view class="cbtn" :class="[kaRadfalg == false ? 'bgb' : '']" @click="getPunchFn">
  34. <text class="time">{{ gettime }}</text>
  35. <text class="ctimea" v-if="kaRadfalg">{{ timetext }}</text>
  36. <text class="ctimea" v-else>外勤打卡</text>
  37. </view>
  38. <view class="ctips" v-if="kaRadfalg" @click="getSuccessFn">
  39. <image :src="yk1img"></image>
  40. <text>已进入考勤范围</text>
  41. </view>
  42. <view class="ctips" v-else>
  43. <image :src="noimg"></image>
  44. <text>未进入考勤范围</text>
  45. </view>
  46. </block>
  47. <view v-else class="cbtn bga"><text class="ctimea">暂无考勤规则</text></view>
  48. </view>
  49. <!-- 第三部分 -->
  50. <view class="lockbom_nam">
  51. <!-- 步骤条 -->
  52. <view class="steps">
  53. <view class="stepsa" v-for="(item, idx) in recordList" :key="idx">
  54. <image :src="stepa" class="stepstb"></image>
  55. <view class="stepst">
  56. {{item.type==1?'上班':'下班'}}打卡
  57. <text class="co1" v-if="item.isOutwork == 3">迟到</text>
  58. <text class="co2" v-else-if="item.isOutwork == 2">外勤</text>
  59. <text class="co3" v-else-if="item.isOutwork == 4">早退</text>
  60. <!-- <text class="co4" >旷工</text> -->
  61. </view>
  62. <view class="stepstc">
  63. <view class="stepstimg"><image :src="stepb" class="imagea"></image></view>
  64. <view class="stepstxt">{{ item.recordTime }} 打卡成功</view>
  65. </view>
  66. <view class="stepstc">
  67. <view class="stepstimg"><image :src="stepc" class="imageb"></image></view>
  68. <view class="stepstxt">{{ item.recordLocations }}</view>
  69. </view>
  70. <!-- 图片 -->
  71. <view class="stepstc" v-if="item.pictureUrl">
  72. <view class="stepstimg"><image :src="pimg" class="imagec"></image></view>
  73. <image :src="baseUrl+item.pictureUrl" class="pimgs" @click="getpreviewImage(baseUrl+item.pictureUrl)"></image>
  74. </view>
  75. <!-- 情况说明 -->
  76. <view class="stepstc" v-if="item.remark">
  77. <view class="stepstimg"><image :src="stepd" class="imagea"></image></view>
  78. <view class="stepstxt">{{ item.remark }}</view>
  79. </view>
  80. </view>
  81. <!-- <view class="stepsa">
  82. <image :src="stepa" class="stepstb"></image>
  83. <view class="stepst">下班打卡</view>
  84. </view> -->
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 迟到打卡 -->
  89. <view class="bgbox" v-if="chiflag" @click="getClose"></view>
  90. <view class="bgfixed" v-if="chiflag">
  91. <!-- <view class="bgfixed" @click="getClose"> -->
  92. <view class="tit mb16">
  93. <image :src="closeimg" @click="getClose"></image>
  94. <view>
  95. <block v-if="!kaRadfalg">外勤</block>
  96. <block v-if="datainfo.isOutwork==3">迟到</block>
  97. <block v-if="datainfo.isOutwork==4">早退</block>
  98. 打卡</view>
  99. </view>
  100. <!-- -->
  101. <view class="txt" style="flex-direction: column;" >
  102. <view class="txta">
  103. <view>拍照</view>
  104. <image :src="photoimg" class="photoimg" @click="getphotoFn"></image>
  105. </view>
  106. <view class="imgsur" v-if="imgurlshow"><image :src="imgurlshow" class="txtimg" @click="getpreviewImage(imgurlshow)"></image></view>
  107. </view>
  108. <view class="txt" style="align-items: flex-start;">
  109. <view>备注</view>
  110. <uni-easyinput class="input" :inputBorder="false" type="textarea" autoHeight v-model="chitext"
  111. placeholder="请填写原因">
  112. </uni-easyinput>
  113. <!-- <input placeholder="请填写原因" v-model="chitext" /> -->
  114. </view>
  115. <view class="btn" @click="getPunchFnchi()">确认打卡</view>
  116. </view>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. // import BMap from 'BMap'
  122. // import AMap from 'AMap'
  123. import amapPlugin from '@/utils/initmap.js';
  124. import self from '@/utils/location.js';
  125. import store from '@/store';
  126. import { clocklist, getRecordList, getNormalFn, getPunchFn, getPunchputFn } from '@/api/work/check.js';
  127. import { uploadPhoto } from '@/api/system/user.js';
  128. import { selectDictLabel } from '@/utils/common';
  129. import amapFile from '@/plugins/amap-wx.js';
  130. import config from '@/config.js';
  131. const baseUrl = config.baseUrl;
  132. // #ifdef APP
  133. var myAmapFun = new amapFile.AMapWX({
  134. key: 'ccbe52b1ec5f66295fa4609c90a819b7',
  135. batch: true
  136. });
  137. // #endif
  138. export default {
  139. // name: 'AMap',
  140. data() {
  141. return {
  142. baseUrl:'',
  143. stepa: require('@/work/static/clock/stepa.png'),
  144. stepb: require('@/work/static/clock/stepb.png'),
  145. stepc: require('@/work/static/clock/stepc.png'),
  146. stepd: require('@/work/static/clock/stepd.png'),
  147. noimg: require('@/work/static/clock/moico.png'),
  148. closeimg: require('@/work/static/clock/close.png'),
  149. photoimg: require('@/work/static/clock/photo.png'),
  150. pimg: require('@/work/static/clock/pimg.png'),
  151. adrimg: require('@/work/static/clock/adress.png'),
  152. headimg: require('@/work/static/clock/pic_mine_hp_normal.png'),
  153. yk1img: require('@/work/static/clock/icon_kqdk_jrfw.png'),
  154. noimg: require('@/work/static/clock/moico.png'),
  155. restimg:require('@/work/static/clock/rest.png'),
  156. address: '',
  157. timefn: '',
  158. gettime: '',
  159. juehg: {
  160. deptName: '暂无数据',
  161. userName: '暂无数据',
  162. avatar: ''
  163. },
  164. timetext: '',
  165. loading: false,
  166. text: '选择日期',
  167. place: {
  168. lng: '',
  169. lat: ''
  170. },
  171. center: {
  172. lng: '',
  173. lat: ''
  174. },
  175. kaNum: 2, //打卡次数
  176. kaRadius: '',
  177. rulelist:[],//考勤规则
  178. kaRadfalg: false,
  179. kaTime: '',
  180. kaYear: '',
  181. kaMonth: '',
  182. kaDay: '',
  183. kaWeek: 0,
  184. recordList: [],
  185. userId: this.$store.state.user.userId,
  186. // userId: 9,
  187. deptId: this.$store.state.user.deptId,
  188. // kaSort: 1, //打卡分类 1:上午上班 2:上午下班 3:下午上班 4:下午下班,
  189. kaType: 1, //打卡类别 1正常 2:迟到 3:外勤 4:早退
  190. kaStatus: 1, //打卡状态 1正常 2:异常
  191. chiflag: false,
  192. recordId: '', //覆盖式打卡
  193. daKainfo: {
  194. "recordDt": "",//打卡记录完整时间(yyyy-MM-dd HH:mm:ss)
  195. "recordDate": "",//打卡记录日期(yyyy-mm-dd)
  196. "recordTime": "",//打卡记录时间(HH:mm:ss)
  197. "recordLocations": "",//打卡地点
  198. "week": "",//周几(1:星期一,2:星期二,3:星期三,4:星期四,5:星期五,6:星期六,7:星期日)
  199. "isOutwork":"",//打卡情况 1:正常打卡,2:外勤打卡,3:迟到,4:早退
  200. "pictureUrl":"",//图片地址
  201. "type":"",//上班,下班打卡 1:上班,2:下班
  202. },
  203. //打卡参数
  204. formData: {
  205. startWorkTime:"",
  206. endWorkTime:'',
  207. },
  208. datainfo:{},
  209. imgurl: '',
  210. imgurlshow:'',
  211. chitit: '',
  212. chitext: '',
  213. chitype: '',
  214. ruleflag:true,
  215. shuatime:30,
  216. refreshflag:true,
  217. yestday:'',
  218. yestkaTime:'',
  219. yestkaYear:'',
  220. yestkaMonth:'',
  221. yestkaDay:'',
  222. yestkaWeek:'',
  223. recordYestList:[],
  224. guoflag:false,
  225. pageNum: 1,
  226. pageSize: 10,
  227. reachflag: true,
  228. };
  229. },
  230. created() {
  231. this.baseUrl=baseUrl;
  232. this.init();
  233. },
  234. mounted() {
  235. this.datainfo.userId = this.$store.state.user.userId;
  236. // this.formData.deptId = this.$store.state.user.deptId;
  237. // this.formData.ancestors = this.$store.state.user.ancestors;
  238. // this.formData.deptName = this.$store.state.user.deptName;
  239. // this.datainfo.userName = this.$store.state.user.nickName;
  240. this.juehg = this.$store.state.user;
  241. },
  242. onUnload() {
  243. clearInterval(this.timefn)
  244. },
  245. onReachBottom() {
  246. if (this.reachflag) {
  247. this.pageNum++
  248. this.getRecordList()
  249. }
  250. },
  251. methods: {
  252. init() {
  253. var that=this;
  254. // 时间
  255. this.gettimeFn();
  256. // 规则
  257. this.getRuleFn();
  258. // that.getRecordYestList();
  259. setTimeout(function(){
  260. that.getRecordList();
  261. },1000)
  262. //加个拍照,考勤设置,加个是否启用拍照
  263. // this.getAbnormal();
  264. },
  265. getClose(){
  266. this.chiflag=false;
  267. },
  268. gettimeFn() {
  269. var that = this;
  270. clearInterval(this.timefn)
  271. that.time();
  272. var stime=this.shuatime
  273. that.timefn = setInterval(function() {
  274. if(stime<=0){
  275. that.shuiux()
  276. stime=that.shuatime
  277. }
  278. stime=stime-1;
  279. that.time();
  280. }, 1000);
  281. },
  282. // 日期
  283. time() {
  284. var date = new Date();
  285. var y = date.getFullYear();
  286. var m = date.getMonth() + 1;
  287. var d = date.getDate();
  288. var h = date.getHours();
  289. var min = date.getMinutes();
  290. var s = date.getSeconds();
  291. var week = date.getDay(); //获取当前星期X(0-6,0代表星期天)
  292. var weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  293. var yearStr = y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);
  294. var timeStr = (h < 10 ? '0' + h : h) + ':' + (min < 10 ? '0' + min : min) + ':' + (s < 10 ? '0' + s : s);
  295. // 获取昨天的
  296. let yesterday_milliseconds=date.getTime()-1000*60*60*24;
  297. let yesterday=new Date();
  298. yesterday.setTime(yesterday_milliseconds);
  299. let year=yesterday.getFullYear();
  300. let day=yesterday.getDate();
  301. let month=yesterday.getMonth()+1;
  302. var yestweek = yesterday.getDay(); //获取当前星期X(0-6,0代表星期天)
  303. var yestday= year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  304. var yesttimeStr = (h < 10 ? '0' + h : h) + ':' + (min < 10 ? '0' + min : min) + ':' + (s < 10 ? '0' + s : s);
  305. this.yestday=yestday;
  306. this.yestkaTime=yestday;
  307. this.yestkaYear = year;
  308. this.yestkaMonth = month < 10 ? '0' + month : month;
  309. this.yestkaDay = day < 10 ? '0' + day : day;
  310. this.yestkaWeek = yestweek;
  311. this.kaTime = yearStr;
  312. this.kaYear = y;
  313. this.kaMonth = m < 10 ? '0' + m : m;
  314. this.kaDay = d < 10 ? '0' + d : d;
  315. this.kaWeek = week;
  316. this.gettime = timeStr;
  317. // 年,月,日, 星期几 时分秒
  318. },
  319. shuiux() {
  320. if(this.refreshflag){
  321. this.refreshflag=false;
  322. this.getLocation();
  323. // this.getRecordList();
  324. // this.getRuleFn();//不至于每次都改打卡规则
  325. var that=this;
  326. setTimeout(function(){
  327. that.refreshflag=true;
  328. that.loctiotimeup();
  329. },2000)
  330. }else{
  331. this.refreshflag=true;
  332. }
  333. },
  334. // 时间比较
  335. getsort(beginTime, endTime, type) {
  336. if(!beginTime||!endTime){
  337. return false
  338. }
  339. var type = type || '';
  340. var nowDate = new Date();
  341. // var nowDate = new Date('2023/02/21 02:02:02');
  342. var beginDate = new Date(nowDate);
  343. var endDate = new Date(nowDate);
  344. var beginIndex = beginTime.indexOf('\:');
  345. var beginIndexs = beginTime.lastIndexOf('\:');
  346. var beginHour = beginTime.substring(0, beginIndex);
  347. var beginMinue = beginTime.substring(beginIndex + 1, beginIndexs);
  348. var beginSecend = beginTime.substring(beginIndexs + 1, beginTime.length);
  349. beginDate.setHours(beginHour, beginMinue, beginSecend, 0);
  350. var endIndex = endTime.indexOf('\:');
  351. var endIndexs = endTime.lastIndexOf('\:');
  352. var endHour = endTime.substring(0, endIndex);
  353. var endMinue = endTime.substring(endIndex + 1, endIndexs);
  354. var endSecend = endTime.substring(endIndexs + 1, endTime.length);
  355. endDate.setHours(endHour, endMinue, endSecend, 0);
  356. if (type == 'guo') {
  357. if (beginDate.getTime() - endDate.getTime() > 0) {
  358. return true;
  359. } else {
  360. return false;
  361. }
  362. } else {
  363. return nowDate.getTime() - beginDate.getTime() >= 0 && nowDate.getTime() <= endDate.getTime();
  364. }
  365. },
  366. // 判断是上班还是下班
  367. loctiotimeup() {
  368. var a = this.daKainfo.startWorkTime;
  369. var b = this.daKainfo.endWorkTime;
  370. var kata =this.formData.startWorkTime;
  371. var katb = '';
  372. if (this.getsort('00:00:00', a)) {
  373. // 上班卡
  374. if(!kata){
  375. this.timetext = '上班打卡';
  376. this.datainfo.type = 1;
  377. this.datainfo.isOutwork=1;
  378. }else if(kata){
  379. // 早退
  380. this.timetext = '下班打卡';
  381. this.datainfo.type = 2;
  382. this.datainfo.isOutwork=4;
  383. }
  384. }else if (this.getsort(a, b)) {
  385. if(!kata){
  386. // 迟到打卡
  387. this.timetext = '上班打卡';
  388. this.datainfo.type = 1;
  389. this.datainfo.isOutwork=3;
  390. }else if(kata){
  391. // 早退打卡
  392. this.timetext = '下班打卡';
  393. this.datainfo.type = 2;
  394. this.datainfo.isOutwork=4;
  395. }
  396. }else if(this.getsort(b, '23:59:59')){
  397. this.timetext = '下班打卡';
  398. this.datainfo.type = 2;
  399. this.datainfo.isOutwork = 1;
  400. }
  401. },
  402. getRuleFn() {
  403. var params={
  404. isEquip:'N'
  405. }
  406. clocklist(params).then(res => {
  407. if (res.rows) {
  408. this.ruleflag=true;
  409. this.rulelist=res.rows;
  410. this.getLocation();
  411. }else{
  412. // 暂无考勤信息
  413. this.ruleflag=false;
  414. this.getLocation();
  415. }
  416. });
  417. },
  418. // 打卡信息
  419. getRecordList() {
  420. var params = {
  421. // deptId: this.deptId,
  422. userId: this.userId,
  423. recordDate: this.kaTime,
  424. pageSize: this.pageSize,
  425. pageNum: this.pageNum,
  426. };
  427. var a=0;
  428. getRecordList(params).then(res => {
  429. if (res.code == 200) {
  430. if (res.rows.length < this.pageSize) {
  431. this.reachflag = false
  432. this.wtdt = '到底了~';
  433. } else {
  434. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
  435. 1)
  436. if (num < res.total) {
  437. this.reachflag = true
  438. this.wtdt = '上拉加载更多'
  439. } else {
  440. this.reachflag = false
  441. this.wtdt = '到底了~';
  442. }
  443. }
  444. var newArr=JSON.parse(JSON.stringify(res.rows))
  445. // 循环处理,获取上班时间,下班时间
  446. if(newArr&&newArr.length&&this.pageNum == 1){
  447. Object.keys(newArr).some((key) => {
  448. // 去重
  449. var type=newArr[key].type||'';
  450. var recordTime=newArr[key].recordTime||'';
  451. if(type==1&&recordTime){
  452. a=1;
  453. this.formData.startWorkTime=recordTime
  454. return
  455. }
  456. })
  457. }
  458. if (this.pageNum == 1) {
  459. this.recordList = newArr;
  460. } else {
  461. this.recordList = this.recordList.concat(newArr)
  462. }
  463. this.loctiotimeup();
  464. } else {
  465. this.$toast(res.msg)
  466. }
  467. // if (res.code == 200) {
  468. // this.recordList = JSON.parse(JSON.stringify(res.rows));
  469. // } else {
  470. // this.$toast(res.msg);
  471. // }
  472. });
  473. // this.$toast("登录中,请耐心等待...")
  474. },
  475. // 获取当前定位
  476. getLocation() {
  477. var that = this;
  478. // #ifdef H5
  479. that.place.lng = '117.212214';
  480. that.place.lat = '31.839812';
  481. that.address = '安徽省合肥市蜀山区高新技术产业开发区黄山路597号时代数码港';
  482. that.datainfo.recordLocations=that.address;
  483. that.distancefor();
  484. // // 解析编码
  485. // that.address = res.addr + res.name;
  486. // self.getLocation(function() {
  487. // that.place.lng = self.__CFG.lng;
  488. // that.place.lat = self.__CFG.lat;
  489. // // 解析编码
  490. // self.getGeocoder(self.__CFG.lng, self.__CFG.lat, function(res) {
  491. // that.address = res.addr + res.name;
  492. // });
  493. // // 判断是不是在范围
  494. // that.distance();
  495. // });
  496. // #endif
  497. // #ifndef H5
  498. this.getlocationapp();
  499. // #endif
  500. },
  501. // 获取定位
  502. getlocationapp() {
  503. var that = this;
  504. uni.getLocation({
  505. type: 'gcj02',
  506. geocode: true,
  507. success: function(res) {
  508. that.place.lng = res.longitude;
  509. that.place.lat = res.latitude;
  510. // #ifdef H5
  511. var adr = address.province + address.city + address.district + address.street + address.streetNum + address.poiName;
  512. // that.address=res.longitude
  513. that.address = adr;
  514. that.datainfo.recordLocations=adr;
  515. // #endif
  516. // #ifdef APP
  517. // 判断是不是在范围
  518. that.distancefor();
  519. that.getCity(res.latitude, res.longitude);
  520. // #endif
  521. },
  522. fail: function(red) {
  523. uni.showToast({
  524. title: '获取定位失败'
  525. });
  526. }
  527. });
  528. },
  529. // 循环判断是不是在中心点
  530. distancefor(lat1, lng1) {
  531. var that = this;
  532. var a=0;
  533. // 中心点
  534. var rules=JSON.parse(JSON.stringify(this.rulelist))
  535. if(this.ruleflag){
  536. Object.keys(rules).some((key) => {
  537. // 去重
  538. var lng=rules[key].lon||'';
  539. var lat=rules[key].lat||'';
  540. var distance=rules[key].distance
  541. if(lng&&lat&&distance){
  542. var type=that.getjiSort(lat,lng,distance);
  543. if(type=='dk'){
  544. this.kaRadfalg = true;
  545. this.daKainfo=rules[key];
  546. a=1;
  547. return
  548. }
  549. }
  550. })
  551. if(a==0){
  552. this.timetext = '外勤打卡';
  553. this.kaRadfalg = false;
  554. this.daKainfo=rules[0];
  555. }
  556. }
  557. },
  558. getjiSort(clat,clng,distance){
  559. // 中心点
  560. var lat1 = clat;
  561. var lng1 = clng;
  562. // 自己点
  563. let lat2 = this.place.lat;
  564. let lng2 = this.place.lng;
  565. let rad1 = (lat1 * Math.PI) / 180.0;
  566. let rad2 = (lat2 * Math.PI) / 180.0;
  567. let a = rad1 - rad2;
  568. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  569. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math.sin(b / 2), 2)));
  570. s = s * 6378.137;
  571. s = Math.round(s * 10000) / 10;
  572. s = s.toString();
  573. s = s.substring(0, s.indexOf('.') + 2);
  574. if (Number(s) < Number(distance)) {
  575. return "dk"
  576. } else {
  577. return 'wq'
  578. }
  579. },
  580. // 是否在打卡范围
  581. distance(lat1, lng1) {
  582. var that = this;
  583. // 中心点
  584. var lat1 = that.center.lat;
  585. var lng1 = that.center.lng;
  586. // 自己点
  587. let lat2 = this.place.lat;
  588. let lng2 = this.place.lng;
  589. let rad1 = (lat1 * Math.PI) / 180.0;
  590. let rad2 = (lat2 * Math.PI) / 180.0;
  591. let a = rad1 - rad2;
  592. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  593. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math.sin(b / 2), 2)));
  594. s = s * 6378.137;
  595. s = Math.round(s * 10000) / 10;
  596. s = s.toString();
  597. s = s.substring(0, s.indexOf('.') + 2);
  598. if (Number(s) < Number(this.kaRadius)) {
  599. this.kaRadfalg = true;
  600. } else {
  601. this.timetext = '外勤打卡';
  602. this.kaRadfalg = false;
  603. }
  604. // console.log(this.kaRadfalg)
  605. },
  606. getCity(latitude, longitude) {
  607. var that = this;
  608. that.location = `${longitude},${latitude}`;
  609. myAmapFun.getRegeo({
  610. //如果经纬度有问题会导致不进入回调方法,从而报错
  611. location: that.location,
  612. success: function(e) {
  613. //成功回调
  614. that.address = '';
  615. that.address = e[0].regeocodeData.formatted_address; //详细地址
  616. that.datainfo.recordLocations=that.address;
  617. },
  618. fail: function(info) {
  619. //失败回调
  620. console.log(info);
  621. }
  622. });
  623. },
  624. getPunchFnchi() {
  625. if (this.daKainfo.isPicture == 'Y' && !this.imgurl) {
  626. this.$toast('请拍照上传');
  627. return;
  628. }
  629. // if(this.chitext==''){
  630. // this.$toast("请填写备注")
  631. // return
  632. // }
  633. // var parmas=JSON.parse(JSON.stringify(this.daKainfo))
  634. this.$nextTick(function() {
  635. // 打卡
  636. this.chiflag = false;
  637. this.getPunchFnes();
  638. });
  639. },
  640. // 打卡
  641. getPunchFnes() {
  642. var that = this;
  643. var params = JSON.parse(JSON.stringify(this.datainfo));
  644. params.recordDate=this.kaTime;
  645. params.recordTime=this.gettime;
  646. params.week=this.kaWeek;
  647. params.recordDt=this.kaTime+' '+this.gettime;
  648. if(this.imgurl){
  649. params.pictureUrl=this.imgurl;
  650. }
  651. if(this.chitext){
  652. params.remark=this.chitext;
  653. }
  654. if(!this.kaRadfalg){
  655. params.isOutwork=2;
  656. }
  657. console.log(params)
  658. // return
  659. getPunchFn(params).then(res => {
  660. if (res.code == 200) {
  661. // 打卡成功
  662. // this.getRecordList()
  663. this.$tab.navigateTo('/work/pages/clock/success?tit=' + this.timetext);
  664. } else {
  665. this.$toast(res.msg);
  666. }
  667. });
  668. return
  669. // return 打卡全走新增,不用覆盖
  670. if (newArr.length) {
  671. var len = newArr.length - 1;
  672. // params['recordId'] = newArr[0].recordId;
  673. // // 覆盖打卡
  674. getPunchputFn(params).then(res => {
  675. if (res.code == 200) {
  676. // 打卡成功
  677. // this.getRecordList()
  678. this.$tab.navigateTo('/work/pages/clock/success?tit=' + this.timetext);
  679. } else {
  680. this.$toast(res.msg);
  681. }
  682. });
  683. } else {
  684. // params['recordId'] = '';
  685. getPunchFn(params).then(res => {
  686. if (res.code == 200) {
  687. // 打卡成功
  688. // this.getRecordList()
  689. this.$tab.navigateTo('/work/pages/clock/success?tit=' + this.timetext);
  690. } else {
  691. this.$toast(res.msg);
  692. }
  693. });
  694. }
  695. },
  696. getRecondFn(){
  697. var obj={
  698. userId:this.userId,
  699. recordDate:this.kaTime
  700. // recordDate:'2024-10-12'
  701. }
  702. this.$tab.navigateTo('/work/pages/record/detail?data='+encodeURIComponent(JSON.stringify(obj)))
  703. },
  704. getPunchFn(){
  705. var that=this;
  706. var parmas=JSON.parse(JSON.stringify(this.datainfo))
  707. if (parmas.isOutwork ==3||parmas.isOutwork==4||!this.kaRadfalg) {
  708. this.chiflag = true;
  709. return
  710. }
  711. this.$nextTick(function() {
  712. // 打卡
  713. this.chiflag = false;
  714. this.getPunchFnes();
  715. });
  716. },
  717. getphotoFn() {
  718. var that = this;
  719. uni.chooseImage({
  720. count: 1, //默认9
  721. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  722. sourceType: ['camera'], //从相册选择
  723. success: function(res) {
  724. const tempFilePaths = res.tempFilePaths;
  725. // 文件上传
  726. let data = { name: 'file', filePath: res.tempFilePaths[0] };
  727. uploadPhoto(data).then(response => {
  728. that.imgurlshow = baseUrl + response.fileName;
  729. that.imgurl = response.fileName;
  730. // if (!that.chiflag) {
  731. // that.getPunchFnes();
  732. // }
  733. });
  734. }
  735. });
  736. },
  737. getpreviewImage(url) {
  738. var urlArr = [];
  739. urlArr[0] = url;
  740. uni.previewImage({
  741. urls: urlArr,
  742. success: function(data) {
  743. },
  744. fail: function(err) {
  745. console.log(err.errMsg);
  746. }
  747. });
  748. },
  749. getSuccessFn(){
  750. this.$tab.navigateTo("/work/pages/clock/success?tit=上班打卡")
  751. },
  752. }
  753. };
  754. </script>
  755. <style lang="less">
  756. page {
  757. background: #ffffff;
  758. }
  759. </style>
  760. <style scoped lang="scss">
  761. .bgfixed /deep/ .uni-easyinput__content-textarea{min-height: 84rpx;margin: 0;}
  762. .steps {
  763. padding: 0 60rpx;
  764. .stepsa {position: relative;padding-bottom: 20rpx;
  765. &::after {position: absolute;width: 2rpx;height: calc(100% - 16rpx);background: #DADADA;position: absolute;left: -30rpx;top: 28rpx;content: '';}
  766. &:last-child::after {display: none;}
  767. .stepstb {width: 16rpx;height: 16rpx;position: absolute;left: -36rpx;top: 12rpx;}
  768. .stepst {font-size: 26rpx;font-weight: bold;color: #343434;
  769. text{
  770. font-size: 22rpx;padding: 0 6rpx;line-height: 20rpx;margin-left: 12rpx;border-radius: 4rpx;min-width: 64rpx;
  771. &.co1{border: 2rpx solid $uni-katype2;color: $uni-katype2;}
  772. &.co2{border: 2rpx solid $uni-katype3;color: $uni-katype3;}
  773. &.co3{border: 2rpx solid $uni-katype4;color: $uni-katype4;}
  774. &.co4{border: 2rpx solid $uni-katype5;color: $uni-katype5;}
  775. }
  776. }
  777. .stepstc {padding-left: 12rpx;display: flex;padding: 6rpx 0;
  778. .stepstimg {width: 22rpx;margin-right: 8rpx;height: 30rpx;flex: 0 0 auto;display: flex;align-items: center;
  779. .imagea {width: 22rpx;height: 22rpx;}
  780. .imageb {width: 18rpx;height: 18rpx;}
  781. .imagec {width: 20rpx;height: 20rpx;}
  782. }
  783. .pimgs{width: 70rpx;height: 70rpx;margin: 0 12rpx 12rpx 0;}
  784. .stepstxt {font-size: 22rpx;color: #343434;flex: 1;}
  785. }
  786. }
  787. }
  788. .lock {background: #fff;padding: 50rpx 34rpx 54rpx;
  789. .van-step--finish {
  790. color: #07c160;
  791. }
  792. .lock_header {padding: 42rpx 40rpx;display: flex;align-items: center;box-shadow: 0px 0px 12rpx 0px rgba(153, 152, 152, 0.39);border-radius: 6rpx;
  793. .limgs{width: 84rpx;height: 84rpx;margin-right: 24rpx;flex: 0 0 auto;
  794. image{width: 100%;height: 100%;border-radius: 50%;}
  795. }
  796. .toptxt{flex: 1;
  797. .tit{font-weight: bold;font-size: 28rpx;color: #343434;margin-bottom: 6rpx;}
  798. .txt{font-weight: 400;font-size: 26rpx;color: #666666;}
  799. }
  800. .topr{font-weight: 400;font-size: 26rpx;color: #009FE8;flex: 0 0 auto;margin-left: 12rpx;}
  801. }
  802. // 第二部分样式
  803. .bottom {box-shadow: 0px 0px 12rpx 0px rgba(153, 152, 152, 0.39);border-radius: 6rpx;margin-top: 30rpx;padding: 46rpx 34rpx 40rpx;
  804. .olp {font-size: 28rpx;font-weight: bold;color: #343434;display: flex;justify-content: space-between;width: 100%;}
  805. .bott_nav {
  806. display: flex;margin-bottom: 100rpx;
  807. image {width: 26rpx;height: 28rpx;margin-right: 12rpx;flex: 0 0 auto;margin-top: 4rpx;}
  808. view {flex: 1;font-size: 28rpx;font-weight: 400;color: #343434;
  809. }
  810. }
  811. }
  812. // 按钮样式
  813. .lock_navebut {display: flex;flex-direction: column;justify-content: center;align-items: center;margin-bottom: 72rpx;
  814. .cbtn {width: 368rpx;height: 194rpx;background: #1678ff;box-shadow: 0px 6rpx 6rpx 0px rgba(3, 141, 204, 0.39);border-radius: 96rpx;
  815. display: flex;flex-direction: column;justify-content: center;align-items: center;margin-bottom: 40rpx;
  816. &.bga{background-color: #999;box-shadow: 0px 6rpx 6rpx 0px rgba(153, 152, 152, 0.39)}
  817. &.bgb{background-color: #39b54a;box-shadow: 0px 6rpx 6rpx 0px rgba(4, 147, 52, 0.39)}
  818. .time{font-size: 30rpx;font-weight: bold;color: #ffffff;margin-bottom: 8rpx;}
  819. .ctimea{
  820. font-weight: 500;font-size: 28rpx;color: #ffffff;
  821. }
  822. }
  823. .ctips{display: flex;
  824. image {width: 20rpx;height: 20rpx;margin-top: 6rpx;}
  825. text {font-size: 26rpx;font-weight: 400;color: #666666;margin-left: 14rpx;}
  826. }
  827. }
  828. }
  829. // 异常弹窗
  830. .bgbox {position: fixed;left: 0;right: 0;top: 0;bottom: 0;background: rgba(0, 0, 0, 0.5);z-index: 2;}
  831. .bgfixed {position: fixed;left: 0;right: 0;bottom: 0;padding: 52rpx 32rpx 26rpx;background: #ffffff;z-index: 10;
  832. .tit {
  833. display: flex;
  834. align-items: center;
  835. image {width: 28rpx;height: 28rpx;flex: 0 0 auto;}
  836. view {font-size: 28rpx;font-weight: bold;color: #000000;padding-right: 28rpx;flex: 1;text-align: center;}
  837. }
  838. .txt {display: flex;align-items: center;margin-top: 20rpx;
  839. view {font-size: 28rpx;color: #343434;font-weight: bold;flex: 0 0 auto;}
  840. .input {font-size:28rpx;flex: 1;text-align: right;font-weight: 500;}
  841. .photoimg{width: 46rpx;height: 40rpx;}
  842. .txta{display: flex;align-items: center;width: 100%;justify-content: space-between;margin-bottom: 20rpx;}
  843. .imgsur{width: 100%;padding-left: 80rpx;display: flex;justify-content: flex-end;
  844. .txtimg{
  845. width: 80rpx;height: 80rpx;margin: 0 12rpx 12rpx 0;
  846. }
  847. }
  848. }
  849. .btn {width: 100%;height: 84rpx;background: #1678FF;border-radius: 6rpx;text-align: center;line-height: 84rpx;font-size: 28rpx;color: #FFFFFF;margin-top: 60rpx;}
  850. }
  851. .restbox{display: flex;flex-direction: column;align-items: center;margin-bottom: 48rpx;
  852. image{width: 396rpx;height: 264rpx;margin-bottom: 20rpx;}
  853. view{font-weight: 500;font-size: 26rpx;color: #343434;}
  854. }
  855. </style>