// pages/tabber/news/index.js const app=getApp(); var id='',deviceId='',spoutDeviceId="",logistic_code=""; Page({ /** * 页面的初始数据 */ data: { selectInfo: {}, content:{}, sealNo:'', height:'1200', info:"", check:true, img:{ 大衣外套:'/image/icon/dayiwaitao.png', 家纺:'/image/icon/jiafang', 库类:'/image/icon/kulei.png', 配件:'/image/icon/peijian.png', 皮衣:'/image/icon/piyi.png', 裙类:'/image/icon/qunlei.png', 上衣:'/image/icon/shangyi.png', 箱包:'/image/icon/xiangbao.png', 鞋类:'/image/icon/xixie.png', } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { id=options&&options.id?options.id:1 deviceId=options&&options.pointId?options.pointId:1 logistic_code=options&&options.logistic_code?options.logistic_code:0 if(logistic_code!=0){ this.setData({ check:false, }) this.getOrder() }else{ this.setData({ check:true, }) this.getData() } }, somao(){ let that = this wx.scanCode({ onlyFromCamera: true, success (res) { that.setData({sealNo: res.result.substr(0)}) } }) }, getData:function(){ var that=this app.api.useApi(app.globalData.baseAppUrl + "api/admin/CheckOrder", { order_id:id }, "get").then(function (res) { console.log(res); wx.hideLoading(); if (res.code != 200) { wx.showLoading({ title: '数据获取失败', }) setTimeout(function () { wx.hideLoading(); }, 1000); } else { that.setData({ content:res.message.data, }) } }).catch(function (err) { console.log(err); }) }, getOrder:function(){ var that=this app.api.useApi(app.globalData.baseAppUrl + "api/admin/TakeOrder", { order_id:id, logistic_code:logistic_code }, "get").then(function (res) { console.log(res); wx.hideLoading(); if (res.code != 200) { wx.showLoading({ title: '数据获取失败', }) setTimeout(function () { wx.hideLoading(); }, 1000); } else { that.setData({ content:res.message.data, }) } }).catch(function (err) { console.log(err); }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, summit(e){ var type=e.currentTarget.dataset.type var that=this if(type==1){ app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserTakeOrder", { logistic_code:logistic_code, order_id:id, }, "post").then(function (res) { wx.hideLoading(); if (res.code== 200) { wx.showModal({ title: '成功', content: res.message.msg, showCancel:false, success (res) { if (res.confirm) { console.log('用户点击确定') wx.navigateBack() } else if (res.cancel) { console.log('用户点击取消') } } }) } else wx.showToast({title: res.message.msg,icon:'none'}) }).catch(function (err) { console.log(222); }) }else{ wx.navigateBack({ delta: 1, }) } }, onClick:function(e){ var type=e.currentTarget.dataset.type var that=this if(type==1){ if(that.data.sealNo=='') return wx.showToast({title: '封签号不能为空',icon:'none'}) return that.onSubmit() app.api.useApi(app.globalData.baseAppUrl + "api/admin/StoreCodeUserInfo", { order_no: that.data.orderSn }, "get").then(function (res) { wx.hideLoading(); if (res.code== 200) { that.setData({ smallPhone:res.message.data.phone }) } else wx.showToast({title: res.message.msg,icon:'none'}) }).catch(function (err) { console.log(222); }) }else this.setData({ show:!this.data.show }) }, scan:function(){ var that=this wx.scanCode({ onlyFromCamera: true, success (res) { that.setData({ sealNo:res.result }) } }) }, onSubmit:function(e){ var that=this if(that.data.sealNo=='') return wx.showToast({title: '封签号不能为空',icon:'none'}) if(deviceId=='') return wx.showToast({title: '设备号不能为空',icon:'none'}) // if(spoutDeviceId=='') // return wx.showToast({title: '柜门号不能为空',icon:'none'}) app.api.useApi(app.globalData.baseAppUrl + "api/admin/CollectBindSeals", { seal_no: that.data.sealNo, device_id:deviceId, order_id:id, }, "post").then(function (res) { wx.hideLoading(); if (res.code== 200) { wx.showModal({ title: '成功', content: res.message.msg, showCancel:false, success (res) { if (res.confirm) { console.log('用户点击确定') wx.navigateBack() } else if (res.cancel) { console.log('用户点击取消') } } }) } else wx.showToast({title: res.message.msg,icon:'none'}) }).catch(function (err) { console.log(222); }) }, })