金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
2.9 KiB

  1. <template>
  2. <view id="express">
  3. <view class="title">
  4. <view class="name">
  5. {{name || '其他快递'}}
  6. </view>
  7. <view class="no">
  8. {{no}}
  9. </view>
  10. </view>
  11. <view class="box mx-1px-left" v-if="init && info && info.length">
  12. <view class="item" v-for="(item, index) in info" :key="index">
  13. <view class="dot">
  14. </view>
  15. <view class="text">
  16. <view class="info">
  17. {{item.context}}
  18. </view>
  19. <view class="time">
  20. {{item.time}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="no-data" v-if="init && !info">
  26. 暂无物流信息
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  32. export default {
  33. data() {
  34. return {
  35. info: '',
  36. name: '',
  37. no: '',
  38. init: false
  39. };
  40. },
  41. onLoad(e) {
  42. if (e.no) {
  43. this.setData({
  44. no: e.no,
  45. name: e.name
  46. });
  47. this.getExpress(e.no);
  48. } else {
  49. wx.showModal({
  50. content: '无物流编号',
  51. showCancel: false
  52. });
  53. }
  54. },
  55. components: {},
  56. props: {},
  57. methods: {
  58. getExpress(no) {
  59. var token = this.$cookieStorage.get('user_token');
  60. wx.showLoading({
  61. title: '查询中',
  62. mask: true
  63. });
  64. this.$http.get({
  65. api: 'api/express/query',
  66. data: {
  67. no: no
  68. },
  69. header: {
  70. Authorization: token
  71. }
  72. }).then(res => {
  73. if (res.statusCode == 200) {
  74. res = res.data;
  75. if (res.data) {
  76. this.setData({
  77. info: res.data,
  78. init: true
  79. });
  80. } else {
  81. wx.showModal({
  82. content: res.message || '请求失败',
  83. showCancel: false
  84. });
  85. }
  86. } else {
  87. wx.showModal({
  88. content: '请求失败',
  89. showCancel: false
  90. });
  91. }
  92. wx.hideLoading();
  93. }).catch(err => {
  94. wx.showModal({
  95. content: '请求失败',
  96. showCancel: false
  97. });
  98. wx.hideLoading();
  99. });
  100. },
  101. setData: function (obj) {
  102. let that = this;
  103. let keys = [];
  104. let val, data;
  105. Object.keys(obj).forEach(function (key) {
  106. keys = key.split('.');
  107. val = obj[key];
  108. data = that.$data;
  109. keys.forEach(function (key2, index) {
  110. if (index + 1 == keys.length) {
  111. that.$set(data, key2, val);
  112. } else {
  113. if (!data[key2]) {
  114. that.$set(data, key2, {});
  115. }
  116. }
  117. data = data[key2];
  118. });
  119. });
  120. }
  121. },
  122. computed: {},
  123. watch: {}
  124. };
  125. </script>
  126. <style rel="stylesheet/less" lang="less">
  127. @import "express";
  128. </style>