orderList.vue 15 KB

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