logistics.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var _request = require('../../../../utils/request.js')
  2. var util = require('../../../../utils/util.js')
  3. var rid
  4. Page({
  5. data: {
  6. order: {},
  7. logistics:{}
  8. },
  9. onLoad: function (options) {
  10. rid = options.id
  11. this.getRadish()
  12. console.log('rid',rid);
  13. },
  14. getRadish () {
  15. var that = this
  16. var url = 'v1/order/' + rid
  17. var params = {
  18. }
  19. var success = function (res) {
  20. var data = res.data
  21. data['paied_time'] = data.paied_time.replace("T"," ").replace("+"," ");
  22. data['dispatch_time'] = data.dispatch_time.replace("T"," ").replace("+"," ");
  23. that.setData({
  24. order: data
  25. })
  26. if(data.sign && data.express_order_no && data.express_code) that.getLogistics2();
  27. }
  28. _request.$get(url, params, success)
  29. },
  30. getLogistics(){
  31. var that = this
  32. var url = 'v1/experess_info/query'
  33. var params = {
  34. express_no:this.data.order.express_order_no,
  35. express_code:this.data.order.express_code,
  36. sign:this.data.order.sign
  37. }
  38. var success = function (res) {
  39. if(res.data.resp.error_code == 0){
  40. var data = res.data.resp.result
  41. data['list'] = data.list.reverse()
  42. that.setData({
  43. logistics: data
  44. })
  45. }else{
  46. wx.showToast({
  47. title: res.data.resp.reason+',请稍后再试',
  48. icon: 'none',
  49. duration: 2000
  50. })
  51. }
  52. }
  53. _request.$post(url, params, success)
  54. },
  55. getLogistics2(){
  56. var that = this;
  57. wx.showNavigationBarLoading()
  58. var token = wx.getStorageSync('lbt_token_key');
  59. // console.log('nowtoken',token);
  60. wx.request({
  61. url: 'https://jingcai.hiwavo.com/three/order/express?tf_code='+that.data.order.express_order_no/* 773175419643033 */,
  62. method: 'GET',
  63. header: {
  64. "content-type": "application/json",
  65. "terminal": 'mini-program',
  66. "Authorization":"Bearer " + token
  67. },
  68. success: function (res) {
  69. console.log('res',res);
  70. if(res.data.s == 0){
  71. var data = res.data.d;
  72. // data['list'] = data.reverse();
  73. console.log('data',data);
  74. that.setData({
  75. logistics: data
  76. })
  77. }else{
  78. wx.showToast({
  79. title: res.data.m+',请稍后再试',
  80. icon: 'none',
  81. duration: 2000
  82. })
  83. }
  84. },
  85. fail: function (res) {
  86. console.log('errres',res);
  87. },
  88. complete: function (res) {
  89. wx.hideNavigationBarLoading()
  90. }
  91. })
  92. },
  93. copeOrder: function () {
  94. var that = this
  95. var id = this.data.order.express_order_no
  96. wx.setClipboardData({
  97. data: id,
  98. success: function(res) {
  99. wx.showToast({
  100. title: '已成功复制到剪贴板',
  101. icon: 'none',
  102. duration: 2000
  103. })
  104. }
  105. })
  106. },
  107. onShareAppMessage: function (val) {
  108. return _request.share({
  109. sc: 'xcx_user_logistics'
  110. })
  111. }
  112. })