修改登录方式

This commit is contained in:
辉 2024-07-01 18:02:26 +08:00
parent d70b5af884
commit e9553a77da
15 changed files with 281 additions and 78 deletions

View File

@ -12,7 +12,7 @@ export function getOpenId(code) {
} }
// 获取当前注册居民 // 获取当前注册居民
export function getCurrentUser(openid) { export function logingetCurrentUser(openid) {
return request({ return request({
url: `/applet/register/getCurrentResident/${openid}`, url: `/applet/register/getCurrentResident/${openid}`,
method: 'GET', method: 'GET',

View File

@ -22,9 +22,18 @@ export function getwxPhoneNumber(code) {
} }
// 判断是否注册 // 判断是否注册
export function isRegistered(logincode,phonecode) { export function isRegistered(logincode, phonecode) {
return request({ return request({
url: `/applet/register/login/${logincode}/${phonecode}`, url: `/applet/register/login/${logincode}/${phonecode}`,
method: 'GET' method: 'GET'
}) })
} }
//静默登录
export function login(loginCode) {
return request({
url: `/applet/register/login/${loginCode}`,
method: 'GET'
})
}

View File

@ -9,6 +9,12 @@
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, {
"path": "pages/myinformation/myinformation",
"style": {
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, { }, {
"path": "pages/message/message", "path": "pages/message/message",
"style": { "style": {
@ -16,12 +22,6 @@
"onReachBottomDistance": 40, //距离底部多远时触发 单位为px "onReachBottomDistance": 40, //距离底部多远时触发 单位为px
"enablePullDownRefresh": true //设置参数为true "enablePullDownRefresh": true //设置参数为true
} }
}, {
"path": "pages/myinformation/myinformation",
"style": {
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, { }, {
"path": "pages/medicalservice/medicalservice", "path": "pages/medicalservice/medicalservice",
"style": { "style": {

View File

@ -252,7 +252,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
}, },
// 家医功能提示 // 家医功能提示

View File

@ -136,7 +136,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, },
@ -168,7 +167,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, 0) }, 0)
@ -188,7 +186,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, 0) }, 0)
@ -206,7 +203,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, },
@ -225,7 +221,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, 50) }, 50)
@ -244,7 +239,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, 0) }, 0)
@ -264,7 +258,6 @@
title: '您未登录,请前往我的页面进行登录', title: '您未登录,请前往我的页面进行登录',
type: 'error', type: 'error',
duration: '1000', duration: '1000',
// url: '/pagesB/login/login'
}) })
} }
}, 0) }, 0)

View File

