index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const Parse = getApp().Parse
  2. const company = getApp().globalData.company
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. /* 订单编号 */
  9. num:{
  10. type:String,
  11. value:''
  12. },
  13. /* 快递公司代码 依据ExpressCompany表code获取*/
  14. com:{
  15. type:String,
  16. value:''
  17. },
  18. /* 寄件/收人手机号(二选一)【顺丰及丰网必填】 */
  19. phone:{
  20. type:String,
  21. value:''
  22. },
  23. },
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. },
  29. lifetimes: {
  30. created() {
  31. },
  32. attached: async function () {
  33. },
  34. ready(){
  35. let {
  36. num,
  37. com
  38. } = this.data
  39. num && this.getExpress()
  40. }
  41. },
  42. /**
  43. * 组件的方法列表
  44. */
  45. methods: {
  46. getExpress() {
  47. let {
  48. num,
  49. com,
  50. phone
  51. } = this.data
  52. let data = {
  53. company:company,
  54. num,
  55. com,
  56. phone
  57. }
  58. let url = `https://server.fmode.cn/api/apig/express/consult`
  59. wx.request({
  60. url: url,
  61. data: data,
  62. header: {
  63. 'content-type': 'application/json'
  64. },
  65. method: 'POST',
  66. dataType: 'json',
  67. responseType: 'text',
  68. success: (result) => {
  69. console.log(result);
  70. if(result?.data.code == 200){
  71. let data = result.data.data.data
  72. this.setData({
  73. step:data[0]
  74. })
  75. return
  76. }
  77. },
  78. fail: () => {},
  79. complete: () => {}
  80. });
  81. },
  82. async getExpressCompany(com){
  83. let query = new Parse.Query('ExpressCompany')
  84. query.equalTo('code',com)
  85. let r = await query.first()
  86. if(r?.id){
  87. this.setData({
  88. companyText:r.get('name')
  89. })
  90. }
  91. },
  92. toUrl(){
  93. let { num, com } = this.data
  94. let url = `/common-page/pages/nova-express/index?num=${num}&com=${com}`
  95. wx.navigateTo({
  96. url: url,
  97. });
  98. }
  99. },
  100. })