orderList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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="showActionSheet">
  14. <image
  15. src="@/static/icon/more2.png"
  16. style="width: 64rpx; height: 64rpx; 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">{{ 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. goBack() {
  163. uni.navigateBack();
  164. },
  165. switchTab(index) {
  166. this.currentTab = index;
  167. },
  168. onSwiperChange(e) {
  169. this.currentTab = e.detail.current;
  170. this.$nextTick(() => {
  171. this.updateSwiperHeight();
  172. });
  173. },
  174. getOrdersByTab(type) {
  175. if (type === "all") return this.orderList;
  176. return this.orderList.filter((o) => o.statusType === type);
  177. },
  178. updateSwiperHeight() {
  179. // 动态获取当前swiper-item内容高度
  180. this.$nextTick(() => {
  181. const query = uni.createSelectorQuery().in(this);
  182. query
  183. .selectAll(".order-list")
  184. .boundingClientRect((rects) => {
  185. if (rects && rects[this.currentTab]) {
  186. this.swiperHeight = rects[this.currentTab].height || 600;
  187. }
  188. })
  189. .exec();
  190. });
  191. },
  192. goToOrderDetail(order) {
  193. uni.navigateTo({
  194. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  195. });
  196. },
  197. pay(order) {
  198. uni.navigateTo({
  199. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  200. });
  201. /* 支付逻辑 */
  202. },
  203. deleteOrder(order) {
  204. /* 删除逻辑 */
  205. uni.navigateTo({
  206. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  207. });
  208. },
  209. cancelOrder(order) {
  210. /* 取消/退款逻辑 */
  211. uni.navigateTo({
  212. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  213. });
  214. },
  215. confirmReceive(order) {
  216. /* 确认收货逻辑 */
  217. uni.navigateTo({
  218. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  219. });
  220. },
  221. commentOrder(order) {
  222. /* 评价逻辑 */
  223. uni.navigateTo({
  224. url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
  225. });
  226. },
  227. getdataList() {
  228. uni.request({
  229. url: this.$apiHost + '/Order/getlist?type=buyCrowdfund',
  230. data:{
  231. uuid: getApp().globalData.uuid,
  232. skey: getApp().globalData.skey,
  233. },
  234. method: 'GET',
  235. success: (res) => {
  236. console.log(res.data.list, "获取订单");
  237. this.orderList = res.data.list.map(order => {
  238. let statusType = '';
  239. let statusText = '';
  240. switch (order.status) {
  241. case 0:
  242. statusType = 'waitPay';
  243. statusText = '待支付';
  244. break;
  245. case 1:
  246. statusType = 'paid';
  247. statusText = '已付款待发货';
  248. break;
  249. case 2:
  250. statusType = 'waitReceive';
  251. statusText = '商品已发货';
  252. break;
  253. case 3:
  254. statusType = 'finish';
  255. statusText = '已收货';
  256. break;
  257. case 5:
  258. statusType = 'finish';
  259. statusText = '交易完成';
  260. break;
  261. case 6:
  262. statusType = 'refund';
  263. statusText = '退款中';
  264. break;
  265. case 8:
  266. statusType = 'payFail';
  267. statusText = '已关闭';
  268. break;
  269. case 9:
  270. statusType = 'finish';
  271. statusText = '已完成';
  272. break;
  273. default:
  274. statusType = 'waitPay';
  275. statusText = '待支付';
  276. }
  277. return {
  278. ...order,
  279. statusType,
  280. statusText,
  281. projectTitle: order.name,
  282. title: order.name,
  283. spec: order.name2,
  284. img: order.image,
  285. price: order.money,
  286. count: order.num,
  287. isInitiator: false
  288. };
  289. });
  290. },
  291. fail: () => {
  292. uni.showToast({ title: '获取订单失败', icon: 'none' });
  293. },
  294. complete: () => {
  295. this.updateSwiperHeight();
  296. }
  297. });
  298. },
  299. },
  300. mounted() {
  301. this.updateSwiperHeight();
  302. },
  303. watch: {
  304. currentTab() {
  305. this.$nextTick(() => {
  306. this.updateSwiperHeight();
  307. });
  308. },
  309. },
  310. };
  311. </script>
  312. <style lang="scss">
  313. .order-list-page {
  314. min-height: 100vh;
  315. background: #f6faf6;
  316. .custom-navbar {
  317. display: flex;
  318. flex-direction: row;
  319. align-items: center;
  320. justify-content: space-between;
  321. height: 90rpx;
  322. padding: 0 20rpx;
  323. padding-top: var(--status-bar-height);
  324. background-color: #ffffff;
  325. position: sticky;
  326. top: 0;
  327. height: calc(90rpx + var(--status-bar-height));
  328. z-index: 100;
  329. .navbar-left {
  330. height: 80rpx;
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. .fa-angle-left {
  335. font-size: 48rpx;
  336. color: #333;
  337. }
  338. }
  339. .navbar-center {
  340. .navbar-title {
  341. max-width: 450rpx;
  342. font-family: "PingFang SC-Bold";
  343. font-weight: 400;
  344. font-size: 32rpx;
  345. color: #1f1f1f;
  346. padding-left: 20rpx;
  347. }
  348. }
  349. .navbar-right {
  350. width: 80rpx;
  351. height: 80rpx;
  352. display: flex;
  353. justify-content: center;
  354. align-items: center;
  355. .fa-ellipsis-h {
  356. font-size: 36rpx;
  357. color: #333;
  358. }
  359. }
  360. }
  361. .tabs-reserveaseat{
  362. width: 100vw;
  363. height: 72rpx;
  364. }
  365. .tabs-section {
  366. background: #fff;
  367. position: fixed;
  368. top: calc(90rpx + var(--status-bar-height));
  369. left: 0;
  370. border-bottom: 6rpx solid #f6faf6;
  371. z-index: 100;
  372. .tabs-scroll-view {
  373. width: 100vw;
  374. box-sizing: border-box;
  375. padding-left: 50rpx;
  376. .tabs-wrapper {
  377. display: flex;
  378. flex-direction: row;
  379. align-items: center;
  380. height: 72rpx;
  381. .tab {
  382. position: relative;
  383. width: auto;
  384. height: 48rpx;
  385. font-size: 32rpx;
  386. font-family: "PingFang SC-Bold";
  387. color: #999;
  388. font-weight: 400;
  389. transition: all 0.5s;
  390. margin-right: 40rpx;
  391. .left {
  392. white-space: nowrap;
  393. display: inline-block;
  394. }
  395. ::after {
  396. content: "";
  397. position: absolute;
  398. right: -15rpx;
  399. top: 0;
  400. width: 96rpx;
  401. height: 48rpx;
  402. background-image: url("../../static/me/wd_img_qiehuan.png");
  403. background-size: auto 100%;
  404. background-repeat: no-repeat;
  405. opacity: 0;
  406. }
  407. &.active {
  408. color: #1f1f1f;
  409. text {
  410. font-family: "PingFang SC-Bold";
  411. }
  412. ::after {
  413. opacity: 0.7;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. .order-list {
  421. padding: 0 0 32rpx 0;
  422. .order-card {
  423. background: #fff;
  424. border-radius: 18rpx;
  425. margin: 32rpx 24rpx 0 24rpx;
  426. padding: 24rpx;
  427. .order-header {
  428. display: flex;
  429. align-items: center;
  430. margin-bottom: 12rpx;
  431. .project-title {
  432. font-size: 28rpx;
  433. font-weight: bold;
  434. color: #1f1f1f;
  435. margin-right: 12rpx;
  436. }
  437. .tag-initiator {
  438. font-size: 20rpx;
  439. color: #b6ff4b;
  440. background: #1f1f1f;
  441. border-radius: 8rpx;
  442. padding: 2rpx 12rpx;
  443. margin-right: 12rpx;
  444. }
  445. .order-status {
  446. font-size: 24rpx;
  447. margin-left: auto;
  448. &.status-waitPay {
  449. color: #888;
  450. }
  451. &.status-paid {
  452. color: #1f1f1f;
  453. }
  454. &.status-waitSend {
  455. color: #888;
  456. }
  457. &.status-waitReceive {
  458. color: #888;
  459. }
  460. &.status-waitComment {
  461. color: #ff9900;
  462. }
  463. &.status-refund {
  464. color: #1f1f1f;
  465. }
  466. &.status-finish {
  467. color: #888;
  468. }
  469. }
  470. }
  471. .order-main {
  472. display: flex;
  473. align-items: center;
  474. margin-bottom: 12rpx;
  475. .order-img {
  476. width: 120rpx;
  477. height: 120rpx;
  478. border-radius: 12rpx;
  479. margin-right: 18rpx;
  480. }
  481. .order-info {
  482. flex: 1;
  483. .order-title {
  484. font-size: 28rpx;
  485. color: #1f1f1f;
  486. font-weight: bold;
  487. margin-bottom: 8rpx;
  488. }
  489. .order-spec {
  490. font-size: 24rpx;
  491. color: #888;
  492. }
  493. }
  494. .order-price {
  495. text-align: right;
  496. view {
  497. font-size: 28rpx;
  498. color: #1f1f1f;
  499. }
  500. .order-count {
  501. font-size: 22rpx;
  502. color: #888;
  503. }
  504. }
  505. }
  506. .order-actions {
  507. display: flex;
  508. align-items: center;
  509. justify-content: flex-end;
  510. gap: 18rpx;
  511. .btn {
  512. min-width: 120rpx;
  513. height: 56rpx;
  514. line-height: 56rpx;
  515. border-radius: 32rpx;
  516. text-align: center;
  517. font-size: 26rpx;
  518. padding: 0 24rpx;
  519. background: #f6faf6;
  520. color: #1f1f1f;
  521. border: 2rpx solid #e5e5e5;
  522. &.btn-pay {
  523. background: #1f1f1f;
  524. color: #acf934;
  525. border: none;
  526. }
  527. &.btn-delete {
  528. background: #f6faf6;
  529. color: #888;
  530. border: 2rpx solid #e5e5e5;
  531. }
  532. &.btn-cancel {
  533. background: #f6faf6;
  534. color: #888;
  535. border: 2rpx solid #e5e5e5;
  536. }
  537. &.btn-remind {
  538. background: #fffbe6;
  539. color: #1f1f1f;
  540. border: 2rpx solid #ffe58f;
  541. }
  542. &.btn-confirm {
  543. background: #1f1f1f;
  544. color: #acf934;
  545. border: none;
  546. }
  547. &.btn-comment {
  548. background: #fff;
  549. color: #1f1f1f;
  550. border: 2rpx solid #e5e5e5;
  551. }
  552. &.btn-refund {
  553. background: #fff;
  554. color: #1f1f1f;
  555. border: 2rpx solid #e5e5e5;
  556. }
  557. }
  558. }
  559. }
  560. }
  561. .order-swiper {
  562. width: 100vw;
  563. background: transparent;
  564. transition: height 0.3s;
  565. }
  566. }
  567. </style>