index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. <template>
  2. <view class="order-apply-page">
  3. <nav-bar title="下单预约"></nav-bar>
  4. <view class="apply-content">
  5. <!-- 01 服务类型 -->
  6. <text class="section-title">01 服务类型</text>
  7. <view class="card service-info-card">
  8. <view class="service-type-display">
  9. <view :class="['service-icon-box', activeService]">
  10. <uni-icons :type="serviceIcon" size="22" color="#fff"></uni-icons>
  11. </view>
  12. <view class="service-info-text">
  13. <text class="main-name">{{ currentServiceName }}</text>
  14. <text class="sub-desc">{{ serviceDesc }}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 02 基础信息 -->
  19. <text class="section-title">02 基础信息</text>
  20. <view class="card basic-info-card">
  21. <view class="field-row" @click="showShopPicker = true">
  22. <text class="field-label">服务门店</text>
  23. <text :class="['field-value', !formData.shopName ? 'placeholder' : '']">{{ formData.shopName ||
  24. '请选择商户门店' }}</text>
  25. <uni-icons type="right" size="14" color="#ccc"></uni-icons>
  26. </view>
  27. <view class="field-row" @click="showUserPopup = true">
  28. <text class="field-label">宠主用户</text>
  29. <view class="field-value-wrap">
  30. <template v-if="selectedUser">
  31. <text class="selected-name">{{ selectedUser.name }}</text>
  32. <text class="selected-phone">{{ selectedUser.phone }}</text>
  33. </template>
  34. <text v-else class="placeholder">搜索手机号/姓名</text>
  35. </view>
  36. </view>
  37. <view class="field-row" @click="openPetPicker">
  38. <text class="field-label">选择宠物</text>
  39. <text :class="['field-value', !formData.petName ? 'placeholder' : '']">{{ formData.petName ||
  40. '点击选择宠物档案' }}</text>
  41. <uni-icons type="right" size="14" color="#ccc"></uni-icons>
  42. </view>
  43. </view>
  44. <!-- 03 业务表单 - 宠物接送 -->
  45. <template v-if="activeService === 'transport'">
  46. <text class="section-title">03 填写接送路线与时间</text>
  47. <view class="card transport-card">
  48. <view class="field-row">
  49. <text class="field-label">团购套餐</text>
  50. <input class="field-input" v-model="formData.packageName" placeholder="请输入套餐名称(选填)" />
  51. </view>
  52. <text class="form-item-label">接送模式</text>
  53. <view class="mode-select">
  54. <view v-for="mode in transportModes" :key="mode.value"
  55. :class="['mode-btn', { active: formData.transportMode === mode.value }]"
  56. @click="formData.transportMode = mode.value">
  57. <text>{{ mode.label }}</text>
  58. </view>
  59. </view>
  60. <!-- 接宠路线 (起点=用户家, 终点=门店) @Author: Antigravity -->
  61. <view class="route-box" v-if="formData.transportMode !== 'return_home'">
  62. <view class="route-icon pick"><text>接</text></view>
  63. <view class="route-fields">
  64. <text class="addr-label">起点</text>
  65. <uni-data-picker :localdata="regionTree" v-model="formData.pickArea"
  66. :map="{ text: 'name', value: 'code' }" @change="onRegionChange('pick', $event)">
  67. <view class="premium-cascader-display">
  68. <text :class="['display-text', !formData.pickArea ? 'placeholder' : '']">
  69. {{ pickAreaLabel || '选择省/市/区' }}
  70. </text>
  71. <uni-icons type="right" size="12" color="#ccc"></uni-icons>
  72. </view>
  73. </uni-data-picker>
  74. <input class="route-input" v-model="formData.pickAddress" placeholder="详细地址 (街道/门牌号)" />
  75. <text class="addr-label">终点</text>
  76. <uni-data-picker :localdata="regionTree" v-model="formData.pickEndArea"
  77. :map="{ text: 'name', value: 'code' }" @change="onRegionChange('pickEnd', $event)">
  78. <view class="premium-cascader-display">
  79. <text :class="['display-text', !formData.pickEndArea ? 'placeholder' : '']">
  80. {{ pickEndAreaLabel || '选择省/市/区' }}
  81. </text>
  82. <uni-icons type="right" size="12" color="#ccc"></uni-icons>
  83. </view>
  84. </uni-data-picker>
  85. <input class="route-input" v-model="formData.pickEndAddress" placeholder="详细地址 (街道/门牌号)" />
  86. <view class="contact-row">
  87. <input class="route-input half" v-model="formData.pickContact" placeholder="联系人" />
  88. <input class="route-input half" v-model="formData.pickPhone" placeholder="电话"
  89. type="tel" />
  90. </view>
  91. <view class="time-picker-row">
  92. <uni-datetime-picker type="datetime" v-model="formData.pickTime" placeholder="选择接宠时间"
  93. :border="false" :hide-second="true">
  94. </uni-datetime-picker>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 送宠路线 (起点=门店, 终点=用户家) @Author: Antigravity -->
  99. <view class="route-box" v-if="formData.transportMode !== 'pick_up'">
  100. <view class="route-icon send"><text>送</text></view>
  101. <view class="route-fields">
  102. <text class="addr-label">起点</text>
  103. <uni-data-picker :localdata="regionTree" v-model="formData.sendStartArea"
  104. :map="{ text: 'name', value: 'code' }" @change="onRegionChange('sendStart', $event)">
  105. <view class="premium-cascader-display">
  106. <text :class="['display-text', !formData.sendStartArea ? 'placeholder' : '']">
  107. {{ sendStartAreaLabel || '选择省/市/区' }}
  108. </text>
  109. <uni-icons type="right" size="12" color="#ccc"></uni-icons>
  110. </view>
  111. </uni-data-picker>
  112. <input class="route-input" v-model="formData.sendStartAddress"
  113. placeholder="详细地址 (街道/门牌号)" />
  114. <text class="addr-label">终点</text>
  115. <uni-data-picker :localdata="regionTree" v-model="formData.sendArea"
  116. :map="{ text: 'name', value: 'code' }" @change="onRegionChange('send', $event)">
  117. <view class="premium-cascader-display">
  118. <text :class="['display-text', !formData.sendArea ? 'placeholder' : '']">
  119. {{ sendAreaLabel || '选择省/市/区' }}
  120. </text>
  121. <uni-icons type="right" size="12" color="#ccc"></uni-icons>
  122. </view>
  123. </uni-data-picker>
  124. <input class="route-input" v-model="formData.sendAddress" placeholder="详细地址 (街道/门牌号)" />
  125. <view class="contact-row">
  126. <input class="route-input half" v-model="formData.sendContact" placeholder="联系人" />
  127. <input class="route-input half" v-model="formData.sendPhone" placeholder="电话"
  128. type="tel" />
  129. </view>
  130. <view class="time-picker-row">
  131. <uni-datetime-picker type="datetime" v-model="formData.sendTime"
  132. placeholder="预计送还时间(可选)" :border="false" :hide-second="true">
  133. </uni-datetime-picker>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <!-- 03 业务表单 - 上门喂遛/洗护 -->
  140. <template v-else>
  141. <text class="section-title">03 选择套餐与服务细则</text>
  142. <view class="card feed-card">
  143. <view class="field-row">
  144. <text class="field-label">团购套餐</text>
  145. <input class="field-input" v-model="formData.packageName" placeholder="请输入套餐名称(选填)" />
  146. </view>
  147. <text class="address-title">上门服务地址</text>
  148. <uni-data-picker :localdata="regionTree" v-model="formData.serviceArea"
  149. :map="{ text: 'name', value: 'code' }" @change="onRegionChange('service', $event)">
  150. <view class="premium-full-picker">
  151. <text :class="['display-text', !formData.serviceArea ? 'placeholder' : '']">
  152. {{ serviceAreaLabel || '请选择省/市/区' }}
  153. </text>
  154. <uni-icons type="right" size="14" color="#ccc"></uni-icons>
  155. </view>
  156. </uni-data-picker>
  157. <input class="full-input" v-model="formData.serviceAddress" placeholder="详细地址 (街道/路名/门牌号)" />
  158. <view class="booking-section">
  159. <view class="booking-header">
  160. <text class="label">预约服务时间</text>
  161. <text class="count-tag">共 {{ formData.feedTimes.length }} 次</text>
  162. </view>
  163. <view class="time-item-row" v-for="(time, index) in formData.feedTimes" :key="index">
  164. <text class="index">{{ index + 1 }}.</text>
  165. <view class="flex-picker-box">
  166. <uni-datetime-picker type="datetime" v-model="time.start" placeholder="开始"
  167. :border="false" class="inline-picker" :hide-second="true"></uni-datetime-picker>
  168. </view>
  169. <text class="to-line">~</text>
  170. <view class="flex-picker-box">
  171. <uni-datetime-picker type="datetime" v-model="time.end" placeholder="结束" :border="false"
  172. class="inline-picker" :hide-second="true"></uni-datetime-picker>
  173. </view>
  174. <view class="action-buttons">
  175. <view class="circle-btn add" v-if="index === formData.feedTimes.length - 1"
  176. @click="addFeedTime">
  177. <text>+</text>
  178. </view>
  179. <view class="circle-btn remove" v-if="formData.feedTimes.length > 1"
  180. @click="removeFeedTime(index)">
  181. <text>-</text>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. <text class="remarks-title">备注信息</text>
  187. <textarea class="remarks-textarea" v-model="formData.otherNote" placeholder="其他注意事项"></textarea>
  188. </view>
  189. </template>
  190. <!-- 04 报价信息 -->
  191. <text class="section-title">04 报价信息</text>
  192. <view class="card quote-card">
  193. <view class="field-row">
  194. <text class="field-label">报价金额</text>
  195. <input class="field-input" v-model="formData.quoteAmount" type="digit" placeholder="请输入报价金额" />
  196. <text class="unit-text">元</text>
  197. </view>
  198. <text class="quote-tips">注:此报价为预估费用,最终费用以实际结算为准。</text>
  199. </view>
  200. </view>
  201. <!-- 底部操作栏 -->
  202. <view class="footer-bar safe-bottom">
  203. <view class="quotation-fulfillmentCommission-box">
  204. <text class="p-label">总计报价:</text>
  205. <text class="p-symbol">¥</text>
  206. <text class="p-amount">{{ totalFulfillmentCommission }}</text>
  207. </view>
  208. <button class="submit-btn" @click="onSubmit">立即下单</button>
  209. </view>
  210. <!-- 门店选择弹窗 -->
  211. <view class="popup-mask" v-if="showShopPicker" @click="showShopPicker = false">
  212. <view class="popup-content" @click.stop>
  213. <text class="popup-title">选择服务门店</text>
  214. <scroll-view scroll-y="true" class="popup-scroll">
  215. <view class="popup-item" v-for="shop in shopList" :key="shop.id" @click="onShopSelect(shop)">
  216. <text>{{ shop.name }}</text>
  217. </view>
  218. </scroll-view>
  219. </view>
  220. </view>
  221. <!-- 用户选择弹窗 -->
  222. <view class="popup-mask" v-if="showUserPopup" @click="showUserPopup = false">
  223. <view class="popup-content user-popup" @click.stop>
  224. <text class="popup-title">选择宠主</text>
  225. <view class="search-bar">
  226. <input class="search-input" v-model="userSearchKey" placeholder="输入姓名或手机号搜索"
  227. @confirm="fetchUsers" />
  228. <uni-icons type="search" size="18" color="#999" @click="fetchUsers"></uni-icons>
  229. </view>
  230. <scroll-view scroll-y="true" class="popup-scroll">
  231. <view class="popup-item" v-for="user in userList" :key="user.id" @click="onUserSelect(user)">
  232. <text class="user-item-name">{{ user.name }}</text>
  233. <text class="user-item-phone">{{ user.phone || user.phoneNumber }}</text>
  234. </view>
  235. </scroll-view>
  236. </view>
  237. </view>
  238. <!-- 宠物选择弹窗 -->
  239. <view class="popup-mask" v-if="showPetPopup" @click="showPetPopup = false">
  240. <view class="popup-content" @click.stop>
  241. <text class="popup-title">选择宠物</text>
  242. <scroll-view scroll-y="true" class="popup-scroll">
  243. <view class="popup-item" v-for="pet in petList" :key="pet.id" @click="onPetSelect(pet)">
  244. <view class="pet-item-cell">
  245. <image :src="pet.avatar" class="pet-avatar-mini" mode="aspectFill"></image>
  246. <text>{{ pet.name }} ({{ pet.breed }})</text>
  247. </view>
  248. </view>
  249. <view v-if="petList.length === 0" class="empty-tips">该用户下暂无宠物档案</view>
  250. </scroll-view>
  251. </view>
  252. </view>
  253. </view>
  254. </template>
  255. <script setup>
  256. import { ref, reactive, computed, watch } from 'vue'
  257. import { onLoad } from '@dcloudio/uni-app'
  258. import navBar from '@/components/nav-bar/index.vue'
  259. import { listStoreOnOrder } from '@/api/system/store'
  260. import { listCustomerOnOrder } from '@/api/archieves/customer'
  261. import { listPetByUser } from '@/api/archieves/pet'
  262. import { createOrder } from '@/api/order/order'
  263. import { listRegionTree } from '@/api/system/region'
  264. const showPetPopup = ref(false)
  265. const activeService = ref('transport')
  266. const showShopPicker = ref(false)
  267. const showUserPopup = ref(false)
  268. const selectedUser = ref(null)
  269. const selectedShop = ref(null)
  270. const selectedPet = ref(null)
  271. const shopList = ref([])
  272. const userList = ref([])
  273. const petList = ref([])
  274. const userSearchKey = ref('')
  275. const serviceInfo = ref(null)
  276. const regionTree = ref([])
  277. const pickAreaLabel = ref('')
  278. const pickEndAreaLabel = ref('')
  279. const sendStartAreaLabel = ref('')
  280. const sendAreaLabel = ref('')
  281. const serviceAreaLabel = ref('')
  282. const currentServiceName = computed(() => {
  283. // @Author: Antigravity
  284. if (serviceInfo.value) return serviceInfo.value.name
  285. const map = { transport: '宠物接送', feed: '上门喂遛', wash: '上门洗护' }
  286. return map[activeService.value]
  287. })
  288. const serviceIcon = computed(() => {
  289. const map = { transport: 'car', feed: 'shop', wash: 'color' }
  290. return map[activeService.value]
  291. })
  292. const serviceDesc = computed(() => {
  293. // @Author: Antigravity
  294. if (serviceInfo.value) return serviceInfo.value.remark
  295. const map = { transport: '专车接送 · 全程监护', feed: '喂食添水 · 陪玩遛狗', wash: '专业设备 · 深度清洁' }
  296. return map[activeService.value]
  297. })
  298. onLoad((options) => {
  299. if (options.service) activeService.value = options.service
  300. // @Author: Antigravity
  301. const stored = uni.getStorageSync('currentService')
  302. if (stored) {
  303. serviceInfo.value = stored
  304. }
  305. // 初始化获取数据
  306. fetchShops()
  307. fetchUsers()
  308. fetchRegionTree()
  309. })
  310. const fetchRegionTree = () => {
  311. listRegionTree().then(res => {
  312. console.log('移动端获取到的地区树数据:', res)
  313. regionTree.value = res || []
  314. }).catch(err => {
  315. console.error('获取地区树异常:', err)
  316. })
  317. }
  318. const onRegionChange = (type, e) => {
  319. // @Author: Antigravity
  320. const text = e.detail.value.map(v => v.text).join(' / ')
  321. if (type === 'pick') pickAreaLabel.value = text
  322. else if (type === 'pickEnd') pickEndAreaLabel.value = text
  323. else if (type === 'sendStart') sendStartAreaLabel.value = text
  324. else if (type === 'send') sendAreaLabel.value = text
  325. else if (type === 'service') serviceAreaLabel.value = text
  326. }
  327. // 根据 code 递归查找地区名称全路径 @Author: Antigravity
  328. const findRegionLabel = (code, list) => {
  329. if (!code || !list || list.length === 0) return ''
  330. // 如果是路径格式,取最后一位
  331. const targetCode = code.includes('/') ? code.split('/').pop() : code
  332. const find = (nodes, target) => {
  333. for (let item of nodes) {
  334. if (item.code === target) return item.name
  335. if (item.children && item.children.length > 0) {
  336. const childMatch = find(item.children, target)
  337. if (childMatch) return item.name + ' / ' + childMatch
  338. }
  339. }
  340. return null
  341. }
  342. return find(list, targetCode) || ''
  343. }
  344. const formData = reactive({
  345. merchantId: '', shopName: '',
  346. customerId: '', customerName: '',
  347. petId: '', petName: '',
  348. packageName: '',
  349. transportMode: 'round_trip',
  350. pickArea: '', pickAddress: '', pickEndArea: '', pickEndAddress: '', pickContact: '', pickPhone: '', pickTime: '',
  351. sendStartArea: '', sendStartAddress: '', sendArea: '', sendAddress: '', sendContact: '', sendPhone: '', sendTime: '',
  352. serviceArea: '', serviceAddress: '',
  353. feedTimes: [{ start: '', end: '' }],
  354. otherNote: '',
  355. quoteAmount: ''
  356. })
  357. const fetchShops = () => {
  358. // @Author: Antigravity
  359. const query = { pageNum: 1, pageSize: 50 }
  360. if (serviceInfo.value && serviceInfo.value.id) {
  361. query.serviceId = serviceInfo.value.id
  362. }
  363. listStoreOnOrder(query).then(res => {
  364. shopList.value = res.rows || []
  365. })
  366. }
  367. const fetchUsers = () => {
  368. listCustomerOnOrder({ pageNum: 1, pageSize: 20, content: userSearchKey.value }).then(res => {
  369. userList.value = res.rows || []
  370. })
  371. }
  372. const fetchPets = (userId) => {
  373. listPetByUser(userId).then(res => {
  374. // @Author: Antigravity
  375. // 移动端 request.js 自动解构 data,res 即为宠物列表数组
  376. petList.value = Array.isArray(res) ? res : (res.rows || [])
  377. })
  378. }
  379. const onShopSelect = (shop) => {
  380. // @Author: Antigravity
  381. selectedShop.value = shop
  382. formData.merchantId = shop.id
  383. formData.shopName = shop.name
  384. showShopPicker.value = false
  385. }
  386. const onUserSelect = (user) => {
  387. // @Author: Antigravity
  388. selectedUser.value = user
  389. formData.customerId = user.id
  390. formData.customerName = user.name
  391. // 重置宠物
  392. formData.petId = ''
  393. formData.petName = ''
  394. selectedPet.value = null
  395. fetchPets(user.id)
  396. showUserPopup.value = false
  397. }
  398. // 核心回填逻辑:watch 响应门店/用户/地区树任一变化,对齐 Web 端 watch([store, user]) @Author: Antigravity
  399. watch(
  400. [selectedShop, selectedUser, regionTree],
  401. ([shop, user, tree]) => {
  402. // 门店区域码与地址 (areaCode 为逗号分隔) @Author: Antigravity
  403. const storeArea = shop?.areaCode || ''
  404. const storeAddr = shop?.address || ''
  405. const storeLeaf = storeArea.includes(',') ? storeArea.split(',').pop() : storeArea
  406. // 用户区域码与地址 (regionCode 为斜杠分隔) @Author: Antigravity
  407. const userArea = user?.regionCode || ''
  408. const userAddr = user?.address || ''
  409. const userPhone = user?.phoneNumber || user?.phone || ''
  410. const userLeaf = userArea.includes('/') ? userArea.split('/').pop() : userArea
  411. // 回填接宠路线:起点=用户家,终点=门店 @Author: Antigravity
  412. formData.pickArea = userLeaf
  413. formData.pickAddress = userAddr
  414. formData.pickEndArea = storeLeaf
  415. formData.pickEndAddress = storeAddr
  416. formData.pickContact = user?.name || ''
  417. formData.pickPhone = userPhone
  418. pickAreaLabel.value = findRegionLabel(userArea, tree)
  419. pickEndAreaLabel.value = findRegionLabel(storeArea.replace(/,/g, '/'), tree)
  420. // 回填送宠路线:起点=门店,终点=用户家 @Author: Antigravity
  421. formData.sendStartArea = storeLeaf
  422. formData.sendStartAddress = storeAddr
  423. formData.sendArea = userLeaf
  424. formData.sendAddress = userAddr
  425. formData.sendContact = user?.name || ''
  426. formData.sendPhone = userPhone
  427. sendStartAreaLabel.value = findRegionLabel(storeArea.replace(/,/g, '/'), tree)
  428. sendAreaLabel.value = findRegionLabel(userArea, tree)
  429. // 回填上门服务地址 @Author: Antigravity
  430. formData.serviceArea = userLeaf
  431. formData.serviceAddress = userAddr
  432. serviceAreaLabel.value = findRegionLabel(userArea, tree)
  433. },
  434. { deep: true }
  435. )
  436. const openPetPicker = () => {
  437. if (!formData.customerId) {
  438. uni.showToast({ title: '请先选择宠主', icon: 'none' })
  439. return
  440. }
  441. showPetPopup.value = true
  442. }
  443. const onPetSelect = (pet) => {
  444. // @Author: Antigravity
  445. selectedPet.value = pet
  446. formData.petId = pet.id
  447. formData.petName = pet.name
  448. showPetPopup.value = false
  449. }
  450. const totalFulfillmentCommission = computed(() => {
  451. if (formData.quoteAmount && !isNaN(parseFloat(formData.quoteAmount))) return parseFloat(formData.quoteAmount).toFixed(2)
  452. return '0.00'
  453. })
  454. const transportModes = [
  455. { label: '往返接送', value: 'round_trip' },
  456. { label: '单程接', value: 'pick_up' },
  457. { label: '单程送', value: 'return_home' }
  458. ]
  459. const addFeedTime = () => { formData.feedTimes.push({ start: '', end: '' }) }
  460. const removeFeedTime = (index) => { formData.feedTimes.splice(index, 1) }
  461. const onSubmit = async () => {
  462. // @Author: Antigravity
  463. if (!formData.merchantId) { uni.showToast({ title: '请选择门店', icon: 'none' }); return }
  464. if (!formData.customerId) { uni.showToast({ title: '请选择宠主', icon: 'none' }); return }
  465. if (!formData.petId) { uni.showToast({ title: '请选择宠物', icon: 'none' }); return }
  466. if (!formData.quoteAmount) { uni.showToast({ title: '请输入报价金额', icon: 'none' }); return }
  467. uni.showLoading({ title: '提交中...', mask: true })
  468. try {
  469. const subOrders = []
  470. const baseMode = serviceInfo.value?.mode || 0
  471. const defaultContact = selectedUser.value?.name || ''
  472. const defaultPhone = selectedUser.value?.phone || selectedUser.value?.phoneNumber || ''
  473. if (activeService.value === 'transport') {
  474. // 接送逻辑:使用表单中回填/编辑后的起终点地址 @Author: Antigravity
  475. if (formData.transportMode === 'round_trip' || formData.transportMode === 'pick_up') {
  476. subOrders.push({
  477. mode: baseMode,
  478. type: formData.transportMode === 'round_trip' ? 0 : 2,
  479. contact: formData.pickContact || defaultContact,
  480. contactPhoneNumber: formData.pickPhone || defaultPhone,
  481. serviceTime: formData.pickTime || '',
  482. endServiceTime: formData.pickTime || '',
  483. fromCode: formData.pickArea || '',
  484. fromAddress: formData.pickAddress || '',
  485. toCode: formData.pickEndArea || '',
  486. toAddress: formData.pickEndAddress || ''
  487. })
  488. }
  489. if (formData.transportMode === 'round_trip' || formData.transportMode === 'return_home') {
  490. subOrders.push({
  491. mode: baseMode,
  492. type: formData.transportMode === 'round_trip' ? 1 : 3,
  493. contact: formData.sendContact || defaultContact,
  494. contactPhoneNumber: formData.sendPhone || defaultPhone,
  495. serviceTime: formData.sendTime || '',
  496. endServiceTime: formData.sendTime || '',
  497. fromCode: formData.sendStartArea || '',
  498. fromAddress: formData.sendStartAddress || '',
  499. toCode: formData.sendArea || '',
  500. toAddress: formData.sendAddress || ''
  501. })
  502. }
  503. } else {
  504. // 上门喂遛或洗护逻辑,补全 fromCode/toCode/toAddress @Author: Antigravity
  505. formData.feedTimes.forEach(time => {
  506. subOrders.push({
  507. mode: baseMode,
  508. contact: defaultContact,
  509. contactPhoneNumber: defaultPhone,
  510. serviceTime: time.start,
  511. endServiceTime: time.end || time.start,
  512. fromCode: formData.serviceArea || '',
  513. fromAddress: formData.serviceAddress,
  514. toCode: formData.serviceArea || '',
  515. toAddress: formData.serviceAddress
  516. })
  517. })
  518. }
  519. const payload = {
  520. store: formData.merchantId,
  521. storeSite: selectedShop.value?.site,
  522. customer: formData.customerId,
  523. pet: formData.petId,
  524. groupPurchasePackageName: formData.packageName || '',
  525. service: serviceInfo.value?.id,
  526. orderCommission: Math.round(Number(formData.quoteAmount) * 100),
  527. remark: formData.otherNote,
  528. tenantId: selectedShop.value?.tenantId,
  529. subOrders: subOrders
  530. }
  531. await createOrder(payload)
  532. uni.hideLoading()
  533. uni.showToast({ title: '下单成功', icon: 'success' })
  534. setTimeout(() => {
  535. uni.reLaunch({ url: '/pages/order/list/index' })
  536. }, 1500)
  537. } catch (error) {
  538. uni.hideLoading()
  539. console.error('下单失败:', error)
  540. }
  541. }
  542. </script>
  543. <style lang="scss" scoped>
  544. .order-apply-page {
  545. background: #f7f8fa;
  546. min-height: 100vh;
  547. padding-bottom: 200rpx;
  548. }
  549. .apply-content {
  550. padding: 0 32rpx;
  551. }
  552. .section-title {
  553. display: flex;
  554. align-items: center;
  555. font-size: 30rpx;
  556. font-weight: bold;
  557. color: #333;
  558. margin: 32rpx 0 20rpx;
  559. }
  560. .section-title::before {
  561. content: '';
  562. width: 8rpx;
  563. height: 28rpx;
  564. background: #f7ca3e;
  565. margin-right: 16rpx;
  566. border-radius: 4rpx;
  567. }
  568. .card {
  569. background: #fff;
  570. border-radius: 24rpx;
  571. padding: 24rpx;
  572. margin-bottom: 24rpx;
  573. }
  574. .service-type-display {
  575. display: flex;
  576. align-items: center;
  577. gap: 24rpx;
  578. }
  579. .service-icon-box {
  580. width: 88rpx;
  581. height: 88rpx;
  582. border-radius: 20rpx;
  583. display: flex;
  584. align-items: center;
  585. justify-content: center;
  586. }
  587. .service-icon-box.transport {
  588. background: linear-gradient(135deg, #64b5f6, #2196f3);
  589. }
  590. .service-icon-box.feed {
  591. background: linear-gradient(135deg, #ffb74d, #ff9800);
  592. }
  593. .service-icon-box.wash {
  594. background: linear-gradient(135deg, #81c784, #4caf50);
  595. }
  596. .main-name {
  597. display: block;
  598. font-size: 32rpx;
  599. font-weight: bold;
  600. color: #333;
  601. }
  602. .sub-desc {
  603. display: block;
  604. font-size: 24rpx;
  605. color: #999;
  606. margin-top: 4rpx;
  607. }
  608. .field-row {
  609. display: flex;
  610. align-items: center;
  611. padding: 24rpx 0;
  612. border-bottom: 1rpx solid #f5f5f5;
  613. }
  614. .field-row:last-child {
  615. border-bottom: none;
  616. }
  617. .field-label {
  618. width: 160rpx;
  619. font-size: 28rpx;
  620. color: #333;
  621. flex-shrink: 0;
  622. }
  623. .field-value {
  624. flex: 1;
  625. font-size: 28rpx;
  626. color: #333;
  627. text-align: right;
  628. }
  629. .field-value.placeholder {
  630. color: #ccc;
  631. }
  632. .field-value-wrap {
  633. flex: 1;
  634. display: flex;
  635. align-items: center;
  636. justify-content: flex-end;
  637. gap: 12rpx;
  638. }
  639. .selected-name {
  640. font-size: 28rpx;
  641. font-weight: bold;
  642. color: #333;
  643. }
  644. .selected-phone {
  645. font-size: 24rpx;
  646. color: #666;
  647. }
  648. .placeholder {
  649. color: #ccc;
  650. font-size: 28rpx;
  651. }
  652. .field-input {
  653. flex: 1;
  654. font-size: 28rpx;
  655. color: #333;
  656. text-align: right;
  657. }
  658. .unit-text {
  659. font-size: 28rpx;
  660. color: #999;
  661. margin-left: 8rpx;
  662. }
  663. .form-item-label {
  664. display: block;
  665. font-size: 28rpx;
  666. color: #333;
  667. margin: 24rpx 0 16rpx;
  668. font-weight: 500;
  669. }
  670. .mode-select {
  671. display: flex;
  672. gap: 16rpx;
  673. margin-bottom: 32rpx;
  674. }
  675. .mode-btn {
  676. flex: 1;
  677. height: 64rpx;
  678. display: flex;
  679. align-items: center;
  680. justify-content: center;
  681. border: 1rpx solid #ddd;
  682. border-radius: 12rpx;
  683. font-size: 24rpx;
  684. color: #666;
  685. }
  686. .mode-btn.active {
  687. background: #fef8e5;
  688. border-color: #f7ca3e;
  689. color: #f7ca3e;
  690. font-weight: bold;
  691. }
  692. .route-box {
  693. display: flex;
  694. gap: 24rpx;
  695. margin-bottom: 24rpx;
  696. }
  697. .route-icon {
  698. width: 48rpx;
  699. height: 48rpx;
  700. border-radius: 8rpx;
  701. color: #fff;
  702. display: flex;
  703. align-items: center;
  704. justify-content: center;
  705. font-size: 24rpx;
  706. font-weight: bold;
  707. flex-shrink: 0;
  708. margin-top: 16rpx;
  709. }
  710. .route-icon.pick {
  711. background: #5bb7ff;
  712. }
  713. .route-icon.send {
  714. background: #64cf5c;
  715. }
  716. .route-fields {
  717. flex: 1;
  718. display: flex;
  719. flex-direction: column;
  720. gap: 8rpx;
  721. }
  722. .route-input {
  723. width: 100%;
  724. height: 72rpx;
  725. font-size: 26rpx;
  726. color: #333;
  727. border-bottom: 1rpx solid #f0f0f0;
  728. padding: 0 8rpx;
  729. }
  730. .contact-row {
  731. display: flex;
  732. gap: 16rpx;
  733. }
  734. .route-input.half {
  735. flex: 1;
  736. }
  737. /* 起点/终点标签 @Author: Antigravity */
  738. .addr-label {
  739. font-size: 24rpx;
  740. color: #606266;
  741. font-weight: bold;
  742. margin-top: 16rpx;
  743. margin-bottom: 4rpx;
  744. }
  745. .address-title {
  746. display: block;
  747. font-size: 28rpx;
  748. color: #333;
  749. font-weight: 500;
  750. margin: 24rpx 0 16rpx;
  751. }
  752. .full-input {
  753. width: 100%;
  754. height: 72rpx;
  755. font-size: 26rpx;
  756. color: #333;
  757. border-bottom: 1rpx solid #f0f0f0;
  758. padding: 0 8rpx;
  759. margin-bottom: 8rpx;
  760. }
  761. .premium-cascader-display {
  762. display: flex;
  763. align-items: center;
  764. padding: 16rpx 8rpx;
  765. border-bottom: 1rpx solid #f0f0f0;
  766. .display-text {
  767. flex: 1;
  768. font-size: 26rpx;
  769. color: #333;
  770. &.placeholder {
  771. color: #ccc;
  772. }
  773. }
  774. }
  775. .premium-full-picker {
  776. display: flex;
  777. align-items: center;
  778. padding: 24rpx 12rpx;
  779. background: #f9f9f9;
  780. border-radius: 12rpx;
  781. margin-bottom: 16rpx;
  782. .display-text {
  783. flex: 1;
  784. font-size: 28rpx;
  785. color: #333;
  786. &.placeholder {
  787. color: #ccc;
  788. }
  789. }
  790. }
  791. .booking-section {
  792. margin-top: 24rpx;
  793. }
  794. .time-picker-row {
  795. border-bottom: 1rpx solid #f0f0f0;
  796. padding: 4rpx 0;
  797. }
  798. .flex-picker-box {
  799. flex: 1;
  800. background: #fcfcfc;
  801. border-radius: 12rpx;
  802. border: 1rpx solid #f0f0f0;
  803. height: 64rpx;
  804. display: flex;
  805. align-items: center;
  806. .inline-picker {
  807. width: 100%;
  808. height: 100%;
  809. display: flex;
  810. align-items: center;
  811. }
  812. }
  813. .booking-header {
  814. display: flex;
  815. justify-content: space-between;
  816. align-items: center;
  817. margin-bottom: 16rpx;
  818. }
  819. .booking-header .label {
  820. font-size: 28rpx;
  821. color: #333;
  822. font-weight: 500;
  823. }
  824. .count-tag {
  825. font-size: 22rpx;
  826. color: #ff9500;
  827. background: #fff3e0;
  828. padding: 4rpx 16rpx;
  829. border-radius: 8rpx;
  830. }
  831. .time-item-row {
  832. display: flex;
  833. align-items: center;
  834. gap: 12rpx;
  835. margin-bottom: 16rpx;
  836. }
  837. .index {
  838. font-size: 26rpx;
  839. color: #999;
  840. width: 40rpx;
  841. }
  842. .time-input {
  843. flex: 1;
  844. height: 64rpx;
  845. font-size: 24rpx;
  846. border: 1rpx solid #f0f0f0;
  847. border-radius: 12rpx;
  848. padding: 0 16rpx;
  849. }
  850. .to-line {
  851. color: #999;
  852. }
  853. .action-buttons {
  854. display: flex;
  855. gap: 8rpx;
  856. }
  857. .circle-btn {
  858. width: 48rpx;
  859. height: 48rpx;
  860. border-radius: 50%;
  861. display: flex;
  862. align-items: center;
  863. justify-content: center;
  864. font-size: 28rpx;
  865. font-weight: bold;
  866. }
  867. .circle-btn.add {
  868. background: #e3f2fd;
  869. color: #2196f3;
  870. }
  871. .circle-btn.remove {
  872. background: #fde2e2;
  873. color: #f56c6c;
  874. }
  875. .remarks-title {
  876. display: block;
  877. font-size: 28rpx;
  878. color: #333;
  879. font-weight: 500;
  880. margin: 24rpx 0 16rpx;
  881. }
  882. .remarks-textarea {
  883. width: 100%;
  884. height: 160rpx;
  885. font-size: 26rpx;
  886. color: #333;
  887. background: #f9f9f9;
  888. border-radius: 16rpx;
  889. padding: 20rpx;
  890. }
  891. .quote-tips {
  892. display: block;
  893. font-size: 22rpx;
  894. color: #999;
  895. margin-top: 12rpx;
  896. }
  897. .footer-bar {
  898. position: fixed;
  899. bottom: 0;
  900. left: 0;
  901. right: 0;
  902. background: #fff;
  903. padding: 20rpx 32rpx;
  904. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  905. display: flex;
  906. align-items: center;
  907. box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
  908. z-index: 10;
  909. }
  910. .quotation-fulfillmentCommission-box {
  911. flex: 1;
  912. display: flex;
  913. align-items: baseline;
  914. }
  915. .p-label {
  916. font-size: 26rpx;
  917. color: #333;
  918. }
  919. .p-symbol {
  920. font-size: 28rpx;
  921. color: #f44336;
  922. font-weight: bold;
  923. margin-left: 8rpx;
  924. }
  925. .p-amount {
  926. font-size: 44rpx;
  927. font-weight: 900;
  928. color: #f44336;
  929. }
  930. .submit-btn {
  931. width: 280rpx;
  932. height: 88rpx;
  933. background: linear-gradient(90deg, #ffd53f, #ff9500);
  934. color: #333;
  935. border: none;
  936. border-radius: 44rpx;
  937. font-size: 30rpx;
  938. font-weight: bold;
  939. line-height: 88rpx;
  940. }
  941. .popup-mask {
  942. position: fixed;
  943. top: 0;
  944. left: 0;
  945. right: 0;
  946. bottom: 0;
  947. background: rgba(0, 0, 0, 0.5);
  948. z-index: 999;
  949. display: flex;
  950. align-items: flex-end;
  951. }
  952. .popup-content {
  953. width: 100%;
  954. background: #fff;
  955. border-radius: 32rpx 32rpx 0 0;
  956. padding: 40rpx 32rpx;
  957. max-height: 70vh;
  958. }
  959. .popup-title {
  960. display: block;
  961. font-size: 32rpx;
  962. font-weight: bold;
  963. color: #333;
  964. margin-bottom: 24rpx;
  965. text-align: center;
  966. }
  967. .popup-item {
  968. padding: 28rpx 0;
  969. border-bottom: 1rpx solid #f5f5f5;
  970. font-size: 28rpx;
  971. color: #333;
  972. }
  973. .user-popup .popup-item {
  974. display: flex;
  975. justify-content: space-between;
  976. }
  977. .user-item-name {
  978. font-weight: bold;
  979. }
  980. .user-item-phone {
  981. color: #999;
  982. }
  983. .popup-scroll {
  984. max-height: 600rpx;
  985. margin-top: 20rpx;
  986. }
  987. .search-bar {
  988. display: flex;
  989. align-items: center;
  990. background: #f5f5f5;
  991. border-radius: 40rpx;
  992. padding: 0 30rpx;
  993. margin-bottom: 20rpx;
  994. height: 72rpx;
  995. }
  996. .search-input {
  997. flex: 1;
  998. font-size: 26rpx;
  999. color: #333;
  1000. }
  1001. .pet-item-cell {
  1002. display: flex;
  1003. align-items: center;
  1004. gap: 20rpx;
  1005. }
  1006. .pet-avatar-mini {
  1007. width: 60rpx;
  1008. height: 60rpx;
  1009. border-radius: 10rpx;
  1010. background: #f0f0f0;
  1011. }
  1012. .empty-tips {
  1013. text-align: center;
  1014. color: #999;
  1015. font-size: 24rpx;
  1016. padding: 40rpx 0;
  1017. }
  1018. </style>