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.
93 lines
2.1 KiB
93 lines
2.1 KiB
<template>
|
|
<view class="padding-top-lg">
|
|
<template v-if="!success">
|
|
<view class="text-xxl padding text-center margin-top-xl">
|
|
<text class="text-black text-bold">{{ site }}</text>
|
|
</view>
|
|
<button @tap="handleSign(siteId)" class="cu-btn lg bg-purple margin sign-btn">{{ typeText }}</button>
|
|
</template>
|
|
<view class="success" v-else>
|
|
<view class="cuIcon-roundcheckfill text-green"></view>
|
|
<text class="text-black margin-top">打卡成功</text>
|
|
<button @tap="goHome" class="cu-btn lg bg-purple margin-lg sign-btn">返回首页</button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState, mapActions } from 'vuex';
|
|
import { formatQuery } from 'utils/util';
|
|
import { SCAN_SIGN } from 'api/api';
|
|
|
|
export default {
|
|
name: 'SignScan',
|
|
data() {
|
|
return {
|
|
siteId: '',
|
|
siteName: '',
|
|
success: false,
|
|
type: 0, // 0进 / 1出
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
...mapState('site', ['site']),
|
|
typeText() {
|
|
return this.type === 0 ? '进场打卡' : '出场打卡';
|
|
},
|
|
},
|
|
|
|
onLoad(options) {
|
|
try {
|
|
const query = formatQuery(decodeURIComponent(options.scene));
|
|
console.log('query: ', query);
|
|
const { d, t } = query;
|
|
if (!d || !t) {
|
|
uni.showToast({
|
|
title: '二维码参数错误',
|
|
icon: 'none',
|
|
duration: 3000,
|
|
});
|
|
}
|
|
this.siteId = d;
|
|
this.type = +t;
|
|
this.getSiteByQrId({ param: { id: d, type: t } });
|
|
} catch (error) {
|
|
console.log('error: ', error);
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
...mapActions('site', ['sign', 'getSiteByQrId']),
|
|
/**
|
|
* 扫码打卡
|
|
* @param {string} siteId 场所id
|
|
*/
|
|
async handleSign(siteId) {
|
|
try {
|
|
const params = { param: { siteId } };
|
|
await this.sign(params);
|
|
this.success = true;
|
|
} catch (error) {
|
|
console.log('error: ', error);
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.sign-btn {
|
|
display: flex;
|
|
}
|
|
.success {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding-top: 100rpx;
|
|
|
|
.cuIcon-roundcheckfill {
|
|
font-size: 200rpx;
|
|
}
|
|
}
|
|
</style>
|
|
|