create_order.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. <template>
  2. <view class="order-container">
  3. <!-- 用户信息卡片 -->
  4. <view class="info-card">
  5. <view class="address-item">
  6. <view class="img-status-text">
  7. <image src="/static/img/icon-send.png" mode="" class="img"></image>
  8. </view>
  9. <view class="user-info">
  10. <AddressInfo v-if="addressSend.id" :address="addressSend" />
  11. <view v-else class="create-btn" @click="handleAddAddress('sender')">新建寄件人</view>
  12. </view>
  13. <view class="img-status-text right" @click="openAddressBook('sender')">
  14. <image src="/static/img/create-order-address.png" mode="" class="address-image"></image>
  15. <view class="status-text">地址薄</view>
  16. </view>
  17. </view>
  18. <view class="address-item">
  19. <view class="img-status-text">
  20. <image src="/static/img/create-order-change.png" mode="" class="img-change"></image>
  21. </view>
  22. <view class="user-info">
  23. <view class="line"></view>
  24. </view>
  25. </view>
  26. <view class="address-item">
  27. <view class="img-status-text">
  28. <image src="/static/img/icon-receive.png" mode="" class="img"></image>
  29. </view>
  30. <view class="user-info">
  31. <AddressInfo v-if="addressReceive.id" :address="addressReceive" />
  32. <view v-else class="create-btn" @click="handleAddAddress('receiver')">新建收件人</view>
  33. </view>
  34. <view class="img-status-text right" @click="openAddressBook('receiver')">
  35. <image src="/static/img/create-order-address.png" mode="" class="address-image"></image>
  36. <view class="status-text">地址薄</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="pickup-title">上门取件</view>
  41. <!-- 物品信息 -->
  42. <view class="goods-card">
  43. <view class="goods-item">
  44. <view class="item-label required">期望上门时间</view>
  45. <view class="time-value" @click="handleTimeClick">
  46. <text class="value">{{ selectedTimeLabel }}</text>
  47. <u-icon class="arrow" name='arrow-right' size="18"></u-icon>
  48. </view>
  49. </view>
  50. <view class="goods-item">
  51. <view class="item-label required">快递类型</view>
  52. <view class="item-control">
  53. <picker :range="expressTypes" :range-key="'label'" @change="onExpressTypeChange" :value="expressTypeIndex">
  54. <view class="picker-text">{{ expressTypes[expressTypeIndex]?.label || '请选择快递类型' }}</view>
  55. </picker>
  56. <u-icon class="arrow" name='arrow-right' size="18"></u-icon>
  57. </view>
  58. </view>
  59. <view class="goods-item">
  60. <view class="item-label required">物品信息</view>
  61. <view class="item-control">
  62. <input
  63. class="input-field"
  64. placeholder="请输入物品信息"
  65. placeholder-class="placeholder"
  66. v-model="goodsInfo"
  67. maxlength="50"
  68. @input="onGoodsInfoInput"
  69. />
  70. </view>
  71. </view>
  72. <!-- 总体重 -->
  73. <view class="goods-item">
  74. <view class="item-label">总体重(KG)</view>
  75. <view class="item-control btn">
  76. <view class="control-btn minus" @click="decreaseWeight">-</view>
  77. <view class="control-value">
  78. <input
  79. class="input-field"
  80. placeholder=""
  81. placeholder-class="placeholder"
  82. :value="weight"
  83. @input="handleWeightInput"
  84. type="digit"
  85. />
  86. </view>
  87. <view class="control-btn plus" @click="increaseWeight">+</view>
  88. </view>
  89. </view>
  90. <!-- 总体积 -->
  91. <view class="goods-item">
  92. <view class="item-label">总体积(m³)</view>
  93. <view class="item-control btn">
  94. <view class="control-btn minus" @click="decreaseVolume">-</view>
  95. <view class="control-value">
  96. <input
  97. class="input-field"
  98. placeholder=""
  99. placeholder-class="placeholder"
  100. :value="volume"
  101. @input="handleVolumeInput"
  102. type="digit"
  103. />
  104. </view>
  105. <view class="control-btn plus" @click="increaseVolume">+</view>
  106. </view>
  107. </view>
  108. <!-- 件数 -->
  109. <view class="goods-item">
  110. <view class="item-label">件数(件)</view>
  111. <view class="item-control btn">
  112. <view class="control-btn minus" @click="decreaseQuantity">-</view>
  113. <view class="control-value">
  114. <input
  115. class="input-field"
  116. placeholder=""
  117. placeholder-class="placeholder"
  118. :value="quantity"
  119. @input="handleQuantityInput"
  120. type="number"
  121. />
  122. </view>
  123. <view class="control-btn plus" @click="increaseQuantity">+</view>
  124. </view>
  125. </view>
  126. </view>
  127. <view class="pickup-title">增值服务</view>
  128. <!-- 物品信息 -->
  129. <view class="goods-card">
  130. <view class="goods-item">
  131. <view class="item-label">包装服务</view>
  132. <view class="item-control">
  133. <switch color="#007AFF" :checked="valueServices.isPack" @change="onPackagingChange" />
  134. </view>
  135. </view>
  136. <view class="goods-item">
  137. <view class="item-label">保价</view>
  138. <view class="item-control">
  139. <switch color="#007AFF" :checked="!!insuranceAmount" @change="onInsuranceChange" />
  140. </view>
  141. </view>
  142. <view v-if="insuranceAmount" class="goods-item">
  143. <view class="item-label">保价金额(元)</view>
  144. <view class="item-control">
  145. <input
  146. class="input-field"
  147. placeholder="请输入保价金额"
  148. placeholder-class="placeholder"
  149. v-model="insuranceAmount"
  150. type="digit"
  151. maxlength="10"
  152. @input="validateInsuranceAmount"
  153. />
  154. </view>
  155. </view>
  156. <!-- 京东没有超长超重和打木架服务 -->
  157. <template v-if="product === '2'">
  158. <view class="goods-item">
  159. <view class="item-label">超长超重</view>
  160. <view class="item-control">
  161. <switch color="#007AFF" :checked="valueServices.isOverLongWeight" @change="onOverweightChange" />
  162. </view>
  163. </view>
  164. <view class="goods-item">
  165. <view class="item-label">打木架</view>
  166. <view class="item-control">
  167. <switch color="#007AFF" :checked="valueServices.isWoodenCrate" @change="onWoodenFrameChange" />
  168. </view>
  169. </view>
  170. </template>
  171. <view class="goods-item">
  172. <view class="item-label">签单返还</view>
  173. <view class="item-control">
  174. <switch color="#007AFF" :checked="valueServices.isReceiptCollect" @change="onSignReturnChange" />
  175. </view>
  176. </view>
  177. <!-- 顺丰的签单返还类型选择 -->
  178. <view v-if="product === '2' && valueServices.isReceiptCollect" class="goods-item">
  179. <view class="item-label">返还类型</view>
  180. <view class="item-control">
  181. <picker :range="receiptReturnTypes" :range-key="'label'" @change="onReceiptReturnTypeChange" :value="receiptReturnTypeIndex">
  182. <view class="picker-text">{{ receiptReturnTypes[receiptReturnTypeIndex]?.label || '请选择返还类型' }}</view>
  183. </picker>
  184. <u-icon class="arrow" name='arrow-right' size="18"></u-icon>
  185. </view>
  186. </view>
  187. </view>
  188. <!-- 协议同意 -->
  189. <view class="agreement-card">
  190. <view class="agreement-item">
  191. <checkbox color="#1B64F0" :checked="agreed" @click="toggleAgreement" style="transform:scale(0.8)" />
  192. <text class="agreement-text">我已理解并同意遵守《快件服务协议》</text>
  193. </view>
  194. <view class="price-notice">
  195. 实际费用以快递员核实为准,四舍五入取整
  196. </view>
  197. </view>
  198. <!-- 下单按钮 -->
  199. <view class="submit-btn" :class="{ disabled: !agreed }" @click="submitOrder">
  200. 提交订单
  201. </view>
  202. <!-- 安全区域占位 -->
  203. <view class="safe-area"></view>
  204. <!-- 时间选择弹窗 -->
  205. <TimePopup :visible="showTimePicker" @close="showTimePicker = false" @confirm="handleTimeConfirm" />
  206. </view>
  207. </template>
  208. <script setup>
  209. import {
  210. ref,
  211. computed,
  212. onMounted,
  213. watch,
  214. } from 'vue'
  215. import { onLoad } from '@dcloudio/uni-app'
  216. import TimePopup from './components/TimePopup.vue'
  217. import AddressInfo from '@/components/AddressInfo.vue'
  218. // 从本地存储获取地址信息
  219. const getAddressFromStorage = (key) => {
  220. const address = uni.getStorageSync(key)
  221. return address || {
  222. id: '',
  223. name: '',
  224. phone: '',
  225. address: '',
  226. provinceName: '',
  227. cityName: '',
  228. countyName: '',
  229. isDefault: false
  230. }
  231. }
  232. // 保存地址到本地存储
  233. const saveAddressToStorage = (key, address) => {
  234. uni.setStorageSync(key, address)
  235. }
  236. // 产品类型:1是京东,2是顺丰
  237. const product = ref('1')
  238. // 物品信息
  239. const goodsInfo = ref('')
  240. const weight = ref(1)
  241. const volume = ref(0.001)
  242. const quantity = ref(1)
  243. // 时间选择
  244. const showTimePicker = ref(false)
  245. const selectedTimeData = ref(null)
  246. // 快递类型相关
  247. const expressTypeIndex = ref(0)
  248. const expressTypes = ref([])
  249. // 快递类型数据字典
  250. const expressTypeDict = {
  251. '1': [ // 京东
  252. { label: '特快', value: 'express' },
  253. { label: '标快', value: 'standard' }
  254. ],
  255. '2': [ // 顺丰
  256. { label: '顺丰即日', value: 'sf_today' },
  257. { label: '顺丰特快', value: 'sf_express' },
  258. { label: '顺丰标快', value: 'sf_standard' },
  259. { label: '顺丰次晨', value: 'sf_next_morning' },
  260. { label: '顺丰标陆', value: 'sf_land' }
  261. ]
  262. }
  263. // 增值服务
  264. const valueServices = ref({
  265. isPack: false,
  266. isOverLongWeight: false,
  267. isReceiptCollect: false,
  268. isWoodenCrate: false
  269. })
  270. // 签单返还类型(仅顺丰)
  271. const receiptReturnTypeIndex = ref(0)
  272. const receiptReturnTypes = ref([
  273. { label: '电子凭证', value: 'electronic' },
  274. { label: '纸质凭证', value: 'paper' }
  275. ])
  276. // 保价金额
  277. const insuranceAmount = ref('')
  278. const insuranceAmountError = ref('')
  279. // 协议同意
  280. const agreed = ref(false)
  281. // 地址信息
  282. const addressSend = ref(getAddressFromStorage('senderAddress'))
  283. const addressReceive = ref(getAddressFromStorage('receiverAddress'))
  284. // 计算显示的时间标签
  285. const selectedTimeLabel = computed(() => {
  286. if (!selectedTimeData.value) return '请选择时间'
  287. const {
  288. dateLabel,
  289. timeLabel,
  290. isToday,
  291. isImmediate
  292. } = selectedTimeData.value
  293. if (isToday && isImmediate) {
  294. return '一小时内'
  295. }
  296. return `${dateLabel} ${timeLabel}`
  297. })
  298. // 监听product变化,更新快递类型
  299. watch(product, (newVal) => {
  300. expressTypes.value = expressTypeDict[newVal] || []
  301. expressTypeIndex.value = 0
  302. // 重置增值服务
  303. valueServices.value = {
  304. isPack: false,
  305. isOverLongWeight: false,
  306. isReceiptCollect: false,
  307. isWoodenCrate: false
  308. }
  309. insuranceAmount.value = ''
  310. receiptReturnTypeIndex.value = 0
  311. }, { immediate: true })
  312. // 重量操作
  313. const increaseWeight = () => {
  314. weight.value = parseFloat((weight.value + 0.5).toFixed(3))
  315. if (weight.value > 100) weight.value = 100
  316. }
  317. const decreaseWeight = () => {
  318. weight.value = parseFloat((weight.value - 0.5).toFixed(3))
  319. if (weight.value < 0.5) weight.value = 0.5
  320. }
  321. // 体积操作
  322. const increaseVolume = () => {
  323. volume.value = parseFloat((volume.value + 0.001).toFixed(3))
  324. if (volume.value > 10) volume.value = 10
  325. }
  326. const decreaseVolume = () => {
  327. volume.value = parseFloat((volume.value - 0.001).toFixed(3))
  328. if (volume.value < 0.001) volume.value = 0.001
  329. }
  330. // 件数操作
  331. const increaseQuantity = () => {
  332. quantity.value += 1
  333. if (quantity.value > 99) quantity.value = 99
  334. }
  335. const decreaseQuantity = () => {
  336. quantity.value -= 1
  337. if (quantity.value < 1) quantity.value = 1
  338. }
  339. // 快递类型选择
  340. const onExpressTypeChange = (e) => {
  341. expressTypeIndex.value = e.detail.value
  342. }
  343. // 物品信息输入
  344. const onGoodsInfoInput = (e) => {
  345. goodsInfo.value = e.detail.value
  346. if (goodsInfo.value.length > 50) {
  347. goodsInfo.value = goodsInfo.value.substring(0, 50)
  348. }
  349. }
  350. // 增值服务开关
  351. const onPackagingChange = (e) => {
  352. valueServices.value.isPack = e.detail.value
  353. }
  354. const onInsuranceChange = (e) => {
  355. if (e.detail.value) {
  356. insuranceAmount.value = '0'
  357. } else {
  358. insuranceAmount.value = ''
  359. insuranceAmountError.value = ''
  360. }
  361. }
  362. const onOverweightChange = (e) => {
  363. valueServices.value.isOverLongWeight = e.detail.value
  364. }
  365. const onSignReturnChange = (e) => {
  366. valueServices.value.isReceiptCollect = e.detail.value
  367. }
  368. const onWoodenFrameChange = (e) => {
  369. valueServices.value.isWoodenCrate = e.detail.value
  370. }
  371. // 签单返还类型选择
  372. const onReceiptReturnTypeChange = (e) => {
  373. receiptReturnTypeIndex.value = e.detail.value
  374. }
  375. // 时间选择确认
  376. const handleTimeConfirm = (time) => {
  377. selectedTimeData.value = time
  378. showTimePicker.value = false
  379. console.log('已选择时间:', time)
  380. }
  381. // 点击时间选择
  382. const handleTimeClick = () => {
  383. showTimePicker.value = true
  384. }
  385. // 打开地址簿
  386. const openAddressBook = (type) => {
  387. uni.navigateTo({
  388. url: `/pages/address/address_list?addType=${type}&from=order`
  389. })
  390. }
  391. // 添加新地址
  392. const handleAddAddress = (type) => {
  393. console.log('添加新地址')
  394. uni.navigateTo({
  395. url: `/pages/address/edit?addType=${type}`
  396. })
  397. }
  398. // 验证保价金额
  399. const validateInsuranceAmount = () => {
  400. if (!insuranceAmount.value) return true
  401. const amount = parseFloat(insuranceAmount.value)
  402. if (isNaN(amount) || amount < 0) {
  403. insuranceAmountError.value = '保价金额必须为数字且不能小于0'
  404. return false
  405. }
  406. if (amount > 1000000) {
  407. insuranceAmountError.value = '保价金额不能超过100万'
  408. return false
  409. }
  410. const decimalPart = insuranceAmount.value.toString().split('.')[1]
  411. if (decimalPart && decimalPart.length > 2) {
  412. insuranceAmountError.value = '保价金额最多保留两位小数'
  413. return false
  414. }
  415. insuranceAmountError.value = ''
  416. return true
  417. }
  418. // 重量输入处理
  419. const handleWeightInput = (e) => {
  420. let value = e.detail.value
  421. // 只允许数字和小数点
  422. value = value.replace(/[^\d.]/g, '')
  423. // 确保只有一个小数点
  424. const parts = value.split('.')
  425. if (parts.length > 2) {
  426. value = parts[0] + '.' + parts.slice(1).join('')
  427. }
  428. // 限制小数点后最多3位
  429. if (value.includes('.')) {
  430. const decimalPart = value.split('.')[1]
  431. if (decimalPart && decimalPart.length > 3) {
  432. value = parseFloat(value).toFixed(3)
  433. }
  434. }
  435. // 转换为数字,确保最小值
  436. const numValue = parseFloat(value) || 0.5
  437. weight.value = Math.max(0.5, Math.min(100, numValue))
  438. }
  439. // 体积输入处理
  440. const handleVolumeInput = (e) => {
  441. let value = e.detail.value
  442. // 只允许数字和小数点
  443. value = value.replace(/[^\d.]/g, '')
  444. // 确保只有一个小数点
  445. const parts = value.split('.')
  446. if (parts.length > 2) {
  447. value = parts[0] + '.' + parts.slice(1).join('')
  448. }
  449. // 限制小数点后最多3位
  450. if (value.includes('.')) {
  451. const decimalPart = value.split('.')[1]
  452. if (decimalPart && decimalPart.length > 3) {
  453. value = parseFloat(value).toFixed(3)
  454. }
  455. }
  456. // 转换为数字,确保最小值
  457. const numValue = parseFloat(value) || 0.001
  458. volume.value = Math.max(0.001, Math.min(10, numValue))
  459. }
  460. // 件数输入处理(整数)
  461. const handleQuantityInput = (e) => {
  462. let value = e.detail.value
  463. // 只允许数字
  464. value = value.replace(/\D/g, '')
  465. // 转换为整数
  466. const intValue = parseInt(value) || 1
  467. quantity.value = Math.max(1, Math.min(99, intValue))
  468. }
  469. // 切换协议同意
  470. const toggleAgreement = () => {
  471. agreed.value = !agreed.value
  472. }
  473. // 表单验证
  474. const validateForm = () => {
  475. if (!addressSend.value.id) {
  476. uni.showToast({
  477. title: '请选择寄件人地址',
  478. icon: 'none'
  479. })
  480. return false
  481. }
  482. if (!addressReceive.value.id) {
  483. uni.showToast({
  484. title: '请选择收件人地址',
  485. icon: 'none'
  486. })
  487. return false
  488. }
  489. if (!selectedTimeData.value) {
  490. uni.showToast({
  491. title: '请选择期望上门时间',
  492. icon: 'none'
  493. })
  494. return false
  495. }
  496. if (!goodsInfo.value.trim()) {
  497. uni.showToast({
  498. title: '请输入物品信息',
  499. icon: 'none'
  500. })
  501. return false
  502. }
  503. if (insuranceAmount.value && !validateInsuranceAmount()) {
  504. uni.showToast({
  505. title: insuranceAmountError.value,
  506. icon: 'none'
  507. })
  508. return false
  509. }
  510. if (product.value === '2' && valueServices.value.isReceiptCollect && receiptReturnTypes.value.length === 0) {
  511. uni.showToast({
  512. title: '请选择签单返还类型',
  513. icon: 'none'
  514. })
  515. return false
  516. }
  517. if (!agreed.value) {
  518. uni.showToast({
  519. title: '请同意服务协议',
  520. icon: 'none'
  521. })
  522. return false
  523. }
  524. return true
  525. }
  526. // 提交订单
  527. const submitOrder = async () => {
  528. if (!validateForm()) return
  529. // 构建增值服务数据
  530. const addedService = {
  531. isPack: valueServices.value.isPack,
  532. guaranteeMoney: insuranceAmount.value ? parseFloat(insuranceAmount.value) : null
  533. }
  534. // 京东和顺丰的不同字段
  535. if (product.value === '1') {
  536. // 京东:签单返还
  537. addedService.isReceiptCollect = valueServices.value.isReceiptCollect
  538. } else {
  539. // 顺丰:超长超重、签单返还、打木架
  540. addedService.isOverLongWeight = valueServices.value.isOverLongWeight
  541. addedService.isReceiptCollect = valueServices.value.isReceiptCollect
  542. addedService.isWoodenCrate = valueServices.value.isWoodenCrate
  543. // 如果顺丰有签单返还,添加返还类型
  544. if (valueServices.value.isReceiptCollect && receiptReturnTypes.value[receiptReturnTypeIndex.value]) {
  545. addedService.receiptCollectType = receiptReturnTypes.value[receiptReturnTypeIndex.value].value
  546. }
  547. }
  548. const orderData = {
  549. orderType: product.value, // 1-非时效件(京东),2-时效件(顺丰)
  550. senderName: addressSend.value.name,
  551. senderPhone: addressSend.value.phone,
  552. senderProvince: addressSend.value.provinceName,
  553. senderCity: addressSend.value.cityName,
  554. senderCounty: addressSend.value.countyName,
  555. senderAddress: addressSend.value.address,
  556. receiverName: addressReceive.value.name,
  557. receiverPhone: addressReceive.value.phone,
  558. receiverProvince: addressReceive.value.provinceName,
  559. receiverCity: addressReceive.value.cityName,
  560. receiverCounty: addressReceive.value.countyName,
  561. receiverAddress: addressReceive.value.address,
  562. goodsName: goodsInfo.value,
  563. goodsWeight: weight.value,
  564. goodsVolume: volume.value,
  565. goodsQty: quantity.value,
  566. sendStartTime: selectedTimeData.value.startTime,
  567. sendEndTime: selectedTimeData.value.endTime,
  568. productCode: expressTypes.value[expressTypeIndex.value]?.value,
  569. addedService: JSON.stringify(addedService)
  570. }
  571. console.log('订单数据:', orderData)
  572. // 这里调用实际的API接口
  573. try {
  574. uni.showLoading({
  575. title: '提交中...'
  576. })
  577. // 模拟API调用
  578. setTimeout(() => {
  579. uni.hideLoading()
  580. uni.showToast({
  581. title: '下单成功',
  582. icon: 'success'
  583. })
  584. // 清空表单数据
  585. resetForm()
  586. // 跳转到订单列表
  587. setTimeout(() => {
  588. uni.switchTab({
  589. url: '/pages/order/list'
  590. })
  591. }, 1500)
  592. }, 1500)
  593. } catch (error) {
  594. console.error('订单提交失败:', error)
  595. uni.showToast({
  596. title: '订单提交失败,请重试',
  597. icon: 'none'
  598. })
  599. }
  600. }
  601. // 重置表单
  602. const resetForm = () => {
  603. selectedTimeData.value = null
  604. goodsInfo.value = ''
  605. weight.value = 1
  606. volume.value = 0.001
  607. quantity.value = 1
  608. expressTypeIndex.value = 0
  609. valueServices.value = {
  610. isPack: false,
  611. isOverLongWeight: false,
  612. isReceiptCollect: false,
  613. isWoodenCrate: false
  614. }
  615. insuranceAmount.value = ''
  616. receiptReturnTypeIndex.value = 0
  617. agreed.value = false
  618. }
  619. // 页面加载
  620. onLoad((option) => {
  621. if (option.product) {
  622. product.value = option.product
  623. }
  624. })
  625. // 监听页面加载
  626. onMounted(() => {
  627. // 监听地址选择返回
  628. uni.$on('addressSelected', (data) => {
  629. if (data.type === 'sender') {
  630. addressSend.value = data.address
  631. saveAddressToStorage('senderAddress', data.address)
  632. } else if (data.type === 'receiver') {
  633. addressReceive.value = data.address
  634. saveAddressToStorage('receiverAddress', data.address)
  635. }
  636. })
  637. })
  638. </script>
  639. <style lang="scss" scoped>
  640. .order-container {
  641. min-height: 100vh;
  642. background-color: #F5F7FA;
  643. padding: 20rpx;
  644. padding-bottom: 180rpx;
  645. box-sizing: border-box;
  646. }
  647. .info-card {
  648. background: #fff;
  649. border-radius: 32rpx;
  650. padding: 20rpx;
  651. margin-bottom: 20rpx;
  652. .address-item {
  653. display: flex;
  654. align-items: center;
  655. &:first-child {
  656. padding-bottom: 20rpx;
  657. }
  658. &:last-child {
  659. padding-top: 20rpx;
  660. }
  661. }
  662. .user-info {
  663. flex: 1;
  664. margin-left: 26rpx;
  665. .line {
  666. width: 590rpx;
  667. height: 3rpx;
  668. background-color: #F1F3F8;
  669. }
  670. .create-btn {
  671. height: 88rpx;
  672. line-height: 88rpx;
  673. font-size: 28rpx;
  674. color: #1B64F0;
  675. }
  676. }
  677. .right {
  678. margin-left: 20rpx;
  679. }
  680. .img-status-text {
  681. align-self: center;
  682. text-align: center;
  683. flex-shrink: 0;
  684. .img {
  685. width: 56rpx;
  686. height: 56rpx;
  687. }
  688. .img-change {
  689. width: 40rpx;
  690. height: 40rpx;
  691. }
  692. .address-image {
  693. width: 48rpx;
  694. height: 48rpx;
  695. }
  696. .status-text {
  697. font-size: 28rpx;
  698. color: #333;
  699. font-size: 400;
  700. }
  701. }
  702. }
  703. .pickup-title {
  704. font-size: 32rpx;
  705. font-weight: 600;
  706. color: #333;
  707. margin-bottom: 20rpx;
  708. }
  709. .goods-card {
  710. background-color: #fff;
  711. border-radius: 32rpx;
  712. padding: 0rpx 20rpx;
  713. margin-bottom: 20rpx;
  714. }
  715. .goods-item {
  716. display: flex;
  717. justify-content: space-between;
  718. align-items: center;
  719. height: 100rpx;
  720. border-bottom: 1rpx solid #F1F3F8;
  721. &:last-child {
  722. border-bottom: none;
  723. margin-bottom: 0;
  724. }
  725. .item-label {
  726. font-size: 28rpx;
  727. color: #666;
  728. font-weight: 400;
  729. &.required::before {
  730. content: '*';
  731. color: #ff4444;
  732. margin-right: 8rpx;
  733. }
  734. }
  735. .item-control {
  736. display: flex;
  737. align-items: center;
  738. .picker-text {
  739. font-size: 28rpx;
  740. color: #333;
  741. text-align: right;
  742. margin-right: 8rpx;
  743. }
  744. &.btn {
  745. background: #fff;
  746. border: 1rpx solid #dcdfe6;
  747. border-radius: 5rpx;
  748. height: 59rpx;
  749. width: 266rpx;
  750. box-sizing: border-box;
  751. }
  752. .control-btn {
  753. width: 56rpx;
  754. height: 56rpx;
  755. background: #F5F7FA;
  756. border-radius: 4rpx;
  757. display: flex;
  758. align-items: center;
  759. justify-content: center;
  760. font-size: 36rpx;
  761. color: #666;
  762. &.minus {
  763. color: #999;
  764. border-right: 1rpx solid #dcdfe6;
  765. }
  766. &.plus {
  767. color: #999;
  768. border-left: 1rpx solid #dcdfe6;
  769. }
  770. }
  771. .control-value {
  772. width: 154rpx;
  773. text-align: center;
  774. font-size: 24rpx;
  775. color: #333;
  776. .input-field {
  777. width: 100%;
  778. height: 100rpx;
  779. line-height: 100rpx;
  780. padding: 0 24rpx;
  781. font-size: 28rpx;
  782. color: #333;
  783. text-align: center;
  784. &::placeholder {
  785. color: #999;
  786. }
  787. }
  788. }
  789. }
  790. .input-field {
  791. width: 100%;
  792. height: 100rpx;
  793. line-height: 100rpx;
  794. padding: 0 24rpx;
  795. font-size: 28rpx;
  796. color: #333;
  797. text-align: right;
  798. &::placeholder {
  799. color: #999;
  800. }
  801. }
  802. .time-value {
  803. display: flex;
  804. align-items: center;
  805. font-size: 28rpx;
  806. color: #333;
  807. line-height: 88rpx;
  808. height: 88rpx;
  809. .value {
  810. margin-right: 16rpx;
  811. }
  812. .arrow {
  813. margin-left: 32rpx;
  814. color: #999;
  815. font-size: 28rpx;
  816. font-weight: bold;
  817. }
  818. }
  819. .arrow {
  820. color: #999;
  821. }
  822. }
  823. .agreement-card {
  824. background-color: #fff;
  825. border-radius: 32rpx;
  826. padding: 30rpx 20rpx;
  827. margin-bottom: 20rpx;
  828. .agreement-item {
  829. display: flex;
  830. align-items: center;
  831. margin-bottom: 20rpx;
  832. .agreement-text {
  833. font-size: 28rpx;
  834. color: #333;
  835. margin-left: 10rpx;
  836. }
  837. }
  838. .price-notice {
  839. font-size: 24rpx;
  840. color: #ff7d00;
  841. text-align: center;
  842. }
  843. }
  844. .submit-btn {
  845. position: fixed;
  846. bottom: 40rpx;
  847. left: 30rpx;
  848. right: 30rpx;
  849. width: 686rpx;
  850. height: 88rpx;
  851. background: #1B64F0;
  852. border-radius: 44rpx;
  853. display: flex;
  854. justify-content: center;
  855. align-items: center;
  856. font-size: 32rpx;
  857. color: #FFFFFF;
  858. line-height: 88rpx;
  859. text-align: center;
  860. z-index: 10;
  861. &.disabled {
  862. background: #f5f5f5;
  863. color: #999;
  864. }
  865. }
  866. .safe-area {
  867. height: 140rpx;
  868. }
  869. </style>