diff --git a/api/pages/login/index.js b/api/pages/login/index.js index 5bde163..462a706 100644 --- a/api/pages/login/index.js +++ b/api/pages/login/index.js @@ -13,13 +13,18 @@ export function createMobileToken() { method: 'GET' }) } - - - // 获取微信手机号 export function getwxPhoneNumber(code) { return request({ url: `/applet/register/getPhone/${code}`, method: 'GET' }) +} + +// 判断是否注册 +export function isRegistered(code) { + return request({ + url: `/applet/register/isRegistered/${code}`, + method: 'GET' + }) } \ No newline at end of file diff --git a/pages/login/login.vue b/pages/login/login.vue index d90d490..fcb6484 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -12,6 +12,7 @@ import { appLoginpwd, getWeChatUser, + isRegistered, } from '../../api/pages/login/index.js' import { createMobileToken @@ -23,7 +24,8 @@ logincode: undefined, code:undefined, timer: undefined, - scenenurseStationId: undefined + scenenurseStationId: undefined, + codes:'', }; }, onShow() { @@ -44,49 +46,76 @@ // uni.$emit('code',loginRes.code) that.code = loginRes.code - that.pwdlogin(); + 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() { - getWeChatUser(this.code).then(res => { + let that = this; + console.log(that.codes,'9999') + getWeChatUser(that.codes).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) - } + // 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' - }) + // this.$refs.uToast.show({ + // title: '登录失败', + // type: 'error', + // duration: '1500' + // }) } }) }, pwdlogin() { var that = this uni.clearStorageSync(); - uni.navigateTo({ - url:`/pages/register/register?code=${this.logincode}` - }) + that.login() // createMobileToken().then(res => { // uni.setStorageSync("token", res.data.token) diff --git a/pages/register/register.vue b/pages/register/register.vue index 8defce8..5543a15 100644 --- a/pages/register/register.vue +++ b/pages/register/register.vue @@ -1,7 +1,7 @@ @@ -138,7 +139,7 @@ import { getSubordinateRegions, } from '@/api/pagesB/modifyAddress/modifyAddress.js'; - import gkcity from "../../components/m-city/m-city.vue"; + import gkcity from "@/components/m-city/m-city.vue"; import ldSelect from '../../components/ld-select/ld-select.vue'; import { registerdata @@ -181,7 +182,7 @@ } ], // radio: 1, - + selected: '', options: [{ value: '1', @@ -205,7 +206,6 @@ localName: "请选择", children: [], }, ], - areashow: false, //经纬度开关 maskshow: false, //用户协议 getNurseTypelist: [], //护理类型数组 medicalcarelist: [], //医疗护理数组 @@ -227,6 +227,7 @@ patientId: '', locationName: '', sex: '', + sexname:'', birthDate: '', cityCode: '1' }, @@ -282,9 +283,9 @@ // onload(){ // }, - // onUnload() { - // // 移除监听事件 - // uni.$off('code'); + // onUnload() { + // // 移除监听事件 + // uni.$off('code'); // }, methods: { onChange(e) { @@ -311,12 +312,12 @@ // uni.navigateTo({ // url: '/pagesB/information/information' // }) - + var that = this that.query.openid = uni.getStorageSync('openid'); - if (that.query.sex == '男') { + if (that.query.sexname == '男') { that.query.sex = 'MALE'; - } else if (that.query.sex == '女') { + } else if (that.query.sexname == '女') { that.query.sex = 'FEMALE'; } if(that.query.sex==""){ @@ -324,10 +325,10 @@ title: '请选择性别', type: 'error' }) - + } console.log(that.selected) - + if (!that.query.locationName) { that.$refs.uToast.show({ title: '请选择所在位置', @@ -362,14 +363,14 @@ type: 'success', duration: '1000', }) - uni.switchTab({ + uni.switchTab({ url: '/pages/homepage/homepage' , }); } - + }) } - + } else { console.log('验证失败'); } @@ -393,82 +394,82 @@ //提交信息 - informationinfo() { - var that = this - if (that.query.sex == '男') { - that.query.sex = 'MALE'; - } else if (that.query.sex == '女') { - that.query.sex = 'FEMALE'; - } - if (this.addresslength) { - if (this.addresslength.length > 2) { - const value = uni.getStorageSync('phone'); - if (value) { - that.query.phone = value - if (that.radio == 1) { - that.$refs.uToast.show({ - title: '请审核并同意用户协议', - type: 'error' - }) - } else { - const patientId = uni.getStorageSync('patientId'); - AppIdentification(patientId).then(resp => { - if (resp.code == 200) { - if (resp.data.loginFlag) { - that.$refs.uToast.show({ - title: '您已完善', - type: 'success', - }) - if (that.timer) { - clearTimeout(that.timer) - } - that.timer = setTimeout(e => { - uni.navigateBack({ - delta: 1 - }) - }, 1500) - } else { - information(that.query).then(res => { - if (res.code == 200) { - uni.removeStorageSync('invitationPatientId'); - that.$refs.uToast.show({ - title: '完善信息成功', - type: 'success', - duration: '1500' - }) - if (that.timer) { - clearTimeout(that.timer) - } - that.timer = setTimeout(e => { - uni.navigateBack({ - delta: 1 - }) - }, 1500) - } else if (res.code == 500) { - that.$refs.uToast.show({ - title: res.msg, - type: 'error', - }) - } - }) - } - } - }) - } - } - } else { - that.$refs.uToast.show({ - title: '所属区域应选择所在的区或街道,请重新选择!', - type: 'error' - }) - } - } else { - that.$refs.uToast.show({ - title: '所属区域应选择所在的区或街道,请重新选择!', - type: 'error' - }) - } - }, + // informationinfo() { + // var that = this + // if (that.query.sex == '男') { + // that.query.sex = 'MALE'; + // } else if (that.query.sex == '女') { + // that.query.sex = 'FEMALE'; + // } + // if (this.addresslength) { + // if (this.addresslength.length > 2) { + // const value = uni.getStorageSync('phone'); + // if (value) { + // that.query.phone = value + // if (that.radio == 1) { + // that.$refs.uToast.show({ + // title: '请审核并同意用户协议', + // type: 'error' + // }) + // } else { + // const patientId = uni.getStorageSync('patientId'); + // AppIdentification(patientId).then(resp => { + // if (resp.code == 200) { + // if (resp.data.loginFlag) { + // that.$refs.uToast.show({ + // title: '您已完善', + // type: 'success', + // }) + // if (that.timer) { + // clearTimeout(that.timer) + // } + // that.timer = setTimeout(e => { + // uni.navigateBack({ + // delta: 1 + // }) + // }, 1500) + // } else { + // information(that.query).then(res => { + // if (res.code == 200) { + // uni.removeStorageSync('invitationPatientId'); + // that.$refs.uToast.show({ + // title: '完善信息成功', + // type: 'success', + // duration: '1500' + // }) + // if (that.timer) { + // clearTimeout(that.timer) + // } + // that.timer = setTimeout(e => { + // uni.navigateBack({ + // delta: 1 + // }) + // }, 1500) + // } else if (res.code == 500) { + // that.$refs.uToast.show({ + // title: res.msg, + // type: 'error', + // }) + // } + // }) + // } + // } + // }) + // } + // } + // } else { + // that.$refs.uToast.show({ + // title: '所属区域应选择所在的区或街道,请重新选择!', + // type: 'error' + // }) + // } + // } else { + // that.$refs.uToast.show({ + // title: '所属区域应选择所在的区或街道,请重新选择!', + // type: 'error' + // }) + // } + // }, //性别 sexchange(e) { if (e == '男') { @@ -509,12 +510,12 @@ // }); // }, //护理类型请求 - getNurseTypeInfo() { - getNurseType().then(res => { - this.medicalcarelist = res.data.filter(e => e.nurseTypeName == '医疗护理') - this.getNurseTypelist = res.data.filter(e => e.nurseTypeName != '医疗护理') - }) - }, + // getNurseTypeInfo() { + // getNurseType().then(res => { + // this.medicalcarelist = res.data.filter(e => e.nurseTypeName == '医疗护理') + // this.getNurseTypelist = res.data.filter(e => e.nurseTypeName != '医疗护理') + // }) + // }, //区街道 areaInfo() { getSubordinateRegions().then(res => { @@ -540,7 +541,6 @@ }, // 显示三级地址联动 showPicker() { - this.areashow = true this.$refs.cityPicker.show(); }, //点击所需服务 @@ -570,20 +570,20 @@ }, //进入界面加载 onLoad(options) { + let that = this console.log(options, '00') this.query.headPictureUrl = options.headPictureUrl - let that = this - this.query.couponId = Number(options.couponId) - const value = uni.getStorageSync('patientId'); - if (value) { - that.query.patientId = value - } + // this.query.couponId = Number(options.couponId) + // const value = uni.getStorageSync('patientId'); + // if (value) { + // that.query.patientId = value + // } this.areaInfo() - this.getNurseTypeInfo(); + // this.getNurseTypeInfo(); }, - // onUnload() { - // // 移除监听事件 - // uni.$off('code'); + // onUnload() { + // // 移除监听事件 + // uni.$off('code'); // }, //带参返回 @@ -591,8 +591,8 @@ onShow() { // uni.$on('headPictureUrl',(res)=>{ // console.log(res, '000') // 为 B 页面传过来的值 - // // this.usnerinfo = options; - // }) + // // this.usnerinfo = options; + // }) var that = this const invitationPatientId = uni.getStorageSync('invitationPatientId') if (invitationPatientId) { @@ -702,7 +702,7 @@ } .radio-right { height: 100rpx; - + .radio { display: inline-block; width: 50rpx; @@ -749,7 +749,7 @@ // margin: 12rpx auto; border: none; border-radius: 5rpx; - + .u-input__input { font-size: 26rpx; @@ -938,4 +938,4 @@ /deep/ .u-form-item__message { padding-left: 0 !important; } - \ No newline at end of file +