index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view class="list-page-container">
  3. <!-- 1. 自定义顶部导航:彻底抹除红框1的原生蓝线 -->
  4. <view class="custom-nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
  5. <view class="nav-content">
  6. <view class="back-icon" @click="goBack">
  7. <view class="arrow-left"></view>
  8. </view>
  9. <text class="nav-title">全部订单</text>
  10. <view class="placeholder-right"></view>
  11. </view>
  12. </view>
  13. <!-- 2. 分类切换:使用翻译位移,彻底消除红框2残影 -->
  14. <view class="tabs-fixed">
  15. <view class="tabs-box">
  16. <view v-for="(tab, index) in tabs" :key="index" class="tab-item"
  17. :class="{ active: currentTab === index }" @click="switchTab(index)">
  18. <text class="tab-txt">{{ tab }}</text>
  19. </view>
  20. <!-- 指示器:只负责位移,不负责显隐,彻底杜绝虚影 -->
  21. <view class="indicator-track">
  22. <view class="indicator-bar" :style="{ transform: 'translateX(' + (currentTab * 100) + '%)' }">
  23. <view class="bar-inner"></view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 3. 固定高度的滚动区:强制启用滚动,解决不能滑动问题 -->
  29. <scroll-view scroll-y class="order-scroll-view" :style="{ height: scrollHeight }" @scrolltolower="onReachEnd"
  30. :refresher-enabled="false" :show-scrollbar="false">
  31. <view class="order-list-inner">
  32. <view class="order-card" v-for="(item, index) in displayList" :key="index" @click="goDetail(item)">
  33. <view class="card-head">
  34. <text class="order-id">单号:{{ item.orderNo }}</text>
  35. <view class="status-badge" :class="item.statusType">{{ item.statusName }}</view>
  36. </view>
  37. <view class="card-body">
  38. <view class="model-row" v-for="(model, mIdx) in item.models.slice(0, 2)" :key="mIdx">
  39. <text class="m-type">{{ model.type }}</text>
  40. <text class="m-spec">{{ model.surface }} | {{ model.length }}mm</text>
  41. <text class="m-count">{{ model.count }} 支</text>
  42. </view>
  43. <view class="more-hint" v-if="item.models.length > 2">
  44. <text>查看更多 {{ item.models.length - 2 }} 个型号...</text>
  45. </view>
  46. <view class="total-summary">
  47. <text class="summary-label">共计:</text>
  48. <text class="summary-val">{{ item.models.length }}</text>
  49. <text class="summary-unit">个型号</text>
  50. <view class="summary-split"></view>
  51. <text class="summary-val highlight">{{ item.totalCount }}</text>
  52. <text class="summary-unit">支</text>
  53. </view>
  54. </view>
  55. <view class="card-foot">
  56. <text class="time">{{ item.time }}</text>
  57. <view class="btns">
  58. <view class="btn-cancel" v-if="item.status === 1" @click.stop="onCancel(item)">撤销</view>
  59. <view class="btn-view primary" @click.stop="goDetail(item)">订单详情</view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 加载提示区 -->
  64. <view class="list-status-info" v-if="displayList.length > 0">
  65. <view class="loading-wrap" v-if="loading">
  66. <view class="load-dot"></view><text>排队加载中...</text>
  67. </view>
  68. <view class="nomore-wrap" v-if="noMore">
  69. <text class="nomore-line"></text>
  70. <text class="nomore-text">已加载全部数据</text>
  71. <text class="nomore-line"></text>
  72. </view>
  73. </view>
  74. <!-- 缺省态 -->
  75. <view class="empty-state" v-if="displayList.length === 0 && !loading">
  76. <image src="https://img.icons8.com/clouds/200/open-box.png" mode="aspectFit"></image>
  77. <text>暂无订单记录</text>
  78. </view>
  79. <view class="safe-bottom"></view>
  80. </view>
  81. </scroll-view>
  82. <!-- 底部菜单栏 -->
  83. <erp-tab-bar active="order"></erp-tab-bar>
  84. </view>
  85. </template>
  86. <script>
  87. import ErpTabBar from '@/components/erp-tab-bar/erp-tab-bar.vue';
  88. import tabs from '@/json/order-status-tabs.json';
  89. import mockOrders from '@/mock/orders.json';
  90. export default {
  91. components: {
  92. ErpTabBar
  93. },
  94. data() {
  95. return {
  96. statusBarHeight: 20,
  97. navBarHeight: 44,
  98. tabBarHeight: 50, // 对应 100rpx
  99. currentTab: 0,
  100. loading: false,
  101. noMore: false,
  102. tabs,
  103. allOrders: JSON.parse(JSON.stringify(mockOrders)),
  104. displayList: []
  105. }
  106. },
  107. computed: {
  108. scrollHeight() {
  109. // 减去状态栏、导航栏、选项卡的高度
  110. return `calc(100vh - ${this.statusBarHeight + this.navBarHeight + this.tabBarHeight}px)`;
  111. }
  112. },
  113. onLoad(options) {
  114. const info = uni.getSystemInfoSync();
  115. this.statusBarHeight = info.statusBarHeight;
  116. // 修正选项卡高度(单位px)
  117. this.tabBarHeight = info.windowWidth / 750 * 110;
  118. if (options.tab) this.currentTab = parseInt(options.tab);
  119. this.refresh();
  120. },
  121. methods: {
  122. goBack() { uni.navigateBack(); },
  123. switchTab(i) { this.currentTab = i; this.refresh(); },
  124. refresh() { this.displayList = []; this.noMore = false; this.loadData(); },
  125. onReachEnd() { if (!this.loading && !this.noMore) this.loadData(); },
  126. loadData() {
  127. this.loading = true;
  128. setTimeout(() => {
  129. let raw = this.currentTab === 0 ? this.allOrders : this.allOrders.filter(o => o.status === this.currentTab);
  130. this.displayList = [...this.displayList, ...raw];
  131. this.noMore = true; // 模拟一次性加载完演示数据
  132. this.loading = false;
  133. }, 500);
  134. },
  135. onCancel(item) {
  136. uni.showModal({
  137. title: '确认撤销',
  138. content: `确认要撤销订单:${item.orderNo} 吗?`,
  139. confirmColor: '#ff4d4f',
  140. success: (res) => {
  141. if (res.confirm) {
  142. uni.showLoading({ title: '撤销中' });
  143. setTimeout(() => {
  144. uni.hideLoading();
  145. uni.showToast({ title: '已撤销' });
  146. // 逻辑修复:修改状态而非移除
  147. const target = this.allOrders.find(o => o.orderNo === item.orderNo);
  148. if (target) {
  149. target.status = 0;
  150. target.statusName = '已撤销';
  151. target.statusType = 'expired';
  152. }
  153. // 再次过滤刷新当前视图
  154. this.refresh();
  155. }, 800);
  156. }
  157. }
  158. });
  159. },
  160. goDetail(item) {
  161. const dataStr = encodeURIComponent(JSON.stringify(item));
  162. uni.navigateTo({
  163. url: `/pages/order/detail/index?data=${dataStr}`
  164. });
  165. }
  166. }
  167. }
  168. </script>
  169. <style scoped>
  170. /deep/ ::-webkit-scrollbar {
  171. display: none !important;
  172. width: 0 !important;
  173. height: 0 !important;
  174. -webkit-appearance: none;
  175. background: transparent;
  176. }
  177. .list-page-container {
  178. width: 100vw;
  179. height: 100vh;
  180. background: #f8fafc;
  181. overflow: hidden;
  182. display: flex;
  183. flex-direction: column;
  184. }
  185. /* 1. 自定义导航栏:解决蓝线红框1 */
  186. .custom-nav-bar {
  187. background: #ffffff;
  188. width: 100%;
  189. flex-shrink: 0;
  190. }
  191. .nav-content {
  192. height: 44px;
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. padding: 0 30rpx;
  197. }
  198. .back-icon {
  199. width: 60rpx;
  200. height: 44px;
  201. display: flex;
  202. align-items: center;
  203. }
  204. .arrow-left {
  205. width: 20rpx;
  206. height: 20rpx;
  207. border-left: 4rpx solid #333;
  208. border-bottom: 4rpx solid #333;
  209. transform: rotate(45deg);
  210. margin-left: 10rpx;
  211. }
  212. .nav-title {
  213. font-size: 34rpx;
  214. font-weight: bold;
  215. color: #1a1a1a;
  216. }
  217. .placeholder-right {
  218. width: 60rpx;
  219. }
  220. /* 2. 选项卡:解决残影红框2 */
  221. .tabs-fixed {
  222. background: #fff;
  223. width: 100%;
  224. flex-shrink: 0;
  225. border-bottom: 1rpx solid #f0f0f0;
  226. }
  227. .tabs-box {
  228. height: 110rpx;
  229. position: relative;
  230. display: flex;
  231. width: 100%;
  232. }
  233. .tab-item {
  234. flex: 1;
  235. display: flex;
  236. align-items: center;
  237. justify-content: center;
  238. z-index: 5;
  239. }
  240. .tab-txt {
  241. font-size: 28rpx;
  242. color: #888;
  243. transition: all 0.2s;
  244. }
  245. .tab-item.active .tab-txt {
  246. color: #C1001C;
  247. font-weight: bold;
  248. font-size: 32rpx;
  249. }
  250. /* 指示器轨道:通过位移消除虚影 */
  251. .indicator-track {
  252. position: absolute;
  253. bottom: 10rpx;
  254. left: 0;
  255. width: 100%;
  256. height: 6rpx;
  257. display: flex;
  258. }
  259. .indicator-bar {
  260. width: 20%;
  261. height: 100%;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  266. }
  267. .bar-inner {
  268. width: 40rpx;
  269. height: 100%;
  270. background: #C1001C;
  271. border-radius: 6rpx;
  272. }
  273. /* 3. 滚动区:解决不可滑动问题 */
  274. .order-scroll-view {
  275. width: 100%;
  276. }
  277. .order-list-inner {
  278. padding: 30rpx;
  279. padding-bottom: 60rpx;
  280. }
  281. .order-card {
  282. background: #fff;
  283. border-radius: 24rpx;
  284. padding: 36rpx;
  285. margin-bottom: 30rpx;
  286. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  287. }
  288. .card-head {
  289. display: flex;
  290. justify-content: space-between;
  291. align-items: center;
  292. margin-bottom: 30rpx;
  293. }
  294. .order-id {
  295. font-size: 28rpx;
  296. color: #1a1a1a;
  297. font-weight: bold;
  298. }
  299. .status-badge {
  300. font-size: 20rpx;
  301. padding: 4rpx 16rpx;
  302. border-radius: 8rpx;
  303. }
  304. .status-badge.pending {
  305. background: #FFF1F2;
  306. color: #C1001C;
  307. }
  308. .status-badge.expired {
  309. background: #f5f5f5;
  310. color: #999;
  311. }
  312. .status-badge.process {
  313. background: #fff7e6;
  314. color: #ffa940;
  315. }
  316. .status-badge.making {
  317. background: #e6fffb;
  318. color: #36cfc9;
  319. }
  320. /* 已撤销样式 */
  321. .status-badge.expired {
  322. background: #f5f5f5;
  323. color: #999;
  324. }
  325. .status-badge.finish {
  326. background: #f6ffed;
  327. color: #52c41a;
  328. }
  329. .card-body {
  330. padding: 24rpx 0;
  331. border-top: 1rpx dashed #f0f0f0;
  332. margin-bottom: 24rpx;
  333. }
  334. .model-row {
  335. display: flex;
  336. align-items: center;
  337. margin-bottom: 12rpx;
  338. font-size: 24rpx;
  339. }
  340. .m-type {
  341. font-size: 28rpx;
  342. font-weight: bold;
  343. color: #333;
  344. width: 140rpx;
  345. }
  346. .m-spec {
  347. color: #888;
  348. flex: 1;
  349. padding: 0 20rpx;
  350. overflow: hidden;
  351. text-overflow: ellipsis;
  352. white-space: nowrap;
  353. }
  354. .m-count {
  355. color: #555;
  356. width: 100rpx;
  357. text-align: right;
  358. font-weight: 500;
  359. }
  360. .more-hint {
  361. padding: 10rpx 0;
  362. font-size: 24rpx;
  363. color: #999;
  364. text-align: center;
  365. background: #fafafa;
  366. border-radius: 8rpx;
  367. margin-bottom: 16rpx;
  368. }
  369. .total-summary {
  370. display: flex;
  371. align-items: center;
  372. justify-content: flex-end;
  373. padding-top: 20rpx;
  374. border-top: 1rpx solid #fafafa;
  375. }
  376. .summary-label {
  377. font-size: 24rpx;
  378. color: #999;
  379. }
  380. .summary-val {
  381. font-size: 32rpx;
  382. font-weight: bold;
  383. color: #333;
  384. margin: 0 4rpx;
  385. }
  386. .summary-val.highlight {
  387. color: #C1001C;
  388. }
  389. .summary-unit {
  390. font-size: 22rpx;
  391. color: #999;
  392. margin-right: 12rpx;
  393. }
  394. .summary-split {
  395. width: 1rpx;
  396. height: 20rpx;
  397. background: #eee;
  398. margin: 0 16rpx;
  399. }
  400. .card-foot {
  401. display: flex;
  402. justify-content: space-between;
  403. align-items: center;
  404. padding-top: 10rpx;
  405. }
  406. .time {
  407. font-size: 24rpx;
  408. color: #bbb;
  409. }
  410. .btns {
  411. display: flex;
  412. gap: 16rpx;
  413. }
  414. .btn-cancel,
  415. .btn-view {
  416. padding: 12rpx 30rpx;
  417. border-radius: 30rpx;
  418. font-size: 24rpx;
  419. }
  420. .btn-cancel {
  421. border: 1rpx solid #ddd;
  422. color: #666;
  423. }
  424. .btn-view.primary {
  425. background: #C1001C;
  426. color: #fff;
  427. }
  428. .list-status-info {
  429. padding: 40rpx 0;
  430. display: flex;
  431. justify-content: center;
  432. }
  433. .nomore-wrap {
  434. display: flex;
  435. align-items: center;
  436. color: #ccc;
  437. font-size: 24rpx;
  438. }
  439. .nomore-line {
  440. width: 40rpx;
  441. height: 1rpx;
  442. background: #eee;
  443. margin: 0 20rpx;
  444. }
  445. .loading-wrap {
  446. color: #999;
  447. font-size: 24rpx;
  448. display: flex;
  449. align-items: center;
  450. }
  451. .load-dot {
  452. width: 10rpx;
  453. height: 10rpx;
  454. background: #C1001C;
  455. border-radius: 50%;
  456. margin-right: 10rpx;
  457. animation: flash 0.6s infinite alternate;
  458. }
  459. @keyframes flash {
  460. from {
  461. opacity: 0.3;
  462. }
  463. to {
  464. opacity: 1;
  465. }
  466. }
  467. .empty-state {
  468. display: flex;
  469. flex-direction: column;
  470. align-items: center;
  471. padding-top: 200rpx;
  472. color: #bbb;
  473. font-size: 28rpx;
  474. }
  475. .empty-state image {
  476. width: 220rpx;
  477. height: 220rpx;
  478. margin-bottom: 30rpx;
  479. opacity: 0.6;
  480. }
  481. .safe-bottom {
  482. height: 40rpx;
  483. }
  484. </style>