bind.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. somao(){
  47. let that = this
  48. wx.scanCode({
  49. onlyFromCamera: true,
  50. success (res) {
  51. that.setData({sealNo: res.result.substr(0)})
  52. }
  53. })
  54. },
  55. getData:function(){
  56. var that=this
  57. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CheckOrder", {
  58. order_id:id
  59. }, "get").then(function (res) {
  60. console.log(res);
  61. wx.hideLoading();
  62. if (res.code != 200) {
  63. wx.showLoading({
  64. title: '数据获取失败',
  65. })
  66. setTimeout(function () {
  67. wx.hideLoading();
  68. }, 1000);
  69. } else {
  70. that.setData({
  71. content:res.message.data,
  72. })
  73. }
  74. }).catch(function (err) {
  75. console.log(err);
  76. })
  77. },
  78. getOrder:function(){
  79. var that=this
  80. app.api.useApi(app.globalData.baseAppUrl + "api/admin/TakeOrder", {
  81. order_id:id,
  82. logistic_code:logistic_code
  83. }, "get").then(function (res) {
  84. console.log(res);
  85. wx.hideLoading();
  86. if (res.code != 200) {
  87. wx.showLoading({
  88. title: '数据获取失败',
  89. })
  90. setTimeout(function () {
  91. wx.hideLoading();
  92. }, 1000);
  93. } else {
  94. that.setData({
  95. content:res.message.data,
  96. })
  97. }
  98. }).catch(function (err) {
  99. console.log(err);
  100. })
  101. },
  102. /**
  103. * 生命周期函数--监听页面初次渲染完成
  104. */
  105. onReady: function () {
  106. },
  107. summit(e){
  108. var type=e.currentTarget.dataset.type
  109. var that=this
  110. if(type==1){
  111. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserTakeOrder", {
  112. logistic_code:logistic_code,
  113. order_id:id,
  114. }, "post").then(function (res) {
  115. wx.hideLoading();
  116. if (res.code== 200) {
  117. wx.showModal({
  118. title: '成功',
  119. content: res.message.msg,
  120. showCancel:false,
  121. success (res) {
  122. if (res.confirm) {
  123. console.log('用户点击确定')
  124. wx.navigateBack()
  125. } else if (res.cancel) {
  126. console.log('用户点击取消')
  127. }
  128. }
  129. })
  130. } else
  131. wx.showToast({title: res.message.msg,icon:'none'})
  132. }).catch(function (err) {
  133. console.log(222);
  134. })
  135. }else{
  136. wx.navigateBack({
  137. delta: 1,
  138. })
  139. }
  140. },
  141. onClick:function(e){
  142. var type=e.currentTarget.dataset.type
  143. var that=this
  144. if(type==1){
  145. if(that.data.sealNo=='')
  146. return wx.showToast({title: '封签号不能为空',icon:'none'})
  147. return that.onSubmit()
  148. app.api.useApi(app.globalData.baseAppUrl + "api/admin/StoreCodeUserInfo", {
  149. order_no: that.data.orderSn
  150. }, "get").then(function (res) {
  151. wx.hideLoading();
  152. if (res.code== 200) {
  153. that.setData({
  154. smallPhone:res.message.data.phone
  155. })
  156. } else
  157. wx.showToast({title: res.message.msg,icon:'none'})
  158. }).catch(function (err) {
  159. console.log(222);
  160. })
  161. }else
  162. this.setData({
  163. show:!this.data.show
  164. })
  165. },
  166. scan:function(){
  167. var that=this
  168. wx.scanCode({
  169. onlyFromCamera: true,
  170. success (res) {
  171. that.setData({
  172. sealNo:res.result
  173. })
  174. }
  175. })
  176. },
  177. onSubmit:function(e){
  178. var that=this
  179. if(that.data.sealNo=='')
  180. return wx.showToast({title: '封签号不能为空',icon:'none'})
  181. if(deviceId=='')
  182. return wx.showToast({title: '设备号不能为空',icon:'none'})
  183. // if(spoutDeviceId=='')
  184. // return wx.showToast({title: '柜门号不能为空',icon:'none'})
  185. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CollectBindSeals", {
  186. seal_no: that.data.sealNo,
  187. device_id:deviceId,
  188. order_id:id,
  189. }, "post").then(function (res) {
  190. wx.hideLoading();
  191. if (res.code== 200) {
  192. wx.showModal({
  193. title: '成功',
  194. content: res.message.msg,
  195. showCancel:false,
  196. success (res) {
  197. if (res.confirm) {
  198. console.log('用户点击确定')
  199. wx.navigateBack()
  200. } else if (res.cancel) {
  201. console.log('用户点击取消')
  202. }
  203. }
  204. })
  205. } else
  206. wx.showToast({title: res.message.msg,icon:'none'})
  207. }).catch(function (err) {
  208. console.log(222);
  209. })
  210. },
  211. })