NurseStationApp/pages/login/login.vue

92 lines
2.1 KiB
Vue
Raw Normal View History

2022-10-12 16:54:34 +08:00
<template>
<view class="app">
<view class="title">
账号登录
</view>
<view class="loginphone">
2022-10-13 17:39:43 +08:00
<input class="phone" type="text" placeholder="手机号码" maxlength="11" v-model="phone" />
2022-10-12 16:54:34 +08:00
</view>
2022-10-31 09:04:45 +08:00
<view class="logincode loginphone" style="top: 40%;">
2022-10-13 17:39:43 +08:00
<u-input class='code phone' placeholder="密码" maxlength="10" v-model="password" type="password"
:border="true" :password-icon="true" />
2022-10-12 16:54:34 +08:00
</view>
2022-10-31 09:04:45 +08:00
<view class="loginbtn" @tap='pwdlogin'>
2022-10-12 16:54:34 +08:00
登录
</view>
2022-10-31 09:04:45 +08:00
<view class="switch" @tap='goregister' style="left:55%">
2022-10-13 16:02:25 +08:00
没有账号,请先注册
2022-10-12 16:54:34 +08:00
</view>
2022-10-13 17:39:43 +08:00
<u-toast ref="uToast" />
2022-10-12 16:54:34 +08:00
</view>
</template>
<script>
2022-10-13 17:39:43 +08:00
import {
2022-10-31 09:04:45 +08:00
appLoginpwd
2022-10-13 17:39:43 +08:00
} from '../../api/login/index.js'
2022-10-12 16:54:34 +08:00
export default {
data() {
return {
2022-11-01 16:26:34 +08:00
phone: '13645678906',
2022-10-13 17:39:43 +08:00
password: '123456',
2022-10-12 16:54:34 +08:00
};
},
2022-10-13 16:02:25 +08:00
//获取到传值
2022-10-31 09:04:45 +08:00
onLoad(options) {},
2022-10-12 16:54:34 +08:00
methods: {
2022-10-13 17:39:43 +08:00
//密码登录
pwdlogin() {
appLoginpwd(this.phone, this.password).then(res => {
if (res.code == 200) {
if (res.data.registerFlag == false) {
2022-10-31 09:04:45 +08:00
uni.setStorage({
key: 'patientId',
data: res.data.patientId,
success: function() {
console.log('patientId保存成功');
}
});
2022-10-13 17:39:43 +08:00
this.$refs.uToast.show({
title: res.data.message,
type: 'success',
duration: '1500'
})
2022-10-31 09:04:45 +08:00
setTimeout(() => {
2022-10-13 17:39:43 +08:00
uni.switchTab({
url: '/pages/homepage/homepage',
})
}, 1500);
} else {
this.$refs.uToast.show({
title: res.data.message,
type: 'error'
})
}
} else {
this.$refs.uToast.show({
title: res.msg,
type: 'error'
})
}
})
},
2022-10-13 16:02:25 +08:00
//跳转注册页
goregister() {
uni.navigateTo({
url: '/pages/register/register'
})
2022-10-12 16:54:34 +08:00
},
},
2022-10-31 09:04:45 +08:00
toLogin() {
// uni.hideKeyboard() //隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。
// uni.redirectTo({
// url: 'login'
// }); //跳转到登录页
// uni.navigateBack(); //关闭当前页面,返回上一页面
}
2022-10-12 16:54:34 +08:00
}
</script>
<style lang="scss">
2022-10-24 14:42:03 +08:00
@import "./login.scss";
2022-10-12 16:54:34 +08:00
</style>