| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <view class="content">
- <view class="dk-title" @click="goDkHis">
- 打卡历史
- </view>
- <map name="" class="map" :latitude="latitude" :longitude="longitude" :markers="markers"></map>
- <view class="info">
- <text class="info-tit">打卡时段</text> <text class="info-val">{{today}} 00:00-23:59</text>
- </view>
- <view class="info">
- <text class="info-tit">打卡地点</text> <text class="info-val">{{address}}</text>
- </view>
- <view class="info" v-for="(item, index) in list">
- <text class="info-tit">打卡记录({{index + 1}})</text> <text class="info-val">{{item.create_time}}</text>
- </view>
- <view class="dk flex" @click="dk">
- <view class="dk-main flex">
- <view class="dk-main-tit">
- 立即打卡
- </view>
- <view class="dk-main-time">
- {{time}}
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { goDk, getClockList } from '@/api/signing.js'
-
- const today = new Date();
- const year = today.getFullYear();
- const month = today.getMonth() + 1; // 月份从0开始,需要加1
- const day = today.getDate();
- const date = `${year}-${month}-${day}`
- export default {
- data() {
- return {
- loading: false,
- id: 0,
- today: date,
- address: '',
- timer: null,
- time: '',
- latitude: '',
- longitude: '',
- latitudes: '',
- longitudes: '',
- markers: [],
- list: []
- }
- },
- onLoad(opt) {
- if (opt.latitude) {
- this.id = opt.id
- this.latitude = opt.latitude
- this.longitude = opt.longitude
- this.address = opt.address
- this.markers.push({
- id: 1,
- latitude: this.latitude,
- longitude: this.longitude,
- title: '打卡点',
- iconPath: '/static/icon/shopAddress.png',
- width: 20,
- height: 20
- })
- }
- this.getLocation()
- this.getDkHis()
- if (this.timer) {
- clearInterval(this.timer);
- }
- this.updateTime();
- // 设置定时器每秒更新时间
- this.timer = setInterval(() => {
- this.updateTime();
- }, 1000);
- },
- methods: {
- goDkHis() {
- uni.navigateTo({
- url:'/pages/user/signing/dkhis?id=' + this.id
- })
- },
- getLocation() {
- let that = this
- uni.getLocation({
- type: 'gcj02',
- success(res) {
- that.latitudes = res.latitude
- that.longitudes = res.longitude
- console.log(that.latitudes,that.longitudes);
- },
- fail(err) {
- console.log(err,'err');
- }
- })
- },
- updateTime() {
- const now = new Date();
- const hours = String(now.getHours()).padStart(2, '0');
- const minutes = String(now.getMinutes()).padStart(2, '0');
- const seconds = String(now.getSeconds()).padStart(2, '0');
- this.time = `${hours}:${minutes}:${seconds}`;
- },
- dk() {
- if(this.loading) return;
- this.loading = true
- goDk({
- contract_id: this.id,
- latitude: this.latitudes,
- longitude: this.longitudes
- }).then(res => {
- this.getDkHis()
- uni.showToast({
- title: '打卡成功',
- duration: 2000
- });
- setTimeout(()=> {
- this.loading = false
- })
- }).catch(err => {
- this.loading = false
- })
- },
- getDkHis() {
- getClockList({
- contract_id: this.id,
- page:1,
- limit: 10,
- time: this.today
- }).then(res => {
- // console.log(res);
- this.list = res.data.list
- })
- }
- },
- onHide() {
- if (this.timer) {
- clearInterval(this.timer);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- background-color: #fff;
- height: 100vh;
- }
- .dk-title {
- padding: 20rpx;
- text-align: right;
- font-weight: bold;
- font-size: 28rpx;
- color: #0066FF;
- }
- .map {
- width: 710rpx;
- height: 500rpx;
- margin:0 auto 40rpx;
- }
- .info {
- font-size: 26rpx;
- padding-left: 28rpx;
- margin: 20rpx 0;
- &-tit {
- display: inline-block;
- width: 160rpx;
- color: #6E6E6E;
- }
- &-val {
- color: #1B1B1B;
- }
- }
- .dk {
- width: 290rpx;
- height: 290rpx;
- margin: 50rpx auto;
- border-radius: 50%;
- border: 3rpx solid #0066FF;
- justify-content: center;
- align-items: center;
- &-main {
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 268rpx;
- height: 268rpx;
- background: #0066FF;
- border-radius: 50%;
- color: #FFFFFF;
- font-size: 38rpx;
- }
- }
- </style>
|