bind.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // pages/tabber/news/index.js
  2. const app=getApp();
  3. var id='',deviceId='',spoutDeviceId="",logistic_code="";
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. selectInfo: {},
  10. content:{},
  11. sealNo:'',
  12. height:'1200',
  13. info:"",
  14. check:true,
  15. img:{
  16. 大衣外套:'/image/icon/dayiwaitao.png',
  17. 家纺:'/image/icon/jiafang',
  18. 库类:'/image/icon/kulei.png',
  19. 配件:'/image/icon/peijian.png',
  20. 皮衣:'/image/icon/piyi.png',
  21. 裙类:'/image/icon/qunlei.png',
  22. 上衣:'/image/icon/shangyi.png',
  23. 箱包:'/image/icon/xiangbao.png',
  24. 鞋类:'/image/icon/xixie.png',
  25. }
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. id=options&&options.id?options.id:1
  32. deviceId=options&&options.pointId?options.pointId:1
  33. logistic_code=options&&options.logistic_code?options.logistic_code:0
  34. if(logistic_code!=0){
  35. this.setData({
  36. check:false,
  37. })
  38. this.getOrder()
  39. }else{
  40. this.setData({
  41. check:true,
  42. })
  43. this.getData()
  44. }
  45. },
  46. getData:function(){
  47. var that=this
  48. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CheckOrder", {
  49. order_id:id
  50. }, "get").then(function (res) {
  51. console.log(res);
  52. wx.hideLoading();
  53. if (res.code != 200) {
  54. wx.showLoading({
  55. title: '数据获取失败',
  56. })
  57. setTimeout(function () {
  58. wx.hideLoading();
  59. }, 1000);
  60. } else {
  61. that.setData({
  62. content:res.message.data,
  63. })
  64. }
  65. }).catch(function (err) {
  66. console.log(err);
  67. })
  68. },
  69. getOrder:function(){
  70. var that=this
  71. app.api.useApi(app.globalData.baseAppUrl + "api/admin/TakeOrder", {
  72. order_id:id,
  73. logistic_code:logistic_code
  74. }, "get").then(function (res) {
  75. console.log(res);
  76. wx.hideLoading();
  77. if (res.code != 200) {
  78. wx.showLoading({
  79. title: '数据获取失败',
  80. })
  81. setTimeout(function () {
  82. wx.hideLoading();
  83. }, 1000);
  84. } else {
  85. that.setData({
  86. content:res.message.data,
  87. })
  88. }
  89. }).catch(function (err) {
  90. console.log(err);
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function () {
  97. },
  98. summit(e){
  99. var type=e.currentTarget.dataset.type
  100. var that=this
  101. if(type==1){
  102. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserTakeOrder", {
  103. logistic_code:logistic_code,
  104. order_id:id,
  105. }, "post").then(function (res) {
  106. wx.hideLoading();
  107. if (res.code== 200) {
  108. wx.showModal({
  109. title: '成功',
  110. content: res.message.msg,
  111. showCancel:false,
  112. success (res) {
  113. if (res.confirm) {
  114. console.log('用户点击确定')
  115. wx.navigateBack()
  116. } else if (res.cancel) {
  117. console.log('用户点击取消')
  118. }
  119. }
  120. })
  121. } else
  122. wx.showToast({title: res.message.msg,icon:'none'})
  123. }).catch(function (err) {
  124. console.log(222);
  125. })
  126. }else{
  127. wx.navigateBack({
  128. delta: 1,
  129. })
  130. }
  131. },
  132. onClick:function(e){
  133. var type=e.currentTarget.dataset.type
  134. var that=this
  135. if(type==1){
  136. if(that.data.sealNo=='')
  137. return wx.showToast({title: '封签号不能为空',icon:'none'})
  138. return that.onSubmit()
  139. app.api.useApi(app.globalData.baseAppUrl + "api/admin/StoreCodeUserInfo", {
  140. order_no: that.data.orderSn
  141. }, "get").then(function (res) {
  142. wx.hideLoading();
  143. if (res.code== 200) {
  144. that.setData({
  145. smallPhone:res.message.data.phone
  146. })
  147. } else
  148. wx.showToast({title: res.message.msg,icon:'none'})
  149. }).catch(function (err) {
  150. console.log(222);
  151. })
  152. }else
  153. this.setData({
  154. show:!this.data.show
  155. })
  156. },
  157. scan:function(){
  158. var that=this
  159. wx.scanCode({
  160. onlyFromCamera: true,
  161. success (res) {
  162. that.setData({
  163. sealNo:res.result
  164. })
  165. }
  166. })
  167. },
  168. onSubmit:function(e){
  169. var that=this
  170. if(that.data.sealNo=='')
  171. return wx.showToast({title: '封签号不能为空',icon:'none'})
  172. if(deviceId=='')
  173. return wx.showToast({title: '设备号不能为空',icon:'none'})
  174. // if(spoutDeviceId=='')
  175. // return wx.showToast({title: '柜门号不能为空',icon:'none'})
  176. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CollectBindSeals", {
  177. seal_no: that.data.sealNo,
  178. device_id:deviceId,
  179. order_id:id,
  180. }, "post").then(function (res) {
  181. wx.hideLoading();
  182. if (res.code== 200) {
  183. wx.showModal({
  184. title: '成功',
  185. content: res.message.msg,
  186. showCancel:false,
  187. success (res) {
  188. if (res.confirm) {
  189. console.log('用户点击确定')
  190. wx.navigateBack()
  191. } else if (res.cancel) {
  192. console.log('用户点击取消')
  193. }
  194. }
  195. })
  196. } else
  197. wx.showToast({title: res.message.msg,icon:'none'})
  198. }).catch(function (err) {
  199. console.log(222);
  200. })
  201. },
  202. })