index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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" @click="handleAddClick">
  16. <image src="/static/icons/plus.png" mode="scaleToFill" />
  17. <text>加一单</text>
  18. </view>
  19. </template>
  20. </u-navbar>
  21. <orderDetailNewView :detail="receiptDetail" :topInfo="topInfo" :orderId="orderId" />
  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. item: '',
  51. orderId: '',
  52. type: '',
  53. clueId: '',
  54. // 订单详情
  55. receiptDetail: {},
  56. }
  57. },
  58. onLoad(option) {
  59. // 接收参数
  60. const { item, orderId, type, clueId } = option;
  61. console.log('接收的参数:', option);
  62. this.item = item;
  63. this.orderId = orderId;
  64. this.type = type;
  65. this.clueId = clueId;
  66. //查询订单详情
  67. this.getOrderDetail();
  68. },
  69. methods: {
  70. handleBrandClick() {
  71. this.openModal('brand', '请输入品牌', this.topInfo.brand, '请输入品牌')
  72. },
  73. handleModelClick() {
  74. this.openModal('model', '请输入型号', this.topInfo.model, '请输入型号')
  75. },
  76. handlePriceClick() {
  77. this.openModal('price', '请输入价格', this.topInfo.price, '请输入价格')
  78. },
  79. openModal(field, title, value, placeholder) {
  80. this.currentEditField = field
  81. this.modalConfig = {
  82. title,
  83. value,
  84. placeholder
  85. }
  86. this.modalVisible = true
  87. },
  88. handleModalInput(value) {
  89. this.modalConfig.value = value
  90. },
  91. handleModalCancel() {
  92. this.modalVisible = false
  93. this.currentEditField = ''
  94. },
  95. handleModalConfirm(newValue) {
  96. if (this.currentEditField) {
  97. this.topInfo[this.currentEditField] = newValue
  98. }
  99. this.modalVisible = false
  100. this.currentEditField = ''
  101. },
  102. handleAddClick() {
  103. console.log('加一单')
  104. },
  105. //查询订单详情
  106. async getOrderDetail() {
  107. const res = await uni.$u.api
  108. .getClueSendFormVoByOrderId({
  109. id: this.orderId,
  110. })
  111. console.log('订单详情', res);
  112. if (res.code === 200) {
  113. this.receiptDetail = res.data;
  114. }
  115. }
  116. }
  117. }
  118. </script>
  119. <style scoped>
  120. .slot-wrap {
  121. display: flex;
  122. align-items: center;
  123. background-color: #fff;
  124. border-radius: 40rpx;
  125. padding: 10rpx 20rpx;
  126. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  127. }
  128. .brand {
  129. font-weight: bold;
  130. color: #333;
  131. font-size: 28rpx;
  132. }
  133. .divider {
  134. margin: 0 15rpx;
  135. color: #ddd;
  136. font-size: 28rpx;
  137. }
  138. .model {
  139. color: #666;
  140. font-size: 26rpx;
  141. }
  142. .price {
  143. color: blueviolet;
  144. font-weight: bold;
  145. font-size: 28rpx;
  146. }
  147. .slot-right {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. justify-content: center;
  152. font-size: 20rpx;
  153. color: blueviolet;
  154. image {
  155. width: 30rpx;
  156. height: 30rpx;
  157. }
  158. }
  159. </style>