wuliu.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // pages/wuliu/wuliu.js
  2. Page({
  3. data: {
  4. company : '',
  5. orderNum : '',
  6. id:'',
  7. dizhi : []
  8. },
  9. onLoad: function (options) {
  10. var that = this;
  11. var host = getApp().globalData.servsers;
  12. var id = options.id;
  13. if (id != undefined){
  14. that.setData({
  15. id: id
  16. })
  17. wx.request({
  18. url: host + "orderapi/findAllOneforxcx",
  19. data: {
  20. order_number: options.id,
  21. },
  22. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  23. header: {
  24. 'Accept': 'application/json'
  25. },
  26. success: function (res) {
  27. console.log(res);
  28. //console.log(res.data.rows[0].order_logistics);
  29. var dizhi = (res.data.rows[0].order_logistics);
  30. console.log("dizhi:" + dizhi);
  31. if (res.data.rows[0].order_logistics != null){
  32. dizhi = dizhi.split(",");
  33. that.setData({
  34. id: id,
  35. dizhi: dizhi,
  36. company: dizhi[0],
  37. orderNum: dizhi[1]
  38. })
  39. that.selectList();
  40. }
  41. if (res == null || res.data == null) {
  42. console.error('网络请求失败');
  43. return;
  44. }
  45. }
  46. })
  47. }
  48. },
  49. selectList:function(e){
  50. var that = this;
  51. var id = that.data.id;
  52. var dizhi = that.data.dizhi;
  53. var orderNum = that.data.orderNum;
  54. if (orderNum != undefined){
  55. wx.request({
  56. url: "https://way.jd.com/jisuapi/query",
  57. data: {
  58. type: 'auto',
  59. number: orderNum,
  60. appkey: '9c5b9c4c777db65e00f4a70aa8c51a8b',
  61. },
  62. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  63. header: {
  64. 'Accept': 'application/json'
  65. },
  66. success: function (res) {
  67. console.log(res);
  68. that.setData({
  69. searchList: res.data.result.result.list,
  70. });
  71. if (res == null || res.data == null) {
  72. console.error('网络请求失败');
  73. return;
  74. }
  75. }
  76. })
  77. }
  78. },
  79. onShow: function (e) {
  80. var that = this;
  81. var host = getApp().globalData.servsers;
  82. var id = that.data.id;
  83. if (id != undefined) {
  84. wx.request({
  85. url: host + "orderapi/findAllOneforxcx",
  86. data: {
  87. order_number: id,
  88. },
  89. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  90. header: {
  91. 'Accept': 'application/json'
  92. },
  93. success: function (res) {
  94. var dizhi = res.data.rows[0].order_logistics;
  95. if (res.data.rows[0].order_logistics != null) {
  96. dizhi = dizhi.split(",");
  97. that.setData({
  98. id: id,
  99. dizhi: dizhi,
  100. company: dizhi[0],
  101. orderNum: dizhi[1]
  102. })
  103. that.selectList();
  104. }
  105. if (res == null || res.data == null) {
  106. console.error('网络请求失败');
  107. return;
  108. }
  109. }
  110. })
  111. }
  112. }
  113. })