登陆模拟身份问题

This commit is contained in:
李彪 2025-04-15 11:22:20 +08:00
parent 0f0594e1f0
commit 82153c42ce
2 changed files with 12 additions and 12 deletions

View File

@ -10,6 +10,10 @@
<view class="card-title">未绑定子区域数</view>
<view class="card-totel">10</view>
</view>
</view>
<!-- 搜索 -->
<view>
</view>
<u-tabbar :list="vuex_tabbar"></u-tabbar>
</view>

View File

@ -14,10 +14,10 @@
</view>
<u-button type="primary" @click="loginFn" style="margin-top: 50rpx">登陆</u-button>
<u-button type="primary" @click="login1Fn" style="margin-top: 50rpx"
>登陆13800451500管理员</u-button
>登陆13800451500清洁工</u-button
>
<u-button type="primary" @click="login2Fn" style="margin-top: 50rpx"
>登陆18174010562清洁工</u-button
>登陆18174010562管理员</u-button
>
</view>
</template>
@ -62,7 +62,7 @@ export default {
},
];
this.$u.vuex("vuex_tabbar", normalTabBar);
this.loginFn(false);
this.loginFn("user");
},
login2Fn() {
this.phone = "18174010562";
@ -89,13 +89,8 @@ export default {
},
];
this.$u.vuex("vuex_tabbar", adminTabBar);
this.loginFn(true);
this.loginFn("admin");
},
//
normalizePath(path) {
return path.startsWith("/") ? path : `/${path}`;
},
async loginFn(type) {
let salt = bcrypt.genSaltSync(12);
let req = {
@ -112,12 +107,13 @@ export default {
}
let token = res.data;
uni.setStorageSync("token", "Bearer " + token);
let userRole = "admin";
if (type) {
console.log(type, "type--");
if (type === "user") {
uni.switchTab({
url: `/pages/index/planList`,
});
} else {
}
if (type === "admin") {
uni.switchTab({
url: `/pages/adminHome/index`,
});