|
|
@@ -11,13 +11,14 @@
|
|
|
<p class="card-title blue">{{disable?'标签信息':'新增标签'}}</p>
|
|
|
<van-cell-group v-if="!disable" :border="false">
|
|
|
<van-cell title="NFC编码" :value="formData.code" />
|
|
|
-<!-- <van-cell title="所属机构" value="内容" is-link/>-->
|
|
|
+ <van-field required label="标签名称" v-model="formData.labelName" placeholder="请输入" />
|
|
|
<van-cell required title="选择所属机构" :label="formData.orgName" is-link @click="clickItem"/>
|
|
|
<select-cell required :disabled="areaList.length == 0" v-model="formData.areaId" title="选择区域" :border="true" :prop="props" :dataList="areaList"></select-cell>
|
|
|
<select-cell required :disabled="pointList.length == 0" v-model="formData.checkId" title="选择采集点" :prop="checkProps" :dataList="pointList"></select-cell>
|
|
|
</van-cell-group>
|
|
|
<van-cell-group v-else :border="false">
|
|
|
<van-cell title="NFC编码" :value="nfcInfo.code" />
|
|
|
+ <van-cell title="标签名称" :value="nfcInfo.labelName" />
|
|
|
<van-cell title="所属机构" :value="nfcInfo.orgName" />
|
|
|
<van-cell title="区域名称" :value="nfcInfo.areaName" />
|
|
|
<van-cell title="采集点名称" :value="nfcInfo.collectionAreaName" />
|
|
|
@@ -69,11 +70,13 @@ export default {
|
|
|
pointList:[],
|
|
|
nfcInfo:{
|
|
|
code:null,
|
|
|
+ labelName:'无',
|
|
|
orgName: '无',
|
|
|
areaName:'无',
|
|
|
collectionAreaName:'无',
|
|
|
},
|
|
|
formData:{
|
|
|
+ labelName:'',
|
|
|
orgName:'',
|
|
|
code:null,
|
|
|
orgId: null,
|
|
|
@@ -83,8 +86,8 @@ export default {
|
|
|
flag:false,
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- window.openNFCScanCallBack = this.openNFCScanCallBack;
|
|
|
+ destroyed(){
|
|
|
+ window.openNFCScanCallBack = null;
|
|
|
},
|
|
|
computed:{
|
|
|
...mapGetters(['orgId']),
|
|
|
@@ -95,19 +98,22 @@ export default {
|
|
|
//alert(data)
|
|
|
this.nfcMsg = '读取中...';
|
|
|
if(!data) {
|
|
|
- this.nfcMsg = '点击扫描';
|
|
|
this.$toast('扫描失败');
|
|
|
//this.showPopup = false;
|
|
|
return
|
|
|
}
|
|
|
let code = JSON.parse(data).content;
|
|
|
this.$toast('扫描成功');
|
|
|
+ this.nfcInfo = {};
|
|
|
+ this.formData = {};
|
|
|
nfcDetails(code).then(res=>{
|
|
|
- console.log(res,'res')
|
|
|
+ //console.log(res,'res')
|
|
|
+ //alert(JSON.stringify(res))
|
|
|
//this.showPopup = false;
|
|
|
- setTimeout(()=>{this.nfcMsg = '点击扫描';},500);
|
|
|
+ setTimeout(()=>{this.nfcMsg = '将NFC贴至手机背部'},500);
|
|
|
if(res.data){
|
|
|
this.nfcInfo = res.data;
|
|
|
+ this.disable = true;
|
|
|
}else {
|
|
|
this.$toast('未查询到NFC相关信息');
|
|
|
this.formData.code = code;
|
|
|
@@ -158,8 +164,13 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
getNfc(){
|
|
|
- if(this.nfcMsg === '扫描中...') return;
|
|
|
- this.useNFC();
|
|
|
+ window.openNFCScanCallBack = this.openNFCScanCallBack;
|
|
|
+ if(this.nfcMsg === '将NFC贴至手机背部'){
|
|
|
+ this.nfcMsg = '点击扫描';
|
|
|
+ window.openNFCScanCallBack = null;
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.useNFC();
|
|
|
},
|
|
|
changeOrg(selected){
|
|
|
this.showPicker = false;
|
|
|
@@ -170,11 +181,16 @@ export default {
|
|
|
this.getCheckList();
|
|
|
},
|
|
|
cancelPicker(){
|
|
|
+ if(this.nfcMsg === '将NFC贴至手机背部') return;
|
|
|
this.showPicker = false;
|
|
|
},
|
|
|
checkData(){
|
|
|
if(!this.formData.code){
|
|
|
- this.$toast('请先扫描NFC标签');
|
|
|
+ this.$toast('先扫描NFC标签');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(!this.formData.labelName){
|
|
|
+ this.$toast('请输入标签名称');
|
|
|
return false;
|
|
|
}
|
|
|
if(!this.formData.orgId){
|
|
|
@@ -198,10 +214,14 @@ export default {
|
|
|
useNFC(){
|
|
|
let system = this.isAndroidOrIos();
|
|
|
console.log(system,'system')
|
|
|
- if(system === 3) return this.$toast('当前环境不支持');
|
|
|
+ if(system === 3){
|
|
|
+ this.$toast('当前环境不支持');
|
|
|
+ return
|
|
|
+ }
|
|
|
const parms = {
|
|
|
"iOS_SessionType":"0"
|
|
|
};
|
|
|
+ this.nfcMsg = '将NFC贴至手机背部';
|
|
|
if(system === 1){
|
|
|
//android
|
|
|
// 判断当前环境是是否存在 js桥 'sap'
|
|
|
@@ -215,13 +235,17 @@ export default {
|
|
|
}
|
|
|
}else {
|
|
|
this.$toast('当前环境不支持');
|
|
|
+ this.nfcMsg = '点击扫描';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if(system === 2){
|
|
|
//ios
|
|
|
// 判断 ios是否存在方法 preview
|
|
|
- if(!window.webkit) return this.$toast('当前环境不支持');
|
|
|
+ if(!window.webkit) {
|
|
|
+ this.nfcMsg = '点击扫描';
|
|
|
+ this.$toast('当前环境不支持');
|
|
|
+ return;
|
|
|
+ }
|
|
|
const fun = window.webkit.messageHandlers.hasOwnProperty('openNFCScan')
|
|
|
if (fun) {
|
|
|
window.webkit.messageHandlers.openNFCScan.postMessage(JSON.stringify(parms))
|
|
|
@@ -236,7 +260,6 @@ export default {
|
|
|
.nfc-container{
|
|
|
padding:0 20px 20px 20px;
|
|
|
height: calc(100vh - 192px);
|
|
|
- -border: 1px solid red;
|
|
|
overflow: auto;
|
|
|
}
|
|
|
.card-title{
|
|
|
@@ -252,8 +275,8 @@ export default {
|
|
|
padding:0 20px;
|
|
|
margin-top:24px;
|
|
|
>div{
|
|
|
- width: 400px;
|
|
|
- height: 400px;
|
|
|
+ width: 360px;
|
|
|
+ height: 360px;
|
|
|
border-radius: 50%;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
@@ -277,7 +300,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.nfc-btn {
|
|
|
- margin: 50px;
|
|
|
+ margin: 40px;
|
|
|
width: 32%;
|
|
|
height: 48vh;
|
|
|
background: linear-gradient(-45deg, #dae, #3c9, #09f, #66f);
|