From ca98468c3a05d10ce38ebee34a07460e5659990f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89?= <814457906@qq.com> Date: Thu, 12 Oct 2023 10:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pages/homepage/homepage.js | 13 +- pages.json | 3 +- pages/homepage/homepage.vue | 174 +++++++++--------- pages/login/login.vue | 105 +++++------ pages/register/register.vue | 235 ++++++++++++------------- pagesC/Onlinesigning/Onlinesigning.vue | 15 +- 6 files changed, 267 insertions(+), 278 deletions(-) diff --git a/api/pages/homepage/homepage.js b/api/pages/homepage/homepage.js index a823ba2..40cbf04 100644 --- a/api/pages/homepage/homepage.js +++ b/api/pages/homepage/homepage.js @@ -22,7 +22,7 @@ export function getCurrentUser(openid, cityCode) { }) } // 获取签约信息 -export function detail(identity,region) { +export function detail(identity, region) { return request({ url: `/applet/signinfo/detail/${identity}`, method: 'GET', @@ -31,4 +31,15 @@ export function detail(identity,region) { // Authorization: 'Bearer' + ' ' + uni.getStorageSync('token') }, }) +} + +//是否注册 +export function checkSignApply(identity, region) { + return request({ + url: `/applet/sign/apply/checkSignApply/${identity}`, + method: 'GET', + header: { + region: region, + }, + }) } \ No newline at end of file diff --git a/pages.json b/pages.json index a3329b9..ec86d29 100644 --- a/pages.json +++ b/pages.json @@ -495,7 +495,6 @@ "onReachBottomDistance": 40, //距离底部多远时触发 单位为px "enablePullDownRefresh": true //设置参数为true } - }, { "path": "selectInstitution/selectInstitution", "style": { @@ -545,4 +544,4 @@ } ] } -} +} \ No newline at end of file diff --git a/pages/homepage/homepage.vue b/pages/homepage/homepage.vue index d3f91a7..dc43a47 100644 --- a/pages/homepage/homepage.vue +++ b/pages/homepage/homepage.vue @@ -68,8 +68,8 @@ import { getOpenId, getCurrentUser, - detail - + detail, + checkSignApply } from '@/api/pages/homepage/homepage.js' export default { data() { @@ -79,6 +79,7 @@ identity: '', region: '', openid: '', + checkSign: null, } }, onLoad() { @@ -86,43 +87,36 @@ }, onShow() { this.userinfo = uni.getStorageSync('userinfo'); - this.region = this.userinfo.cityCode; - this.openid = this.userinfo.openid; - this.identity = this.userinfo.cardNo; - if (!this.openid && !this.region) { - // that.appPersonallist = null - this.$refs.uToast.show({ - title: '您未登录,请先登录', - type: 'error', - duration: '1000', - }) - } else { - getCurrentUser(this.openid, this.region).then(res => { - this.patientName = res.data.patientName - uni.setStorageSync('patientId', res.data.id); - // if (!res.data) { - // // 注册 - // } + if (this.userinfo) { + checkSignApply(this.userinfo.cardNo, '1').then(res => { + if (res.code != 0) { + this.checkSign = true + } }) } }, methods: { // 登录 login() { - this.gologin(); + uni.navigateTo({ + url: "/pages/login/login" + }) }, gologin() { - this.$refs.uToast.show({ - title: '您未登录,请先登录', - type: 'error', - duration: '1000', - url: '/pages/login/login' - }) + if (!this.userinfo) { + this.$refs.uToast.show({ + title: '您未登录,请先登录', + type: 'error', + duration: '1000', + url: '/pages/login/login' + }) + return + } }, // 签约信息 detailinfo(url1, url2) { detail(this.identity, this.region).then(res => { - // detail('372424194703207523', '1').then(res => { + // detail('372424194703207523', '1').then(res => { if (res.code == 200) { uni.navigateTo({ url: url2 + `?item=${JSON.stringify(res.data)}` @@ -139,98 +133,100 @@ }, // 家医签约 goonline() { - uni.navigateTo({ - url:"/pagesC/Onlinesigning/Onlinesigning" - }) - // this.detailinfo('/pagesC/Onlinesigning/Onlinesigning', '/pagesB/mysigning/mysigning') - if (!this.userinfo && !this.identity) { - // this.gologin(); + this.gologin(); + if (!this.checkSign) { + this.$refs.uToast.show({ + title: '未签约,请先签约', + type: 'error', + duration: '1000', + url: "/pagesC/Onlinesigning/Onlinesigning" + }) } else { - // this.detailinfo('/pagesC/Onlinesigning/Onlinesigning', '/pagesB/mysigning/mysigning') + uni.navigateTo({ + url: "/pagesB/mysigning/mysigning" + }) } }, // 积分兑换 count() { - if (!this.userinfo && !this.identity) { - this.gologin(); + this.gologin(); + if (!this.checkSign) { + this.$refs.uToast.show({ + title: '未签约,请先签约', + type: 'error', + duration: '1000', + url: "/pagesC/Onlinesigning/Onlinesigning" + }) } else { - this.detailinfo('', '') + uni.navigateTo({ + url: "" + }) } }, // 健康档案 goHealthrecords() { - if (!this.userinfo && !this.identity) { - this.gologin(); - } else { - // this.detailinfo('', '') - uni.navigateTo({ - url: '/pagesC/Healthrecords/Healthrecords' - }) - } + this.gologin(); + uni.navigateTo({ + url: "/pagesC/Healthrecords/Healthrecords" + }) }, // 筛查记录 gorecords() { - if (!this.userinfo && !this.identity) { - this.gologin(); - } else { - // this.detailinfo('', '') - uni.navigateTo({ - url: '/pagesC/Screeningrecords/Screeningrecords' - }) - } + this.gologin(); + uni.navigateTo({ + url: "/pagesC/Screeningrecords/Screeningrecords" + }) }, // 健康自评 healthtest() { - if (!this.userinfo && !this.identity) { - this.gologin(); - } else { - // this.detailinfo('', '') - uni.navigateTo({ - url: '/pagesC/healthtest/healthtest' - }) - } + this.gologin(); + uni.navigateTo({ + url: "/pagesC/healthtest/healthtest" + }) }, // 体征检测 sign() { - if (!this.userinfo && !this.identity) { - this.gologin(); - } else { - // this.detailinfo('', '') - uni.navigateTo({ - url: '/pagesC/Physicalexamination/Physicalexamination' - }) - } + this.gologin(); + uni.navigateTo({ + url: "/pagesC/Physicalexamination/Physicalexamination" + }) }, // 服务预约 goappoint() { - uni.navigateTo({ - url: '/pagesC/ServiceAppointment/ServiceAppointment' - }) - // if (!this.userinfo && !this.identity) { - // this.gologin(); - // } else { - // this.detailinfo('', '/pagesC/ServiceAppointment/ServiceAppointment') - // } - }, - // 服务记录 - servicerecord() { - if (!this.userinfo && !this.identity) { - this.gologin(); + this.gologin(); + if (!this.checkSign) { + this.$refs.uToast.show({ + title: '未签约,请先签约', + type: 'error', + duration: '1000', + url: "/pagesC/Onlinesigning/Onlinesigning" + }) } else { - // this.detailinfo('', '') uni.navigateTo({ - url: '/pagesC/servicerecord/servicerecord' + url: "/pagesC/ServiceAppointment/ServiceAppointment" }) } }, + // 服务记录 + servicerecord() { + this.gologin(); + uni.navigateTo({ + url: "/pagesC/servicerecord/servicerecord" + }) + }, // 我的预约 myappointment() { - if (!this.userinfo && !this.identity) { - this.gologin(); + this.gologin(); + if (!this.checkSign) { + this.$refs.uToast.show({ + title: '未签约,请先签约', + type: 'error', + duration: '1000', + url: "/pagesC/Onlinesigning/Onlinesigning" + }) } else { - // this.detailinfo('', '') uni.navigateTo({ - url: '/pagesC/Myappointment/Myappointment' + url: "/pagesC/Myappointment/Myappointment" }) } }, @@ -240,4 +236,4 @@ + \ No newline at end of file diff --git a/pages/login/login.vue b/pages/login/login.vue index fcb6484..dbca6c6 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -22,17 +22,16 @@ return { phonecode: undefined, logincode: undefined, - code:undefined, + code: undefined, timer: undefined, - scenenurseStationId: undefined, - codes:'', + // scenenurseStationId: undefined, }; }, onShow() { this.phonecode = undefined this.logincode = undefined this.code = undefined - this.scenenurseStationId = uni.getStorageSync('scenenurseStationId'); + // this.scenenurseStationId = uni.getStorageSync('scenenurseStationId'); }, methods: { getPhoneNumberp(val) { @@ -42,81 +41,61 @@ wx.login({ provider: 'weixin', success: function(loginRes) { - console.log(loginRes) - - // uni.$emit('code',loginRes.code) that.code = loginRes.code - isRegistered(that.code).then(resp=>{ - console.log(resp,'0000') - if(!resp.data){ - uni.navigateTo({ - url:`/pages/register/register?code=${that.logincode}` - }) - - }else{ - uni.setStorageSync('userinfo', resp.data); - uni.switchTab({ - url:'/pages/homepage/homepage' - - }) - - - } - - }), - that.codes=that.code that.login() - - - } }); } - }, - // 是否注册 - isRegisteredget(){ - - }, login() { let that = this; - console.log(that.codes,'9999') - getWeChatUser(that.codes).then(res => { + getWeChatUser(that.code).then(res => { if (res.code == 200) { uni.setStorageSync("openid", res.data) - // uni.setStorageSync("patientId", res.data.id) - // uni.setStorageSync("phone", res.data.phone) - // this.$refs.uToast.show({ - // title: '登录成功', - // type: 'success', - // duration: '1500' - // }) - // console.log(this.logincode) - // this.phonecode = undefined - // this.logincode = undefined - // uni.setStorageSync("Refresh", 'Refresh') - // if (this.timer) { - // clearTimeout(this.timer) - // } - // this.timer = setTimeout(e => { - // uni.navigateBack({ - // delta: 1 - // }) - // }, 500) - } else { - // this.$refs.uToast.show({ - // title: '登录失败', - // type: 'error', - // duration: '1500' - // }) + isRegistered(that.code).then(resp => { + if (!resp.data) { + that.$refs.uToast.show({ + title: '未注册,请先注册', + type: 'error', + duration: '1500', + url: '/pages/register/register', + }) + } else { + getCurrentUser(that.openid, that.region).then(res => { + if (res.code == 200) { + that.$refs.uToast.show({ + title: '登录成功', + type: 'success', + duration: '1500' + }) + uni.setStorageSync('patientId', res.data.id); + uni.setStorageSync('userinfo', resp.data); + if (this.timer) { + clearTimeout(this.timer) + } + this.timer = setTimeout(e => { + uni.navigateBack({ + delta: 1 + }) + }, 500) + } else { + that.$refs.uToast.show({ + title: '登录失败', + type: 'error', + duration: '1500' + }) + } + }) + } + }) } }) }, pwdlogin() { var that = this uni.clearStorageSync(); - - that.login() + + that.login() // createMobileToken().then(res => { // uni.setStorageSync("token", res.data.token) // if (this.scenenurseStationId) { diff --git a/pages/register/register.vue b/pages/register/register.vue index 5543a15..404faa9 100644 --- a/pages/register/register.vue +++ b/pages/register/register.vue @@ -41,7 +41,7 @@ 所属区域 - + 请选择所属区域 {{address}} @@ -72,7 +72,7 @@ @@ -127,6 +127,9 @@ + \ No newline at end of file