2025-04-14 14:29:21 +08:00
|
|
|
<template>
|
|
|
|
<view class="content">
|
2025-04-24 15:03:07 +08:00
|
|
|
<view style="margin-top: 50rpx; display: flex; align-items: center; padding-right: 50rpx">
|
2025-04-14 14:29:21 +08:00
|
|
|
<view style="margin-right: 50rpx">账号</view>
|
|
|
|
<u-input v-model="phone" border placeholder="账号"></u-input>
|
|
|
|
</view>
|
2025-04-24 15:03:07 +08:00
|
|
|
<view style="margin-top: 50rpx; display: flex; align-items: center; padding-right: 50rpx">
|
2025-04-14 14:29:21 +08:00
|
|
|
<view style="margin-right: 50rpx">账号</view>
|
|
|
|
<u-input v-model="pwd" border placeholder="密码"></u-input>
|
|
|
|
</view>
|
2025-04-24 15:03:07 +08:00
|
|
|
<u-button type="primary" @click="loginFn('admin')" style="margin-top: 50rpx">登陆-管理员</u-button>
|
|
|
|
<u-button type="primary" @click="login1Fn" style="margin-top: 50rpx">登陆13800451500-清洁工</u-button>
|
|
|
|
<u-button type="primary" @click="login2Fn" style="margin-top: 50rpx">登陆18174010562-管理员</u-button>
|
|
|
|
<u-button type="primary" @click="login4Fn" style="margin-top: 50rpx">登陆18174010562-清洁工</u-button>
|
|
|
|
<u-button type="primary" @click="login3Fn" style="margin-top: 50rpx">登陆18174010561-清洁工</u-button>
|
|
|
|
<u-button type="primary" @click="login5Fn" style="margin-top: 50rpx">登陆18174010561-管理员</u-button>
|
2025-04-14 14:29:21 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import bcrypt from "bcryptjs";
|
|
|
|
import { loginApi } from "@/api/apiList";
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2025-04-24 15:03:07 +08:00
|
|
|
phone: "18174010566",
|
2025-04-14 14:29:21 +08:00
|
|
|
pwd: "123456",
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
// console.log("%c%s", "color:red", "mounted--");
|
|
|
|
uni.hideLoading(); // 关闭 Loading
|
|
|
|
},
|
2025-04-24 15:03:07 +08:00
|
|
|
onLoad() { },
|
2025-04-14 14:29:21 +08:00
|
|
|
methods: {
|
|
|
|
login1Fn() {
|
2025-04-18 11:55:50 +08:00
|
|
|
this.phone = "13800451500";
|
|
|
|
// this.phone = "18174010561";
|
2025-04-14 14:29:21 +08:00
|
|
|
this.pwd = "123456";
|
2025-04-15 11:22:20 +08:00
|
|
|
this.loginFn("user");
|
2025-04-14 14:29:21 +08:00
|
|
|
},
|
|
|
|
login2Fn() {
|
|
|
|
this.phone = "18174010562";
|
|
|
|
this.pwd = "123456";
|
2025-04-15 11:22:20 +08:00
|
|
|
this.loginFn("admin");
|
2025-04-14 14:29:21 +08:00
|
|
|
},
|
2025-04-24 15:03:07 +08:00
|
|
|
login3Fn() {
|
|
|
|
this.phone = "18174010561";
|
|
|
|
this.pwd = "123456";
|
|
|
|
this.loginFn("user");
|
|
|
|
},
|
2025-04-18 11:55:50 +08:00
|
|
|
login4Fn() {
|
|
|
|
this.phone = "18174010562";
|
|
|
|
this.pwd = "123456";
|
|
|
|
this.loginFn("user");
|
|
|
|
},
|
2025-04-24 15:03:07 +08:00
|
|
|
login5Fn() {
|
2025-04-18 11:55:50 +08:00
|
|
|
this.phone = "18174010561";
|
|
|
|
this.pwd = "123456";
|
2025-04-24 15:03:07 +08:00
|
|
|
this.loginFn("admin");
|
2025-04-18 11:55:50 +08:00
|
|
|
},
|
2025-04-15 10:07:11 +08:00
|
|
|
async loginFn(type) {
|
2025-04-14 14:29:21 +08:00
|
|
|
let salt = bcrypt.genSaltSync(12);
|
|
|
|
let req = {
|
|
|
|
phone: this.phone,
|
|
|
|
password: bcrypt.hashSync(this.pwd, salt),
|
|
|
|
};
|
|
|
|
const res = await loginApi(req);
|
|
|
|
if (!res.succeed) {
|
|
|
|
uni.showToast({
|
|
|
|
title: res.error || "登录失败",
|
|
|
|
icon: "none",
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let token = res.data;
|
|
|
|
uni.setStorageSync("token", "Bearer " + token);
|
2025-04-15 11:22:20 +08:00
|
|
|
console.log(type, "type--");
|
|
|
|
if (type === "user") {
|
2025-04-24 15:03:07 +08:00
|
|
|
const normalTabBar = [
|
|
|
|
{
|
|
|
|
pagePath: "/pages/index/planList",
|
|
|
|
iconPath: "/static/tab/planList.png",
|
|
|
|
selectedIconPath: "/static/tab/planList-active.png",
|
|
|
|
text: "计划",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pagePath: "/pages/index/index",
|
|
|
|
iconPath: "/static/tab/admin-home.png",
|
|
|
|
selectedIconPath: "/static/tab/admin-home-acitve.png",
|
|
|
|
text: "首页",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pagePath: "/pages/user/index",
|
|
|
|
iconPath: "/static/tab/admin-my.png",
|
|
|
|
selectedIconPath: "/static/tab/admin-my-active.png",
|
|
|
|
text: "设置",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
this.$u.vuex("vuex_tabbar", normalTabBar);
|
|
|
|
|
2025-04-15 10:07:11 +08:00
|
|
|
uni.switchTab({
|
|
|
|
url: `/pages/index/planList`,
|
|
|
|
});
|
2025-04-15 11:22:20 +08:00
|
|
|
}
|
|
|
|
if (type === "admin") {
|
2025-04-24 15:03:07 +08:00
|
|
|
const adminTabBar = [
|
|
|
|
{
|
|
|
|
pagePath: "/pages/adminHome/index",
|
|
|
|
iconPath: "/static/tab/admin-home.png",
|
|
|
|
selectedIconPath: "/static/tab/admin-home-acitve.png",
|
|
|
|
text: "首页",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pagePath: "/pages/adminNfc/index",
|
|
|
|
iconPath: "/static/tab/nfc.png",
|
|
|
|
selectedIconPath: "/static/tab/nfc-active.png",
|
|
|
|
text: "nfc写入",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pagePath: "/pages/adminMy/index",
|
|
|
|
iconPath: "/static/tab/admin-my.png",
|
|
|
|
selectedIconPath: "/static/tab/admin-my-active.png",
|
|
|
|
text: "我的",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
this.$u.vuex("vuex_tabbar", adminTabBar);
|
2025-04-15 10:07:11 +08:00
|
|
|
uni.switchTab({
|
|
|
|
url: `/pages/adminHome/index`,
|
|
|
|
});
|
|
|
|
}
|
2025-04-14 14:29:21 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.content {
|
|
|
|
height: 100vh; // 确保容器有明确高度
|
|
|
|
// background-color: skyblue;
|
|
|
|
overflow: hidden;
|
|
|
|
padding-bottom: 100rpx;
|
|
|
|
}
|
|
|
|
</style>
|