access.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/order/access/access.js
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. orders:"",
  9. network_id:0,
  10. orde_num:0
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. console.log(options.q);
  17. var network_id=options.network_id;
  18. if(options.q){
  19. var url=decodeURIComponent(options.q)
  20. var order_num=app.getQueryVariable(url,"orde_num");
  21. var network_id=wx.getStorageSync('nid');
  22. }
  23. this.setData({
  24. network_id:network_id,
  25. orde_num:order_num?order_num:0
  26. })
  27. },
  28. scan(){
  29. wx.scanCode({
  30. onlyFromCamera: true,
  31. success: (result) => {
  32. var url=result.result;
  33. var network_id=this.data.network_id;
  34. var order_num=app.getQueryVariable(url,"orde_num");
  35. wx.navigateTo({
  36. url: '/pages/order/deposit/deposit?network_id='+network_id+"&order_num="+order_num+"&is_deposit=1"
  37. })
  38. console.log(result)
  39. },
  40. fail: (res) => {},
  41. complete: (res) => {},
  42. })
  43. },
  44. /**
  45. * 取件
  46. */
  47. receive(){
  48. wx.scanCode({
  49. onlyFromCamera: true,
  50. success: (result) => {
  51. var url=result.result;
  52. var network_id=this.data.network_id?this.data.network_id:app.getQueryVariable(url,"network_id");
  53. var order_num=app.getQueryVariable(url,"orde_num");
  54. wx.navigateTo({
  55. url: '/pages/order/deposit/deposit?network_id='+network_id+"&order_num="+order_num+"&is_deposit=0",
  56. })
  57. console.log(result)
  58. },
  59. fail: (res) => {},
  60. complete: (res) => {},
  61. })
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow: function () {
  72. this.getDeviceinfo(this.data.orde_num);
  73. },
  74. /**
  75. * @name 获取当前网点存取单
  76. * @param int network_id 网点id
  77. */
  78. getDeviceinfo:function(order_num){
  79. var that=this;
  80. wx.showLoading({
  81. title: '加载中...',
  82. })
  83. app.api.useApi(app.globalData.baseAppUrl+"api/order/getDeviceinfo",{
  84. order_num:order_num,
  85. network_id:this.data.network_id
  86. }).then((res)=>{
  87. if(res.code!=200){
  88. setTimeout(() => {
  89. that.getDeviceinfo(order_num)
  90. }, 1000);
  91. // wx.showToast({
  92. // title: res.message.msg,
  93. // icon:"none",
  94. // success:function(){
  95. // setTimeout(() => {
  96. // wx.hideLoading({
  97. // success: (res) => {},
  98. // })
  99. // }, 2000);
  100. // }
  101. // })
  102. }else{
  103. wx.hideLoading()
  104. var orders=res.message.data;
  105. that.setData({
  106. orders:orders
  107. })
  108. if(orders.send_count<1 && orders.receive_count <1){
  109. wx.navigateTo({
  110. url: "/pages/order/placeOrder/placeOrder?network_id="+orders.network.id
  111. })
  112. }
  113. }
  114. }).catch((err)=>{
  115. console.log(err);
  116. })
  117. }
  118. })