123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 |
- <template>
- <view class="order-list-page">
- <!-- 顶部自定义导航栏 -->
- <view class="custom-navbar">
- <view class="navbar-left">
- <text class="fa fa-angle-left" @click="goBack"></text>
- </view>
- <view class="navbar-center">
- <view class="navbar-title one-omit">
- 订单
- </view>
- </view>
- <view class="navbar-right" @click="goPages('/pages/crowdFunding/searchOrder')">
- <image
- src="@/static/crowdFunding/search2.png"
- style="width: 40rpx; height: 40rpx; margin-top: 15rpx"
- mode="widthFix"
- ></image>
- </view>
- </view>
- <!-- Tab导航 -->
- <view class="tabs-section">
- <scroll-view
- scroll-x
- class="tabs-scroll-view"
- :show-scrollbar="false"
- :scroll-into-view="'tab-' + (currentTab - 1)"
- scroll-with-animation
- >
- <view class="tabs-wrapper">
- <view
- v-for="(tab, index) in tabs"
- :key="index"
- :id="'tab-' + index"
- :class="['tab-item', currentTab === index ? 'active' : '']"
- @click="switchTab(index)"
- >
- <view class="tab" :class="{ active: currentTab === index }">
- <text class="left">{{ tab.name }}</text>
- <view class="line"></view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="tabs-reserveaseat"></view>
- <!-- Swiper订单列表 -->
- <swiper
- :current="currentTab"
- @change="onSwiperChange"
- class="order-swiper"
- :style="'height:' + swiperHeight + 'px'"
- >
- <swiper-item v-for="tab in tabs" :key="tab.type">
- <view class="order-list">
- <view
- class="order-card"
- v-for="order in getOrdersByTab(tab.type)"
- :key="order.id"
- >
- <view class="order-header">
- <text class="project-title one-omit">{{ order.projectTitle }}</text>
- <text class="tag-initiator" v-if="order.isInitiator">发起人</text>
- <text
- class="order-status"
- :class="'status-' + order.statusType"
- >{{ order.statusText }}</text
- >
- </view>
- <view class="order-main" @click="goToOrderDetail(order)">
- <image class="order-img" :src="order.img" />
- <view class="order-info">
- <view class="order-title">{{ order.title }}</view>
- <view class="order-spec">{{ order.spec }}</view>
- </view>
- <view class="order-price">
- <view>¥{{ order.price }}</view>
- <view class="order-count">x{{ order.count }}</view>
- </view>
- </view>
- <view class="order-actions">
- <!-- 1. 支付失败 -->
- <template v-if="order.statusType === 'payFail'">
- <view class="btn btn-delete" @click="deleteOrder(order)"
- >删除订单</view
- >
- </template>
- <!-- 2. 待支付 -->
- <template v-else-if="order.statusType === 'waitPay'">
- <view class="btn btn-pay" @click="pay(order)">立即支付</view>
- <view class="btn btn-cancel" @click="cancelOrder(order)"
- >取消订单</view
- >
- </template>
- <!-- 3. 已付款待发货 -->
- <template v-else-if="order.statusType === 'paid'">
- <view class="btn btn-cancel" @click="cancelOrder(order)"
- >取消订单</view
- >
- </template>
- <!-- 4. 商品已发货 -->
- <template v-else-if="order.statusType === 'waitReceive'">
- <view class="btn btn-confirm" @click="confirmReceive(order)"
- >确认收货</view
- >
- </template>
- <!-- 5. 交易完成 -->
- <template v-else-if="order.statusType === 'finish'">
- <!-- <view class="btn btn-comment" @click="commentOrder(order)">去评价</view> -->
- <view class="btn btn-delete" @click="deleteOrder(order)"
- >删除订单</view
- >
- </template>
- <!-- 6. 已退款 -->
- <template v-else-if="order.statusType === 'refund'">
- <view class="btn btn-delete" @click="deleteOrder(order)"
- >删除订单</view
- >
- </template>
- </view>
- </view>
- </view>
- </swiper-item>
- </swiper>
- <DialogBox ref="DialogBox"></DialogBox>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- currentTab: 0,
- tabs: [
- { name: "全部", type: "all" },
- { name: "待支付", type: "waitPay" },
- // { name: "已付款", type: "paid" },
- { name: "待发货", type: "waitSend" },
- { name: "待收货", type: "waitReceive" },
- { name: "交易完成", type: "finish" },
- { name: "退款中", type: "refund" },
- { name: "已关闭", type: "payFail" },
- ],
- orderList: [],
- swiperHeight: 600, // 默认高度,后续可动态调整
- };
- },
- onLoad() {
- // this.getdataList();
- },
- onShow() {
- this.getdataList();
- },
- computed: {
- filteredOrders() {
- if (this.tabs[this.currentTab].type === "all") return this.orderList;
- return this.orderList.filter(
- (o) => o.statusType === this.tabs[this.currentTab].type
- );
- },
- },
- methods: {
- goPages(url) {
- uni.navigateTo({
- url: url,
- });
- },
- goBack() {
- uni.navigateBack();
- },
- switchTab(index) {
- this.currentTab = index;
- // 切换标签时刷新数据
- this.getdataList();
- },
- onSwiperChange(e) {
- this.currentTab = e.detail.current;
- this.$nextTick(() => {
- this.updateSwiperHeight();
- });
- },
- getOrdersByTab(type) {
- if (type === "all") return this.orderList;
- return this.orderList.filter((o) => o.statusType === type);
- },
- updateSwiperHeight() {
- // 动态获取当前swiper-item内容高度
- this.$nextTick(() => {
- const query = uni.createSelectorQuery().in(this);
- query
- .selectAll(".order-list")
- .boundingClientRect((rects) => {
- if (rects && rects[this.currentTab]) {
- this.swiperHeight = rects[this.currentTab].height || 600;
- }
- })
- .exec();
- });
- },
- goToOrderDetail(order) {
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- },
- pay(order) {
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- /* 支付逻辑 */
- },
- deleteOrder(order) {
- /* 删除逻辑 */
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- },
- cancelOrder(order) {
- /* 取消/退款逻辑 */
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- },
- confirmReceive(order) {
- /* 确认收货逻辑 */
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- },
- commentOrder(order) {
- /* 评价逻辑 */
- uni.navigateTo({
- url: "/pages/crowdFunding/orderDetail?orderId=" + order.id,
- });
- },
- getdataList() {
- uni.request({
- url: this.$apiHost + '/Order/getlist?type=buyCrowdfund',
- data:{
- uuid: getApp().globalData.uuid,
- skey: getApp().globalData.skey,
- },
- method: 'GET',
- success: (res) => {
- console.log(res.data.list, "获取订单");
- this.orderList = res.data.list.map(order => {
- let statusType = '';
- let statusText = '';
- switch (order.status) {
- case 0:
- statusType = 'waitPay';
- statusText = '待支付';
- break;
- case 1:
- statusType = 'waitSend';
- statusText = '待发货';
- break;
- case 2:
- statusType = 'waitReceive';
- statusText = '商品已发货';
- break;
- case 3:
- statusType = 'finish';
- statusText = '已收货';
- break;
- case 5:
- statusType = 'finish';
- statusText = '交易完成';
- break;
- case 6:
- statusType = 'refund';
- statusText = '退款中';
- break;
- case 8:
- statusType = 'payFail';
- statusText = '已关闭';
- break;
- case 9:
- statusType = 'finish';
- statusText = '已完成';
- break;
- default:
- statusType = 'waitPay';
- statusText = '待支付';
- }
- return {
- ...order,
- statusType,
- statusText,
- projectTitle: order.name,
- title: order.name,
- spec: order.name2,
- img: order.image,
- price: order.money,
- count: order.num,
- isInitiator: false
- };
- });
- },
- fail: () => {
- uni.showToast({ title: '获取订单失败', icon: 'none' });
- },
- complete: () => {
- this.updateSwiperHeight();
- }
- });
- },
- },
- mounted() {
- this.updateSwiperHeight();
- },
- watch: {
- currentTab() {
- this.$nextTick(() => {
- this.updateSwiperHeight();
- });
- },
- },
- };
- </script>
- <style lang="scss">
- .order-list-page {
- min-height: 100vh;
- background: #f6faf6;
- .custom-navbar {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- height: 90rpx;
- padding: 0 20rpx;
- padding-top: var(--status-bar-height);
- background-color: #ffffff;
- position: sticky;
- top: 0;
- height: calc(90rpx + var(--status-bar-height));
- z-index: 100;
- .navbar-left {
- height: 80rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- .fa-angle-left {
- font-size: 48rpx;
- color: #333;
- }
- }
- .navbar-center {
- .navbar-title {
- max-width: 450rpx;
- font-family: "PingFang SC-Bold";
- font-weight: 400;
- font-size: 32rpx;
- color: #1f1f1f;
- padding-left: 20rpx;
- }
- }
- .navbar-right {
- width: 80rpx;
- height: 80rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- .fa-ellipsis-h {
- font-size: 36rpx;
- color: #333;
- }
- }
- }
- .tabs-reserveaseat{
- width: 100vw;
- height: 72rpx;
- }
- .tabs-section {
- background: #fff;
- position: fixed;
- top: calc(90rpx + var(--status-bar-height));
- left: 0;
- border-bottom: 6rpx solid #f6faf6;
- z-index: 100;
- .tabs-scroll-view {
- width: 100vw;
- box-sizing: border-box;
- padding-left: 50rpx;
- .tabs-wrapper {
- display: flex;
- flex-direction: row;
- align-items: center;
- height: 72rpx;
- .tab {
- position: relative;
- width: auto;
- height: 48rpx;
- font-size: 32rpx;
- font-family: "PingFang SC-Bold";
- color: #999;
- font-weight: 400;
- transition: all 0.5s;
- margin-right: 40rpx;
- .left {
- white-space: nowrap;
- display: inline-block;
- }
- ::after {
- content: "";
- position: absolute;
- right: -15rpx;
- top: 0;
- width: 96rpx;
- height: 48rpx;
- background-image: url("../../static/me/wd_img_qiehuan.png");
- background-size: auto 100%;
- background-repeat: no-repeat;
- opacity: 0;
- }
- &.active {
- color: #1f1f1f;
- text {
- font-family: "PingFang SC-Bold";
- }
- ::after {
- opacity: 0.7;
- }
- }
- }
- }
- }
- }
- .order-list {
- padding: 0 0 32rpx 0;
- .order-card {
- background: #fff;
- border-radius: 18rpx;
- margin: 32rpx 24rpx 0 24rpx;
- padding: 24rpx;
- .order-header {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- .project-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #1f1f1f;
- margin-right: 40rpx;
- }
- .tag-initiator {
- font-size: 20rpx;
- color: #b6ff4b;
- background: #1f1f1f;
- border-radius: 8rpx;
- padding: 2rpx 12rpx;
- margin-right: 12rpx;
- }
- .order-status {
- font-size: 24rpx;
- margin-left: auto;
- white-space: nowrap;
- &.status-waitPay {
- color: #888;
- }
- &.status-paid {
- color: #1f1f1f;
- }
- &.status-waitSend {
- color: #888;
- }
- &.status-waitReceive {
- color: #888;
- }
- &.status-waitComment {
- color: #ff9900;
- }
- &.status-refund {
- color: #1f1f1f;
- }
- &.status-finish {
- color: #888;
- }
- }
- }
- .order-main {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- .order-img {
- width: 120rpx;
- height: 120rpx;
- border-radius: 12rpx;
- margin-right: 18rpx;
- }
- .order-info {
- flex: 1;
- .order-title {
- font-size: 28rpx;
- color: #1f1f1f;
- font-weight: bold;
- margin-bottom: 8rpx;
- }
- .order-spec {
- font-size: 24rpx;
- color: #888;
- }
- }
- .order-price {
- text-align: right;
- view {
- font-size: 28rpx;
- color: #1f1f1f;
- }
- .order-count {
- font-size: 22rpx;
- color: #888;
- }
- }
- }
- .order-actions {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 18rpx;
- .btn {
- min-width: 120rpx;
- height: 56rpx;
- line-height: 56rpx;
- border-radius: 32rpx;
- text-align: center;
- font-size: 26rpx;
- padding: 0 24rpx;
- background: #f6faf6;
- color: #1f1f1f;
- border: 2rpx solid #e5e5e5;
- &.btn-pay {
- background: #1f1f1f;
- color: #acf934;
- border: none;
- }
- &.btn-delete {
- background: #f6faf6;
- color: #888;
- border: 2rpx solid #e5e5e5;
- }
- &.btn-cancel {
- background: #f6faf6;
- color: #888;
- border: 2rpx solid #e5e5e5;
- }
- &.btn-remind {
- background: #fffbe6;
- color: #1f1f1f;
- border: 2rpx solid #ffe58f;
- }
- &.btn-confirm {
- background: #1f1f1f;
- color: #acf934;
- border: none;
- }
- &.btn-comment {
- background: #fff;
- color: #1f1f1f;
- border: 2rpx solid #e5e5e5;
- }
- &.btn-refund {
- background: #fff;
- color: #1f1f1f;
- border: 2rpx solid #e5e5e5;
- }
- }
- }
- }
- }
- .order-swiper {
- width: 100vw;
- background: transparent;
- transition: height 0.3s;
- }
- }
- </style>
|