index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <!-- 正确使用 u-navbar 的具名插槽 -->
  4. <u-navbar :autoBack="true" :placeholder="true" v-hideNav>
  5. <template v-slot:center>
  6. <view class="slot-wrap">
  7. <text @click="handleBrandClick" class="brand">{{ topInfo.brand }}</text>
  8. <text class="divider">|</text>
  9. <text @click="handleModelClick" class="model">{{ topInfo.model }}</text>
  10. <text class="divider">|</text>
  11. <text @click="handlePriceClick" class="price">¥{{ topInfo.price }}</text>
  12. </view>
  13. </template>
  14. <template v-slot:right>
  15. <view class="slot-right">
  16. <image src="/static/icons/plus.png" mode="scaleToFill" />
  17. <text>加一单</text>
  18. </view>
  19. </template>
  20. </u-navbar>
  21. <orderDetailNewView />
  22. <!-- 通用模态窗 -->
  23. <custom-modal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
  24. :placeholder="modalConfig.placeholder" @cancel="handleModalCancel" @confirm="handleModalConfirm" />
  25. </view>
  26. </template>
  27. <script>
  28. import orderDetailNewView from './components/orderDetailNewView.vue'
  29. import CustomModal from './components/CustomModal.vue'
  30. export default {
  31. name: 'CustomNavbar',
  32. components: {
  33. orderDetailNewView,
  34. CustomModal
  35. },
  36. data() {
  37. return {
  38. topInfo: {
  39. brand: 'Hermes',
  40. model: 'Birkin 30',
  41. price: '125,000'
  42. },
  43. modalVisible: false,
  44. currentEditField: '',
  45. modalConfig: {
  46. title: '',
  47. value: '',
  48. placeholder: ''
  49. }
  50. }
  51. },
  52. methods: {
  53. handleBrandClick() {
  54. this.openModal('brand', '请输入品牌', this.topInfo.brand, '请输入品牌')
  55. },
  56. handleModelClick() {
  57. this.openModal('model', '请输入型号', this.topInfo.model, '请输入型号')
  58. },
  59. handlePriceClick() {
  60. this.openModal('price', '请输入价格', this.topInfo.price, '请输入价格')
  61. },
  62. openModal(field, title, value, placeholder) {
  63. this.currentEditField = field
  64. this.modalConfig = {
  65. title,
  66. value,
  67. placeholder
  68. }
  69. this.modalVisible = true
  70. },
  71. handleModalInput(value) {
  72. this.modalConfig.value = value
  73. },
  74. handleModalCancel() {
  75. this.modalVisible = false
  76. this.currentEditField = ''
  77. },
  78. handleModalConfirm(newValue) {
  79. if (this.currentEditField) {
  80. this.topInfo[this.currentEditField] = newValue
  81. }
  82. this.modalVisible = false
  83. this.currentEditField = ''
  84. }
  85. }
  86. }
  87. </script>
  88. <style scoped>
  89. .slot-wrap {
  90. display: flex;
  91. align-items: center;
  92. background-color: #fff;
  93. border-radius: 40rpx;
  94. padding: 10rpx 20rpx;
  95. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  96. }
  97. .brand {
  98. font-weight: bold;
  99. color: #333;
  100. font-size: 28rpx;
  101. }
  102. .divider {
  103. margin: 0 15rpx;
  104. color: #ddd;
  105. font-size: 28rpx;
  106. }
  107. .model {
  108. color: #666;
  109. font-size: 26rpx;
  110. }
  111. .price {
  112. color: blueviolet;
  113. font-weight: bold;
  114. font-size: 28rpx;
  115. }
  116. .slot-right {
  117. display: flex;
  118. flex-direction: column;
  119. align-items: center;
  120. justify-content: center;
  121. font-size: 20rpx;
  122. color: blueviolet;
  123. image {
  124. width: 30rpx;
  125. height: 30rpx;
  126. }
  127. }
  128. </style>