opentask.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // pages/tabber/news/index.js
  2. const app=getApp();
  3. var deviceId='',spoutDeviceId='',num='';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. selectInfo: {},
  10. factoryName:[],
  11. factoryId:[],
  12. index:0,
  13. content:[],
  14. show:false,
  15. orderSn:'',
  16. status:'',
  17. num:''
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. //this.gettaskList();
  24. deviceId=options&&options.deviceId?options.deviceId:1
  25. spoutDeviceId=options&&options.spoutDeviceId?options.spoutDeviceId:8
  26. num=options&&options.num?options.num:''
  27. this.getFactory()
  28. },
  29. bindput(e){
  30. this.setData({
  31. orderSn:e.detail.value
  32. })
  33. },
  34. getFactory:function(){
  35. var that=this
  36. app.api.useApi(app.globalData.baseAppUrl + "api/admin/FactoryList", {
  37. device_id: deviceId,
  38. spout_device_id:spoutDeviceId
  39. }, "get").then(function (res) {
  40. console.log(res);
  41. if (res.code != 200) {
  42. wx.showLoading({
  43. title: '数据获取失败',
  44. })
  45. setTimeout(function () {
  46. wx.hideLoading();
  47. }, 1000);
  48. } else {
  49. wx.hideLoading();
  50. var FactoryList=res.message.data.list
  51. for(var i in FactoryList){
  52. that.data.factoryName.push(FactoryList[i].external_title)
  53. that.data.factoryId.push(FactoryList[i].id)
  54. }
  55. console.log(that.data.factoryName)
  56. that.setData({
  57. factoryName:that.data.factoryName,
  58. factoryId:that.data.factoryId,
  59. num,
  60. content:res.message.data.group
  61. })
  62. }
  63. }).catch(function (err) {
  64. console.log(222);
  65. })
  66. },
  67. bindPickerChange: function(e) {
  68. console.log('picker发送选择改变,携带值为', e.detail.value)
  69. this.setData({
  70. index: e.detail.value
  71. })
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. saoma:function(){
  79. var that=this
  80. wx.scanCode({
  81. onlyFromCamera: true,
  82. success (res) {
  83. that.setData({
  84. orderSn:res.result
  85. })
  86. }
  87. })
  88. },
  89. onClick:function(e){
  90. var type=e.currentTarget.dataset.type
  91. var that=this
  92. if(type==1){
  93. if(that.data.orderSn=='')
  94. return wx.showToast({title: '封签号不能为空',icon:'none'})
  95. app.api.useApi(app.globalData.baseAppUrl + "api/admin/StoreCodeUserInfo", {
  96. seal_no: that.data.orderSn
  97. }, "get").then(function (res) {
  98. wx.hideLoading();
  99. if (res.code== 200) {
  100. that.setData({
  101. status:res.message.data.phone
  102. })
  103. } else
  104. wx.showToast({title: res.message.msg,icon:'none'})
  105. }).catch(function (err) {
  106. console.log(222);
  107. })
  108. }else
  109. this.setData({
  110. show:!this.data.show
  111. })
  112. },
  113. onSubmit:function(e){
  114. var that=this
  115. if(that.data.orderSn=='')
  116. return wx.showToast({title: '封签号不能为空',icon:'none'})
  117. if(deviceId=='')
  118. return wx.showToast({title: '设备号不能为空',icon:'none'})
  119. if(spoutDeviceId=='')
  120. return wx.showToast({title: '柜门号不能为空',icon:'none'})
  121. if(that.data.factoryName.length<=0)
  122. return wx.showToast({title: '目的地不能为空',icon:'none'})
  123. app.api.useApi(app.globalData.baseAppUrl + "api/admin/BindSeals", {
  124. seal_no: that.data.orderSn,
  125. device_id:deviceId,
  126. spout_device_id:spoutDeviceId,
  127. factory_id:that.data.factoryId[that.data.index]
  128. }, "post").then(function (res) {
  129. wx.hideLoading();
  130. that.setData({status:res.message.msg,result:res.code== 200?true:false})
  131. if (res.code== 200) {
  132. res.message.data.id=res.message.data.logistic_group_id
  133. that.data.content.unshift(res.message.data)
  134. that.setData({
  135. content:that.data.content,
  136. })
  137. }
  138. }).catch(function (err) {
  139. console.log(err);
  140. })
  141. },
  142. quitBind:function(e){
  143. var that=this
  144. wx.showModal({
  145. title: '提示',
  146. content: '确认删除该条封签么?',
  147. success(res) {
  148. if (res.confirm) {
  149. that.remove(e);
  150. } else if (res.cancel) {
  151. console.log('用户点击取消')
  152. }
  153. }
  154. })
  155. return;
  156. },
  157. remove:function(e){
  158. var that=this
  159. var logistic_group_id=e.currentTarget.dataset.id;
  160. if(logistic_group_id=='')
  161. return wx.showToast({title: '封签对象不能为空',icon:'none'})
  162. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UnsealBind", {
  163. logistic_group_id
  164. }, "post").then(function (res) {
  165. wx.hideLoading();
  166. if (res.code== 200) {
  167. var info = that.data.content;
  168. var info = info.filter(function (item) {
  169. return item.id != logistic_group_id;
  170. });
  171. that.setData({
  172. content: info
  173. })
  174. }else
  175. wx.showToast({title: res.message.msg,icon:'none'})
  176. }).catch(function (err) {
  177. console.log(222);
  178. })
  179. },
  180. confirm:function(){
  181. var that=this;
  182. wx.showModal({
  183. title: '提示',
  184. content: '请确认是否提交?',
  185. success(res) {
  186. if (res.confirm) {
  187. that.finish();
  188. } else if (res.cancel) {
  189. console.log('用户点击取消')
  190. }
  191. }
  192. })
  193. },
  194. finish:function(){
  195. var that=this
  196. app.api.useApi(app.globalData.baseAppUrl + "api/admin/SubmitSeals", {
  197. device_id:deviceId,
  198. spout_device_id:spoutDeviceId,
  199. }, "post").then(function (res) {
  200. wx.hideLoading();
  201. if (res.code== 200) {
  202. wx.showModal({
  203. title: '成功',
  204. content: res.message.msg,
  205. showCancel:false,
  206. success (res) {
  207. if (res.confirm) {
  208. console.log('用户点击确定')
  209. wx.navigateBack()
  210. } else if (res.cancel) {
  211. console.log('用户点击取消')
  212. }
  213. }
  214. })
  215. }else
  216. wx.showToast({title: res.message.msg,icon:'none'})
  217. }).catch(function (err) {
  218. console.log(222);
  219. })
  220. }
  221. })