myPackage.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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
  54. :itemInfo="item"
  55. @toInformation="toInformation"
  56. @freeze="freeze"
  57. />
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import PackageCard from "./component/packageCard.vue";
  64. export default {
  65. components: {
  66. PackageCard,
  67. },
  68. data() {
  69. return {
  70. follow: "to_transit",
  71. weights: 0,
  72. orderId: "",
  73. containerId: "",
  74. statusNum: {},
  75. page: 1,
  76. orderList: [],
  77. limit: 10,
  78. };
  79. },
  80. computed: {
  81. i18n() {
  82. return this.$t("index");
  83. },
  84. },
  85. onLoad(options) {
  86. this.follow = options.type || "to_transit";
  87. this.getPackageList(1);
  88. },
  89. onShow() {
  90. this.page = 1;
  91. this.getPackageList(1);
  92. this.getNum();
  93. },
  94. methods: {
  95. tabSwitch(num) {
  96. this.page = 1;
  97. this.follow = num;
  98. this.getPackageList(1);
  99. },
  100. toInformation(value) {
  101. if (value.status == "imperfect") {
  102. return;
  103. }
  104. uni.navigateTo({
  105. url: `/pageD/orderInformation/orderInformation?orderStatus=${value.id}`,
  106. });
  107. },
  108. //获取每个状态数量
  109. getNum() {
  110. uni.$u.http.get(`/api/express-order/status-count`).then((res) => {
  111. this.statusNum = res;
  112. });
  113. },
  114. //获取订单列表,默认获取发往中转点的包裹,
  115. getPackageList(value) {
  116. uni.$u.http
  117. .get(
  118. `/api/express-order?container_id=${this.containerId}&status_collection=${this.follow}&order_no=${this.orderId}&page=${this.page}&limit=${this.limit}`
  119. )
  120. .then((res) => {
  121. if (value == 1) {
  122. this.weights = 0; //所有包裹重量
  123. this.orderList = res.data;
  124. } else {
  125. this.orderList = this.orderList.concat(res.data);
  126. }
  127. //将获取到的包裹重量相加
  128. this.orderList.map((item) => {
  129. this.weights += Number(item.actual_weight);
  130. });
  131. this.total = res.total;
  132. });
  133. },
  134. //冻结
  135. freeze(itemInfo) {
  136. uni.$u.http
  137. .post(`/api/express-order/froze/${itemInfo.id}`)
  138. .then((res) => {
  139. this.limit = this.page * this.limit;
  140. this.page = 1;
  141. this.getPackageList(1);
  142. uni.showToast({
  143. title: itemInfo.is_frozen == 0 ? "已冻结" : "已恢复",
  144. icon: "none",
  145. });
  146. });
  147. },
  148. },
  149. onReachBottom() {
  150. //商品总数量小于当前获取到的商品数量
  151. if (this.total > this.orderList.length) {
  152. this.page++;
  153. this.getPackageList(0);
  154. }
  155. },
  156. created() {
  157. // this.getPackageList(1);
  158. uni.setNavigationBarTitle({
  159. title: this.i18n.myPackage,
  160. });
  161. },
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. .top-search {
  166. background-color: #fff;
  167. padding: 20rpx 24rpx;
  168. }
  169. /deep/.u-input {
  170. background-color: #f4f4f4;
  171. }
  172. .top-tab {
  173. margin-top: 10rpx;
  174. display: flex;
  175. justify-content: space-between;
  176. overflow-y: auto;
  177. // flex-shrink: 1;
  178. width: 100vw;
  179. .tab {
  180. margin-right: 40rpx;
  181. font-size: 26rpx;
  182. color: #555;
  183. flex-shrink: 0;
  184. height: 44rpx;
  185. display: flex;
  186. align-items: flex-end;
  187. font-size: 32rpx;
  188. }
  189. .commodity {
  190. position: relative;
  191. font-weight: 600;
  192. color: #222;
  193. }
  194. .commodity::before {
  195. content: "";
  196. display: block;
  197. height: 8rpx;
  198. width: 100%;
  199. background: linear-gradient(to right, #f83224, #fff);
  200. position: absolute;
  201. bottom: 5rpx;
  202. opacity: 0.8;
  203. }
  204. }
  205. .content {
  206. padding: 20rpx 24rpx;
  207. .prompt {
  208. background-color: #fbe8e6;
  209. border-radius: 10rpx;
  210. padding: 16rpx 22rpx;
  211. font-size: 24rpx;
  212. display: flex;
  213. align-items: center;
  214. color: #f83224;
  215. .prompt-icon {
  216. width: 36rpx;
  217. height: 36rpx;
  218. margin-right: 20rpx;
  219. }
  220. }
  221. }
  222. </style>