From a93fdfe6fddffa95eadee7e4fb94c263584cf654 Mon Sep 17 00:00:00 2001 From: chenrx Date: Fri, 7 Jun 2024 15:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=91=E7=A5=A8=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=92=8C=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/signup/code.js | 76 ++++++++++++++++++++++++------------- pages/signup/code.wxml | 2 +- pages/signup/index.js | 46 ++++++++++++---------- project.private.config.json | 2 +- 4 files changed, 79 insertions(+), 47 deletions(-) diff --git a/pages/signup/code.js b/pages/signup/code.js index 6a9ea4d..b41a7c9 100644 --- a/pages/signup/code.js +++ b/pages/signup/code.js @@ -78,34 +78,39 @@ Page({ * 接口请求小程序码 */ getappSignConf() { - if (this.loading) return - wx.showLoading({ - title: '重新生成中...', - mask: true - }) - if (wxTimer) { - wxTimer.stop(); - wxTimer = null - } - this.setData({ - wxTimerList: {}, - wxTimer: null, - loading: true - }) - - /////接口方法 - _.apiQuery.getappSignConf().then(res => { + this.getUserLocation().then(() => { + if (this.loading) return + wx.showLoading({ + title: '重新生成中...', + mask: true + }) + if (wxTimer) { + wxTimer.stop(); + wxTimer = null + } this.setData({ - qrcode_img: res.data.qcode, - qrcode_count_time: parseInt(res.data.qrcode_count_time), - loading: false, - info: res.data - }, () => { - wx.hideLoading() - this.getTimes(this.data.qrcode_count_time).then(() => { - this.getappSignConf() + wxTimerList: {}, + wxTimer: null, + loading: true + }) + const params = { + lat: this.data.lat, + lng: this.data.lng + } + /////接口方法 + _.apiQuery.getappSignConf(params).then(res => { + this.setData({ + qrcode_img: res.data.qcode, + qrcode_count_time: parseInt(res.data.qrcode_count_time), + loading: false, + info: res.data + }, () => { + wx.hideLoading() + this.getTimes(this.data.qrcode_count_time).then(() => { + this.getappSignConf() + }) + this.setScreenBright() }) - this.setScreenBright() }) }) }, @@ -158,4 +163,23 @@ Page({ } }, + /** + * 授权地理位置 + */ + getUserLocation() { + let that = this + return new Promise(function (resolve, reject) { + _.userManager.getUserLocation().then(location => { + that.setData({ + lat: location.lat, + lng: location.lng + }, () => { + resolve() + }) + }).catch(res => { + reject(res) + }) + }) + }, + }) \ No newline at end of file diff --git a/pages/signup/code.wxml b/pages/signup/code.wxml index 74a642a..b82020c 100644 --- a/pages/signup/code.wxml +++ b/pages/signup/code.wxml @@ -16,7 +16,7 @@ - {{wxTimerList.wxTimer.tim||0}}秒后失效 + {{wxTimerList.wxTimer.tim||0}}秒后失效 立即刷新 客户点击签到,授权手机号及地理位置方可签到成功 diff --git a/pages/signup/index.js b/pages/signup/index.js index b2c6442..134ffa6 100644 --- a/pages/signup/index.js +++ b/pages/signup/index.js @@ -146,27 +146,37 @@ Page({ getUserLocation() { let that = this return new Promise(function (resolve, reject) { - if (app.getStorageByKey('u_lat') && app.getStorageByKey('u_lng')) { + _.userManager.getUserLocation().then(location => { that.setData({ - lat: app.getStorageByKey('u_lat'), - lng: app.getStorageByKey('u_lng') + lat: location.lat, + lng: location.lng }, () => { resolve() }) - } else { - //u_lat u_lng - _.userManager.getUserLocation().then(location => { - console.log(location) - that.setData({ - lat: location.lat, - lng: location.lng - }, () => { - resolve() - }) - }).catch(res => { - reject(res) - }) - } + }).catch(res => { + reject(res) + }) + // if (app.getStorageByKey('u_lat') && app.getStorageByKey('u_lng')) { + // that.setData({ + // lat: app.getStorageByKey('u_lat'), + // lng: app.getStorageByKey('u_lng') + // }, () => { + // resolve() + // }) + // } else { + // //u_lat u_lng + // _.userManager.getUserLocation().then(location => { + // console.log(location) + // that.setData({ + // lat: location.lat, + // lng: location.lng + // }, () => { + // resolve() + // }) + // }).catch(res => { + // reject(res) + // }) + // } }) }, @@ -180,8 +190,6 @@ Page({ 'lng': this.data.lng.toFixed(11), 'lat': this.data.lat.toFixed(11) } - console.log(this.data.lng) - console.log(this.data.lat) _.apiQuery.postAppSign(params).then(res => { let arr = []; for (const key in res.data) { diff --git a/project.private.config.json b/project.private.config.json index 265b69b..b4b6608 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -11,7 +11,7 @@ { "name": "pages/signup/index", "pathName": "pages/signup/index", - "query": "scene=fwef5165we", + "query": "scene=25lzwSFJ3QcXvMLR6WIE2", "launchMode": "default", "scene": 1047 },