@ -160,7 +160,7 @@
position: relative; position: relative;
color: #FFFFFF; color: #FFFFFF;
margin-bottom: 50rpx; margin-bottom: 50rpx;
background-color: #26A888;
.btn { .btn {
position: absolute; position: absolute;
@ -184,20 +184,28 @@
.phone { .phone {
position: absolute; position: absolute;
top: 56%; top: 56%;
left: 30%; left: 32%;
font-size: 24rpx; font-size: 24rpx;
} }
.nologin{
padding:6rpx 12rpx;
border: 2rpx solid #fff;
border-radius: 5px;
display: inline-block;
font-size: 36rpx;
}
.namesigning { .namesigning {
position: absolute; position: absolute;
top: 38%; top: 40%;
left: 30%; left: 32%;
.name { .name {
display: inline-block; display: inline-block;
font-size: 36rpx; font-size: 36rpx;
} }
.signing { .signing {
text-align: center; text-align: center;
margin-left: 30rpx; margin-left: 30rpx;

View File

@ -9,18 +9,19 @@
v-if="!appPersonallist.headPictureUrl" /> v-if="!appPersonallist.headPictureUrl" />
<image :src="baseurl+appPersonallist.headPictureUrl" mode="" class="headsculpture" @tap='updatainfo' <image :src="baseurl+appPersonallist.headPictureUrl" mode="" class="headsculpture" @tap='updatainfo'
v-else /> v-else />
<view class="namesigning" @tap='updatainfo'> <view class="namesigning" @tap='updatainfo' v-if="appPersonallist.patientName">
<span class="name"> <span class="name">
{{appPersonallist.patientName?appPersonallist.patientName:'点击登录'}} {{appPersonallist.patientName}}
</span> </span>
<span class="" v-show="appPersonallist.patientName"> <span class="signing" v-if="appPersonallist.signNo">
<span class="signing" v-if="appPersonallist.signNo"> 已签约
已签约
</span>
<span class="signing" v-else>
未签约
</span>
</span> </span>
<span class="signing" v-else>
未签约
</span>
</view>
<view class="nologin namesigning" @tap='updatainfo' v-else>
点击登录
</view> </view>
<view class="phone" v-if="appPersonallist.phone"> <view class="phone" v-if="appPersonallist.phone">
{{appPersonallist.phone}} {{appPersonallist.phone}}
@ -172,14 +173,14 @@
<image src="@/static/huijiantou.png" mode=""></image> <image src="@/static/huijiantou.png" mode=""></image>
</view> </view>
</view> </view>
<!-- <view class="myorder titles" @tap="remove()"> <view class="myorder titles" @tap="remove()">
<view class="title"> <view class="title">
退出登录 退出登录
</view> </view>
<view class="righttitle"> <view class="righttitle">
<image src="@/static/huijiantou.png" mode=""></image> <image src="@/static/huijiantou.png" mode=""></image>
</view> </view>
</view> --> </view>
<view class="mask" @click.stop='showhome = false' v-if="showhome"> <view class="mask" @click.stop='showhome = false' v-if="showhome">
<view class="masktext" @click.stop=''> <view class="masktext" @click.stop=''>
<view class="maskcontent" v-if="familyList"> <view class="maskcontent" v-if="familyList">
@ -209,16 +210,26 @@
getCurrentUser, getCurrentUser,
switchResident switchResident
} from '@/api/pages/myinformation/myinformation.js'; } from '@/api/pages/myinformation/myinformation.js';
import {
logingetCurrentUser,
} from '@/api/pages/homepage/homepage.js'
import {
login
} from '@/api/pages/login/index.js'
import { import {
existPatientInfo existPatientInfo
} from '@/api/pages/startup/index.js' } from '@/api/pages/startup/index.js'
import { import {
checkSignApply checkSignApply
} from '@/api/pages/homepage/homepage.js' } from '@/api/pages/homepage/homepage.js'
import {
mapMutations
} from "vuex";
import baseurl from '@/api/baseurl.js' import baseurl from '@/api/baseurl.js'
export default { export default {
data() { data() {
return { return {
timer: undefined,
baseurl: '', baseurl: '',
appPersonallist: null, //获取个人信息 appPersonallist: null, //获取个人信息
list: {}, list: {},
@ -305,8 +316,8 @@
this.appPersonallist = res.data this.appPersonallist = res.data
uni.setStorageSync('userinfo', res.data); uni.setStorageSync('userinfo', res.data);
uni.setStorageSync('patientId', res.data.id); uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('patientName', res.data uni.setStorageSync('phone', res.data.phone);
.patientName); uni.setStorageSync('patientName', res.data.patientName);
this.$refs.uToast.show({ this.$refs.uToast.show({
title: '切换成功', title: '切换成功',
type: 'success', type: 'success',
@ -338,20 +349,16 @@
const value = uni.getStorageSync('openid'); const value = uni.getStorageSync('openid');
const value2 = uni.getStorageSync('patientId'); const value2 = uni.getStorageSync('patientId');
if (value && value2) { if (value && value2) {
existPatientInfo(value).then(res => { // existPatientInfo(value).then(res => {
if (res.code == 200 && res.msg == 'LOGIN') { // if (res.code == 200 && res.msg == 'LOGIN') {
appPersonal(value2).then(Response => { appPersonal(value2).then(Response => {
if (Response.code == 200) { if (Response.code == 200) {
uni.setStorageSync('userinfo', Response.data); uni.setStorageSync('userinfo', Response.data);
that.appPersonallist = Response.data that.appPersonallist = Response.data
that.appPersonallist.homeLatitude = Number(that.appPersonallist that.appPersonallist.homeLatitude = Number(that.appPersonallist
.homeLatitude) .homeLatitude)
that.appPersonallist.homeLongitude = Number(that.appPersonallist that.appPersonallist.homeLongitude = Number(that.appPersonallist
.homeLongitude) .homeLongitude)
} else {
that.removes();
}
})
} else { } else {
that.removes(); that.removes();
} }
@ -359,8 +366,65 @@
} else { } else {
that.removes(); that.removes();
} }
// })
// } else {
// that.removes();
// }
}, },
//获取当前位置
getAddress() {
let that = this;
uni.getLocation({
type: 'wgs84',
success: (res) => {
let location = res.latitude + ',' + res.longitude
//调用逆解析接口
uni.request({
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=location', //腾讯官方逆解析接口,可直接复制
data: {
location: location,
'key': "7Y7BZ-PVXRA-IPYKT-C6YKF-YS3VF-LMFWJ", //自己申请的Key
},
method: "GET",
success(res) {
if (!res.data.result) {
uni.setStorageSync("region", 2)
uni.setStorageSync("location", '东营市')
} else {
var address = res.data.result.address_component.city
if (address == '德州市') {
uni.setStorageSync("region", 1)
} else if (address == '东营市') {
uni.setStorageSync("region", 2)
} else if (address == '济南市') {
uni.setStorageSync("region", 3)
}
uni.setStorageSync('location', res.data.result.address_component
.city)
}
},
fail: res => {
console.log(res.errMsg, '解析失败返回的错误信息');
}
})
},
//失败
fail: (res) => {
uni.showToast({
icon: 'none',
title: '获取地址失败,请打开定位',
})
}
})
},
sportinfo() {
wx.getWeRunData({
success: function(res) {}
});
},
...mapMutations(['scoket']),
updatainfo() { updatainfo() {
let that = this;
const value = uni.getStorageSync('userinfo'); const value = uni.getStorageSync('userinfo');
const value2 = uni.getStorageSync('patientId'); const value2 = uni.getStorageSync('patientId');
if (value && value2) { if (value && value2) {
@ -368,9 +432,75 @@
url: `/pagesB/modify/modify` url: `/pagesB/modify/modify`
}) })
} else { } else {
uni.navigateTo({ if (!uni.getStorageSync('location') || !uni.getStorageSync('region')) {
url: '/pagesB/login/login' that.getAddress()
}) }
that.sportinfo();
wx.login({
provider: 'weixin',
success: function(loginRes) {
login(loginRes.code).then(resp => {
if (!resp.data) {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
return
}
if (resp.data.openid) {
uni.setStorageSync("openid", resp.data.openid)
}
if (resp.data.code == '0') {
that.$refs.uToast.show({
title: '未注册,请先注册',
type: 'error',
duration: '1500',
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(() => {
uni.navigateTo({
url: '/pagesB/register/register',
})
}, 1500)
} else if (resp.data.code == '2') {
that.$refs.uToast.show({
title: '已被其他人注册',
type: 'error',
duration: '1500',
})
} else if (resp.data.code == '1') {
logingetCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) {
if (res.data) {
that.appPersonallist = res.data
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
uni.setStorageSync('phone', res.data.phone);
that.scoket();
}
that.$refs.uToast.show({
title: '登录成功',
type: 'success',
back: 1
})
} else {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
}
})
} else {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
}
})
}
});
} }
}, },
//护理站服务订单 //护理站服务订单
@ -535,9 +665,6 @@
// cancelText: '否', // cancelText: '否',
// success(res) { // success(res) {
// if (res.confirm) { // if (res.confirm) {
// uni.redirectTo({
// url: "/pagesB/login/login?mode=注册"
// })
// } else { // } else {
// wx.exitMiniProgram() // wx.exitMiniProgram()
// } // }
@ -545,9 +672,6 @@
// }) // })
// } else { // } else {
// this.getSetting() // this.getSetting()
// uni.navigateTo({
// url: '/pagesB/login/login'
// });
// } // }
}, },
//积分页面 //积分页面

View File

@ -247,4 +247,4 @@
<style lang="scss"> <style lang="scss">
@import './ProjectDetails.scss'; @import './ProjectDetails.scss';
</style> </style>

View File

@ -656,4 +656,4 @@
<style lang="scss"> <style lang="scss">
@import "./healthybeans.scss"; @import "./healthybeans.scss";
</style> </style>

View File

@ -4,9 +4,11 @@
<!-- <view class="text"> <!-- <view class="text">
新医路健康服务平台 新医路健康服务平台
</view> --> </view> -->
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp" <!-- <button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp"
v-if="radio==2">手机号快捷登录</button> v-if="radio==2">手机号快捷登录</button>
<button class="loginbtn" v-else @click="nologin">手机号快捷登录</button> <button class="loginbtn" v-else @click="nologin">手机号快捷登录</button> -->
<button class="loginbtn" @click="logincode" v-if="radio==2">登录</button>
<button class="loginbtn" @click="nologin" v-else>登录</button>
<view class="radio-content"> <view class="radio-content">
<view class="radio-right" @tap="changeRadio"> <view class="radio-right" @tap="changeRadio">
<view class="radio" :class="radio == 2 ? 'radio-default':''"> <view class="radio" :class="radio == 2 ? 'radio-default':''">
@ -44,11 +46,12 @@
isRegistered, isRegistered,
} from '../../api/pages/login/index.js' } from '../../api/pages/login/index.js'
import { import {
getCurrentUser, logingetCurrentUser,
wxSportDecrypt wxSportDecrypt
} from '@/api/pages/homepage/homepage.js' } from '@/api/pages/homepage/homepage.js'
import { import {
createMobileToken createMobileToken,
login
} from '@/api/pages/login/index.js' } from '@/api/pages/login/index.js'
import { import {
mapMutations mapMutations
@ -62,8 +65,6 @@
return { return {
phonecode: undefined, phonecode: undefined,
timer: undefined, timer: undefined,
cityCode: null,
SOCKETURL: '',
radio: 1, radio: 1,
maskshow: false, maskshow: false,
}; };
@ -146,6 +147,74 @@
} }
}) })
}, },
logincode() {
let that = this;
wx.login({
provider: 'weixin',
success: function(loginRes) {
login(loginRes.code).then(resp => {
if (!resp.data) {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
return
}
if (resp.data.openid) {
uni.setStorageSync("openid", resp.data.openid)
}
if (resp.data.code == '0') {
that.$refs.uToast.show({
title: '未注册,请先注册',
type: 'error',
duration: '1500',
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(() => {
uni.redirectTo({
url: '/pagesB/register/register',
})
}, 1500)
} else if (resp.data.code == '2') {
that.$refs.uToast.show({
title: '已被其他人注册',
type: 'error',
duration: '1500',
})
} else if (resp.data.code == '1') {
logingetCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) {
if (res.data) {
that.appPersonallist = res.data
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('userinfo', res.data);
uni.setStorageSync('phone', res.data.phone);
that.scoket();
}
that.$refs.uToast.show({
title: '登录成功',
type: 'success',
back: 1
})
} else {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
}
})
} else {
that.$refs.uToast.show({
title: '登录失败',
type: 'error',
})
}
})
}
});
},
getPhoneNumberp(val) { getPhoneNumberp(val) {
let that = this; let that = this;
if (val.detail.code) { if (val.detail.code) {
@ -191,7 +260,7 @@
duration: '1500', duration: '1500',
}) })
} else if (resp.data.code == '1') { } else if (resp.data.code == '1') {
getCurrentUser(resp.data.openid).then(res => { logingetCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) { if (res.code == 200) {
if (res.data) { if (res.data) {
uni.setStorageSync('patientId', res.data.id); uni.setStorageSync('patientId', res.data.id);

View File

@ -304,4 +304,4 @@
<style lang="scss"> <style lang="scss">
@import "./medicine.scss"; @import "./medicine.scss";
</style> </style>

View File

@ -14,6 +14,11 @@
<u-input :clearable='false' v-model="appPersonallist.patientName" placeholder="请输入" type="text" <u-input :clearable='false' v-model="appPersonallist.patientName" placeholder="请输入" type="text"
maxlength='30' /> maxlength='30' />
</view> </view>
<view class="item">
<span>手机号:</span>
<u-input :clearable='false' v-model="appPersonallist.phone" placeholder="请输入" maxlength='11'
type="number" />
</view>
<view class="item"> <view class="item">
<span>性别:</span> <span>性别:</span>
<u-radio-group v-model="sex" size='44'> <u-radio-group v-model="sex" size='44'>
@ -23,11 +28,6 @@
</u-radio> </u-radio>
</u-radio-group> </u-radio-group>
</view> </view>
<!-- <view class="item">
<span>电话:</span>
<u-input :clearable='false' v-model="appPersonallist.phone" placeholder="请输入" maxlength='11'
type="number" />
</view> -->
<view class="item" @tap='timeshow=true'> <view class="item" @tap='timeshow=true'>
<span>出生日期:</span> <span>出生日期:</span>
<view class="address" style="" v-if="appPersonallist.birthDate"> <view class="address" style="" v-if="appPersonallist.birthDate">

View File

@ -553,4 +553,4 @@
<style lang="scss"> <style lang="scss">
@import './nursestation.scss'; @import './nursestation.scss';
</style> </style>

View File

@ -132,7 +132,7 @@
detail, detail,
} from '@/api/pages/homepage/homepage.js' } from '@/api/pages/homepage/homepage.js'
import { import {
getCurrentUser, logingetCurrentUser,
} from '@/api/pages/homepage/homepage.js' } from '@/api/pages/homepage/homepage.js'
import { import {
AppIdentification AppIdentification
@ -486,10 +486,11 @@
if (that.addresslength.length > 2) { if (that.addresslength.length > 2) {
registerdata(that.query).then(res => { registerdata(that.query).then(res => {
if (res.code == 200) { if (res.code == 200) {
getCurrentUser(that.query.openid).then(res => { logingetCurrentUser(that.query.openid).then(res => {
uni.setStorageSync('patientId', res.data.id); uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('phone', res.data.phone);
uni.setStorageSync('patientName', res.data uni.setStorageSync('patientName', res.data
.patientName); .patientName);
uni.setStorageSync("userinfo", res.data) uni.setStorageSync("userinfo", res.data)
that.scoket(); that.scoket();
that.$refs.uToast.show({ that.$refs.uToast.show({
@ -645,7 +646,7 @@
that.query.source = 'REGISTER_YOURSELF' that.query.source = 'REGISTER_YOURSELF'
that.query.invitationPatientId = null that.query.invitationPatientId = null
} }
this.query.phone = uni.getStorageSync("phone") // this.query.phone = uni.getStorageSync("phone")
// const chooseLocation = requirePlugin('chooseLocation'); // const chooseLocation = requirePlugin('chooseLocation');
// const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null // const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
// if (location) { // if (location) {

View File

@ -116,4 +116,4 @@
<style lang="scss"> <style lang="scss">
@import './healthtest.scss' @import './healthtest.scss'
</style> </style>