orderList.vue 15 KB

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