opentask.js 6.8 KB

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