index.vue 12 KB

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