123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- // pages/tabber/news/index.js
- const app=getApp();
- var deviceId='',spoutDeviceId='',num='';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- selectInfo: {},
- factoryName:[],
- factoryId:[],
- index:0,
- content:[],
- show:false,
- orderSn:'',
- status:'',
- num:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- //this.gettaskList();
- deviceId=options&&options.deviceId?options.deviceId:1
- spoutDeviceId=options&&options.spoutDeviceId?options.spoutDeviceId:8
- num=options&&options.num?options.num:''
- this.getFactory()
- },
- blankorder(){
- wx.navigateTo({
- url: '/pages/take/blankorder/blankorder',
- })
- },
- bindput(e){
- this.setData({
- orderSn:e.detail.value
- })
- },
- getFactory:function(){
- var that=this
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/FactoryList", {
- device_id: deviceId,
- spout_device_id:spoutDeviceId
- }, "get").then(function (res) {
- console.log(res);
- if (res.code != 200) {
- wx.showLoading({
- title: '数据获取失败',
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 1000);
-
- } else {
- wx.hideLoading();
- var FactoryList=res.message.data.list
- for(var i in FactoryList){
- that.data.factoryName.push(FactoryList[i].external_title)
- that.data.factoryId.push(FactoryList[i].id)
- }
- console.log(that.data.factoryName)
- that.setData({
- factoryName:that.data.factoryName,
- factoryId:that.data.factoryId,
- num,
- content:res.message.data.group
- })
-
- }
- }).catch(function (err) {
-
- console.log(222);
- })
-
- },
- bindPickerChange: function(e) {
- console.log('picker发送选择改变,携带值为', e.detail.value)
- this.setData({
- index: e.detail.value
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- saoma:function(){
- var that=this
- wx.scanCode({
- onlyFromCamera: true,
- success (res) {
- that.setData({
- orderSn:res.result
- })
- }
-
- })
- },
- onClick:function(e){
- var type=e.currentTarget.dataset.type
- var that=this
- if(type==1){
- if(that.data.orderSn=='')
- return wx.showToast({title: '封签号不能为空',icon:'none'})
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/StoreCodeUserInfo", {
- seal_no: that.data.orderSn
- }, "get").then(function (res) {
- wx.hideLoading();
- if (res.code== 200) {
- that.setData({
- status: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
- })
- },
- onSubmit:function(e){
- var that=this
- if(that.data.orderSn=='')
- return wx.showToast({title: '封签号不能为空',icon:'none'})
- if(deviceId=='')
- return wx.showToast({title: '设备号不能为空',icon:'none'})
- if(spoutDeviceId=='')
- return wx.showToast({title: '柜门号不能为空',icon:'none'})
- if(that.data.factoryName.length<=0)
- return wx.showToast({title: '目的地不能为空',icon:'none'})
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/BindSeals", {
- seal_no: that.data.orderSn,
- device_id:deviceId,
- spout_device_id:spoutDeviceId,
- factory_id:that.data.factoryId[that.data.index]
- }, "post").then(function (res) {
- wx.hideLoading();
- that.setData({status:res.message.msg,result:res.code== 200?true:false})
- if (res.code== 200) {
- res.message.data.id=res.message.data.logistic_group_id
- that.data.content.unshift(res.message.data)
- that.setData({
-
- content:that.data.content,
-
- })
- }
- }).catch(function (err) {
- console.log(err);
- })
- },
- quitBind:function(e){
- var that=this
- wx.showModal({
- title: '提示',
- content: '确认删除该条封签么?',
- success(res) {
- if (res.confirm) {
- that.remove(e);
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return;
- },
- remove:function(e){
- var that=this
- var logistic_group_id=e.currentTarget.dataset.id;
- if(logistic_group_id=='')
- return wx.showToast({title: '封签对象不能为空',icon:'none'})
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/UnsealBind", {
- logistic_group_id
- }, "post").then(function (res) {
- wx.hideLoading();
- if (res.code== 200) {
- var info = that.data.content;
- var info = info.filter(function (item) {
- return item.id != logistic_group_id;
- });
- that.setData({
- content: info
- })
- }else
- wx.showToast({title: res.message.msg,icon:'none'})
- }).catch(function (err) {
- console.log(222);
- })
- },
- confirm:function(){
- var that=this;
- wx.showModal({
- title: '提示',
- content: '请确认是否提交?',
- success(res) {
- if (res.confirm) {
- that.finish();
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- finish:function(){
- var that=this
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/SubmitSeals", {
- device_id:deviceId,
- spout_device_id:spoutDeviceId,
- }, "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);
- })
- }
- })
|