| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- <template>
- <view class="list-page-container">
- <!-- 1. 自定义顶部导航:彻底抹除红框1的原生蓝线 -->
- <view class="custom-nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
- <view class="nav-content">
- <view class="back-icon" @click="goBack">
- <view class="arrow-left"></view>
- </view>
- <text class="nav-title">全部订单</text>
- <view class="placeholder-right"></view>
- </view>
- </view>
- <!-- 2. 分类切换:使用翻译位移,彻底消除红框2残影 -->
- <view class="tabs-fixed">
- <view class="tabs-box">
- <view v-for="(tab, index) in tabs" :key="index" class="tab-item"
- :class="{ active: currentTab === index }" @click="switchTab(index)">
- <text class="tab-txt">{{ tab }}</text>
- </view>
- <!-- 指示器:只负责位移,不负责显隐,彻底杜绝虚影 -->
- <view class="indicator-track">
- <view class="indicator-bar" :style="{ transform: 'translateX(' + (currentTab * 100) + '%)' }">
- <view class="bar-inner"></view>
- </view>
- </view>
- </view>
- </view>
- <!-- 3. 固定高度的滚动区:强制启用滚动,解决不能滑动问题 -->
- <scroll-view scroll-y class="order-scroll-view" :style="{ height: scrollHeight }" @scrolltolower="onReachEnd"
- :refresher-enabled="false" :show-scrollbar="false">
- <view class="order-list-inner">
- <view class="order-card" v-for="(item, index) in displayList" :key="index" @click="goDetail(item)">
- <view class="card-head">
- <text class="order-id">单号:{{ item.orderNo }}</text>
- <view class="status-badge" :class="item.statusType">{{ item.statusName }}</view>
- </view>
- <view class="card-body">
- <view class="model-row" v-for="(model, mIdx) in item.models.slice(0, 2)" :key="mIdx">
- <text class="m-type">{{ model.type }}</text>
- <text class="m-spec">{{ model.surface }} | {{ model.length }}mm</text>
- <text class="m-count">{{ model.count }} 支</text>
- </view>
- <view class="more-hint" v-if="item.models.length > 2">
- <text>查看更多 {{ item.models.length - 2 }} 个型号...</text>
- </view>
- <view class="total-summary">
- <text class="summary-label">共计:</text>
- <text class="summary-val">{{ item.models.length }}</text>
- <text class="summary-unit">个型号</text>
- <view class="summary-split"></view>
- <text class="summary-val highlight">{{ item.totalCount }}</text>
- <text class="summary-unit">支</text>
- </view>
- </view>
- <view class="card-foot">
- <text class="time">{{ item.time }}</text>
- <view class="btns">
- <view class="btn-cancel" v-if="item.status === 1" @click.stop="onCancel(item)">撤销</view>
- <view class="btn-view primary" @click.stop="goDetail(item)">订单详情</view>
- </view>
- </view>
- </view>
- <!-- 加载提示区 -->
- <view class="list-status-info" v-if="displayList.length > 0">
- <view class="loading-wrap" v-if="loading">
- <view class="load-dot"></view><text>排队加载中...</text>
- </view>
- <view class="nomore-wrap" v-if="noMore">
- <text class="nomore-line"></text>
- <text class="nomore-text">已加载全部数据</text>
- <text class="nomore-line"></text>
- </view>
- </view>
- <!-- 缺省态 -->
- <view class="empty-state" v-if="displayList.length === 0 && !loading">
- <image src="https://img.icons8.com/clouds/200/open-box.png" mode="aspectFit"></image>
- <text>暂无订单记录</text>
- </view>
- <view class="safe-bottom"></view>
- </view>
- </scroll-view>
- <!-- 底部菜单栏 -->
- <erp-tab-bar active="order"></erp-tab-bar>
- </view>
- </template>
- <script>
- import ErpTabBar from '@/components/erp-tab-bar/erp-tab-bar.vue';
- import tabs from '@/json/order-status-tabs.json';
- import mockOrders from '@/mock/orders.json';
- export default {
- components: {
- ErpTabBar
- },
- data() {
- return {
- statusBarHeight: 20,
- navBarHeight: 44,
- tabBarHeight: 50, // 对应 100rpx
- currentTab: 0,
- loading: false,
- noMore: false,
- tabs,
- allOrders: JSON.parse(JSON.stringify(mockOrders)),
- displayList: []
- }
- },
- computed: {
- scrollHeight() {
- // 减去状态栏、导航栏、选项卡的高度
- return `calc(100vh - ${this.statusBarHeight + this.navBarHeight + this.tabBarHeight}px)`;
- }
- },
- onLoad(options) {
- const info = uni.getSystemInfoSync();
- this.statusBarHeight = info.statusBarHeight;
- // 修正选项卡高度(单位px)
- this.tabBarHeight = info.windowWidth / 750 * 110;
- if (options.tab) this.currentTab = parseInt(options.tab);
- this.refresh();
- },
- methods: {
- goBack() { uni.navigateBack(); },
- switchTab(i) { this.currentTab = i; this.refresh(); },
- refresh() { this.displayList = []; this.noMore = false; this.loadData(); },
- onReachEnd() { if (!this.loading && !this.noMore) this.loadData(); },
- loadData() {
- this.loading = true;
- setTimeout(() => {
- let raw = this.currentTab === 0 ? this.allOrders : this.allOrders.filter(o => o.status === this.currentTab);
- this.displayList = [...this.displayList, ...raw];
- this.noMore = true; // 模拟一次性加载完演示数据
- this.loading = false;
- }, 500);
- },
- onCancel(item) {
- uni.showModal({
- title: '确认撤销',
- content: `确认要撤销订单:${item.orderNo} 吗?`,
- confirmColor: '#ff4d4f',
- success: (res) => {
- if (res.confirm) {
- uni.showLoading({ title: '撤销中' });
- setTimeout(() => {
- uni.hideLoading();
- uni.showToast({ title: '已撤销' });
- // 逻辑修复:修改状态而非移除
- const target = this.allOrders.find(o => o.orderNo === item.orderNo);
- if (target) {
- target.status = 0;
- target.statusName = '已撤销';
- target.statusType = 'expired';
- }
- // 再次过滤刷新当前视图
- this.refresh();
- }, 800);
- }
- }
- });
- },
- goDetail(item) {
- const dataStr = encodeURIComponent(JSON.stringify(item));
- uni.navigateTo({
- url: `/pages/order/detail/index?data=${dataStr}`
- });
- }
- }
- }
- </script>
- <style scoped>
- /deep/ ::-webkit-scrollbar {
- display: none !important;
- width: 0 !important;
- height: 0 !important;
- -webkit-appearance: none;
- background: transparent;
- }
- .list-page-container {
- width: 100vw;
- height: 100vh;
- background: #f8fafc;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- }
- /* 1. 自定义导航栏:解决蓝线红框1 */
- .custom-nav-bar {
- background: #ffffff;
- width: 100%;
- flex-shrink: 0;
- }
- .nav-content {
- height: 44px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 30rpx;
- }
- .back-icon {
- width: 60rpx;
- height: 44px;
- display: flex;
- align-items: center;
- }
- .arrow-left {
- width: 20rpx;
- height: 20rpx;
- border-left: 4rpx solid #333;
- border-bottom: 4rpx solid #333;
- transform: rotate(45deg);
- margin-left: 10rpx;
- }
- .nav-title {
- font-size: 34rpx;
- font-weight: bold;
- color: #1a1a1a;
- }
- .placeholder-right {
- width: 60rpx;
- }
- /* 2. 选项卡:解决残影红框2 */
- .tabs-fixed {
- background: #fff;
- width: 100%;
- flex-shrink: 0;
- border-bottom: 1rpx solid #f0f0f0;
- }
- .tabs-box {
- height: 110rpx;
- position: relative;
- display: flex;
- width: 100%;
- }
- .tab-item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 5;
- }
- .tab-txt {
- font-size: 28rpx;
- color: #888;
- transition: all 0.2s;
- }
- .tab-item.active .tab-txt {
- color: #C1001C;
- font-weight: bold;
- font-size: 32rpx;
- }
- /* 指示器轨道:通过位移消除虚影 */
- .indicator-track {
- position: absolute;
- bottom: 10rpx;
- left: 0;
- width: 100%;
- height: 6rpx;
- display: flex;
- }
- .indicator-bar {
- width: 20%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
- }
- .bar-inner {
- width: 40rpx;
- height: 100%;
- background: #C1001C;
- border-radius: 6rpx;
- }
- /* 3. 滚动区:解决不可滑动问题 */
- .order-scroll-view {
- width: 100%;
- }
- .order-list-inner {
- padding: 30rpx;
- padding-bottom: 60rpx;
- }
- .order-card {
- background: #fff;
- border-radius: 24rpx;
- padding: 36rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
- }
- .card-head {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .order-id {
- font-size: 28rpx;
- color: #1a1a1a;
- font-weight: bold;
- }
- .status-badge {
- font-size: 20rpx;
- padding: 4rpx 16rpx;
- border-radius: 8rpx;
- }
- .status-badge.pending {
- background: #FFF1F2;
- color: #C1001C;
- }
- .status-badge.expired {
- background: #f5f5f5;
- color: #999;
- }
- .status-badge.process {
- background: #fff7e6;
- color: #ffa940;
- }
- .status-badge.making {
- background: #e6fffb;
- color: #36cfc9;
- }
- /* 已撤销样式 */
- .status-badge.expired {
- background: #f5f5f5;
- color: #999;
- }
- .status-badge.finish {
- background: #f6ffed;
- color: #52c41a;
- }
- .card-body {
- padding: 24rpx 0;
- border-top: 1rpx dashed #f0f0f0;
- margin-bottom: 24rpx;
- }
- .model-row {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- font-size: 24rpx;
- }
- .m-type {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- width: 140rpx;
- }
- .m-spec {
- color: #888;
- flex: 1;
- padding: 0 20rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .m-count {
- color: #555;
- width: 100rpx;
- text-align: right;
- font-weight: 500;
- }
- .more-hint {
- padding: 10rpx 0;
- font-size: 24rpx;
- color: #999;
- text-align: center;
- background: #fafafa;
- border-radius: 8rpx;
- margin-bottom: 16rpx;
- }
- .total-summary {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- padding-top: 20rpx;
- border-top: 1rpx solid #fafafa;
- }
- .summary-label {
- font-size: 24rpx;
- color: #999;
- }
- .summary-val {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin: 0 4rpx;
- }
- .summary-val.highlight {
- color: #C1001C;
- }
- .summary-unit {
- font-size: 22rpx;
- color: #999;
- margin-right: 12rpx;
- }
- .summary-split {
- width: 1rpx;
- height: 20rpx;
- background: #eee;
- margin: 0 16rpx;
- }
- .card-foot {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-top: 10rpx;
- }
- .time {
- font-size: 24rpx;
- color: #bbb;
- }
- .btns {
- display: flex;
- gap: 16rpx;
- }
- .btn-cancel,
- .btn-view {
- padding: 12rpx 30rpx;
- border-radius: 30rpx;
- font-size: 24rpx;
- }
- .btn-cancel {
- border: 1rpx solid #ddd;
- color: #666;
- }
- .btn-view.primary {
- background: #C1001C;
- color: #fff;
- }
- .list-status-info {
- padding: 40rpx 0;
- display: flex;
- justify-content: center;
- }
- .nomore-wrap {
- display: flex;
- align-items: center;
- color: #ccc;
- font-size: 24rpx;
- }
- .nomore-line {
- width: 40rpx;
- height: 1rpx;
- background: #eee;
- margin: 0 20rpx;
- }
- .loading-wrap {
- color: #999;
- font-size: 24rpx;
- display: flex;
- align-items: center;
- }
- .load-dot {
- width: 10rpx;
- height: 10rpx;
- background: #C1001C;
- border-radius: 50%;
- margin-right: 10rpx;
- animation: flash 0.6s infinite alternate;
- }
- @keyframes flash {
- from {
- opacity: 0.3;
- }
- to {
- opacity: 1;
- }
- }
- .empty-state {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding-top: 200rpx;
- color: #bbb;
- font-size: 28rpx;
- }
- .empty-state image {
- width: 220rpx;
- height: 220rpx;
- margin-bottom: 30rpx;
- opacity: 0.6;
- }
- .safe-bottom {
- height: 40rpx;
- }
- </style>
|