xinelu-nurse-app/pages/login/login.vue

109 lines
2.6 KiB
Vue
Raw Normal View History

2023-09-19 15:05:27 +08:00
<template>
<view class="app">
2023-12-25 10:40:41 +08:00
<image src="../../static/logos.png" mode=""></image>
<view class="text">
2023-12-28 15:35:03 +08:00
欢迎登录医护助手
2023-09-19 15:05:27 +08:00
</view>
2023-12-25 10:40:41 +08:00
<view class="body">
<view class="name">
2023-12-25 10:52:29 +08:00
<u-form :model="form" ref="uForm" label-width="200">
2023-12-25 10:40:41 +08:00
<u-form-item label="手机号码:">
<u-input placeholder="请输入手机号码" maxlength="11" v-model="phonenumber" /></u-form-item>
<u-form-item label="密码:">
<u-input class='code phone' placeholder="密码" maxlength="10" v-model="password" type="password"
:password-icon="true" />
</u-form-item>
</u-form>
<view class="forget" @tap='forgetpassword'>
忘记密码
</view>
</view>
<view class="loginsubmit" @tap="pwdlogin">
登录
</view>
<view class="loginsubmit" @tap='goregister'
style="top: 70%; color: #969394;background-color: #ffffff; margin-top: 10rpx;">
注册
</view>
2023-09-19 15:05:27 +08:00
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
appLogin,
createMobileToken
} from '@/api/login/index.js'
export default {
data() {
return {
2023-12-25 10:40:41 +08:00
form: {},
2023-09-19 15:05:27 +08:00
checked: false,
phonenumber: '',
password: '',
timer: null,
};
},
//获取到传值
onLoad(options) {
if (options.phonenumber && options.password) {
this.phonenumber = options.phonenumber
this.password = options.password
}
},
methods: {
login() {
var that = this
appLogin(this.phonenumber, this.password).then(res => {
if (res.code == 200) {
uni.setStorageSync("nursePersonId", res.data.nursePersonId)
uni.setStorageSync("phone", res.data.phone)
uni.setStorageSync("nursePersonName", res.data.nursePersonName)
uni.setStorageSync("nurseStationId", res.data.nurseStationId)
that.$refs.uToast.show({
title: '登录成功',
type: 'success',
duration: '1500'
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(e => {
uni.reLaunch({
url: '/pages/homepage/homepage',
})
}, 1500)
} else {
that.$refs.uToast.show({
title: res.msg,
type: 'error'
})
}
})
},
//密码登录
pwdlogin() {
var that = this
createMobileToken().then(res => {
uni.setStorageSync("token", res.data.token)
that.login();
})
},
//跳转注册页
goregister() {
uni.navigateTo({
url: '/pages/register/register'
})
},
forgetpassword() {
uni.navigateTo({
url: `/pages/forgotPassword/forgotPassword?phonenumber=${this.phonenumber}`
})
},
},
}
</script>
<style lang="scss">
@import './login.scss';
2023-12-25 10:40:41 +08:00
</style>