| | |
| | | "intelCard": "" |
| | | } |
| | | }; |
| | | |
| | | var data1 = { |
| | | "interfaceId": "5208", |
| | | "outId": "10208", |
| | | "reqDateTime": new Date(), |
| | | "tokenAuth": "", |
| | | "data": { |
| | | "type": "OUT", |
| | | "id": "", |
| | | "intelCard": "" |
| | | } |
| | | }; |
| | | //初始化数据 |
| | | function init() { |
| | | var user = JSON.parse(localStorage.getItem('user')); |
| | |
| | | function getOutHandleList() { |
| | | outHandleData = null; |
| | | data.data.plateNum = mui("#plateNum")[0].value; |
| | | // //请求 |
| | | // mui.ajax(url, { |
| | | // type: "POST", |
| | | // dataType: "json", |
| | | // crossDomain: true, |
| | | // contentType: "application/json;charset=utf-8", |
| | | // data: JSON.stringify(data), |
| | | // success: function(result) { |
| | | // if (result.code == "0000") { |
| | | // outHandleData = result.data; |
| | | // console.log("if",JSON.stringify(result)) |
| | | // renderData(); |
| | | // } else { |
| | | // renderData(); |
| | | // mui.toast(result.msg); |
| | | // console.log("else",JSON.stringify(result)) |
| | | // } |
| | | // }, |
| | | // error: function() { |
| | | // mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") |
| | | // } |
| | | // }) |
| | | outHandleData = [{ |
| | | "id": "44", |
| | | "plateNum": "97", |
| | | "deHandle": "ut", |
| | | "depotId": "16", |
| | | "depotName": "青张列做总", |
| | | "foodVariety": "magna pariatur laboris sunt dolor", |
| | | "foodVarietyName": "提清除", |
| | | "foodLevel": "fugiat", |
| | | "foodLevelName": "应发热四民是始", |
| | | "storeKeeperName":"" |
| | | }, |
| | | { |
| | | "id": "62", |
| | | "plateNum": "71", |
| | | "deHandle": "dolore ut non", |
| | | "depotId": "79", |
| | | "depotName": "增象定立样", |
| | | "foodVariety": "Lorem est", |
| | | "foodVarietyName": "市条群求被团两", |
| | | "foodLevel": "ex labore", |
| | | "foodLevelName": "持在写称情并", |
| | | "storeKeeperName":"2" |
| | | }, |
| | | { |
| | | "id": "96", |
| | | "plateNum": "61", |
| | | "deHandle": "nulla magna ut proident cillum", |
| | | "depotId": "42", |
| | | "depotName": "条全他", |
| | | "foodVariety": "aliquip", |
| | | "foodVarietyName": "连开阶动际干", |
| | | "foodLevel": "in id sunt", |
| | | "foodLevelName": "没置定使文", |
| | | "storeKeeperName":"3" |
| | | }, |
| | | { |
| | | "id": "61", |
| | | "plateNum": "17", |
| | | "deHandle": "commodo", |
| | | "depotId": "80", |
| | | "depotName": "展观快火全领", |
| | | "foodVariety": "voluptate eu Lorem", |
| | | "foodVarietyName": "他边派斯重离", |
| | | "foodLevel": "dolor", |
| | | "foodLevelName": "装第上", |
| | | "storeKeeperName":"4" |
| | | //请求 |
| | | mui.ajax(url, { |
| | | type: "POST", |
| | | dataType: "json", |
| | | crossDomain: true, |
| | | contentType: "application/json;charset=utf-8", |
| | | data: JSON.stringify(data), |
| | | success: function(result) { |
| | | if (result.code == "0000") { |
| | | outHandleData = result.data; |
| | | console.log("if",JSON.stringify(result)) |
| | | renderData(); |
| | | } else { |
| | | renderData(); |
| | | mui.toast(result.msg); |
| | | console.log("else",JSON.stringify(result)) |
| | | } |
| | | ] |
| | | }, |
| | | error: function() { |
| | | mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") |
| | | } |
| | | }) |
| | | // outHandleData = [{ |
| | | // "id": "44", |
| | | // "plateNum": "97", |
| | | // "deHandle": "ut", |
| | | // "depotId": "16", |
| | | // "depotName": "青张列做总", |
| | | // "foodVariety": "magna pariatur laboris sunt dolor", |
| | | // "foodVarietyName": "提清除", |
| | | // "foodLevel": "fugiat", |
| | | // "foodLevelName": "应发热四民是始", |
| | | // "storeKeeperName": "" |
| | | // }, |
| | | // { |
| | | // "id": "62", |
| | | // "plateNum": "71", |
| | | // "deHandle": "dolore ut non", |
| | | // "depotId": "79", |
| | | // "depotName": "增象定立样", |
| | | // "foodVariety": "Lorem est", |
| | | // "foodVarietyName": "市条群求被团两", |
| | | // "foodLevel": "ex labore", |
| | | // "foodLevelName": "持在写称情并", |
| | | // "storeKeeperName": "2" |
| | | // }, |
| | | // { |
| | | // "id": "96", |
| | | // "plateNum": "61", |
| | | // "deHandle": "nulla magna ut proident cillum", |
| | | // "depotId": "42", |
| | | // "depotName": "条全他", |
| | | // "foodVariety": "aliquip", |
| | | // "foodVarietyName": "连开阶动际干", |
| | | // "foodLevel": "in id sunt", |
| | | // "foodLevelName": "没置定使文", |
| | | // "storeKeeperName": "3" |
| | | // }, |
| | | // { |
| | | // "id": "61", |
| | | // "plateNum": "17", |
| | | // "deHandle": "commodo", |
| | | // "depotId": "80", |
| | | // "depotName": "展观快火全领", |
| | | // "foodVariety": "voluptate eu Lorem", |
| | | // "foodVarietyName": "他边派斯重离", |
| | | // "foodLevel": "dolor", |
| | | // "foodLevelName": "装第上", |
| | | // "storeKeeperName": "4" |
| | | // } |
| | | // ] |
| | | renderData(); |
| | | } |
| | | |
| | |
| | | if (outHandleData && outHandleData.length > 0) { |
| | | $.each(outHandleData, function(index, item) { |
| | | html += '<li><div class="con"><div class="top">'; |
| | | html += '<div class="info">车牌号: <b>' + (item.plateNum == null ? "" : item.plateNum) + |
| | | '</b></div>'; |
| | | html += '<div class="info">车牌号: <b>' + (item.plateNum == null ? "" : item.plateNum) + '</b></div>'; |
| | | html += '<a href="" id = "' + item.id + '" plateNum = "' + item.plateNum + '" depotName = "' + |
| | | item.depotName + '" storeKeeperName = "' + (item.storeKeeperName == ""||item.storeKeeperName == "" ? '--' : item.storeKeeperName)+ |
| | | item.depotName + '" storeKeeperName = "' + (item.storeKeeperName == "" || item |
| | | .storeKeeperName == "" ? '--' : item.storeKeeperName) + |
| | | '" class="link">值仓<span class="mui-icon mui-icon-arrowright"></span></a>'; |
| | | html += '</div><div class="box">'; |
| | | html += |
| | | '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i19.png);">'; |
| | | html += '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i19.png);">'; |
| | | html += '<div class="h3">' + (item.depotName == null ? "" : item.depotName) + '</div>'; |
| | | html += '<div class="bot">目标仓库</div></div></div>'; |
| | | html += |
| | | '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i20.png);">'; |
| | | html += '<div class="h3">' + (item.foodVarietyName == null ? "" : item.foodVarietyName) + |
| | | '</div>'; |
| | | html += '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i20.png);">'; |
| | | html += '<div class="h3">' + (item.foodVarietyName == null ? "" : item.foodVarietyName) + '</div>'; |
| | | html += '<div class="bot">粮食品种</div></div></div>'; |
| | | html += |
| | | '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i21.png);">'; |
| | | html += '<div class="item"><div class="conbox" style="background-image: url(images/icons/g-i21.png);">'; |
| | | html += '<div class="h3">' + (item.foodLevelName == null ? "" : item.foodLevelName) + '</div>'; |
| | | html += '<div class="bot">粮食等级</div></div></div>'; |
| | | html += '</div></div></li>'; |
| | |
| | | var depotName = this.getAttribute("depotName") |
| | | var plateNum = this.getAttribute("plateNum") |
| | | var storeKeeperName = this.getAttribute("storeKeeperName") |
| | | |
| | | var picker = new mui.PopPicker(); |
| | | picker.setData([{ |
| | | value: "photo", |
| | | text: "现场值仓" |
| | | |
| | | }, { |
| | | value: "snap", |
| | | text: "远程值仓" |
| | | }]) |
| | | picker.pickers[0].setSelectedValue('photo'); |
| | | picker.show(function(SelectedItem) { |
| | | console.log(JSON.stringify(SelectedItem)); |
| | | if(SelectedItem.value == 'photo'){ |
| | | mui.openWindow({ |
| | | url: "inout-out-handle.html", |
| | | id: "inout-out-handle", |
| | |
| | | storeKeeperName:storeKeeperName |
| | | } |
| | | } |
| | | |
| | | }) |
| | | }else{ |
| | | mui.openWindow({ |
| | | url: "inout-out-handle.html", |
| | | id: "inout-out-handle", |
| | | extras: { |
| | | data: { |
| | | serialNumber: id, |
| | | plateNum: plateNum, |
| | | depotName: depotName, |
| | | storeKeeperName: storeKeeperName |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | // var btnArray = [{ |
| | | // title:"现场值仓" |
| | | // },{ |
| | | // title:"远程值仓" |
| | | // }]; |
| | | // plus.nativeUI.actionSheet({ |
| | | // title:"请选择", |
| | | // cancel:"取消", |
| | | // buttons:btnArray |
| | | // },function(e) { |
| | | // var index = e.index; |
| | | // switch (index) { |
| | | // case 1: |
| | | // mui.openWindow({ |
| | | // url: "inout-out-handle.html", |
| | | // id: "inout-out-handle", |
| | | // extras: { |
| | | // data: { |
| | | // serialNumber: id, |
| | | // plateNum: plateNum, |
| | | // depotName: depotName, |
| | | // storeKeeperName: storeKeeperName |
| | | // } |
| | | // } |
| | | // }) |
| | | // break; |
| | | // case 2: |
| | | // mui.openWindow({ |
| | | // url: "inout-out-handle.html", |
| | | // id: "inout-out-handle", |
| | | // extras: { |
| | | // data: { |
| | | // serialNumber: id, |
| | | // plateNum: plateNum, |
| | | // depotName: depotName, |
| | | // storeKeeperName: storeKeeperName |
| | | // } |
| | | // } |
| | | // }) |
| | | // break; |
| | | // } |
| | | // }); |
| | | }); |
| | | |
| | | /*---------------NFC读卡功能-------------------*/ |
| | | var waiting; |
| | | var readyRead = false; |
| | | //读卡方法 |
| | | function readCard() { |
| | | readyRead = true; |
| | | listenNFCStatus(); |
| | | } |
| | | |
| | | var NfcAdapter; |
| | | var NdefRecord; |
| | | var NdefMessage; |
| | | var count = 0; |
| | | |
| | | //监听NFC状态 |
| | | function listenNFCStatus() { |
| | | try { |
| | | var main = plus.android.runtimeMainActivity(); |
| | | var Intent = plus.android.importClass('android.content.Intent'); |
| | | var Activity = plus.android.importClass('android.app.Activity'); |
| | | var PendingIntent = plus.android.importClass('android.app.PendingIntent'); |
| | | var IntentFilter = plus.android.importClass('android.content.IntentFilter'); |
| | | NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter'); |
| | | var nfcAdapter = NfcAdapter.getDefaultAdapter(main); |
| | | //判断设备是否支持NFC功能 |
| | | if (nfcAdapter == null) { |
| | | mui.alert("设备不支持NFC功能!", '提示', ["确定"], function() {}, "div"); |
| | | return; |
| | | } |
| | | //判断设备是否开启NFC功能 |
| | | if (!nfcAdapter.isEnabled()) { |
| | | mui.alert("请在系统设置中启用NFC功能!", '提示', ["确定"], function() {}, "div"); |
| | | return; |
| | | } |
| | | waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!"); |
| | | |
| | | //倒计时10秒,读取不到后提示是否重新读卡 |
| | | var interval = setInterval(function() { //定义定时器 |
| | | count++; |
| | | if (count == 10 && readyRead) { |
| | | readyRead = false; |
| | | count = 0; |
| | | waiting.close(); |
| | | clearInterval(interval); //清除定时器 |
| | | var btnArray = ["重试", "取消"]; |
| | | mui.confirm("已超时,是否重新读卡!", "提示", btnArray, function(e) { |
| | | if (e.index == 0) { |
| | | readCard(); |
| | | } |
| | | }, "div") |
| | | } |
| | | }, 1000); |
| | | |
| | | var intent = new Intent(main, main.getClass()); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| | | var pendingIntent = PendingIntent.getActivity(main, 0, intent, 0); |
| | | var ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED"); |
| | | ndef.addDataType("*/*"); |
| | | var intentFiltersArray = [ndef]; |
| | | var techListsArray = [ |
| | | ["android.nfc.tech.IsoDep"], |
| | | ["android.nfc.tech.NfcA"], |
| | | ["android.nfc.tech.NfcB"], |
| | | ["android.nfc.tech.NfcF"], |
| | | ["android.nfc.tech.Ndef"], |
| | | ["android.nfc.tech.NfcV"], |
| | | ["android.nfc.tech.NdefFormatable"], |
| | | ["android.nfc.tech.MifareClassic"], |
| | | ["android.nfc.tech.MifareUltralight"] |
| | | ]; |
| | | document.addEventListener("newintent", |
| | | function() { |
| | | setTimeout(readData, 1000); |
| | | }, false); |
| | | document.addEventListener("pause", function(e) { |
| | | if (nfcAdapter) { |
| | | nfcAdapter.disableForegroundDispatch(main); |
| | | } |
| | | }, false); |
| | | document.addEventListener("resume", function(e) { |
| | | if (nfcAdapter) { |
| | | nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray); |
| | | } |
| | | }, false); |
| | | nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray); |
| | | } catch (e) { |
| | | mui.toast("读卡失败,请重试!"); |
| | | waiting.close(); |
| | | } |
| | | } |
| | | |
| | | //读取数据 |
| | | function readData() { |
| | | NdefRecord = plus.android.importClass("android.nfc.NdefRecord"); |
| | | NdefMessage = plus.android.importClass("android.nfc.NdefMessage"); |
| | | var main = plus.android.runtimeMainActivity(); |
| | | var intent = main.getIntent(); |
| | | // if ("android.nfc.action.TAG_DISCOVERED" == intent.getAction()) { //真机调试 |
| | | if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) { //打包 |
| | | if (readyRead) { |
| | | readyRead = false; |
| | | |
| | | waiting.setTitle('请勿移开标签\n正在读取数据...'); |
| | | var Parcelable = plus.android.importClass("android.os.Parcelable"); |
| | | //读取id |
| | | var byteId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); |
| | | //将id转为16进制字符串 |
| | | var id = ByteArrayToHexString(byteId); |
| | | //关闭等待圆圈 |
| | | waiting.close(); |
| | | |
| | | //读取id成功,赋值并发送请求查询 |
| | | data.data.intelCard = id; |
| | | getInoutDetail(); |
| | | } |
| | | } else { |
| | | waiting.close(); |
| | | mui.alert('读取失败,请重试!', '提示', ["确定"], function() {}, "div"); |
| | | } |
| | | } |
| | | |
| | | //获取值仓单子详细信息 |
| | | function getInoutDetail() { |
| | | mui.ajax(url, { |
| | | type: "POST", |
| | | dataType: "json", |
| | | crossDomain: true, |
| | | contentType: "application/json;charset=utf-8", |
| | | data: JSON.stringify(data1), |
| | | success: function(result) { |
| | | if (result.code == "0000") { |
| | | //弹窗信息:单子车牌跟仓库,去值仓则进入值仓页面,传递单子id; |
| | | var btnArray = ["去值仓", "取消"]; |
| | | var text = '值仓仓库:' + result.data.depotName + '<br/>车牌号:' + result.data.plateNum; |
| | | mui.confirm(text, "检测到待值仓信息如下", btnArray, function(e) { |
| | | if (e.index == 0) { |
| | | //先判断单子是否在值仓状态 |
| | | if (result.data.progress == "HANDLE") { |
| | | //去值仓时判断单子类型是否是入库,不是给出提醒; |
| | | if (result.data.type == "OUT") { |
| | | mui.openWindow({ |
| | | url: "inout-out-handle.html", |
| | | id: "inout-out-handle", |
| | | extras: { |
| | | data: { |
| | | serialNumber: result.data.id, |
| | | plateNum: result.data.plateNum, |
| | | depotName: result.data.depotName, |
| | | storeKeeperName: result.data.storeKeeperName |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | mui.alert("该卡信息不是出库类型,请核对!", "提示", ["确定"], function() {}, "div") |
| | | } |
| | | } else { |
| | | mui.alert("当前卡不在值仓状态,请核查!", "提示", ["确定"], function() {}, "div") |
| | | } |
| | | } |
| | | }, "div") |
| | | } else { |
| | | mui.toast(result.msg); |
| | | } |
| | | }, |
| | | error: function() { |
| | | mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div"); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | //将字节数组转为16进制字符串 |
| | | function ByteArrayToHexString(inarray) { |
| | | var i, j, inn; |
| | | hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; |
| | | out = ""; |
| | | for (j = 0; j < inarray.length; ++j) { |
| | | inn = inarray[j] & 0xff; |
| | | i = (inn >>> 4) & 0x0f; |
| | | out += hex[i]; |
| | | i = inn & 0x0f; |
| | | out += hex[i]; |
| | | } |
| | | return out; |
| | | } |
| | | |
| | | mui('.mui-scroll-wrapper').scroll({ |
| | | indicators: false, //是否显示滚动条 |
| | | deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 |