Browse Source

签到页 获取信息修复

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

59
pages/sign/sign.vue

@ -2,7 +2,7 @@
<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>
<text class="text-black text-bold">{{ site.siteName }}</text>
</view>
<button @tap="handleSign(siteId)" class="cu-btn lg bg-purple margin sign-btn">{{ typeText }}</button>
</template>
@ -27,38 +27,61 @@ export default {
siteName: '',
success: false,
type: 0, // 0 / 1
timer: null,
};
},
computed: {
...mapState('site', ['site']),
...mapState('user', ['token']),
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);
}
console.log('options: ', options);
this.init(options);
},
methods: {
...mapActions('site', ['sign', 'getSiteByQrId']),
init(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.getSignInfo({ param: { id: d, type: t } });
} catch (error) {
console.log('error: ', error);
}
},
/**
* 获取场所的基本信息
* @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

Loading…
Cancel
Save