index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view>
  3. <!-- 正确使用 u-navbar 的具名插槽 -->
  4. <u-navbar :autoBack="true" :placeholder="true" v-hideNav>
  5. <template 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 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. <u-sticky bgColor="#fff">
  22. <u-tabs keyName="brand" :list="receiptList" @click="clickReceipt"></u-tabs>
  23. </u-sticky>
  24. <orderDetailNewView :detail="receiptDetail" :topInfo="topInfo" :orderId="orderId"
  25. :currentReceipt="currentReceipt" />
  26. <!-- 通用模态窗 -->
  27. <custom-modal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
  28. :placeholder="modalConfig.placeholder" @cancel="handleModalCancel" @confirm="handleModalConfirm" />
  29. </view>
  30. </template>
  31. <script>
  32. import orderDetailNewView from './components/orderDetailNewView.vue'
  33. import CustomModal from './components/CustomModal.vue'
  34. export default {
  35. name: 'CustomNavbar',
  36. components: {
  37. orderDetailNewView,
  38. CustomModal
  39. },
  40. data() {
  41. return {
  42. topInfo: {
  43. brand: 'Hermes',
  44. model: 'Birkin 30',
  45. price: '125,000'
  46. },
  47. modalVisible: false,
  48. currentEditField: '',
  49. modalConfig: {
  50. title: '',
  51. value: '',
  52. placeholder: ''
  53. },
  54. item: '',
  55. orderId: '',
  56. type: '',
  57. clueId: '',
  58. // 订单详情
  59. receiptDetail: {},
  60. //接单单个订单的receiptList
  61. receiptList: [],
  62. //当前选中的收单订单
  63. currentReceipt: {}
  64. }
  65. },
  66. onLoad(option) {
  67. // 接收参数
  68. const { item, orderId, type, clueId } = option;
  69. console.log('接收的参数:', option);
  70. this.item = item;
  71. this.orderId = orderId;
  72. this.type = type;
  73. this.clueId = clueId;
  74. //查询订单详情
  75. this.getOrderDetail();
  76. //获取收单列表
  77. this.getReceiptList();
  78. },
  79. methods: {
  80. handleBrandClick() {
  81. this.openModal('brand', '请输入品牌', this.topInfo.brand, '请输入品牌')
  82. },
  83. handleModelClick() {
  84. this.openModal('model', '请输入型号', this.topInfo.model, '请输入型号')
  85. },
  86. handlePriceClick() {
  87. this.openModal('price', '请输入价格', this.topInfo.price, '请输入价格')
  88. },
  89. openModal(field, title, value, placeholder) {
  90. this.currentEditField = field
  91. this.modalConfig = {
  92. title,
  93. value,
  94. placeholder
  95. }
  96. this.modalVisible = true
  97. },
  98. handleModalInput(value) {
  99. this.modalConfig.value = value
  100. },
  101. handleModalCancel() {
  102. this.modalVisible = false
  103. this.currentEditField = ''
  104. },
  105. handleModalConfirm(newValue) {
  106. if (this.currentEditField) {
  107. this.topInfo[this.currentEditField] = newValue
  108. }
  109. this.modalVisible = false
  110. this.currentEditField = ''
  111. },
  112. handleAddClick() {
  113. console.log('加一单')
  114. //判断如果当前有收单的id是‘’的话,说明是新增的收单订单
  115. if (this.receiptList.some(item => item.id === '')) {
  116. uni.$u.toast('请先保存新增的收单订单')
  117. return
  118. }
  119. this.receiptList.push({
  120. "id": "",//订单id
  121. "sendFormId": this.orderId,
  122. "clueId": this.clueId,
  123. "brand": "新加一单",
  124. });
  125. },
  126. //查询订单详情
  127. async getOrderDetail() {
  128. const res = await uni.$u.api
  129. .getClueSendFormVoByOrderId({
  130. id: this.orderId,
  131. })
  132. console.log('订单详情', res.data);
  133. if (res.code === 200) {
  134. this.receiptDetail = res.data;
  135. }
  136. },
  137. //获取收单列表
  138. async getReceiptList() {
  139. const res = await uni.$u.api.clueReceiptFormListByOrderId(this.orderId);
  140. console.log('这里是收件列表page', res)
  141. if (res.code === 200) {
  142. this.receiptList = res.data || [];
  143. }
  144. },
  145. clickReceipt(item) {
  146. // console.log('点击了', item);
  147. this.currentReceipt = item;
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped>
  153. .slot-wrap {
  154. display: flex;
  155. align-items: center;
  156. background-color: #fff;
  157. border-radius: 40rpx;
  158. padding: 10rpx 20rpx;
  159. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  160. }
  161. .brand {
  162. font-weight: bold;
  163. color: #333;
  164. font-size: 28rpx;
  165. }
  166. .divider {
  167. margin: 0 15rpx;
  168. color: #ddd;
  169. font-size: 28rpx;
  170. }
  171. .model {
  172. color: #666;
  173. font-size: 26rpx;
  174. }
  175. .price {
  176. color: blueviolet;
  177. font-weight: bold;
  178. font-size: 28rpx;
  179. }
  180. .slot-right {
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. justify-content: center;
  185. font-size: 20rpx;
  186. color: blueviolet;
  187. image {
  188. width: 30rpx;
  189. height: 30rpx;
  190. }
  191. }
  192. </style>