From 83c3ed0e72d5a6b33c0131b87b53f984fae71a52 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Sun, 8 Mar 2020 16:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E9=A1=B5=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=BF=A1=E6=81=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/sign/sign.vue | 59 +++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/pages/sign/sign.vue b/pages/sign/sign.vue index 57a9999..ac268bd 100644 --- a/pages/sign/sign.vue +++ b/pages/sign/sign.vue @@ -2,7 +2,7 @@ @@ -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