等待安卓对接
This commit is contained in:
parent
8efffa4b94
commit
f9e3cb3f93
|
@ -1 +1,2 @@
|
||||||
.history
|
.history
|
||||||
|
unpackage/dist
|
||||||
|
|
148
App.vue
148
App.vue
|
@ -1,63 +1,95 @@
|
||||||
<script>
|
<script>
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
import appUpdate from "@/components/appUpdate/appUpdate.js";
|
||||||
|
// #endif
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
export default {
|
||||||
import appUpdate from '@/components/appUpdate/appUpdate.js'
|
onLaunch: function () {
|
||||||
// #endif
|
console.log("%c%s", "color:red", "onLaunch---");
|
||||||
|
uni.showLoading({ title: "等待参数传入" });
|
||||||
export default {
|
// uni.setStorageSync("token", "");
|
||||||
onLaunch: function() {
|
window.initFn = this.initFn;
|
||||||
//console.log('App Launch')
|
// this.initFn();
|
||||||
// #ifdef APP-PLUS
|
//console.log('App Launch')
|
||||||
let systemInfo = uni.getSystemInfoSync()
|
// #ifdef APP-PLUS
|
||||||
const data={
|
let systemInfo = uni.getSystemInfoSync();
|
||||||
appid: systemInfo.appId,
|
const data = {
|
||||||
version: systemInfo.appVersion
|
appid: systemInfo.appId,
|
||||||
}
|
version: systemInfo.appVersion,
|
||||||
console.log(data)
|
};
|
||||||
//把appid和版本发送请求服务器,看服务器上是否有更新
|
console.log(data);
|
||||||
this.$api.checkVersion(data).then(res => {
|
//把appid和版本发送请求服务器,看服务器上是否有更新
|
||||||
console.log(res)
|
this.$api.checkVersion(data).then((res) => {
|
||||||
if(res.code==0){
|
console.log(res);
|
||||||
//如果返回0则表示有更新
|
if (res.code == 0) {
|
||||||
appUpdate(res)
|
//如果返回0则表示有更新
|
||||||
}
|
appUpdate(res);
|
||||||
})
|
}
|
||||||
// #endif
|
});
|
||||||
},
|
// #endif
|
||||||
onShow: function() {
|
},
|
||||||
// #ifdef MP-WEIXIN
|
onShow: function () {
|
||||||
|
// console.log('%c%s', 'color:red', 'onShow---');
|
||||||
// 当向小程序后台请求完新版本信息,会进行回调。res: {hasUpdate: true, version: 1.0.0}
|
// #ifdef MP-WEIXIN
|
||||||
updateManager.onCheckForUpdate(function (res) {
|
|
||||||
if (res.hasUpdate) { // 有更新
|
// 当向小程序后台请求完新版本信息,会进行回调。res: {hasUpdate: true, version: 1.0.0}
|
||||||
uni.showLoading({title:'更新中...'}); // 开始下载前,显示Loading
|
updateManager.onCheckForUpdate(function (res) {
|
||||||
}
|
if (res.hasUpdate) {
|
||||||
});
|
// 有更新
|
||||||
// 当新版本下载完成,会进行回调
|
uni.showLoading({ title: "更新中..." }); // 开始下载前,显示Loading
|
||||||
updateManager.onUpdateReady(function () {
|
}
|
||||||
uni.hideLoading(); // 关闭 Loading
|
});
|
||||||
uni.showModal({ // 弹确认框(强制更新)
|
// 当新版本下载完成,会进行回调
|
||||||
title:'更新提示',
|
updateManager.onUpdateReady(function () {
|
||||||
content:'更新完毕,是否重启?',
|
uni.hideLoading(); // 关闭 Loading
|
||||||
success:function (res) {
|
uni.showModal({
|
||||||
if (res.confirm) {
|
// 弹确认框(强制更新)
|
||||||
updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
|
title: "更新提示",
|
||||||
}
|
content: "更新完毕,是否重启?",
|
||||||
}
|
success: function (res) {
|
||||||
})
|
if (res.confirm) {
|
||||||
});
|
updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
|
||||||
// 当新版本下载失败,会进行回调
|
}
|
||||||
updateManager.onUpdateFailed(function () {
|
},
|
||||||
uni.hideLoading(); // 关闭 Loading
|
});
|
||||||
uni.showToast({ title:'更新失败,稍后再试...', icon:"error" });
|
});
|
||||||
});
|
// 当新版本下载失败,会进行回调
|
||||||
// #endif
|
updateManager.onUpdateFailed(function () {
|
||||||
},
|
uni.hideLoading(); // 关闭 Loading
|
||||||
onHide: function() {
|
uni.showToast({ title: "更新失败,稍后再试...", icon: "error" });
|
||||||
|
});
|
||||||
}
|
// #endif
|
||||||
}
|
},
|
||||||
|
onHide: function () {},
|
||||||
|
methods: {
|
||||||
|
initFn(data) {
|
||||||
|
uni.hideLoading(); // 关闭 Loading
|
||||||
|
// uni.showModal({
|
||||||
|
// title: '查看initFn',
|
||||||
|
// content: data || '未传入参数 initFn',
|
||||||
|
// showCancel: true,
|
||||||
|
// success: function (res) {},
|
||||||
|
// });
|
||||||
|
console.log("%c%s", "color:red", "init");
|
||||||
|
console.log(data, "data--");
|
||||||
|
uni.setStorageSync(
|
||||||
|
"token",
|
||||||
|
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MjQ3MTcwLCJleHAiOjE3NDQyNTA3NzAsImlhdCI6MTc0NDI0NzE3MH0.ljZeF0Q1H8rMeh69x2N6e_qID_Y72KwmXQ1-tlOGTYc"
|
||||||
|
);
|
||||||
|
|
||||||
|
uni.switchTab({
|
||||||
|
url: "/pages/index/index",
|
||||||
|
success() {
|
||||||
|
console.log("跳转成功");
|
||||||
|
},
|
||||||
|
fail(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>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name" : "巡检保洁",
|
"name" : "巡检保洁",
|
||||||
"appid" : "",
|
"appid" : "__UNI__659FDE6",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.0.0",
|
"versionName" : "1.0.0",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
|
@ -87,6 +87,6 @@
|
||||||
"uniStatistics" : {
|
"uniStatistics" : {
|
||||||
"enable" : false
|
"enable" : false
|
||||||
},
|
},
|
||||||
"sassImplementationName": "node-sass",
|
"sassImplementationName" : "node-sass",
|
||||||
"vueVersion" : "2"
|
"vueVersion" : "2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"name": "巡检保洁",
|
||||||
|
"version": "1.0.6",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
|
@ -4,6 +4,12 @@
|
||||||
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
|
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
|
||||||
},
|
},
|
||||||
"pages": [
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "pages/home/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<template>
|
||||||
|
<view class="content"> </view>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { useRouter } from "@/utils/utils.js";
|
||||||
|
import daySelect from "@/components/daySelect/index.vue";
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
daySelect,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// console.log("%c%s", "color:red", "mounted--");
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.content {
|
||||||
|
// height: 100vh; // 确保容器有明确高度
|
||||||
|
overflow: hidden;
|
||||||
|
padding-bottom: 100rpx;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -53,6 +53,35 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<button @click="nfcResFn">
|
||||||
|
{{errorShow}}
|
||||||
|
</button>
|
||||||
|
<!-- nfc刷卡成功弹窗 -->
|
||||||
|
<u-popup v-model="successShow" mode="center" :round="30" >
|
||||||
|
<view class="success-box">
|
||||||
|
<view class="box-content">
|
||||||
|
<view class="logo"></view>
|
||||||
|
<view class="content-title">刷卡成功</view>
|
||||||
|
<view class="btn-box">
|
||||||
|
<view class="btn-cancel" @click="successShow = false">暂不</view>
|
||||||
|
<view class="btn-success" @click="uploadFn">上传图片</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
|
<!-- nfc刷卡失败弹窗 -->
|
||||||
|
<u-popup v-model="errorShow" mode="center" :round="30" >
|
||||||
|
<view class="error-box">
|
||||||
|
<view class="box-content">
|
||||||
|
<view class="logo"></view>
|
||||||
|
<view class="content-title">刷卡失败</view>
|
||||||
|
<view class="btn-box">
|
||||||
|
<view class="btn-cancel" @click="errorShow = false">暂不</view>
|
||||||
|
<view class="btn-success" @click="exceptionReportFn">异常上报</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -95,18 +124,46 @@ export default {
|
||||||
],
|
],
|
||||||
|
|
||||||
paramsId: "",
|
paramsId: "",
|
||||||
|
// 刷卡成功弹窗
|
||||||
|
successShow:false,
|
||||||
|
// 刷卡失败弹窗
|
||||||
|
errorShow:false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.paramsId = options.id;
|
this.paramsId = options.id;
|
||||||
|
window.nfcFn = this.nfcResFn;
|
||||||
|
// this.nfcResFn();
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.getPlanInfoAreaList();
|
// this.getPlanInfoAreaList();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
nfcResFn(data){
|
||||||
|
if(false){
|
||||||
|
console.log('%c%s', 'color:red', 'nfc刷卡成功');
|
||||||
|
this.successShow = true;
|
||||||
|
}else{
|
||||||
|
console.log('%c%s', 'color:red', '刷卡失败');
|
||||||
|
this.errorShow = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 上传图片
|
||||||
|
uploadFn(){
|
||||||
|
console.log('%c%s', 'color:red', '上传图片');
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/index/uploadPhoto",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 异常上报
|
||||||
|
exceptionReportFn(){
|
||||||
|
console.log('%c%s', 'color:red', '异常上报');
|
||||||
|
},
|
||||||
|
openFn(){},
|
||||||
|
closeFn(){},
|
||||||
changeTab(i) {
|
changeTab(i) {
|
||||||
console.log(i);
|
console.log(i);
|
||||||
this.selectIdx = i;
|
this.selectIdx = i;
|
||||||
|
@ -244,4 +301,128 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.success-box{
|
||||||
|
// overflow:hidden;
|
||||||
|
width:650rpx;
|
||||||
|
padding-top:50rpx;
|
||||||
|
background-color:transparent;
|
||||||
|
.box-content{
|
||||||
|
height:450rpx;
|
||||||
|
background-color: #ffffff;
|
||||||
|
background: linear-gradient(to bottom, #A7DAFC, white 60%, white);
|
||||||
|
border-radius:30rpx;
|
||||||
|
// border:1px solid red;
|
||||||
|
position:relative;
|
||||||
|
.logo{
|
||||||
|
position:absolute;
|
||||||
|
top:-50rpx;
|
||||||
|
left:50%;
|
||||||
|
transform:translateX(-50%);
|
||||||
|
width:200rpx;
|
||||||
|
height:200rpx;
|
||||||
|
background-color:red;
|
||||||
|
}
|
||||||
|
.content-title{
|
||||||
|
position:absolute;
|
||||||
|
top:40%;
|
||||||
|
width:100%;
|
||||||
|
color:black;
|
||||||
|
font-size:40rpx;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
.btn-box{
|
||||||
|
position:absolute;
|
||||||
|
bottom:10%;
|
||||||
|
width:100%;
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-evenly;
|
||||||
|
.btn-cancel{
|
||||||
|
width:200rpx;
|
||||||
|
height:70rpx;
|
||||||
|
background-color:#F3F6F7;
|
||||||
|
border-radius:50rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size:30rpx;
|
||||||
|
color:#32353B;
|
||||||
|
}
|
||||||
|
.btn-success{
|
||||||
|
width:200rpx;
|
||||||
|
height:70rpx;
|
||||||
|
background-color:#4278F4;
|
||||||
|
border-radius:50rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size:30rpx;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.error-box{
|
||||||
|
// overflow:hidden;
|
||||||
|
width:650rpx;
|
||||||
|
padding-top:50rpx;
|
||||||
|
background-color:transparent;
|
||||||
|
.box-content{
|
||||||
|
height:450rpx;
|
||||||
|
background-color: #ffffff;
|
||||||
|
background: linear-gradient(to bottom, #A7DAFC, white 60%, white);
|
||||||
|
border-radius:30rpx;
|
||||||
|
// border:1px solid red;
|
||||||
|
position:relative;
|
||||||
|
.logo{
|
||||||
|
position:absolute;
|
||||||
|
top:-50rpx;
|
||||||
|
left:50%;
|
||||||
|
transform:translateX(-50%);
|
||||||
|
width:200rpx;
|
||||||
|
height:200rpx;
|
||||||
|
background-color:red;
|
||||||
|
}
|
||||||
|
.content-title{
|
||||||
|
position:absolute;
|
||||||
|
top:40%;
|
||||||
|
width:100%;
|
||||||
|
color:black;
|
||||||
|
font-size:40rpx;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
.btn-box{
|
||||||
|
position:absolute;
|
||||||
|
bottom:10%;
|
||||||
|
width:100%;
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-evenly;
|
||||||
|
.btn-cancel{
|
||||||
|
width:200rpx;
|
||||||
|
height:70rpx;
|
||||||
|
background-color:#F3F6F7;
|
||||||
|
border-radius:50rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size:30rpx;
|
||||||
|
color:#32353B;
|
||||||
|
}
|
||||||
|
.btn-success{
|
||||||
|
width:200rpx;
|
||||||
|
height:70rpx;
|
||||||
|
background-color:#4278F4;
|
||||||
|
border-radius:50rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size:30rpx;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::v-deep .u-mode-center-box{
|
||||||
|
margin-top:-500rpx !important;
|
||||||
|
background-color:transparent !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -128,11 +128,14 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log('%c%s', 'color:red', 'mounted--')
|
||||||
this.getPlanByDate();
|
this.getPlanByDate();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onDateChange({ date, isToday }) {
|
onDateChange({ date, isToday }) {
|
||||||
|
// 对接完登陆后解开
|
||||||
|
// return
|
||||||
this.isToday = isToday;
|
this.isToday = isToday;
|
||||||
this.currentDate = date;
|
this.currentDate = date;
|
||||||
this.getPlanByDate();
|
this.getPlanByDate();
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
// if ('nfc' in navigator) {
|
||||||
|
// console.log('设备支持NFC');
|
||||||
|
// uni.showToast({ title: '支持NFC', icon: "none" });
|
||||||
|
// } else {
|
||||||
|
// uni.showToast({ title: '设备不支持NFC', icon: "none" });
|
||||||
|
// console.log('设备不支持NFC');
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// await navigator.permissions.query({ name: 'nfc' });
|
||||||
|
// this.nfcMsg = 'NFC权限已授予'
|
||||||
|
// console.log('NFC权限已授予');
|
||||||
|
// } catch (error) {
|
||||||
|
// this.nfcMsg = '获取NFC权限失败'
|
||||||
|
// console.error('获取NFC权限失败', error);
|
||||||
|
// }
|
||||||
|
|
||||||
|
document.addEventListener("plusready", function () {
|
||||||
|
// NFC监听
|
||||||
|
monitorNFC()
|
||||||
|
})
|
||||||
|
|
||||||
|
function monitorNFC(t) {
|
||||||
|
this.nfcMsg = '111'
|
||||||
|
let NfcAdapter;
|
||||||
|
let NdefRecord;
|
||||||
|
let NdefMessage;
|
||||||
|
function listenNFCStatus() {
|
||||||
|
try {
|
||||||
|
let main = plus.android.runtimeMainActivity();
|
||||||
|
let Intent = plus.android.importClass('android.content.Intent');
|
||||||
|
let Activity = plus.android.importClass('android.app.Activity');
|
||||||
|
let PendingIntent = plus.android.importClass('android.app.PendingIntent');
|
||||||
|
let IntentFilter = plus.android.importClass('android.content.IntentFilter');
|
||||||
|
NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
|
||||||
|
let nfcAdapter = NfcAdapter.getDefaultAdapter(main);
|
||||||
|
let intent = new Intent(main, main.getClass());
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
let pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
|
||||||
|
let ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
|
||||||
|
ndef.addDataType("*/*");
|
||||||
|
let intentFiltersArray = [ndef];
|
||||||
|
let techListsArray = [
|
||||||
|
["android.nfc.tech.IsoDep"],
|
||||||
|
["android.nfc.tech.NfcA"],
|
||||||
|
["android.nfc.tech.NfcB"],
|
||||||
|
["android.nfc.tech.NfcF"],
|
||||||
|
["android.nfc.tech.Nfcf"],
|
||||||
|
["android.nfc.tech.NfcV"],
|
||||||
|
["android.nfc.tech.NdefFormatable"],
|
||||||
|
["android.nfc.tech.MifareClassic"],
|
||||||
|
["android.nfc.tech.MifareUltralight"]
|
||||||
|
];
|
||||||
|
document.addEventListener("newintent",
|
||||||
|
function () {
|
||||||
|
console.error('newintent');
|
||||||
|
setTimeout(handle_nfc_data1, 1000);
|
||||||
|
}, false);
|
||||||
|
document.addEventListener("pause", function (e) {
|
||||||
|
if (nfcAdapter) {
|
||||||
|
nfcAdapter.disableForegroundDispatch(main);
|
||||||
|
console.log('pause');
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
document.addEventListener("resume", function (e) {
|
||||||
|
if (nfcAdapter) {
|
||||||
|
console.log('resume');
|
||||||
|
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_nfc_data1() {
|
||||||
|
NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
|
||||||
|
NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
|
||||||
|
let main = plus.android.runtimeMainActivity();
|
||||||
|
let intent = main.getIntent();
|
||||||
|
if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) {
|
||||||
|
// if (readyWriteData) {
|
||||||
|
// __write(intent);
|
||||||
|
// readyWriteData = false;
|
||||||
|
// } else if (readyRead) {
|
||||||
|
console.log("进行读取NFC")
|
||||||
|
__read(intent);
|
||||||
|
readyRead = false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function __read(intent) {
|
||||||
|
try {
|
||||||
|
let content = "";
|
||||||
|
waiting = plus.nativeUI.showWaiting("请勿移开标签\n正在读取数据...");
|
||||||
|
let tag = plus.android.importClass("android.nfc.Tag");
|
||||||
|
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
||||||
|
let bytesId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
|
||||||
|
let rawmsgs = intent.getParcelableArrayExtra("android.nfc.extra.NDEF_MESSAGES");
|
||||||
|
let records = rawmsgs[0].getRecords();
|
||||||
|
let result = records[0].getPayload();
|
||||||
|
let s = plus.android.newObject("java.lang.String", result);
|
||||||
|
console.log(s)
|
||||||
|
if (s) {
|
||||||
|
s = s.slice(s.indexOf('en') + 2)
|
||||||
|
}
|
||||||
|
console.log('查询解过:' + s)
|
||||||
|
// console.log("bytesId:" + (bytesId));
|
||||||
|
// console.log("十六进制ID:" + (bytesToHexString(tag.getId())));
|
||||||
|
} catch (e) {
|
||||||
|
alert(e);
|
||||||
|
}
|
||||||
|
readyRead = false
|
||||||
|
waiting.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function bytesToHexString(inarray) {
|
||||||
|
let i, j, x;
|
||||||
|
let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
|
||||||
|
"B", "C", "D", "E", "F"
|
||||||
|
];
|
||||||
|
let out = "";
|
||||||
|
for (j = 0; j < inarray.length; ++j) {
|
||||||
|
x = parseInt(inarray[j]) & 0xff;
|
||||||
|
i = (x >> 4) & 0x0f;
|
||||||
|
out += hex[i];
|
||||||
|
i = x & 0x0f;
|
||||||
|
out += hex[i];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ const manager = new RequestManager()
|
||||||
|
|
||||||
|
|
||||||
// 先写死调接口
|
// 先写死调接口
|
||||||
uni.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MTc1MjA2LCJleHAiOjE3NDQxNzg4MDYsImlhdCI6MTc0NDE3NTIwNn0.1qDnEAJH-bJlEr1wbwjTfqLY9xAyJKzf6bmLP6svUNo')
|
// uni.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiI1YmJiYTBhMi04YmJmLTcxMmUtMjMxMy1kYTc0N2E1MGUxYzEiLCJ1bmlxdWVfbmFtZSI6Iua1i-ivlSIsInJvbGUiOiJBZG1pbiIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL21vYmlsZXBob25lIjoiMTgxNzQwMTA1NjEiLCJncm91cHNpZCI6IjRiMmQ5NjYyLWE3NjgtMDhmMi1hMGM4LTc2MmI4Yzc2ZGEyYSIsIm5iZiI6MTc0NDE3OTY2NiwiZXhwIjoxNzQ0MTgzMjY2LCJpYXQiOjE3NDQxNzk2NjZ9.TTLt3vwefdrd8rx3zNN4rr0OI4yp14m781N3PC3lIHw')
|
||||||
|
|
||||||
|
|
||||||
const baseRequest = async (url, method, data = {}, loading = true) =>{
|
const baseRequest = async (url, method, data = {}, loading = true) =>{
|
||||||
|
|
Loading…
Reference in New Issue