Browse Source

签到页 获取信息修复

remotes/origin/HEAD
wally 5 years ago
parent
commit
83c3ed0e72
  1. 31
      pages/sign/sign.vue

31
pages/sign/sign.vue

@ -2,7 +2,7 @@
<view class="padding-top-lg"> <view class="padding-top-lg">
<template v-if="!success"> <template v-if="!success">
<view class="text-xxl padding text-center margin-top-xl"> <view class="text-xxl padding text-center margin-top-xl">
<text class="text-black text-bold">{{ site }}</text> <text class="text-black text-bold">{{ site.siteName }}</text>
</view> </view>
<button @tap="handleSign(siteId)" class="cu-btn lg bg-purple margin sign-btn">{{ typeText }}</button> <button @tap="handleSign(siteId)" class="cu-btn lg bg-purple margin sign-btn">{{ typeText }}</button>
</template> </template>
@ -27,17 +27,27 @@ export default {
siteName: '', siteName: '',
success: false, success: false,
type: 0, // 0 / 1 type: 0, // 0 / 1
timer: null,
}; };
}, },
computed: { computed: {
...mapState('site', ['site']), ...mapState('site', ['site']),
...mapState('user', ['token']),
typeText() { typeText() {
return this.type === 0 ? '进场打卡' : '出场打卡'; return this.type === 0 ? '进场打卡' : '出场打卡';
}, },
}, },
onLoad(options) { onLoad(options) {
console.log('options: ', options);
this.init(options);
},
methods: {
...mapActions('site', ['sign', 'getSiteByQrId']),
init(options) {
try { try {
const query = formatQuery(decodeURIComponent(options.scene)); const query = formatQuery(decodeURIComponent(options.scene));
console.log('query: ', query); console.log('query: ', query);
@ -51,14 +61,27 @@ export default {
} }
this.siteId = d; this.siteId = d;
this.type = +t; this.type = +t;
this.getSiteByQrId({ param: { id: d, type: t } }); this.getSignInfo({ param: { id: d, type: t } });
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);
} }
}, },
methods: { /**
...mapActions('site', ['sign', 'getSiteByQrId']), * 获取场所的基本信息
* @param {object} params 提交给后端的参数
*/
getSignInfo(params) {
this.timer && clearInterval(this.timer);
if (!this.token) {
this.timer = setTimeout(() => {
this.getSignInfo(params);
}, 100);
} else {
this.getSiteByQrId(params);
}
},
/** /**
* 扫码打卡 * 扫码打卡
* @param {string} siteId 场所id * @param {string} siteId 场所id

Loading…
Cancel
Save