// pages/nfc/encryptionNfc/encryptionNfc.js Page({ /** * 页面的初始数据 */ data: { type:null, path:null, showDialog: false,// 详情弹窗 activeText:'--', scanType:'7', //1查看当前激活状态 2激活 3锁闭 4读温度 7读取UID 8读自定义信息 9写入自定义信息 10读采温周期 X106:X106端读卡 seleteType:[{transportStatus:'00',transportStatusName:'入库'},{transportStatus:'10',transportStatusName:'出库'},{transportStatus:'20',transportStatusName:'结束'}], modalHidden:true, region:[], modalName: null, chainId:null, }, getNfcRes(e){ const {sta,msg} = e.detail; var type1 = ['X101','X102','X103','X104','X106','X107']; var type = this.data.type; var path = this.data.path; switch (path) { case 'find': this.goDetailInfo(msg.uid,type) break; case 'factorycheck': this.getInfo(msg.uid,type) break; case 'iodep': this.iodep(msg.uid,type) break; case 'addLabel': this.chainBind(msg.uid,type,this.data.chainId); break; default: break; } // this.setData({ // activeText:msg // }) }, // 绑定标签 chainBind(deviceCode,type,chainId){ var that = this; const {latitude,longitude} = that.data; app.requestP({ url:'/chainBound/checkBind', method:'post', data:{ deviceCode, } }).then(res=>{ if(res.data.data == 0){ app.requestP({ url:'/chainBound/bind', method:'post', contentType:' application/json', data:{ chainId, deviceCode, type:type, lat:latitude, lng:longitude } }).then(response=>{ app.showToptip(that,'success',response.data.msg) }).catch(err=>{ app.showToptip(that,'error',err.data.msg) }) }else{ app.showToptip(that,'error',res.data.msg); } }).catch(err=>{ app.showToptip(that,'error',err.data.msg) }) }, // 查一查 goDetailInfo(message,type){ var that = this; app.requestP({ url:'/chainBound/checkBind', method:'post', // contentType:' application/json', data:{ deviceCode:message, } }).then(res=>{ if(res.data.data !=1){ app.showToptip(that,'error',res.data.msg); return; } app.requestP({ url:'/chain/scan', method:'post', contentType:' application/json', data:{ inoculatorId:'', payload:message, type } }).then(res=>{ var id = res.data.msg; that.setData({ showDialog: !this.data.showDialog, detailId:id, deviceCode:message }); }).catch(err=>{ app.showToptip(that,'error',err.data.msg) }) }).catch(err=>{ app.showToptip(that,'error',err.data.msg); }) }, goDetail(){ var detailId = this.data.detailId; var deviceCode = this.data.deviceCode || ''; wx.navigateTo({ url: '/pages/query/details?id='+detailId+'&deviceCode='+deviceCode, }) this.setData({ showDialog:!this.data.showDialog, }) }, // 出厂检测 getInfo(message){ var that = this; app.requestP({ url: "/query/scanChip1", method:"post", needToken:false, contentType:' application/json', data:{ payload:message } }).then(res=>{ wx.navigateTo({ url: '/pages/nfc/outNfcTempInfo/outNfcTempInfo?data='+JSON.stringify(res.data.data), }) }).catch(err=>{ app.showToptip(that,'error',err.data.msg) }) }, // 出入库 iodep(code,type){ var that =this; app.requestP({ url:'/chainBound/checkBind', method:'post', // contentType:' application/json', data:{ deviceCode:code, } }).then(res=>{ if(res.data.data!=1){ app.showToptip(that,'error',res.data.msg); return; } app.requestP({ url:'/chain/scan', method:'post', contentType:' application/json', data:{ inoculatorId:'', payload:code, type, } }).then(res=>{ const {transportStatus,id,code} = res.data.chain; that.setData({ transportStatus, iodepId:id, modalHidden:!that.data.modalHidden, seleteType:that.setSeleteType(transportStatus), }); }).catch(err=>{ app.showToptip(that,'error',err.data.msg) }) }).catch(err=>{ app.showToptip(that,'error',err.data.msg); }) }, setTransportStatus(transportStatus){ var seleteType = this.data.seleteType; var deptType; for(var i=0;i{ that.setData({ modalHidden:!that.data.modalHidden, region:[], modalVal:'', iodepId:'', }) app.showToptip(that,'success',res.data.msg); }).catch(err=>{ app.showToptip(that,'error',err.data.msg); }) }else{ app.showToptip(that,'error','地址不能为空'); } }, setType(e){ var value = e.detail.value; var that = this; that.setData({ deptType:value }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if(that.data.isIOS){ that.goApp() return; } }, goApp(e) { this.setData({ modalName: "goApp" }) }, hideModal(e) { this.setData({ modalName: null }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })