修改登录方式

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({
url: `/applet/register/getCurrentResident/${openid}`,
method: 'GET',

View File

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

View File

@ -9,6 +9,12 @@
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, {
"path": "pages/myinformation/myinformation",
"style": {
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, {
"path": "pages/message/message",
"style": {
@ -16,12 +22,6 @@
"onReachBottomDistance": 40, // px
"enablePullDownRefresh": true //true
}
}, {
"path": "pages/myinformation/myinformation",
"style": {
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, {
"path": "pages/medicalservice/medicalservice",
"style": {

View File

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

View File

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

View File

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

View File

@ -9,18 +9,19 @@
v-if="!appPersonallist.headPictureUrl" />
<image :src="baseurl+appPersonallist.headPictureUrl" mode="" class="headsculpture" @tap='updatainfo'
v-else />
<view class="namesigning" @tap='updatainfo'>
<view class="namesigning" @tap='updatainfo' v-if="appPersonallist.patientName">
<span class="name">
{{appPersonallist.patientName?appPersonallist.patientName:'点击登录'}}
{{appPersonallist.patientName}}
</span>
<span class="" v-show="appPersonallist.patientName">
<span class="signing" v-if="appPersonallist.signNo">
已签约
</span>
<span class="signing" v-else>
未签约
</span>
</span>
</view>
<view class="nologin namesigning" @tap='updatainfo' v-else>
点击登录
</view>
<view class="phone" v-if="appPersonallist.phone">
{{appPersonallist.phone}}
@ -172,14 +173,14 @@
<image src="@/static/huijiantou.png" mode=""></image>
</view>
</view>
<!-- <view class="myorder titles" @tap="remove()">
<view class="myorder titles" @tap="remove()">
<view class="title">
退出登录
</view>
<view class="righttitle">
<image src="@/static/huijiantou.png" mode=""></image>
</view>
</view> -->
</view>
<view class="mask" @click.stop='showhome = false' v-if="showhome">
<view class="masktext" @click.stop=''>
<view class="maskcontent" v-if="familyList">
@ -209,16 +210,26 @@
getCurrentUser,
switchResident
} from '@/api/pages/myinformation/myinformation.js';
import {
logingetCurrentUser,
} from '@/api/pages/homepage/homepage.js'
import {
login
} from '@/api/pages/login/index.js'
import {
existPatientInfo
} from '@/api/pages/startup/index.js'
import {
checkSignApply
} from '@/api/pages/homepage/homepage.js'
import {
mapMutations
} from "vuex";
import baseurl from '@/api/baseurl.js'
export default {
data() {
return {
timer: undefined,
baseurl: '',
appPersonallist: null, //
list: {},
@ -305,8 +316,8 @@
this.appPersonallist = res.data
uni.setStorageSync('userinfo', res.data);
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('patientName', res.data
.patientName);
uni.setStorageSync('phone', res.data.phone);
uni.setStorageSync('patientName', res.data.patientName);
this.$refs.uToast.show({
title: '切换成功',
type: 'success',
@ -338,8 +349,8 @@
const value = uni.getStorageSync('openid');
const value2 = uni.getStorageSync('patientId');
if (value && value2) {
existPatientInfo(value).then(res => {
if (res.code == 200 && res.msg == 'LOGIN') {
// existPatientInfo(value).then(res => {
// if (res.code == 200 && res.msg == 'LOGIN') {
appPersonal(value2).then(Response => {
if (Response.code == 200) {
uni.setStorageSync('userinfo', Response.data);
@ -355,12 +366,65 @@
} else {
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 {
that.removes();
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() {
let that = this;
const value = uni.getStorageSync('userinfo');
const value2 = uni.getStorageSync('patientId');
if (value && value2) {
@ -368,9 +432,75 @@
url: `/pagesB/modify/modify`
})
} else {
uni.navigateTo({
url: '/pagesB/login/login'
if (!uni.getStorageSync('location') || !uni.getStorageSync('region')) {
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: '',
// success(res) {
// if (res.confirm) {
// uni.redirectTo({
// url: "/pagesB/login/login?mode="
// })
// } else {
// wx.exitMiniProgram()
// }
@ -545,9 +672,6 @@
// })
// } else {
// this.getSetting()
// uni.navigateTo({
// url: '/pagesB/login/login'
// });
// }
},
//

View File

@ -4,9 +4,11 @@
<!-- <view class="text">
新医路健康服务平台
</view> -->
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp"
<!-- <button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp"
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-right" @tap="changeRadio">
<view class="radio" :class="radio == 2 ? 'radio-default':''">
@ -44,11 +46,12 @@
isRegistered,
} from '../../api/pages/login/index.js'
import {
getCurrentUser,
logingetCurrentUser,
wxSportDecrypt
} from '@/api/pages/homepage/homepage.js'
import {
createMobileToken
createMobileToken,
login
} from '@/api/pages/login/index.js'
import {
mapMutations
@ -62,8 +65,6 @@
return {
phonecode: undefined,
timer: undefined,
cityCode: null,
SOCKETURL: '',
radio: 1,
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) {
let that = this;
if (val.detail.code) {
@ -191,7 +260,7 @@
duration: '1500',
})
} else if (resp.data.code == '1') {
getCurrentUser(resp.data.openid).then(res => {
logingetCurrentUser(resp.data.openid).then(res => {
if (res.code == 200) {
if (res.data) {
uni.setStorageSync('patientId', res.data.id);

View File

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

View File

@ -132,7 +132,7 @@
detail,
} from '@/api/pages/homepage/homepage.js'
import {
getCurrentUser,
logingetCurrentUser,
} from '@/api/pages/homepage/homepage.js'
import {
AppIdentification
@ -486,8 +486,9 @@
if (that.addresslength.length > 2) {
registerdata(that.query).then(res => {
if (res.code == 200) {
getCurrentUser(that.query.openid).then(res => {
logingetCurrentUser(that.query.openid).then(res => {
uni.setStorageSync('patientId', res.data.id);
uni.setStorageSync('phone', res.data.phone);
uni.setStorageSync('patientName', res.data
.patientName);
uni.setStorageSync("userinfo", res.data)
@ -645,7 +646,7 @@
that.query.source = 'REGISTER_YOURSELF'
that.query.invitationPatientId = null
}
this.query.phone = uni.getStorageSync("phone")
// this.query.phone = uni.getStorageSync("phone")
// const chooseLocation = requirePlugin('chooseLocation');
// const location = chooseLocation.getLocation(); // null
// if (location) {