const app = getApp(); const api = require('../../../utils/api'); const cloudApi = require('../../../utils/cloudApi') Page({ data: { page: 'pages/tabBar/current/current', statusBarHeight: '', searchContent: '', dataList: [] }, onLoad() { this.setData({ statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'] }); wx.hideTabBar(); }, onShow() { // 可以在这里添加页面显示时的逻辑 }, onSearchInput(e) { this.setData({ searchContent: e.detail.value }); }, scanCode() { const t = this; t.setData({ dataList: [], searchContent: '' }); wx.scanCode({ autoZoom: false, scanType: ['qrCode'], success: function (res) { if(res && res.result) { if(res.result.indexOf('SJ') == -1 && res.result.indexOf('CP') == -1) { wx.showToast({ title: '没有识别到正确的编码,请重新扫码', icon: 'error', duration: 2000 }); return; } t.setData({ searchContent: res.result }); t.getList() // api请求 // api.getHazmatFlowByCode({code: res.result}).then(re => { // if(re.code == 200) { // t.setData({ // dataList: re.data ? re.data : [] // }); // } else { // wx.showToast({ // title: re.message, // icon: 'error', // duration: 2000 // }); // } // }); } else { wx.showToast({ title: '该二维码已失效或不包含条码信息', icon: 'error', duration: 2000 }); } } }); }, getList() { const t = this; if(t.data.searchContent == '') { wx.showToast({ title: '请输入二维码编号', icon: 'none' }); } else { // api请求 api.getHazmatFlowByCode({code: t.data.searchContent}).then(re => { if(re.code == 200) { t.setData({ dataList: re.data ? re.data : [] }); } else { wx.showToast({ title: re.message, icon: 'none' }); } }); } }, toStudy(e) { const item = e.currentTarget.dataset.item; wx.setStorageSync("prevPage", '/pages/tabBar/current/current'); wx.navigateTo({ url: `/pages/tabBar/current/detail?bank=` + encodeURIComponent(JSON.stringify(item)) }); } });