index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <template>
  2. <view class="order-container">
  3. <erp-nav-bar title="ERP 下单" :show-back="false" />
  4. <!-- 1. 待管理员授权状态 -->
  5. <view class="auth-waiting-full" v-if="!isAuthorized">
  6. <view class="auth-card">
  7. <image class="auth-icon" src="https://img.icons8.com/color/192/hourglass-sand-top.png" mode="aspectFit">
  8. </image>
  9. <text class="auth-title">待管理员授权</text>
  10. <text class="auth-desc">您的账户尚未获得下单权限,请联系管理员核准授权后即可进行下单操作。</text>
  11. <button class="contact-btn" @click="contactAdmin">联系管理员</button>
  12. <button class="authorized-btn" @click="isAuthorized = true">我已授权</button>
  13. </view>
  14. </view>
  15. <!-- 2. 已授权状态:已选型号列表 (参考草图2) -->
  16. <template v-else>
  17. <scroll-view scroll-y class="order-scroll-list" :show-scrollbar="false" :enhanced="true">
  18. <view class="list-wrapper">
  19. <!-- 列表头部:仅在有数据时显示 -->
  20. <view class="list-header" v-if="selectedModels.length > 0">
  21. <text class="header-text">已选型号列表:</text>
  22. </view>
  23. <!-- 1. 列表渲染 (精品化设计) -->
  24. <view class="model-item-card" v-for="(item, index) in selectedModels" :key="index"
  25. v-if="selectedModels.length > 0" @click="editItem(index, item)">
  26. <view class="remove-icon" @click.stop="removeItem(index)">
  27. <text class="x-icon">×</text>
  28. </view>
  29. <view class="card-line">
  30. <text class="model-value">{{ item.type }}</text>
  31. <view class="count-tag">
  32. 支数<text class="count-num">{{ item.count }}</text>
  33. </view>
  34. </view>
  35. <view class="card-line secondary">
  36. <text class="surface-label">表面名称:</text>
  37. <text class="surface-text">{{ item.surfaceName }}</text>
  38. </view>
  39. </view>
  40. <!-- 2. 全屏缺省状态:美化后的引导页 -->
  41. <view class="empty-state-full" v-else>
  42. <view class="empty-visual">
  43. <image class="empty-img" src="https://img.icons8.com/clouds/200/shopping-cart.png"
  44. mode="aspectFit"></image>
  45. <view class="empty-bg-glow"></view>
  46. </view>
  47. <text class="empty-title">暂无已选型号</text>
  48. <button class="empty-action-btn" @click="goToAddModel">选型下单</button>
  49. </view>
  50. <view class="bottom-safe-space"></view>
  51. </view>
  52. </scroll-view>
  53. <!-- 悬浮添加按钮 (仅在有数据时显示) -->
  54. <view class="floating-add-btn" @click="goToAddModel" v-if="selectedModels.length > 0">
  55. <view class="plus-icon"></view>
  56. </view>
  57. <!-- 底部支付/下单汇总栏 (仅在有数据时显示) -->
  58. <view class="footer-summary-bar" v-if="selectedModels.length > 0">
  59. <view class="summary-info">
  60. <text class="count-label">共计:</text>
  61. <text class="num-highlight">{{ selectedModels.length }}</text>
  62. <text class="unit">条</text>
  63. <view class="split-line"></view>
  64. <text class="num-highlight green">{{ totalCount }}</text>
  65. <text class="unit">支</text>
  66. </view>
  67. <button class="submit-order-btn" :disabled="selectedModels.length === 0"
  68. @click="submitFinalOrder">立即下单</button>
  69. </view>
  70. </template>
  71. <!-- 底部菜单栏 -->
  72. <erp-tab-bar active="order"></erp-tab-bar>
  73. </view>
  74. </template>
  75. <script>
  76. import ErpTabBar from '@/components/erp-tab-bar.vue';
  77. import ErpNavBar from '@/components/erp-nav-bar.vue';
  78. export default {
  79. components: { ErpNavBar, ErpTabBar },
  80. data() {
  81. return {
  82. isAuthorized: false,
  83. selectedModels: []
  84. }
  85. },
  86. computed: {
  87. totalCount() {
  88. return this.selectedModels.reduce((sum, item) => sum + parseInt(item.count || 0), 0);
  89. }
  90. },
  91. onLoad() {
  92. // 监听添加型号的事件
  93. uni.$on('add_order_item', (data) => {
  94. this.selectedModels.push(data);
  95. uni.showToast({ title: '添加成功', icon: 'success' });
  96. });
  97. // 监听修改型号的事件
  98. uni.$on('update_order_item', (res) => {
  99. if (res.index > -1) {
  100. this.$set(this.selectedModels, res.index, res.data);
  101. uni.showToast({ title: '修改成功', icon: 'success' });
  102. }
  103. });
  104. },
  105. onUnload() {
  106. uni.$off('add_order_item');
  107. uni.$off('update_order_item');
  108. },
  109. methods: {
  110. contactAdmin() { uni.showModal({ title: '联系管理员', content: '管理员电话:138-0000-0000', showCancel: false, confirmColor: '#C1001C' }); },
  111. goToAddModel() {
  112. uni.navigateTo({
  113. url: '/pages/order/add-model/index'
  114. });
  115. },
  116. editItem(index, item) {
  117. uni.navigateTo({
  118. url: `/pages/order/edit-model/index?index=${index}&data=${encodeURIComponent(JSON.stringify(item))}`
  119. });
  120. },
  121. removeItem(index) {
  122. const self = this;
  123. uni.showModal({
  124. title: '提示',
  125. content: '确定移除该型号吗?',
  126. success: (res) => {
  127. if (res.confirm) {
  128. self.selectedModels.splice(index, 1);
  129. }
  130. }
  131. });
  132. },
  133. submitFinalOrder() {
  134. if (this.selectedModels.length === 0) return;
  135. uni.showLoading({ title: '正在提交结果', mask: true });
  136. setTimeout(() => {
  137. uni.hideLoading();
  138. uni.navigateTo({
  139. url: '/pages/order/success/index'
  140. });
  141. // 注意:此处不再手动清空 selectedModels,防止跳转前页面出现“暂无数据”的闪现
  142. // 并在 success 页面点击“再来一单”时通过 reLaunch 自动重置页面状态
  143. }, 1500);
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped>
  149. /deep/ ::-webkit-scrollbar {
  150. display: none !important;
  151. width: 0 !important;
  152. height: 0 !important;
  153. }
  154. .order-container {
  155. width: 100%;
  156. height: 100vh;
  157. background: #f8fafc;
  158. display: flex;
  159. flex-direction: column;
  160. overflow: hidden;
  161. }
  162. /* 授权等待样式保持一致 */
  163. .auth-waiting-full {
  164. flex: 1;
  165. display: flex;
  166. flex-direction: column;
  167. align-items: center;
  168. justify-content: flex-start;
  169. padding: 200rpx 40rpx 40rpx;
  170. background: linear-gradient(180deg, rgba(0, 122, 255, 0.08) 0%, rgba(247, 248, 250, 1) 100%);
  171. }
  172. .auth-card {
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. text-align: center;
  177. }
  178. .auth-icon {
  179. width: 200rpx;
  180. height: 200rpx;
  181. margin-bottom: 50rpx;
  182. }
  183. .auth-title {
  184. font-size: 44rpx;
  185. font-weight: bold;
  186. color: #1a1a1a;
  187. margin-bottom: 24rpx;
  188. }
  189. .auth-desc {
  190. font-size: 28rpx;
  191. color: #666;
  192. line-height: 1.8;
  193. margin-bottom: 80rpx;
  194. padding: 0 20rpx;
  195. }
  196. .contact-btn {
  197. width: 360rpx;
  198. height: 96rpx;
  199. background: linear-gradient(135deg, #C1001C 0%, #FF4D4F 100%);
  200. color: #fff;
  201. border-radius: 48rpx;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. font-size: 32rpx;
  206. font-weight: bold;
  207. border: none;
  208. box-shadow: 0 12rpx 30rpx rgba(193, 0, 28, 0.2);
  209. }
  210. .authorized-btn {
  211. width: 360rpx;
  212. height: 96rpx;
  213. background: #fff;
  214. color: #C1001C;
  215. border-radius: 48rpx;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. font-size: 32rpx;
  220. font-weight: bold;
  221. border: 2rpx solid #C1001C;
  222. margin-top: 30rpx;
  223. }
  224. /* 已授权列表页样式 */
  225. .order-container {
  226. width: 100%;
  227. height: 100vh;
  228. background: #f7f8fa;
  229. display: flex;
  230. flex-direction: column;
  231. overflow: hidden;
  232. }
  233. .order-scroll-list {
  234. flex: 1;
  235. height: 0;
  236. }
  237. .list-wrapper {
  238. padding: 30rpx;
  239. /* 确保最后一条数据不被底部双层固定栏遮挡:汇总栏130 + 菜单栏110 + 安全区 + 缓冲余量 */
  240. padding-bottom: calc(280rpx + env(safe-area-inset-bottom));
  241. }
  242. .list-header {
  243. padding: 10rpx 0 20rpx;
  244. }
  245. .header-text {
  246. font-size: 34rpx;
  247. font-weight: bold;
  248. color: #1a1a1a;
  249. position: relative;
  250. padding-left: 24rpx;
  251. }
  252. .header-text::before {
  253. content: '';
  254. position: absolute;
  255. left: 0;
  256. top: 10%;
  257. height: 80%;
  258. width: 8rpx;
  259. background: #C1001C;
  260. border-radius: 4rpx;
  261. }
  262. /* 型号卡片:大幅升级美化 */
  263. .model-item-card {
  264. background: #fff;
  265. border-radius: 24rpx;
  266. padding: 36rpx;
  267. margin-bottom: 30rpx;
  268. position: relative;
  269. box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.04);
  270. border: 1rpx solid rgba(0, 0, 0, 0.02);
  271. }
  272. .remove-icon {
  273. position: absolute;
  274. right: 0;
  275. top: 0;
  276. width: 50rpx;
  277. height: 50rpx;
  278. background: rgba(255, 77, 79, 0.1);
  279. border-radius: 0 24rpx 0 24rpx;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. z-index: 5;
  284. }
  285. .x-icon {
  286. font-size: 32rpx;
  287. color: #ff4d4f;
  288. font-weight: bold;
  289. }
  290. .card-line {
  291. display: flex;
  292. align-items: center;
  293. margin-bottom: 20rpx;
  294. }
  295. .card-line.secondary {
  296. margin-bottom: 0;
  297. padding-top: 20rpx;
  298. border-top: 1rpx dashed #f0f0f0;
  299. }
  300. .model-label {
  301. font-size: 26rpx;
  302. color: #999;
  303. }
  304. .model-value {
  305. font-size: 34rpx;
  306. font-weight: bold;
  307. color: #333;
  308. flex: 1;
  309. }
  310. .count-tag {
  311. background: #FFF1F2;
  312. color: #C1001C;
  313. padding: 4rpx 16rpx;
  314. border-radius: 8rpx;
  315. font-size: 24rpx;
  316. font-weight: bold;
  317. }
  318. .count-num {
  319. font-size: 30rpx;
  320. margin-left: 8rpx;
  321. }
  322. .surface-label {
  323. font-size: 26rpx;
  324. color: #999;
  325. }
  326. .surface-text {
  327. font-size: 28rpx;
  328. color: #666;
  329. }
  330. /* 悬浮添加按钮:位置上移避免拥挤 */
  331. .floating-add-btn {
  332. position: fixed;
  333. right: 40rpx;
  334. bottom: calc(260rpx + env(safe-area-inset-bottom) + 40rpx);
  335. width: 110rpx;
  336. height: 110rpx;
  337. background: #C1001C;
  338. border-radius: 50%;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. box-shadow: 0 12rpx 40rpx rgba(193, 0, 28, 0.4);
  343. z-index: 100;
  344. transition: transform 0.2s;
  345. }
  346. .floating-add-btn:active {
  347. transform: scale(0.9);
  348. }
  349. .plus-icon {
  350. width: 40rpx;
  351. height: 4rpx;
  352. background: #fff;
  353. border-radius: 2rpx;
  354. position: relative;
  355. }
  356. .plus-icon::after {
  357. content: '';
  358. position: absolute;
  359. top: 0;
  360. left: 0;
  361. width: 100%;
  362. height: 100%;
  363. background: #fff;
  364. transform: rotate(90deg);
  365. border-radius: 2rpx;
  366. }
  367. /* 底部汇总栏:微调间距与样式 */
  368. .footer-summary-bar {
  369. position: fixed;
  370. bottom: calc(110rpx + env(safe-area-inset-bottom));
  371. left: 0;
  372. width: 100%;
  373. height: 130rpx;
  374. background: #fff;
  375. border-top: 1rpx solid #f0f0f0;
  376. display: flex;
  377. align-items: center;
  378. justify-content: space-between;
  379. padding: 0 40rpx;
  380. box-sizing: border-box;
  381. z-index: 99;
  382. box-shadow: 0 -10rpx 40rpx rgba(0, 0, 0, 0.05);
  383. }
  384. .summary-info {
  385. display: flex;
  386. align-items: center;
  387. }
  388. .count-label {
  389. font-size: 26rpx;
  390. color: #999;
  391. }
  392. .num-highlight {
  393. font-size: 36rpx;
  394. font-weight: bold;
  395. color: #1a1a1a;
  396. margin: 0 4rpx;
  397. }
  398. .num-highlight.green {
  399. color: #C1001C;
  400. }
  401. .unit {
  402. font-size: 24rpx;
  403. color: #999;
  404. margin-left: 2rpx;
  405. }
  406. .split-line {
  407. width: 1rpx;
  408. height: 30rpx;
  409. background: #eee;
  410. margin: 0 20rpx;
  411. }
  412. .submit-order-btn {
  413. width: 220rpx;
  414. height: 80rpx;
  415. background: #e0e0e0;
  416. color: #666;
  417. font-size: 28rpx;
  418. border-radius: 40rpx;
  419. display: flex;
  420. align-items: center;
  421. justify-content: center;
  422. border: none;
  423. margin: 0;
  424. transition: all 0.3s;
  425. }
  426. .submit-order-btn:not([disabled]) {
  427. background: #C1001C;
  428. color: #fff;
  429. font-weight: bold;
  430. }
  431. /* 全屏缺省页样式 */
  432. .empty-state-full {
  433. display: flex;
  434. flex-direction: column;
  435. align-items: center;
  436. justify-content: center;
  437. padding-top: 120rpx;
  438. }
  439. .empty-visual {
  440. position: relative;
  441. margin-bottom: 40rpx;
  442. width: 400rpx;
  443. height: 400rpx;
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. }
  448. .empty-img {
  449. width: 320rpx;
  450. height: 320rpx;
  451. z-index: 2;
  452. }
  453. .empty-bg-glow {
  454. position: absolute;
  455. width: 240rpx;
  456. height: 240rpx;
  457. background: radial-gradient(circle, rgba(193, 0, 28, 0.15) 0%, rgba(248, 250, 252, 0) 70%);
  458. z-index: 1;
  459. border-radius: 50%;
  460. }
  461. .empty-title {
  462. font-size: 36rpx;
  463. font-weight: bold;
  464. color: #1a1a1a;
  465. margin-bottom: 80rpx;
  466. }
  467. .empty-desc {
  468. font-size: 26rpx;
  469. color: #999;
  470. margin-bottom: 60rpx;
  471. text-align: center;
  472. padding: 0 80rpx;
  473. line-height: 1.6;
  474. }
  475. .empty-action-btn {
  476. width: 320rpx;
  477. height: 90rpx;
  478. background: #C1001C;
  479. color: #fff;
  480. border-radius: 45rpx;
  481. font-size: 30rpx;
  482. font-weight: bold;
  483. display: flex;
  484. align-items: center;
  485. justify-content: center;
  486. box-shadow: 0 10rpx 30rpx rgba(193, 0, 28, 0.2);
  487. border: none;
  488. }
  489. .empty-action-btn:active {
  490. opacity: 0.8;
  491. transform: scale(0.96);
  492. }
  493. .bottom-safe-space {
  494. height: 100rpx;
  495. }
  496. </style>