index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. const Parse = getApp().Parse
  2. const company = getApp().globalData.company
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. steps: [
  9. ],
  10. active:0,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. let {
  17. num,
  18. com,
  19. phone
  20. } = options
  21. this.setData({
  22. num,
  23. com
  24. })
  25. num && this.getExpress()
  26. com && this.getExpressCompany(com)
  27. },
  28. getExpress() {
  29. let {
  30. num,
  31. com,
  32. phone
  33. } = this.data
  34. let data = {
  35. company:company,
  36. num,
  37. com,
  38. phone
  39. }
  40. let url = `https://server.fmode.cn/api/apig/express/consult`
  41. wx.request({
  42. url: url,
  43. data: data,
  44. header: {
  45. 'content-type': 'application/json'
  46. },
  47. method: 'POST',
  48. dataType: 'json',
  49. responseType: 'text',
  50. success: (result) => {
  51. if(result?.data.code == 200){
  52. let steps = []
  53. let data = result.data.data.data
  54. console.log(data);
  55. data.forEach(item => {
  56. let obj = {
  57. text: item.context,
  58. desc: item.time,
  59. activeIcon: 'checked',
  60. }
  61. steps.push(obj)
  62. });
  63. this.setData({
  64. steps
  65. })
  66. let com = data = result.data.data.com
  67. this.getExpressCompany(com)
  68. return
  69. }
  70. console.log(result);
  71. },
  72. fail: () => {},
  73. complete: () => {}
  74. });
  75. },
  76. async getExpressCompany(com){
  77. let query = new Parse.Query('ExpressCompany')
  78. query.equalTo('code',com)
  79. let r = await query.first()
  80. if(r?.id){
  81. this.setData({
  82. companyText:r.get('name')
  83. })
  84. }
  85. },
  86. onCopy(){
  87. let { num } = this.data
  88. wx.setClipboardData({
  89. data: num,
  90. success: (result)=>{
  91. wx.showToast({
  92. title: '复制成功',
  93. icon: 'success',
  94. image: '',
  95. duration: 1500,
  96. mask: false,
  97. });
  98. },
  99. fail: ()=>{},
  100. complete: ()=>{}
  101. });
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function () {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function () {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function () {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function () {
  137. }
  138. })