From dc3f3dd97880dc240e71fc9f788a6a4285ab3553 Mon Sep 17 00:00:00 2001 From: shidongli Date: Fri, 10 Nov 2023 15:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pages/homepage/homepage.js | 6 +++--- pages/homepage/homepage.vue | 4 +++- pages/login/login.vue | 39 ++++++++++++++++++++++++++++------ pages/register/register.vue | 5 ++--- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/api/pages/homepage/homepage.js b/api/pages/homepage/homepage.js index ca16c9e..45d91e5 100644 --- a/api/pages/homepage/homepage.js +++ b/api/pages/homepage/homepage.js @@ -12,9 +12,9 @@ export function getOpenId(code) { } // 获取当前注册居民 -export function getCurrentUser(openid, cityCode) { +export function getCurrentUser(openid) { return request({ - url: `/applet/register/getCurrentResident/${openid}/${cityCode}`, + url: `/applet/register/getCurrentResident/${openid}`, method: 'GET', header: { Authorization: 'Bearer' + ' ' + uni.getStorageSync('token') @@ -42,4 +42,4 @@ export function checkSignApply(identity) { region: uni.getStorageSync('region'), }, }) -} \ No newline at end of file +} diff --git a/pages/homepage/homepage.vue b/pages/homepage/homepage.vue index 367a67e..7a44cd2 100644 --- a/pages/homepage/homepage.vue +++ b/pages/homepage/homepage.vue @@ -169,10 +169,12 @@ goonline() { if (!this.userinfo) { this.gologin(); - } else { + } else if(this.userinfo){ if (this.region == 3) { this.family() } else { + console.log(this.userinfo,'0900') + if (this.region == 1 || this.region == 2) { if (this.checkSign == "0") { this.$refs.uToast.show({ diff --git a/pages/login/login.vue b/pages/login/login.vue index 7711cd7..e8ef1d3 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -96,15 +96,27 @@ getPhoneNumberp(val) { let that = this; if (val.detail.code) { + that.phonecode = val.detail.code that.login(); } }, login() { + wx.login({ + provider: 'weixin', + success: function(loginRes) { + that.logincode = loginRes.code + } + }); let that = this; + // console.log(that.logincode, that.phonecode) isRegistered(that.logincode, that.phonecode).then(resp => { - uni.setStorageSync("openid", resp.data.openid) - uni.setStorageSync("phone", resp.data.phone) + if(resp.data.openid && resp.data.phone){ + uni.setStorageSync("openid", resp.data.openid) + uni.setStorageSync("phone", resp.data.phone) + + } + if (resp.data.code == '0') { that.$refs.uToast.show({ title: '未注册,请先注册', @@ -112,18 +124,31 @@ duration: '1500', }) if (that.timer) { - clearTimeout(that.timer) + learTimeout(that.timer) } that.timer = setTimeout(() => { uni.redirectTo({ url: '/pages/register/register', }) }, 1500) - } else if (resp.data.code == '1') { - getCurrentUser(resp.data.openid, resp.data.cityCode).then(res => { + } else if(resp.data.code == '2'){ + that.$refs.uToast.show({ + title: '已被其他人注册, 不能再登录', + type: 'error', + duration: '1500', + }) + + } + else if (resp.data.code == '1') { + getCurrentUser(resp.data.openid).then(res => { if (res.code == 200) { - uni.setStorageSync('patientId', res.data.id); - uni.setStorageSync('userinfo', res.data); + console.log(res,'000') + if(res.data){ + uni.setStorageSync('patientId', res.data.id); + uni.setStorageSync('userinfo', res.data); + + } + that.$refs.uToast.show({ title: '登录成功', type: 'success', diff --git a/pages/register/register.vue b/pages/register/register.vue index 6b8e447..982a848 100644 --- a/pages/register/register.vue +++ b/pages/register/register.vue @@ -399,14 +399,13 @@ if (valid) { registerdata(that.query).then(res => { if (res.code == 200) { - getCurrentUser(that.query.openid, that.query.cityCode).then(res => { + getCurrentUser(that.query.openid).then(res => { uni.setStorageSync('patientId', res.data.id); uni.setStorageSync('patientName', res.data.patientName); uni.setStorageSync("userinfo", res.data) that.$refs.uToast.show({ title: '注册成功', type: 'success', - duration: '1000', back: 1, }) }) @@ -902,4 +901,4 @@ /deep/ .u-form-item__message { padding-left: 0 !important; } - \ No newline at end of file +