parcel.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar fixed border :navShow="navShow">
  5. <template #center>
  6. <view class="nav_search">
  7. <Search
  8. v-model="searchValue"
  9. @confirm="searchConfirm"
  10. :placeholder="t('名称订单号商品名称')"
  11. >
  12. <template #prefix>
  13. <i class="icon-font icon-search"></i>
  14. </template>
  15. </Search>
  16. </view>
  17. </template>
  18. <template #right>
  19. <navFilter @submit="filterSubmit" isOrderTime />
  20. <navMenu
  21. :options="{ icon: 'icon-home', text: '主页' }"
  22. page="parcel"
  23. />
  24. </template>
  25. </Navbar>
  26. <view class="content3">
  27. <view class="cont_tab">
  28. <Tab
  29. :active="tabActive"
  30. :tabList="tabList"
  31. @confirm="tabConfirm"
  32. keyName="text"
  33. />
  34. </view>
  35. <view class="cont">
  36. <List
  37. url="/shop/packages/lists"
  38. :topHeight="tabHeight"
  39. :defaultParams="{ keywords: searchValue, ...params }"
  40. ref="listRef"
  41. >
  42. <template #item="{ item }">
  43. <view class="order_list">
  44. <view class="order_header">
  45. <view class="create_time">
  46. <trans _t="创建时间" />:
  47. {{ useGlobal().$format(item.indate) }}
  48. </view>
  49. </view>
  50. <view class="order_item">
  51. <view
  52. class="order_item_wrapper"
  53. v-for="(val, num) in item.goods"
  54. :key="num"
  55. @click="listClick(item)"
  56. >
  57. <view class="_item_wrapper">
  58. <view class="thumb_img">
  59. <image :src="val.pic_url" class="_img"></image>
  60. </view>
  61. <view class="goods_info">
  62. <view class="info_name">
  63. <view class="_name">{{ val.goodTitle }}</view>
  64. <view class="_price"
  65. >{{ symbol.symbol }}&nbsp;{{
  66. Moneyhtml(val.price)
  67. }}</view
  68. >
  69. </view>
  70. <view class="spec_info">
  71. <view class="spec_desc">{{ val.sku_desc }}</view>
  72. <view class="spec_num">x{{ val.total }}</view>
  73. </view>
  74. <up-copy
  75. :content="item?.orderNo"
  76. :notice="t('复制成功')"
  77. class="right_value"
  78. @click.stop
  79. >
  80. <up-icon name="file-text" size="16px"></up-icon>
  81. <text>{{ item?.orderNo }}</text>
  82. </up-copy>
  83. </view>
  84. </view>
  85. <view class="order_status">
  86. <text>{{ item.statusTxt }}&nbsp;</text>
  87. <!-- <i class="icon-font icon-question2"></i> -->
  88. </view>
  89. </view>
  90. <view class="order_footer">
  91. <view class="order_price">
  92. <view class="price_text"> <trans _t="运费" />: </view>
  93. <text class="price-pay"
  94. >{{ symbol.symbol
  95. }}{{
  96. Moneyhtml(item.money - item.discount) < 0
  97. ? 0.01
  98. : Moneyhtml(item.money - item.discount)
  99. }}</text
  100. >
  101. <text class="price-original" v-if="item.discount > 0"
  102. >{{ symbol.symbol }}{{ Moneyhtml(item.money) }}</text
  103. >
  104. <!-- <i class="icon-font icon-question2"></i> -->
  105. </view>
  106. <view class="order_btns">
  107. <view class="btn" @click="logisticsPop(item)">
  108. <trans _t="订单详情" />
  109. </view>
  110. <view
  111. class="btn"
  112. v-if="item.status <= 100"
  113. @click="deleteOrder(item)"
  114. >
  115. <trans _t="删除订单" />
  116. </view>
  117. <view
  118. class="btn pay_btn"
  119. @click="paySubmit(item)"
  120. v-if="item.status == 100"
  121. >
  122. <trans _t="支付" />
  123. </view>
  124. <template v-if="item.status == 401">
  125. <view class="btn pay_btn" @click="confirmReceive(item)">
  126. <trans _t="确认收货" />
  127. </view>
  128. </template>
  129. <template v-if="item.status == 402 && !item.isComment">
  130. <view class="btn pay_btn" @click="openReview(item)">
  131. <trans _t="待评价" />
  132. </view>
  133. </template>
  134. <template v-if="item.isComment">
  135. <view
  136. class="btn pay_btn"
  137. @click="openCommentPopup(item)"
  138. >
  139. <trans _t="查看评论" />
  140. </view>
  141. </template>
  142. </view>
  143. <!-- <view class="order_btns" v-if="item.status == 100">
  144. <view class="btn" @click="orderCancel(item)">
  145. <trans _t="取消" />
  146. </view>
  147. <view class="btn pay_btn" @click="paySubmit(item)">
  148. <trans _t="支付" />
  149. </view>
  150. </view> -->
  151. </view>
  152. </view>
  153. </view>
  154. </template>
  155. </List>
  156. </view>
  157. </view>
  158. <ReviewPopup
  159. ref="reviewPopupRef"
  160. :id="productId"
  161. @submit="handleSubmit"
  162. />
  163. <CommentPopup ref="commentPopupRef" :commentId="currentCommentId" />
  164. </view>
  165. </Theme>
  166. </template>
  167. <script setup>
  168. import Navbar from "@/components/navbar";
  169. import navMenu from "@/components/nav_menu";
  170. import navFilter from "@/components/nav_filter";
  171. import Search from "@/components/input";
  172. import Tab from "@/components/tabs";
  173. import List from "@/components/list";
  174. import ReviewPopup from "./components/ReviewPopup.vue";
  175. import CommentPopup from "./components/CommentPopup.vue";
  176. import { ref, watch, onMounted, nextTick, computed } from "vue";
  177. import { t } from "@/locale";
  178. import { useGlobal, Modal, Toast, Moneyhtml } from "@/utils";
  179. import { useSystemStore, useShopStore } from "@/store";
  180. import { onShow, onReachBottom } from "@dcloudio/uni-app";
  181. import {
  182. SHOP_PACKAGES_CANCEL,
  183. SHOP_PACKAGES_FINISH,
  184. SHOP_ORDER_EXPRESS,
  185. } from "@/api";
  186. const useSystem = useSystemStore();
  187. const useShop = useShopStore();
  188. const searchValue = ref("");
  189. const tabActive = ref(0);
  190. const listRef = ref(null);
  191. const tabList = [
  192. { text: "所有包裹", status: 0 },
  193. { text: "待确认", status: 100 },
  194. ];
  195. const params = ref({});
  196. const symbol = computed(() => useSystem.getSymbol);
  197. const reviewPopupRef = ref(null);
  198. const productId = ref("");
  199. const commentPopupRef = ref(null);
  200. const currentCommentId = ref("");
  201. const props = defineProps({
  202. tabHeight: {
  203. type: Number,
  204. default: 0,
  205. },
  206. tabParams: {
  207. type: Object,
  208. },
  209. navShow: Boolean,
  210. });
  211. watch(
  212. () => props.tabParams,
  213. (newVal) => {
  214. if (newVal && newVal.tab == 2) {
  215. tabActive.value = newVal.type;
  216. params.value.status = newVal.status;
  217. useShop.setTabParams(null);
  218. nextTick(() => {
  219. listRef.value?.handleRefresh();
  220. });
  221. }
  222. },
  223. { immediate: true }
  224. );
  225. const openReview = (item) => {
  226. productId.value = item.id;
  227. reviewPopupRef.value?.open();
  228. };
  229. const openCommentPopup = (item) => {
  230. currentCommentId.value = item.id;
  231. commentPopupRef.value?.open(item.id);
  232. };
  233. const handleSubmit = () => {
  234. nextTick(() => {
  235. // listRef.value && listRef.value.handleRefresh();
  236. });
  237. };
  238. const searchConfirm = () => {
  239. nextTick(() => {
  240. listRef.value && listRef.value.handleRefresh();
  241. });
  242. };
  243. const listClick = (item) => {
  244. uni.navigateTo({ url: `/pages/dashboard/parcel_detail?orderid=${item.id}` });
  245. };
  246. const tabConfirm = (item, index) => {
  247. if (!item) return;
  248. tabActive.value = index;
  249. params.value.status = item.status;
  250. nextTick(() => {
  251. listRef.value && listRef.value.handleRefresh();
  252. });
  253. };
  254. const filterSubmit = (obj) => {
  255. const { status, ...newObj } = obj;
  256. params.value = newObj;
  257. nextTick(() => {
  258. listRef.value && listRef.value.handleRefresh();
  259. });
  260. };
  261. const paySubmit = (item) => {
  262. uni.navigateTo({
  263. url: `/pages/shop/payment?oid=${item.id}&type=package&money=${item.money}`,
  264. });
  265. };
  266. const logisticsPop = (item) => {
  267. uni.navigateTo({
  268. url: `/pages/dashboard/parcel_detail?orderid=${item.id}`,
  269. });
  270. };
  271. const confirmReceive = (item) => {
  272. Modal({ content: t("确定收到货了吗?") }).then(async () => {
  273. try {
  274. const res = await SHOP_PACKAGES_FINISH(item.id);
  275. nextTick(() => {
  276. listRef.value && listRef.value.handleRefresh();
  277. });
  278. } catch (error) {
  279. Toast(error.msg);
  280. }
  281. });
  282. };
  283. const deleteOrder = async (item) => {
  284. Modal({ content: t("你确定要删除此订单吗?") }).then(async () => {
  285. try {
  286. await SHOP_PACKAGES_CANCEL(item.id);
  287. nextTick(() => {
  288. listRef.value && listRef.value.handleRefresh();
  289. });
  290. } catch (error) {
  291. Toast(error.msg);
  292. }
  293. });
  294. };
  295. onMounted(() => {
  296. listRef.value && listRef.value.getData();
  297. });
  298. onShow(() => {
  299. listRef.value && listRef.value.getData();
  300. });
  301. onReachBottom(() => {
  302. nextTick(() => {
  303. listRef.value && listRef.value.scrolltolower();
  304. });
  305. });
  306. </script>
  307. <style lang="less" scoped>
  308. @import url("@/style.less");
  309. .wrap {
  310. background-color: var(--bg);
  311. .flex();
  312. flex-direction: column;
  313. /deep/ .u-navbar__content {
  314. justify-content: unset;
  315. .u-navbar__content__left {
  316. position: unset;
  317. }
  318. }
  319. .nav_search {
  320. .icon-search {
  321. color: #a8abb2;
  322. .size(28px);
  323. }
  324. }
  325. .content3 {
  326. flex-grow: 1;
  327. // height: calc(100vh - 44px);
  328. flex-direction: column;
  329. .flex();
  330. .cont_tab {
  331. background-color: var(--light);
  332. padding: 0 48rpx;
  333. :deep(.tab) {
  334. .active {
  335. color: var(--text) !important;
  336. &::before {
  337. background-color: var(--text) !important;
  338. }
  339. }
  340. }
  341. }
  342. .cont {
  343. flex-grow: 1;
  344. overflow: hidden scroll;
  345. padding: 0 24rpx 24rpx;
  346. .order_list {
  347. margin-top: 24rpx;
  348. padding: 16rpx 24rpx;
  349. background-color: var(--light);
  350. border-radius: 16rpx;
  351. .order_header {
  352. .ver();
  353. margin-bottom: 16rpx;
  354. .create_time {
  355. .size(24rpx);
  356. color: var(--text);
  357. font-weight: 700;
  358. text {
  359. font-weight: 500;
  360. }
  361. }
  362. }
  363. .order_item {
  364. &_wrapper {
  365. margin-top: 16rpx;
  366. ._item_wrapper {
  367. .flex();
  368. .thumb_img {
  369. width: 140rpx;
  370. height: 140rpx;
  371. ._img {
  372. width: inherit;
  373. height: inherit;
  374. border-radius: 16rpx;
  375. }
  376. }
  377. .goods_info {
  378. margin-left: 16rpx;
  379. flex: 1;
  380. .info_name {
  381. color: var(--text);
  382. .size(24rpx);
  383. font-weight: 700;
  384. line-height: 44rpx;
  385. .ver();
  386. ._name {
  387. flex: 1;
  388. // .ellipsis();
  389. margin-right: 8rpx;
  390. }
  391. }
  392. .spec_info {
  393. .flex();
  394. flex: 1;
  395. margin-top: 8rpx;
  396. color: var(--text-01);
  397. .size(24rpx);
  398. line-height: 40rpx;
  399. .spec_desc {
  400. flex: 1;
  401. margin-right: 8rpx;
  402. }
  403. }
  404. .right_value {
  405. .hor(flex-end);
  406. .size(24rpx);
  407. margin-top: 12rpx;
  408. }
  409. }
  410. }
  411. .order_status {
  412. color: var(--primary);
  413. .size(24rpx);
  414. height: 40rpx;
  415. .flex_position(flex-end);
  416. margin-top: 16rpx;
  417. .icon-question2 {
  418. .size(36rpx);
  419. }
  420. }
  421. }
  422. .order_footer {
  423. margin-top: 16rpx;
  424. border-top: 1px solid #f5f6f7;
  425. .order_price {
  426. padding-top: 16rpx;
  427. .flex_position(flex-end);
  428. color: var(--red);
  429. .size();
  430. font-weight: 700;
  431. height: 48rpx;
  432. line-height: 1;
  433. .price_text {
  434. color: var(--text);
  435. .size(24rpx);
  436. font-weight: 400;
  437. }
  438. .icon-question2 {
  439. font-weight: 400;
  440. color: var(--text-01);
  441. margin-left: 8rpx;
  442. }
  443. .price-pay {
  444. color: var(--red);
  445. font-weight: bold;
  446. margin-right: 16rpx;
  447. }
  448. .price-original {
  449. font-size: 24rpx;
  450. color: #999;
  451. text-decoration: line-through;
  452. line-height: 1;
  453. }
  454. }
  455. .end_time {
  456. .flex_position(flex-end);
  457. margin-top: 16rpx;
  458. color: #e62e2e;
  459. font-weight: 700;
  460. .size(24rpx);
  461. text {
  462. font-weight: 400;
  463. }
  464. }
  465. .order_btns {
  466. flex-wrap: wrap;
  467. .flex_position(flex-end);
  468. margin-top: 16rpx;
  469. gap: 16rpx;
  470. .btn {
  471. .flex_center();
  472. border-radius: 16rpx;
  473. padding: 0 30rpx;
  474. .size(24rpx);
  475. height: 48rpx;
  476. border: 1px solid var(--black);
  477. background-color: var(--light);
  478. color: var(--black);
  479. }
  480. .pay_btn {
  481. color: var(--light);
  482. background-color: var(--black);
  483. }
  484. }
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. </style>