orderList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <template>
  2. <view class="order-list-page">
  3. <!-- 顶部自定义导航栏 -->
  4. <view class="custom-navbar">
  5. <view class="navbar-left">
  6. <text class="fa fa-angle-left" @click="goBack"></text>
  7. </view>
  8. <view class="navbar-center">
  9. <view class="navbar-title one-omit">
  10. 订单
  11. </view>
  12. </view>
  13. <view class="navbar-right" @click="goPages('/pages/crowdFunding/searchOrder')">
  14. <image
  15. src="@/static/crowdFunding/search2.png"
  16. style="width: 40rpx; height: 40rpx; margin-top: 15rpx"
  17. mode="widthFix"
  18. ></image>
  19. </view>
  20. </view>
  21. <!-- Tab导航 -->
  22. <view class="tabs-section">
  23. <scroll-view
  24. scroll-x
  25. class="tabs-scroll-view"
  26. :show-scrollbar="false"
  27. :scroll-into-view="'tab-' + (currentTab - 1)"
  28. scroll-with-animation
  29. >
  30. <view class="tabs-wrapper">
  31. <view
  32. v-for="(tab, index) in tabs"
  33. :key="index"
  34. :id="'tab-' + index"
  35. :class="['tab-item', currentTab === index ? 'active' : '']"
  36. @click="switchTab(index)"
  37. >
  38. <view class="tab" :class="{ active: currentTab === index }">
  39. <text class="left">{{ tab.name }}</text>
  40. <view class="line"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. <view class="tabs-reserveaseat"></view>
  47. <!-- Swiper订单列表 -->
  48. <swiper
  49. :current="currentTab"
  50. @change="onSwiperChange"
  51. class="order-swiper"
  52. :style="'height:' + swiperHeight + 'px'"
  53. >
  54. <swiper-item v-for="tab in tabs" :key="tab.type">
  55. <view class="order-list">
  56. <view
  57. class="order-card"
  58. v-for="order in getOrdersByTab(tab.type)"
  59. :key="order.id"
  60. >
  61. <view class="order-header">
  62. <text class="project-title one-omit">{{ order.projectTitle }}</text>
  63. <text class="tag-initiator" v-if="order.isInitiator">发起人</text>
  64. <text
  65. class="order-status"
  66. :class="'status-' + order.statusType"
  67. >{{ order.statusText }}</text
  68. >
  69. </view>
  70. <view class="order-main" @click="goToOrderDetail(order)">
  71. <image class="order-img" :src="order.img" />
  72. <view class="order-info">
  73. <view class="order-title">{{ order.title }}</view>
  74. <view class="order-spec">{{ order.spec }}</view>
  75. </view>
  76. <view class="order-price">
  77. <view>¥{{ order.price }}</view>
  78. <view class="order-count">x{{ order.count }}</view>
  79. </view>
  80. </view>
  81. <view class="order-actions">
  82. <!-- 1. 支付失败 -->
  83. <template v-if="order.statusType === 'payFail'">
  84. <view class="btn btn-delete" @click="deleteOrder(order)"
  85. >删除订单</view
  86. >
  87. </template>
  88. <!-- 2. 待支付 -->
  89. <template v-else-if="order.statusType === 'waitPay'">
  90. <view class="btn btn-pay" @click="pay(order)">立即支付</view>
  91. <view class="btn btn-cancel" @click="cancelOrder(order)"
  92. >取消订单</view
  93. >
  94. </template>
  95. <!-- 3. 已付款待发货 -->
  96. <template v-else-if="order.statusType === 'paid'">
  97. <view class="btn btn-cancel" @click="cancelOrder(order)"
  98. >取消订单</view
  99. >
  100. </template>
  101. <!-- 4. 商品已发货 -->
  102. <template v-else-if="order.statusType === 'waitReceive'">
  103. <view class="btn btn-confirm" @click="confirmReceive(order)"
  104. >确认收货</view
  105. >
  106. </template>
  107. <!-- 5. 交易完成 -->
  108. <template v-else-if="order.statusType === 'finish'">
  109. <!-- <view class="btn btn-comment" @click="commentOrder(order)">去评价</view> -->
  110. <view class="btn btn-delete" @click="deleteOrder(order)"
  111. >删除订单</view
  112. >
  113. </template>
  114. <!-- 6. 已退款 -->
  115. <template v-else-if="order.statusType === 'refund'">
  116. <view class="btn btn-delete" @click="deleteOrder(order)"
  117. >删除订单</view
  118. >
  119. </template>
  120. </view>
  121. </view>
  122. </view>
  123. </swiper-item>
  124. </swiper>
  125. <DialogBox ref="DialogBox"></DialogBox>
  126. </view>
  127. </template>
  128. <script>
  129. export default {
  130. data() {
  131. return {
  132. currentTab: 0,
  133. tabs: [
  134. { name: "全部", type: "all" },
  135. { name: "待支付", type: "waitPay" },
  136. // { name: "已付款", type: "paid" },
  137. { name: "待发货", type: "waitSend" },
  138. { name: "待收货", type: "waitReceive" },
  139. { name: "交易完成", type: "finish" },
  140. { name: "退款中", type: "refund" },
  141. { name: "已关闭", type: "payFail" },
  142. ],
  143. orderList: [],
  144. swiperHeight: 600, // 默认高度,后续可动态调整
  145. };
  146. },
  147. onLoad() {
  148. // this.getdataList();
  149. },
  150. onShow() {
  151. this.getdataList();
  152. },
  153. computed: {
  154. filteredOrders() {
  155. if (this.tabs[this.currentTab].type === "all") return this.orderList;
  156. return this.orderList.filter(
  157. (o) => o.statusType === this.tabs[this.currentTab].type
  158. );
  159. },
  160. },
  161. methods: {
  162. goPages(url) {
  163. uni.navigateTo({
  164. url: url,
  165. });
  166. },
  167. goBack() {
  168. uni.navigateBack();
  169. },
  170. switchTab(index) {
  171. this.currentTab = index;
  172. // 切换标签时刷新数据
  173. this.getdataList();
  174. },
  175. onSwiperChange(e) {
  176. this.currentTab = e.detail.current;
  177. this.$nextTick(() => {
  178. this.updateSwiperHeight();
  179. });
  180. },
  181. getOrdersByTab(type) {
  182. if (type === "all") return this.orderList;
  183. return this.orderList.filter((o) => o.statusType === type);
  184. },
  185. updateSwiperHeight() {
  186. // 动态获取当前swiper-item内容高度
  187. this.$nextTick(() => {
  188. const query = uni.createSelectorQuery().in(this);
  189. query
  190. .selectAll(".order-list")
  191. .boundingClientRect((rects) => {
  192. if (rects && rects[this.currentTab]) {
  193. this.swiperHeight = rects[this.currentTab].height || 600;
  194. }
  195. })
  196. .exec();
  197. });
  198. },
  199. goToOrderDetail(order) {
  200. uni.navigateTo({
  201. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  202. });
  203. },
  204. pay(order) {
  205. uni.navigateTo({
  206. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  207. });
  208. /* 支付逻辑 */
  209. },
  210. deleteOrder(order) {
  211. /* 删除逻辑 */
  212. uni.navigateTo({
  213. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  214. });
  215. },
  216. cancelOrder(order) {
  217. /* 取消/退款逻辑 */
  218. uni.navigateTo({
  219. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  220. });
  221. },
  222. confirmReceive(order) {
  223. /* 确认收货逻辑 */
  224. uni.navigateTo({
  225. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  226. });
  227. },
  228. commentOrder(order) {
  229. /* 评价逻辑 */
  230. uni.navigateTo({
  231. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  232. });
  233. },
  234. getdataList() {
  235. uni.request({
  236. url: this.$apiHost + '/Order/getlist?type=buyCrowdfund',
  237. data:{
  238. uuid: getApp().globalData.uuid,
  239. skey: getApp().globalData.skey,
  240. },
  241. method: 'GET',
  242. success: (res) => {
  243. console.log(res.data.list, "获取订单");
  244. this.orderList = res.data.list.map(order => {
  245. let statusType = '';
  246. let statusText = '';
  247. switch (order.status) {
  248. case 0:
  249. statusType = 'waitPay';
  250. statusText = '待支付';
  251. break;
  252. case 1:
  253. statusType = 'waitSend';
  254. statusText = '待发货';
  255. break;
  256. case 2:
  257. statusType = 'waitReceive';
  258. statusText = '商品已发货';
  259. break;
  260. case 3:
  261. statusType = 'finish';
  262. statusText = '已收货';
  263. break;
  264. case 5:
  265. statusType = 'finish';
  266. statusText = '交易完成';
  267. break;
  268. case 6:
  269. statusType = 'refund';
  270. statusText = '退款中';
  271. break;
  272. case 8:
  273. statusType = 'payFail';
  274. statusText = '已关闭';
  275. break;
  276. case 9:
  277. statusType = 'finish';
  278. statusText = '已完成';
  279. break;
  280. default:
  281. statusType = 'waitPay';
  282. statusText = '待支付';
  283. }
  284. return {
  285. ...order,
  286. statusType,
  287. statusText,
  288. projectTitle: order.name,
  289. title: order.name,
  290. spec: order.name2,
  291. img: order.image,
  292. price: order.money,
  293. count: order.num,
  294. isInitiator: false
  295. };
  296. });
  297. },
  298. fail: () => {
  299. uni.showToast({ title: '获取订单失败', icon: 'none' });
  300. },
  301. complete: () => {
  302. this.updateSwiperHeight();
  303. }
  304. });
  305. },
  306. },
  307. mounted() {
  308. this.updateSwiperHeight();
  309. },
  310. watch: {
  311. currentTab() {
  312. this.$nextTick(() => {
  313. this.updateSwiperHeight();
  314. });
  315. },
  316. },
  317. };
  318. </script>
  319. <style lang="scss">
  320. .order-list-page {
  321. min-height: 100vh;
  322. background: #f6faf6;
  323. .custom-navbar {
  324. display: flex;
  325. flex-direction: row;
  326. align-items: center;
  327. justify-content: space-between;
  328. height: 90rpx;
  329. padding: 0 20rpx;
  330. padding-top: var(--status-bar-height);
  331. background-color: #ffffff;
  332. position: sticky;
  333. top: 0;
  334. height: calc(90rpx + var(--status-bar-height));
  335. z-index: 100;
  336. .navbar-left {
  337. height: 80rpx;
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. .fa-angle-left {
  342. font-size: 48rpx;
  343. color: #333;
  344. }
  345. }
  346. .navbar-center {
  347. .navbar-title {
  348. max-width: 450rpx;
  349. font-family: "PingFang SC-Bold";
  350. font-weight: 400;
  351. font-size: 32rpx;
  352. color: #1f1f1f;
  353. padding-left: 20rpx;
  354. }
  355. }
  356. .navbar-right {
  357. width: 80rpx;
  358. height: 80rpx;
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. .fa-ellipsis-h {
  363. font-size: 36rpx;
  364. color: #333;
  365. }
  366. }
  367. }
  368. .tabs-reserveaseat{
  369. width: 100vw;
  370. height: 72rpx;
  371. }
  372. .tabs-section {
  373. background: #fff;
  374. position: fixed;
  375. top: calc(90rpx + var(--status-bar-height));
  376. left: 0;
  377. border-bottom: 6rpx solid #f6faf6;
  378. z-index: 100;
  379. .tabs-scroll-view {
  380. width: 100vw;
  381. box-sizing: border-box;
  382. padding-left: 50rpx;
  383. .tabs-wrapper {
  384. display: flex;
  385. flex-direction: row;
  386. align-items: center;
  387. height: 72rpx;
  388. .tab {
  389. position: relative;
  390. width: auto;
  391. height: 48rpx;
  392. font-size: 32rpx;
  393. font-family: "PingFang SC-Bold";
  394. color: #999;
  395. font-weight: 400;
  396. transition: all 0.5s;
  397. margin-right: 40rpx;
  398. .left {
  399. white-space: nowrap;
  400. display: inline-block;
  401. }
  402. ::after {
  403. content: "";
  404. position: absolute;
  405. right: -15rpx;
  406. top: 0;
  407. width: 96rpx;
  408. height: 48rpx;
  409. background-image: url("../../static/me/wd_img_qiehuan.png");
  410. background-size: auto 100%;
  411. background-repeat: no-repeat;
  412. opacity: 0;
  413. }
  414. &.active {
  415. color: #1f1f1f;
  416. text {
  417. font-family: "PingFang SC-Bold";
  418. }
  419. ::after {
  420. opacity: 0.7;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. .order-list {
  428. padding: 0 0 32rpx 0;
  429. .order-card {
  430. background: #fff;
  431. border-radius: 18rpx;
  432. margin: 32rpx 24rpx 0 24rpx;
  433. padding: 24rpx;
  434. .order-header {
  435. display: flex;
  436. align-items: center;
  437. margin-bottom: 12rpx;
  438. .project-title {
  439. font-size: 28rpx;
  440. font-weight: bold;
  441. color: #1f1f1f;
  442. margin-right: 40rpx;
  443. }
  444. .tag-initiator {
  445. font-size: 20rpx;
  446. color: #b6ff4b;
  447. background: #1f1f1f;
  448. border-radius: 8rpx;
  449. padding: 2rpx 12rpx;
  450. margin-right: 12rpx;
  451. }
  452. .order-status {
  453. font-size: 24rpx;
  454. margin-left: auto;
  455. white-space: nowrap;
  456. &.status-waitPay {
  457. color: #888;
  458. }
  459. &.status-paid {
  460. color: #1f1f1f;
  461. }
  462. &.status-waitSend {
  463. color: #888;
  464. }
  465. &.status-waitReceive {
  466. color: #888;
  467. }
  468. &.status-waitComment {
  469. color: #ff9900;
  470. }
  471. &.status-refund {
  472. color: #1f1f1f;
  473. }
  474. &.status-finish {
  475. color: #888;
  476. }
  477. }
  478. }
  479. .order-main {
  480. display: flex;
  481. align-items: center;
  482. margin-bottom: 12rpx;
  483. .order-img {
  484. width: 120rpx;
  485. height: 120rpx;
  486. border-radius: 12rpx;
  487. margin-right: 18rpx;
  488. }
  489. .order-info {
  490. flex: 1;
  491. .order-title {
  492. font-size: 28rpx;
  493. color: #1f1f1f;
  494. font-weight: bold;
  495. margin-bottom: 8rpx;
  496. }
  497. .order-spec {
  498. font-size: 24rpx;
  499. color: #888;
  500. }
  501. }
  502. .order-price {
  503. text-align: right;
  504. view {
  505. font-size: 28rpx;
  506. color: #1f1f1f;
  507. }
  508. .order-count {
  509. font-size: 22rpx;
  510. color: #888;
  511. }
  512. }
  513. }
  514. .order-actions {
  515. display: flex;
  516. align-items: center;
  517. justify-content: flex-end;
  518. gap: 18rpx;
  519. .btn {
  520. min-width: 120rpx;
  521. height: 56rpx;
  522. line-height: 56rpx;
  523. border-radius: 32rpx;
  524. text-align: center;
  525. font-size: 26rpx;
  526. padding: 0 24rpx;
  527. background: #f6faf6;
  528. color: #1f1f1f;
  529. border: 2rpx solid #e5e5e5;
  530. &.btn-pay {
  531. background: #1f1f1f;
  532. color: #acf934;
  533. border: none;
  534. }
  535. &.btn-delete {
  536. background: #f6faf6;
  537. color: #888;
  538. border: 2rpx solid #e5e5e5;
  539. }
  540. &.btn-cancel {
  541. background: #f6faf6;
  542. color: #888;
  543. border: 2rpx solid #e5e5e5;
  544. }
  545. &.btn-remind {
  546. background: #fffbe6;
  547. color: #1f1f1f;
  548. border: 2rpx solid #ffe58f;
  549. }
  550. &.btn-confirm {
  551. background: #1f1f1f;
  552. color: #acf934;
  553. border: none;
  554. }
  555. &.btn-comment {
  556. background: #fff;
  557. color: #1f1f1f;
  558. border: 2rpx solid #e5e5e5;
  559. }
  560. &.btn-refund {
  561. background: #fff;
  562. color: #1f1f1f;
  563. border: 2rpx solid #e5e5e5;
  564. }
  565. }
  566. }
  567. }
  568. }
  569. .order-swiper {
  570. width: 100vw;
  571. background: transparent;
  572. transition: height 0.3s;
  573. }
  574. }
  575. </style>