NurseStationPersonAppletUl/pages/login/login.vue
2023-03-28 10:02:47 +08:00

87 lines
1.9 KiB
Vue

<template>
<view class="app">
<view class="title">
<image src="../../static/logo.png" mode=""></image>
<view class="text">
泉医到家
</view>
</view>
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp">微信一键登录</button>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
appLogin,
createMobileToken
} from '@/api/login/index.js'
export default {
data() {
return {
checked: false,
phonenumber: '',
password: '',
userId: '',
};
},
//获取到传值
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 => {
console.log(res)
if (res.code == 200) {
uni.setStorageSync("phonenumber", that.phonenumber)
uni.setStorageSync("password", that.password)
uni.setStorageSync("nursePersonId", res.data.nursePersonId)
that.$refs.uToast.show({
title: '登录成功',
type: 'success',
duration: '1500'
})
setTimeout(() => {
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>