智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LightingSystemApp-serial/.svn/pristine/9d/9df2cb7fe3f5b9dafa52ecb27f4...

149 lines
2.9 KiB

3 years ago
<template>
<view class="page">
<u-navbar :is-back="false" :border-bottom="false" :background="{backgroundColor:'transparent'}">
<view slot="right" style="margin-right: 16px">
<u-icon name="setting" size="50" color="#4E73DF" @click="clickIcon" />
</view>
</u-navbar>
<h1 class="logo">智慧照明系统</h1>
<!--<u-image class="logo" mode="widthFix" src="@/static/img/logo.png" width="420" /> -->
<u-field
v-model="form.username"
icon="account"
label-width="0"
placeholder="请输入帐号"
placeholder-style="color: #8D92A6"
/>
<u-field
v-model="password"
icon="lock"
label-width="0"
placeholder="请输入密码"
placeholder-style="color: #8D92A6"
password
/>
<view class="submit">
<u-button type="primary" shape="circle" @click="formSubmit">登录</u-button>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import { getToken } from "@/common/network/user";
export default {
data() {
return {
form: {
username: "",
password: "",
//auth_type: "customer",
},
password: "",
};
},
created() {},
mounted() {},
methods: {
clickIcon() {
uni.navigateTo({
url: "/pages/user/serverConfig/serverConfig",
});
},
formSubmit() {
if (uni.getStorageSync("serverConfig"))
{
this.form.password=this.$md5(this.password)
getToken(this.form).then((res) => {
if(res.successed == true){
console.log('登录成功');
uni.setStorageSync("username", this.form.username);
uni.setStorageSync("password", this.form.password);
uni.setStorageSync("role", res.data.role);
uni.setStorageSync("token", res.data.token);
uni.reLaunch({
url: "/pages/index/index",
});
}
else{
this.$refs.uToast.show({
type: "error",
title: res.message,
});
}
})
.catch((err) => {
console.log(err);
this.$refs.uToast.show({
type: "error",
title: "服务器错误",
});
});
}
else {
this.$refs.uToast.show({
type: "warning",
title: "未配置服务器,请先配置服务器",
});
}
},
},
onShow() {
this.$nextTick(() => {
if (!uni.getStorageSync("serverConfig")) {
this.$refs.uToast.show({
type: "warning",
title: "未配置服务器,请先配置服务器",
});
}
});
},
onLoad(){
//location.reload()
},
};
</script>
<style scoped>
.page {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.logo {
margin: 160rpx 0;
}
.u-field {
width: 90%;
margin: 10px auto;
}
.u-field::after {
border-color: #a0a0a0;
}
.u-radio-group {
justify-content: space-around;
width: 87%;
line-height: 28px;
}
.submit {
flex: 1;
width: 85%;
margin-top: 100rpx;
display: flex;
align-items: center;
}
.submit .u-btn {
width: 100%;
}
</style>