myPackage.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view>
  3. <view class="top-search">
  4. <u--input
  5. :placeholder="i18n.orderNum"
  6. prefixIcon="search"
  7. shape="circle"
  8. @change="getPackageList(1)"
  9. v-model="orderId"
  10. prefixIconStyle="font-size: 22px;color: #909399;background: #f4f4f4;"
  11. ></u--input>
  12. <view class="top-tab">
  13. <view
  14. :class="{ commodity: follow == 'to_transit' }"
  15. class="tab"
  16. @click="tabSwitch('to_transit')"
  17. >
  18. {{ i18n.deliver }}{{ statusNum.to_transit }}
  19. </view>
  20. <view
  21. :class="{ commodity: follow == 'transit_receipt' }"
  22. class="tab"
  23. @click="tabSwitch('transit_receipt')"
  24. >
  25. {{ i18n.Sign }} {{ statusNum.transit_receipt }}
  26. </view>
  27. <view
  28. :class="{ commodity: follow == 'to_overseas' }"
  29. class="tab"
  30. @click="tabSwitch('to_overseas')"
  31. >
  32. {{ i18n.overseas }} {{ statusNum.to_overseas }}
  33. </view>
  34. <view
  35. :class="{ commodity: follow == 'other' }"
  36. class="tab"
  37. @click="tabSwitch('other')"
  38. >
  39. {{ i18n.other }} {{ statusNum.other }}
  40. </view>
  41. </view>
  42. </view>
  43. <view class="content">
  44. <view class="prompt">
  45. <image
  46. class="prompt-icon"
  47. src="../../static/mine/336.png"
  48. mode=""
  49. ></image>
  50. {{ i18n.orderWeight }}{{ weights }}kg
  51. </view>
  52. <view v-for="item in orderList" :key="item.orderStatus">
  53. <PackageCard :itemInfo="item" @toInformation="toInformation" />
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import PackageCard from "./component/packageCard.vue";
  60. export default {
  61. components: {
  62. PackageCard,
  63. },
  64. data() {
  65. return {
  66. follow: "to_transit",
  67. weights: 0,
  68. orderId: "",
  69. containerId: "",
  70. statusNum: {},
  71. page: 1,
  72. orderList: [],
  73. };
  74. },
  75. computed: {
  76. i18n() {
  77. return this.$t("index");
  78. },
  79. },
  80. onLoad(options) {
  81. this.follow = options.type || "to_transit";
  82. this.getPackageList(1);
  83. },
  84. onShow() {
  85. this.page = 1;
  86. this.getPackageList(1);
  87. this.getNum();
  88. },
  89. methods: {
  90. tabSwitch(num) {
  91. this.page = 1;
  92. this.follow = num;
  93. this.getPackageList(1);
  94. },
  95. toInformation(value) {
  96. if (value.status == "imperfect") {
  97. return;
  98. }
  99. uni.navigateTo({
  100. url: `/pageD/orderInformation/orderInformation?orderStatus=${value.id}`,
  101. });
  102. },
  103. //获取每个状态数量
  104. getNum() {
  105. uni.$u.http.get(`/api/express-order/status-count`).then((res) => {
  106. this.statusNum = res;
  107. });
  108. },
  109. //获取订单列表,默认获取发往中转点的包裹,
  110. getPackageList(value) {
  111. uni.$u.http
  112. .get(
  113. `/api/express-order?container_id=${this.containerId}&status_collection=${this.follow}&order_no=${this.orderId}&page=${this.page}&limit=10`
  114. )
  115. .then((res) => {
  116. if (value == 1) {
  117. this.weights = 0; //所有包裹重量
  118. this.orderList = res.data;
  119. } else {
  120. this.orderList = this.orderList.concat(res.data);
  121. }
  122. //将获取到的包裹重量相加
  123. this.orderList.map((item) => {
  124. this.weights += Number(item.actual_weight);
  125. });
  126. this.total = res.total;
  127. });
  128. },
  129. },
  130. onReachBottom() {
  131. //商品总数量小于当前获取到的商品数量
  132. if (this.total > this.orderList.length) {
  133. this.page++;
  134. this.getPackageList(0);
  135. }
  136. },
  137. created() {
  138. // this.getPackageList(1);
  139. uni.setNavigationBarTitle({
  140. title: this.i18n.myPackage,
  141. });
  142. },
  143. };
  144. </script>
  145. <style lang="scss" scoped>
  146. .top-search {
  147. background-color: #fff;
  148. padding: 20rpx 24rpx;
  149. }
  150. /deep/.u-input {
  151. background-color: #f4f4f4;
  152. }
  153. .top-tab {
  154. margin-top: 10rpx;
  155. display: flex;
  156. justify-content: space-between;
  157. overflow-y: auto;
  158. // flex-shrink: 1;
  159. width: 100vw;
  160. .tab {
  161. margin-right: 40rpx;
  162. font-size: 26rpx;
  163. color: #555;
  164. flex-shrink: 0;
  165. height: 44rpx;
  166. display: flex;
  167. align-items: flex-end;
  168. font-size: 32rpx;
  169. }
  170. .commodity {
  171. position: relative;
  172. font-weight: 600;
  173. color: #222;
  174. }
  175. .commodity::before {
  176. content: "";
  177. display: block;
  178. height: 8rpx;
  179. width: 100%;
  180. background: linear-gradient(to right, #f83224, #fff);
  181. position: absolute;
  182. bottom: 5rpx;
  183. opacity: 0.8;
  184. }
  185. }
  186. .content {
  187. padding: 20rpx 24rpx;
  188. .prompt {
  189. background-color: #fbe8e6;
  190. border-radius: 10rpx;
  191. padding: 16rpx 22rpx;
  192. font-size: 24rpx;
  193. display: flex;
  194. align-items: center;
  195. color: #f83224;
  196. .prompt-icon {
  197. width: 36rpx;
  198. height: 36rpx;
  199. margin-right: 20rpx;
  200. }
  201. }
  202. }
  203. </style>