登陆调整
This commit is contained in:
parent
61e0cd0ce7
commit
f7c77fe20d
3
App.vue
3
App.vue
|
@ -115,8 +115,7 @@ export default {
|
||||||
console.error("跳转失败", err);
|
console.error("跳转失败", err);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
if (role === "Admin") {
|
|
||||||
const adminTabBar = [
|
const adminTabBar = [
|
||||||
{
|
{
|
||||||
pagePath: "/pages/adminHome/index",
|
pagePath: "/pages/adminHome/index",
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
<view>传入参数:{{ showMsg }}</view>
|
<view>传入参数:{{ showMsg }}</view>
|
||||||
<view>接口返回结果:{{ resData }}</view>
|
<view>接口返回结果:{{ resData }}</view>
|
||||||
|
|
||||||
|
|
||||||
<!-- 已存在卡片时显示图片 -->
|
<!-- 已存在卡片时显示图片 -->
|
||||||
<view class="dialog-image-container" v-if="isChange === true">
|
<view class="dialog-image-container" v-if="isChange === true">
|
||||||
<!-- 替换为实际的图片路径 -->
|
<!-- 替换为实际的图片路径 -->
|
||||||
|
@ -112,48 +111,50 @@ export default {
|
||||||
this.step = 3
|
this.step = 3
|
||||||
this.lookData = data
|
this.lookData = data
|
||||||
const req = {
|
const req = {
|
||||||
"AreaId": data.areaId,
|
AreaId: data.areaId,
|
||||||
"pwd": data.pwd,
|
pwd: data.pwd,
|
||||||
"isAdd": this.isAdd,
|
isAdd: this.isAdd
|
||||||
// "isAdd": true,
|
// "isAdd": true,
|
||||||
}
|
}
|
||||||
console.log(req, '重置nfc--req')
|
// console.log(req, '重置nfc--req')
|
||||||
console.log(666);
|
// console.log(666)
|
||||||
|
|
||||||
// uni.showLoading({ title: '加载中...' })
|
// uni.showLoading({ title: '加载中...' })
|
||||||
const res = await ResetNFCApi(req).catch(e => e)
|
const res = await ResetNFCApi(req).catch(e => e)
|
||||||
if (!res.succeed) {
|
if (!res.succeed) {
|
||||||
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
|
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 {
|
try {
|
||||||
if (isAndroid && AndroidJs) {
|
if (isAndroid && AndroidJs) {
|
||||||
console.log("%c%s", "color:red", "安卓--调用方法");
|
console.log('%c%s', 'color:red', '安卓--调用方法')
|
||||||
const reqRow = {
|
const reqRow = {
|
||||||
name: "resetNFCRes",
|
name: 'resetNFCRes',
|
||||||
data: res,
|
data: res
|
||||||
};
|
}
|
||||||
console.log(reqRow, 'reqRow--')
|
console.log(reqRow, 'reqRow--')
|
||||||
AndroidJs.func(JSON.stringify(reqRow)); // 给安卓传参
|
AndroidJs.func(JSON.stringify(reqRow)) // 给安卓传参
|
||||||
} else {
|
} else {
|
||||||
console.log("%c%s", "color:red", "苹果--调用方法");
|
console.log('%c%s', 'color:red', '苹果--调用方法')
|
||||||
const reqRow = {
|
const reqRow = {
|
||||||
name: "back-iphone",
|
name: 'back-iphone',
|
||||||
data: "",
|
data: ''
|
||||||
};
|
}
|
||||||
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // 给ios 传参
|
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)) // 给ios 传参
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, "e-----判断安卓苹果类型出错");
|
console.log(e, 'e-----判断安卓苹果类型出错')
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
// uni.hideLoading()
|
// uni.hideLoading()
|
||||||
console.log(res, '重置nfc')
|
console.log(res, '重置nfc')
|
||||||
this.resData = res;
|
this.resData = res
|
||||||
if (res.succeed) {
|
if (res.succeed) {
|
||||||
uni.showToast({ title: '绑定成功', icon: 'none' })
|
uni.showToast({ title: '绑定成功', icon: 'none' })
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
|
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -186,30 +187,30 @@ export default {
|
||||||
this.step = 1
|
this.step = 1
|
||||||
console.log(this.currentRow, 'this.currentRow--')
|
console.log(this.currentRow, 'this.currentRow--')
|
||||||
// 给安卓传参
|
// 给安卓传参
|
||||||
let u = navigator.userAgent;
|
let u = navigator.userAgent
|
||||||
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 //android
|
||||||
try {
|
try {
|
||||||
if (isAndroid && AndroidJs) {
|
if (isAndroid && AndroidJs) {
|
||||||
console.log("%c%s", "color:red", "安卓--调用方法");
|
console.log('%c%s', 'color:red', '安卓--调用方法')
|
||||||
const reqRow = {
|
const reqRow = {
|
||||||
name: "area",
|
name: 'area',
|
||||||
data: {
|
data: {
|
||||||
// state: this.currentRow.state,
|
// state: this.currentRow.state,
|
||||||
state: true,
|
state: true,
|
||||||
areaId: this.currentRow.id,
|
areaId: this.currentRow.id
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
AndroidJs.func(JSON.stringify(reqRow)); // 给安卓传参
|
AndroidJs.func(JSON.stringify(reqRow)) // 给安卓传参
|
||||||
} else {
|
} else {
|
||||||
console.log("%c%s", "color:red", "苹果--调用方法");
|
console.log('%c%s', 'color:red', '苹果--调用方法')
|
||||||
const reqRow = {
|
const reqRow = {
|
||||||
name: "back-iphone",
|
name: 'back-iphone',
|
||||||
data: "",
|
data: ''
|
||||||
};
|
}
|
||||||
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // 给ios 传参
|
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)) // 给ios 传参
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, "e-----判断安卓苹果类型出错");
|
console.log(e, 'e-----判断安卓苹果类型出错')
|
||||||
}
|
}
|
||||||
// this.$emit('changeBinding')
|
// this.$emit('changeBinding')
|
||||||
// this.closeDialogInternal(); // 可以选择点击后是否关闭弹窗
|
// this.closeDialogInternal(); // 可以选择点击后是否关闭弹窗
|
||||||
|
@ -230,10 +231,10 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
visible(newVal) {
|
visible(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
console.log('打开');
|
console.log('打开')
|
||||||
window.nfcInitFn = this.nfcInitFn
|
window.nfcInitFn = this.nfcInitFn
|
||||||
} else {
|
} else {
|
||||||
console.log('关闭');
|
console.log('关闭')
|
||||||
// 清除 nfcInitFn 函数引用,避免内存泄漏
|
// 清除 nfcInitFn 函数引用,避免内存泄漏
|
||||||
window.nfcInitFn = null
|
window.nfcInitFn = null
|
||||||
}
|
}
|
||||||
|
@ -361,4 +362,5 @@ export default {
|
||||||
/* 可以添加按钮按下的效果 */
|
/* 可以添加按钮按下的效果 */
|
||||||
// .confirm-button:active {
|
// .confirm-button:active {
|
||||||
// background-color: #4879e6;
|
// background-color: #4879e6;
|
||||||
// }</style>
|
// }
|
||||||
|
</style>
|
||||||
|
|
|
@ -232,6 +232,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.content {
|
.content {
|
||||||
min-height: calc(100vh - 180rpx); // 确保容器有明确高度
|
min-height: calc(100vh - 180rpx); // 确保容器有明确高度
|
||||||
|
|
|
@ -9,131 +9,132 @@
|
||||||
<u-input v-model="pwd" border placeholder="密码"></u-input>
|
<u-input v-model="pwd" border placeholder="密码"></u-input>
|
||||||
</view>
|
</view>
|
||||||
<u-button type="primary" @click="loginFn('admin')" style="margin-top: 50rpx">登陆-管理员</u-button>
|
<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="loginFn('user')" style="margin-top: 50rpx">登陆-清洁工</u-button>
|
||||||
<u-button type="primary" @click="login2Fn" style="margin-top: 50rpx">登陆18174010562-管理员</u-button>
|
<u-button type="primary" v-if="false" @click="login1Fn" style="margin-top: 50rpx">登陆13800451500-清洁工</u-button>
|
||||||
<u-button type="primary" @click="login4Fn" style="margin-top: 50rpx">登陆18174010562-清洁工</u-button>
|
<u-button type="primary" v-if="false" @click="login2Fn" style="margin-top: 50rpx">登陆18174010562-管理员</u-button>
|
||||||
<u-button type="primary" @click="login3Fn" style="margin-top: 50rpx">登陆18174010561-清洁工</u-button>
|
<u-button type="primary" v-if="false" @click="login4Fn" style="margin-top: 50rpx">登陆18174010562-清洁工</u-button>
|
||||||
<u-button type="primary" @click="login5Fn" style="margin-top: 50rpx">登陆18174010561-管理员</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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from 'bcryptjs'
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from 'jwt-decode'
|
||||||
import { loginApi } from "@/api/apiList";
|
import { loginApi } from '@/api/apiList'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
phone: "18174010566",
|
phone: '18174010566',
|
||||||
pwd: "123456",
|
pwd: '123456'
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// console.log("%c%s", "color:red", "mounted--");
|
// console.log("%c%s", "color:red", "mounted--");
|
||||||
uni.hideLoading(); // 关闭 Loading
|
uni.hideLoading() // 关闭 Loading
|
||||||
},
|
},
|
||||||
onLoad() {},
|
onLoad() {},
|
||||||
methods: {
|
methods: {
|
||||||
login1Fn() {
|
login1Fn() {
|
||||||
this.phone = "13800451500";
|
this.phone = '13800451500'
|
||||||
// this.phone = "18174010561";
|
// this.phone = "18174010561";
|
||||||
this.pwd = "123456";
|
this.pwd = '123456'
|
||||||
this.loginFn("user");
|
this.loginFn('user')
|
||||||
},
|
},
|
||||||
login2Fn() {
|
login2Fn() {
|
||||||
this.phone = "18174010562";
|
this.phone = '18174010562'
|
||||||
this.pwd = "123456";
|
this.pwd = '123456'
|
||||||
this.loginFn("admin");
|
this.loginFn('admin')
|
||||||
},
|
},
|
||||||
login3Fn() {
|
login3Fn() {
|
||||||
this.phone = "18174010561";
|
this.phone = '18174010561'
|
||||||
this.pwd = "123456";
|
this.pwd = '123456'
|
||||||
this.loginFn("user");
|
this.loginFn('user')
|
||||||
},
|
},
|
||||||
login4Fn() {
|
login4Fn() {
|
||||||
this.phone = "18174010562";
|
this.phone = '18174010562'
|
||||||
this.pwd = "123456";
|
this.pwd = '123456'
|
||||||
this.loginFn("user");
|
this.loginFn('user')
|
||||||
},
|
},
|
||||||
login5Fn() {
|
login5Fn() {
|
||||||
this.phone = "18174010561";
|
this.phone = '18174010561'
|
||||||
this.pwd = "123456";
|
this.pwd = '123456'
|
||||||
this.loginFn("admin");
|
this.loginFn('admin')
|
||||||
},
|
},
|
||||||
async loginFn(type) {
|
async loginFn(type) {
|
||||||
let salt = bcrypt.genSaltSync(12);
|
let salt = bcrypt.genSaltSync(12)
|
||||||
let req = {
|
let req = {
|
||||||
phone: this.phone,
|
phone: this.phone,
|
||||||
password: bcrypt.hashSync(this.pwd, salt),
|
password: bcrypt.hashSync(this.pwd, salt)
|
||||||
};
|
}
|
||||||
const res = await loginApi(req);
|
const res = await loginApi(req)
|
||||||
if (!res.succeed) {
|
if (!res.succeed) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.error || "登录失败",
|
title: res.error || '登录失败',
|
||||||
icon: "none",
|
icon: 'none'
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
let token = res.data;
|
let token = res.data
|
||||||
uni.setStorageSync("token", "Bearer " + token);
|
uni.setStorageSync('token', 'Bearer ' + token)
|
||||||
console.log(jwtDecode(token), "解析的token信息");
|
console.log(jwtDecode(token), '解析的token信息')
|
||||||
// return
|
// return
|
||||||
console.log(type, "type--");
|
console.log(type, 'type--')
|
||||||
if (type === "user") {
|
if (type === 'user') {
|
||||||
const normalTabBar = [
|
const normalTabBar = [
|
||||||
{
|
{
|
||||||
pagePath: "/pages/index/planList",
|
pagePath: '/pages/index/planList',
|
||||||
iconPath: "/static/tab/planList.png",
|
iconPath: '/static/tab/planList.png',
|
||||||
selectedIconPath: "/static/tab/planList-active.png",
|
selectedIconPath: '/static/tab/planList-active.png',
|
||||||
text: "计划",
|
text: '计划'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: "/pages/index/index",
|
pagePath: '/pages/index/index',
|
||||||
iconPath: "/static/tab/admin-home.png",
|
iconPath: '/static/tab/admin-home.png',
|
||||||
selectedIconPath: "/static/tab/admin-home-acitve.png",
|
selectedIconPath: '/static/tab/admin-home-acitve.png',
|
||||||
text: "首页",
|
text: '首页'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: "/pages/user/index",
|
pagePath: '/pages/user/index',
|
||||||
iconPath: "/static/tab/admin-my.png",
|
iconPath: '/static/tab/admin-my.png',
|
||||||
selectedIconPath: "/static/tab/admin-my-active.png",
|
selectedIconPath: '/static/tab/admin-my-active.png',
|
||||||
text: "设置",
|
text: '设置'
|
||||||
},
|
}
|
||||||
];
|
]
|
||||||
this.$u.vuex("vuex_tabbar", normalTabBar);
|
this.$u.vuex('vuex_tabbar', normalTabBar)
|
||||||
|
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: `/pages/index/planList`,
|
url: `/pages/index/planList`
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
if (type === "admin") {
|
if (type === 'admin') {
|
||||||
const adminTabBar = [
|
const adminTabBar = [
|
||||||
{
|
{
|
||||||
pagePath: "/pages/adminHome/index",
|
pagePath: '/pages/adminHome/index',
|
||||||
iconPath: "/static/tab/admin-home.png",
|
iconPath: '/static/tab/admin-home.png',
|
||||||
selectedIconPath: "/static/tab/admin-home-acitve.png",
|
selectedIconPath: '/static/tab/admin-home-acitve.png',
|
||||||
text: "首页",
|
text: '首页'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: "/pages/adminNfc/index",
|
pagePath: '/pages/adminNfc/index',
|
||||||
iconPath: "/static/tab/nfc.png",
|
iconPath: '/static/tab/nfc.png',
|
||||||
selectedIconPath: "/static/tab/nfc-active.png",
|
selectedIconPath: '/static/tab/nfc-active.png',
|
||||||
text: "nfc写入",
|
text: 'nfc写入'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: "/pages/adminMy/index",
|
pagePath: '/pages/adminMy/index',
|
||||||
iconPath: "/static/tab/admin-my.png",
|
iconPath: '/static/tab/admin-my.png',
|
||||||
selectedIconPath: "/static/tab/admin-my-active.png",
|
selectedIconPath: '/static/tab/admin-my-active.png',
|
||||||
text: "我的",
|
text: '我的'
|
||||||
},
|
}
|
||||||
];
|
]
|
||||||
this.$u.vuex("vuex_tabbar", adminTabBar);
|
this.$u.vuex('vuex_tabbar', adminTabBar)
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: `/pages/adminHome/index`,
|
url: `/pages/adminHome/index`
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.content {
|
.content {
|
||||||
|
|
Loading…
Reference in New Issue