orderList.vue 16 KB

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