登陆调整

This commit is contained in:
李彪 2025-04-29 11:45:17 +08:00
parent 61e0cd0ce7
commit f7c77fe20d
4 changed files with 123 additions and 120 deletions

View File

@ -115,8 +115,7 @@ export default {
console.error("跳转失败", err);
},
});
}
if (role === "Admin") {
} else {
const adminTabBar = [
{
pagePath: "/pages/adminHome/index",

View File

@ -18,7 +18,6 @@
<view>传入参数{{ showMsg }}</view>
<view>接口返回结果{{ resData }}</view>
<!-- 已存在卡片时显示图片 -->
<view class="dialog-image-container" v-if="isChange === true">
<!-- 替换为实际的图片路径 -->
@ -112,48 +111,50 @@ export default {
this.step = 3
this.lookData = data
const req = {
"AreaId": data.areaId,
"pwd": data.pwd,
"isAdd": this.isAdd,
AreaId: data.areaId,
pwd: data.pwd,
isAdd: this.isAdd
// "isAdd": true,
}
console.log(req, '重置nfc--req')
console.log(666);
// console.log(req, 'nfc--req')
// console.log(666)
// uni.showLoading({ title: '...' })
const res = await ResetNFCApi(req).catch(e => e)
if (!res.succeed) {
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
}
this.resData = res;
this.resData = res
//
let u = navigator.userAgent
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 //android
try {
if (isAndroid && AndroidJs) {
console.log("%c%s", "color:red", "安卓--调用方法");
console.log('%c%s', 'color:red', '安卓--调用方法')
const reqRow = {
name: "resetNFCRes",
data: res,
};
name: 'resetNFCRes',
data: res
}
console.log(reqRow, 'reqRow--')
AndroidJs.func(JSON.stringify(reqRow)); //
AndroidJs.func(JSON.stringify(reqRow)) //
} else {
console.log("%c%s", "color:red", "苹果--调用方法");
console.log('%c%s', 'color:red', '苹果--调用方法')
const reqRow = {
name: "back-iphone",
data: "",
};
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // ios
name: 'back-iphone',
data: ''
}
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)) // ios
}
} catch (e) {
console.log(e, "e-----判断安卓苹果类型出错");
console.log(e, 'e-----判断安卓苹果类型出错')
}
return
// uni.hideLoading()
console.log(res, '重置nfc')
this.resData = res;
this.resData = res
if (res.succeed) {
uni.showToast({ title: '绑定成功', icon: 'none' })
} else {
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
}
return
@ -186,30 +187,30 @@ export default {
this.step = 1
console.log(this.currentRow, 'this.currentRow--')
//
let u = navigator.userAgent;
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android
let u = navigator.userAgent
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 //android
try {
if (isAndroid && AndroidJs) {
console.log("%c%s", "color:red", "安卓--调用方法");
console.log('%c%s', 'color:red', '安卓--调用方法')
const reqRow = {
name: "area",
name: 'area',
data: {
// state: this.currentRow.state,
state: true,
areaId: this.currentRow.id,
},
};
AndroidJs.func(JSON.stringify(reqRow)); //
areaId: this.currentRow.id
}
}
AndroidJs.func(JSON.stringify(reqRow)) //
} else {
console.log("%c%s", "color:red", "苹果--调用方法");
console.log('%c%s', 'color:red', '苹果--调用方法')
const reqRow = {
name: "back-iphone",
data: "",
};
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // ios
name: 'back-iphone',
data: ''
}
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)) // ios
}
} catch (e) {
console.log(e, "e-----判断安卓苹果类型出错");
console.log(e, 'e-----判断安卓苹果类型出错')
}
// this.$emit('changeBinding')
// this.closeDialogInternal(); //
@ -230,10 +231,10 @@ export default {
watch: {
visible(newVal) {
if (newVal) {
console.log('打开');
console.log('打开')
window.nfcInitFn = this.nfcInitFn
} else {
console.log('关闭');
console.log('关闭')
// nfcInitFn
window.nfcInitFn = null
}
@ -361,4 +362,5 @@ export default {
/* 可以添加按钮按下的效果 */
// .confirm-button:active {
// background-color: #4879e6;
// }</style>
// }
</style>

View File

@ -232,6 +232,7 @@ export default {
}
}
</script>
<style lang="scss" scoped>
.content {
min-height: calc(100vh - 180rpx); //

View File

@ -9,131 +9,132 @@
<u-input v-model="pwd" border placeholder="密码"></u-input>
</view>
<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>
<u-button type="primary" @click="loginFn('user')" style="margin-top: 50rpx">登陆-清洁工</u-button>
<u-button type="primary" v-if="false" @click="login1Fn" style="margin-top: 50rpx">登陆13800451500-清洁工</u-button>
<u-button type="primary" v-if="false" @click="login2Fn" style="margin-top: 50rpx">登陆18174010562-管理员</u-button>
<u-button type="primary" v-if="false" @click="login4Fn" style="margin-top: 50rpx">登陆18174010562-清洁工</u-button>
<u-button type="primary" v-if="false" @click="login3Fn" style="margin-top: 50rpx">登陆18174010561-清洁工</u-button>
<u-button type="primary" v-if="false" @click="login5Fn" style="margin-top: 50rpx">登陆18174010561-管理员</u-button>
</view>
</template>
<script>
import bcrypt from "bcryptjs";
import { jwtDecode } from "jwt-decode";
import { loginApi } from "@/api/apiList";
import bcrypt from 'bcryptjs'
import { jwtDecode } from 'jwt-decode'
import { loginApi } from '@/api/apiList'
export default {
data() {
return {
phone: "18174010566",
pwd: "123456",
};
phone: '18174010566',
pwd: '123456'
}
},
mounted() {
// console.log("%c%s", "color:red", "mounted--");
uni.hideLoading(); // Loading
uni.hideLoading() // Loading
},
onLoad() {},
methods: {
login1Fn() {
this.phone = "13800451500";
this.phone = '13800451500'
// this.phone = "18174010561";
this.pwd = "123456";
this.loginFn("user");
this.pwd = '123456'
this.loginFn('user')
},
login2Fn() {
this.phone = "18174010562";
this.pwd = "123456";
this.loginFn("admin");
this.phone = '18174010562'
this.pwd = '123456'
this.loginFn('admin')
},
login3Fn() {
this.phone = "18174010561";
this.pwd = "123456";
this.loginFn("user");
this.phone = '18174010561'
this.pwd = '123456'
this.loginFn('user')
},
login4Fn() {
this.phone = "18174010562";
this.pwd = "123456";
this.loginFn("user");
this.phone = '18174010562'
this.pwd = '123456'
this.loginFn('user')
},
login5Fn() {
this.phone = "18174010561";
this.pwd = "123456";
this.loginFn("admin");
this.phone = '18174010561'
this.pwd = '123456'
this.loginFn('admin')
},
async loginFn(type) {
let salt = bcrypt.genSaltSync(12);
let salt = bcrypt.genSaltSync(12)
let req = {
phone: this.phone,
password: bcrypt.hashSync(this.pwd, salt),
};
const res = await loginApi(req);
password: bcrypt.hashSync(this.pwd, salt)
}
const res = await loginApi(req)
if (!res.succeed) {
uni.showToast({
title: res.error || "登录失败",
icon: "none",
});
return;
title: res.error || '登录失败',
icon: 'none'
})
return
}
let token = res.data;
uni.setStorageSync("token", "Bearer " + token);
console.log(jwtDecode(token), "解析的token信息");
let token = res.data
uni.setStorageSync('token', 'Bearer ' + token)
console.log(jwtDecode(token), '解析的token信息')
// return
console.log(type, "type--");
if (type === "user") {
console.log(type, 'type--')
if (type === 'user') {
const normalTabBar = [
{
pagePath: "/pages/index/planList",
iconPath: "/static/tab/planList.png",
selectedIconPath: "/static/tab/planList-active.png",
text: "计划",
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/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);
pagePath: '/pages/user/index',
iconPath: '/static/tab/admin-my.png',
selectedIconPath: '/static/tab/admin-my-active.png',
text: '设置'
}
]
this.$u.vuex('vuex_tabbar', normalTabBar)
uni.switchTab({
url: `/pages/index/planList`,
});
url: `/pages/index/planList`
})
}
if (type === "admin") {
if (type === 'admin') {
const adminTabBar = [
{
pagePath: "/pages/adminHome/index",
iconPath: "/static/tab/admin-home.png",
selectedIconPath: "/static/tab/admin-home-acitve.png",
text: "首页",
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/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);
uni.switchTab({
url: `/pages/adminHome/index`,
});
pagePath: '/pages/adminMy/index',
iconPath: '/static/tab/admin-my.png',
selectedIconPath: '/static/tab/admin-my-active.png',
text: '我的'
}
]
this.$u.vuex('vuex_tabbar', adminTabBar)
uni.switchTab({
url: `/pages/adminHome/index`
})
}
}
}
}
},
},
};
</script>
<style lang="scss" scoped>
.content {