clock.vue 26 KB

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