109 lines
2.6 KiB
Vue
109 lines
2.6 KiB
Vue
<template>
|
|
<view class="app">
|
|
<image src="../../static/logos.png" mode=""></image>
|
|
<view class="text">
|
|
欢迎登录医护助手
|
|
</view>
|
|
<view class="body">
|
|
<view class="name">
|
|
<u-form :model="form" ref="uForm" label-width="200">
|
|
<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>
|
|
</view>
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
appLogin,
|
|
createMobileToken
|
|
} from '@/api/login/index.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
form: {},
|
|
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';
|
|
</style> |