nfc卡写入权限问题
This commit is contained in:
parent
4a734eb1e7
commit
ec5165021e
165
App.vue
165
App.vue
|
@ -1,31 +1,31 @@
|
||||||
<script>
|
<script>
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
import appUpdate from "@/components/appUpdate/appUpdate.js";
|
import appUpdate from '@/components/appUpdate/appUpdate.js'
|
||||||
// #endif
|
// #endif
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from 'jwt-decode'
|
||||||
export default {
|
export default {
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
console.log("%c%s", "color:red", "onLaunch---");
|
console.log('%c%s', 'color:red', 'onLaunch---')
|
||||||
uni.showLoading({ title: "加载中" });
|
uni.showLoading({ title: '加载中' })
|
||||||
// uni.setStorageSync("token", "");
|
// uni.setStorageSync("token", "");
|
||||||
window.initFn = this.initFn;
|
window.initFn = this.initFn
|
||||||
// this.initFn();
|
// this.initFn();
|
||||||
//console.log('App Launch')
|
//console.log('App Launch')
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
let systemInfo = uni.getSystemInfoSync();
|
let systemInfo = uni.getSystemInfoSync()
|
||||||
const data = {
|
const data = {
|
||||||
appid: systemInfo.appId,
|
appid: systemInfo.appId,
|
||||||
version: systemInfo.appVersion,
|
version: systemInfo.appVersion
|
||||||
};
|
}
|
||||||
console.log(data);
|
console.log(data)
|
||||||
//把appid和版本发送请求服务器,看服务器上是否有更新
|
//把appid和版本发送请求服务器,看服务器上是否有更新
|
||||||
this.$api.checkVersion(data).then((res) => {
|
this.$api.checkVersion(data).then(res => {
|
||||||
console.log(res);
|
console.log(res)
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
//如果返回0则表示有更新
|
//如果返回0则表示有更新
|
||||||
appUpdate(res);
|
appUpdate(res)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
|
@ -36,36 +36,36 @@ export default {
|
||||||
updateManager.onCheckForUpdate(function (res) {
|
updateManager.onCheckForUpdate(function (res) {
|
||||||
if (res.hasUpdate) {
|
if (res.hasUpdate) {
|
||||||
// 有更新
|
// 有更新
|
||||||
uni.showLoading({ title: "更新中..." }); // 开始下载前,显示Loading
|
uni.showLoading({ title: '更新中...' }) // 开始下载前,显示Loading
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
// 当新版本下载完成,会进行回调
|
// 当新版本下载完成,会进行回调
|
||||||
updateManager.onUpdateReady(function () {
|
updateManager.onUpdateReady(function () {
|
||||||
uni.hideLoading(); // 关闭 Loading
|
uni.hideLoading() // 关闭 Loading
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
// 弹确认框(强制更新)
|
// 弹确认框(强制更新)
|
||||||
title: "更新提示",
|
title: '更新提示',
|
||||||
content: "更新完毕,是否重启?",
|
content: '更新完毕,是否重启?',
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
|
updateManager.applyUpdate() // 强制小程序重启并使用新版本。
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
// 当新版本下载失败,会进行回调
|
// 当新版本下载失败,会进行回调
|
||||||
updateManager.onUpdateFailed(function () {
|
updateManager.onUpdateFailed(function () {
|
||||||
uni.hideLoading(); // 关闭 Loading
|
uni.hideLoading() // 关闭 Loading
|
||||||
uni.showToast({ title: "更新失败,稍后再试...", icon: "error" });
|
uni.showToast({ title: '更新失败,稍后再试...', icon: 'error' })
|
||||||
});
|
})
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
onHide: function () { },
|
onHide: function () {},
|
||||||
methods: {
|
methods: {
|
||||||
initFn(data) {
|
initFn(data) {
|
||||||
uni.hideLoading(); // 关闭 Loading
|
uni.hideLoading() // 关闭 Loading
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return uni.showToast({ title: "未传入参数 initFn", icon: "none" });
|
return uni.showToast({ title: '未传入参数 initFn', icon: 'none' })
|
||||||
}
|
}
|
||||||
// uni.showModal({
|
// uni.showModal({
|
||||||
// title: "查看initFn",
|
// title: "查看initFn",
|
||||||
|
@ -74,84 +74,85 @@ export default {
|
||||||
// success: function (res) {},
|
// success: function (res) {},
|
||||||
// });
|
// });
|
||||||
// "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MjYzMTAyLCJleHAiOjE3NDQyNjY3MDIsImlhdCI6MTc0NDI2MzEwMn0.ZJTwC7rWCcywoM7ncysw-JRIiwXz4y_6hlmqctN-gMM"
|
// "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MjYzMTAyLCJleHAiOjE3NDQyNjY3MDIsImlhdCI6MTc0NDI2MzEwMn0.ZJTwC7rWCcywoM7ncysw-JRIiwXz4y_6hlmqctN-gMM"
|
||||||
let token = data.token;
|
let token = data.token
|
||||||
uni.setStorageSync("token", "Bearer " + token);
|
uni.setStorageSync('token', 'Bearer ' + token)
|
||||||
console.log(jwtDecode(token), "解析的token信息");
|
console.log(jwtDecode(token), '解析的token信息')
|
||||||
let resData = jwtDecode(token);
|
let resData = jwtDecode(token)
|
||||||
this.$u.vuex("vuex_userData", resData);
|
this.$u.vuex('vuex_userData', resData)
|
||||||
|
console.log(this.vuex_userData, 'vuex_userData')
|
||||||
// User | Admin
|
// User | Admin
|
||||||
let role = resData.role;
|
let role = resData.role
|
||||||
console.log(role, "role----");
|
console.log(role, 'role----')
|
||||||
// return;
|
// return;
|
||||||
if (role === "User") {
|
if (role === '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/index",
|
url: '/pages/index/index',
|
||||||
success() {
|
success() {
|
||||||
console.log("跳转成功");
|
console.log('跳转成功')
|
||||||
window.initFn = null; // 清除全局函数
|
window.initFn = null // 清除全局函数
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error("跳转失败", err);
|
console.error('跳转失败', err)
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
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',
|
||||||
success() {
|
success() {
|
||||||
console.log("跳转成功");
|
console.log('跳转成功')
|
||||||
window.initFn = null; // 清除全局函数
|
window.initFn = null // 清除全局函数
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error("跳转失败", err);
|
console.error('跳转失败', err)
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "@/uni_modules/uview-ui/index.scss";
|
@import '@/uni_modules/uview-ui/index.scss';
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -82,6 +82,10 @@ export default {
|
||||||
onLoad() {},
|
onLoad() {},
|
||||||
methods: {
|
methods: {
|
||||||
async nfcInitFn(data) {
|
async nfcInitFn(data) {
|
||||||
|
if(this.vuex_userData.nfcwrite !== 'True'){
|
||||||
|
uni.showToast({ title: '暂无NFC卡写入权限', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
uni.showToast({ title: '未传入参数nfcInitFn', icon: 'none' })
|
uni.showToast({ title: '未传入参数nfcInitFn', icon: 'none' })
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- tabs -->
|
<!-- tabs -->
|
||||||
<u-tabs class="tabs-box" bg-color="#F6F8FC" :list="tabsList" :is-scroll="true" :current="tabCurrent"
|
<u-tabs class="tabs-box" bg-color="#F6F8FC" :list="tabsList" :is-scroll="true" :current="tabCurrent" @change="tabChangeFn"></u-tabs>
|
||||||
@change="tabChangeFn"></u-tabs>
|
|
||||||
<!-- 搜索 -->
|
<!-- 搜索 -->
|
||||||
<view class="search-box">
|
<view class="search-box">
|
||||||
<u-input class="search-input" v-model="keyword" :clearable="false" border placeholder="搜索名称"
|
<u-input class="search-input" v-model="keyword" :clearable="false" border placeholder="搜索名称" @keyup.enter="searchFn"></u-input>
|
||||||
@keyup.enter="searchFn"></u-input>
|
|
||||||
<u-icon name="search" class="search-icon" size="40" @click="searchFn"></u-icon>
|
<u-icon name="search" class="search-icon" size="40" @click="searchFn"></u-icon>
|
||||||
<view class="select-box" @click="selectFn">
|
<view class="select-box" @click="selectFn">
|
||||||
<view>
|
<view>
|
||||||
|
@ -45,8 +43,7 @@
|
||||||
<!-- 筛选的下拉 -->
|
<!-- 筛选的下拉 -->
|
||||||
<u-action-sheet :list="options" title="请选择" @click="changeFn" v-model:value="selectShow"></u-action-sheet>
|
<u-action-sheet :list="options" title="请选择" @click="changeFn" v-model:value="selectShow"></u-action-sheet>
|
||||||
<!-- 弹窗 -->
|
<!-- 弹窗 -->
|
||||||
<bind-dialog ref="dialogRef" :visible="showDialog" @close="showDialog = false" :currentRow="currentRow"
|
<bind-dialog ref="dialogRef" :visible="showDialog" @close="showDialog = false" :currentRow="currentRow" @changeBinding="onChangeBinding" @confirm="onConfirm" @closeRes="closeResFn"></bind-dialog>
|
||||||
@changeBinding="onChangeBinding" @confirm="onConfirm" @closeRes="closeResFn"></bind-dialog>
|
|
||||||
|
|
||||||
<u-tabbar :list="vuex_tabbar"></u-tabbar>
|
<u-tabbar :list="vuex_tabbar"></u-tabbar>
|
||||||
</view>
|
</view>
|
||||||
|
@ -114,35 +111,37 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
dialogShowFn(row) {
|
dialogShowFn(row) {
|
||||||
|
// console.log(this.vuex_userData.nfcwrite)
|
||||||
|
// return
|
||||||
// 给安卓传参
|
// 给安卓传参
|
||||||
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
|
||||||
console.log(row.state, 'row.state--')
|
console.log(row.state, 'row.state--')
|
||||||
// 添加的时候给安卓传参
|
// 添加的时候给安卓传参
|
||||||
if (row.state === false) {
|
if (row.state === false) {
|
||||||
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: row.state,
|
// state: row.state,
|
||||||
state: true,
|
state: true,
|
||||||
areaId: row.id,
|
areaId: row.id
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
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-----判断安卓苹果类型出错')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@ export default {
|
||||||
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信息')
|
||||||
|
let resData = jwtDecode(token)
|
||||||
|
this.$u.vuex('vuex_userData', resData)
|
||||||
|
console.log(this.vuex_userData, 'vuex_userData')
|
||||||
// return
|
// return
|
||||||
console.log(type, 'type--')
|
console.log(type, 'type--')
|
||||||
if (type === 'user') {
|
if (type === 'user') {
|
||||||
|
|
Loading…
Reference in New Issue