access.js 2.7 KB

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