check-order.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="container">
  3. <view class="book-list">
  4. <book-item v-for="(book, index) in bookList" :key="index" :book="book" @remove="removeBook" />
  5. </view>
  6. <!-- 底部信息和按钮 -->
  7. <view class="footer fixed-bottom flex-d" style="padding-top:10rpx">
  8. <text class="pad-10">共 {{ totalBooks }} 本,预估回收价 ¥{{ totalPrice }}</text>
  9. <view class="flex-a mt-12">
  10. <u-button size="large" type="primary" text="提交" @click="handleSubmit" />
  11. <u-button size="large" type="warning" text="扫码" @click="handleScan" />
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { ref } from 'vue';
  18. import BookItem from '../components/BookItem.vue';
  19. import PageScroll from '@/components/PageScroll/index.vue';
  20. const bookList = ref([
  21. {
  22. title: '动物解剖生理第三版',
  23. isbn: '9787109260962',
  24. price: '39.6',
  25. discount: '0',
  26. quantity: '1/1',
  27. estimatedPrice: '2.8',
  28. reviewAmount: '0',
  29. good: 0,
  30. average: 0,
  31. poor: 0,
  32. image: 'https://example.com/book.jpg'
  33. },
  34. // ...更多书籍
  35. ]);
  36. const totalBooks = ref(bookList.value.length);
  37. const totalPrice = ref(bookList.value.reduce((sum, book) => sum + parseFloat(book.estimatedPrice), 0).toFixed(2));
  38. const removeBook = (book) => {
  39. const index = bookList.value.indexOf(book);
  40. if (index > -1) {
  41. bookList.value.splice(index, 1);
  42. updateTotals();
  43. }
  44. };
  45. const updateTotals = () => {
  46. totalBooks.value = bookList.value.length;
  47. totalPrice.value = bookList.value.reduce((sum, book) => sum + parseFloat(book.estimatedPrice), 0).toFixed(2);
  48. };
  49. const handleSubmit = () => {
  50. console.log('提交订单');
  51. };
  52. const handleScan = () => {
  53. uni.scanCode({
  54. success: (res) => {
  55. console.log('扫码结果:', res.result);
  56. // 添加新书逻辑
  57. }
  58. });
  59. };
  60. </script>
  61. <style scoped>
  62. .container {
  63. display: flex;
  64. flex-direction: column;
  65. padding: 12px;
  66. box-sizing: border-box;
  67. height: 100%;
  68. .book-list{
  69. height: calc(100% - 96px);
  70. overflow: auto;
  71. }
  72. }
  73. .footer {
  74. background-color: #fff;
  75. border-top: 1px solid #eee;
  76. }
  77. </style>