order.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <template>
  2. <view class="app">
  3. <view class="header">
  4. <view class="header_inner">
  5. <image src="../../static/order/clock.png"></image>
  6. <text class="txt1">配送剩余时间
  7. <text class="txt2">{{ preTime }}</text>
  8. </text>
  9. </view>
  10. <view class="tip">你需要在{{ sdTime === 'aN:aN' ? '' : sdTime }}前送达</view>
  11. </view>
  12. <view class="goods">
  13. <view class="goods_tit">商品信息</view>
  14. <view class="goods_details">
  15. <view class="detials_l">
  16. <scroll-view scroll-x="true">
  17. <image mode="aspectFit" v-for="(item,index) in details.riderItemVoList" :key="index"
  18. :src="JSON.parse(item.url)[0].url" class="details_img"></image>
  19. </scroll-view>
  20. </view>
  21. <view class="detials_r">
  22. <view class="detials_r_inner">
  23. <text style="margin-left: 20rpx;">共{{ count }}件</text>
  24. <image @click="open()" src="../../static/order/dian.png"></image>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="count">
  30. <view class="count_item">
  31. <text class="txt3">配送费</text>
  32. <text class="txt4">{{ details.freightPrice }}元</text>
  33. </view>
  34. <view class="count_item nobor">
  35. <text class="txt3">商品费用</text>
  36. <text class="txt4 txt5">¥{{ details.totalPrice }}</text>
  37. </view>
  38. <view class="count_item nobor">
  39. <text class="txt3">合计</text>
  40. <text class="txt4 txt5">¥{{ (parseFloat(details.totalPrice) + parseFloat(details.freightPrice)).toFixed(2) }}
  41. </text>
  42. </view>
  43. </view>
  44. <view class="count">
  45. <view class="count_item">
  46. <text class="txt3">配送信息</text>
  47. <text class="txt4"></text>
  48. </view>
  49. <view class="count_item">
  50. <text class="txt3 txt6">收货人</text>
  51. <text class="txt4 txt5 txt7">{{ details.consignee }}</text>
  52. </view>
  53. <view class="count_item">
  54. <text class="txt3 txt6">联系电话</text>
  55. <text class="txt4 txt5 txt7">{{ details.phone }}</text>
  56. </view>
  57. <view class="count_item nobor">
  58. <text class="txt3 txt6">收货地址</text>
  59. <text class="txt4 txt5 txt7">{{ details.province }}{{ details.city }}{{ details.county }}{{ details.address }}
  60. </text>
  61. </view>
  62. </view>
  63. <view class="count">
  64. <view class="count_item">
  65. <text class="txt3">订单信息</text>
  66. <text class="txt4"></text>
  67. </view>
  68. <view class="count_item">
  69. <text class="txt3 txt6">订单编号</text>
  70. <text class="txt4 txt5 txt7">{{ details.orderNo }}
  71. <text style="padding-left: 20rpx;color: #3662DD;" @click="copy(details.orderNo)">复制</text>
  72. </text>
  73. </view>
  74. <view class="count_item">
  75. <text class="txt3 txt6">备注信息</text>
  76. <text class="txt4 txt5 txt7">{{ details.mono || '' }}</text>
  77. </view>
  78. <view class="count_item">
  79. <text class="txt3 txt6">支付方式</text>
  80. <text class="txt4 txt5 txt7">{{ details.payChannel }}</text>
  81. </view>
  82. <view class="count_item">
  83. <text class="txt3 txt6">下单时间</text>
  84. <text class="txt4 txt5 txt7">{{ orderCreateTime }}</text>
  85. </view>
  86. <view class="count_item nobor">
  87. <text class="txt3 txt6">支付时间</text>
  88. <text class="txt4 txt5 txt7">{{ payTime }}</text>
  89. </view>
  90. </view>
  91. <view class="count" v-if="userOrderPhotos.length > 0">
  92. <view class="count_item">
  93. <text class="txt3">用户上传照片</text>
  94. </view>
  95. <view class="count_item nobor photo-upload-section">
  96. <view class="photo-upload-container">
  97. <view class="photo-list">
  98. <!-- 已上传的照片预览 -->
  99. <view
  100. v-for="(photo, index) in userOrderPhotos"
  101. :key="index"
  102. class="photo-item"
  103. >
  104. <image :src="photo" class="photo-preview" mode="aspectFill" @click="previewPhoto(index)"></image>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="count_item nobor"></view>
  110. </view>
  111. <!-- 照片上传区域 - 仅在订单状态为4时显示 -->
  112. <view class="count" v-if="orderPhotos.length > 0">
  113. <view class="count_item">
  114. <text class="txt3">订单照片</text>
  115. <view class="photo-mode-btn" @click="togglePhotoMode" v-if="details.status === 4">
  116. <button class="mini-btn" @click="addScreenshot" :type="isEditMode ? 'primary' : 'default'" size="mini">
  117. {{ isEditMode ? '上传' : '编辑' }}
  118. </button>
  119. </view>
  120. </view>
  121. <view class="count_item nobor photo-upload-section">
  122. <view class="photo-upload-container">
  123. <view class="photo-list">
  124. <!-- 已上传的照片预览 -->
  125. <view
  126. v-for="(photo, index) in orderPhotos"
  127. :key="index"
  128. class="photo-item"
  129. >
  130. <image :src="photo" class="photo-preview" mode="aspectFill" @click="previewPhoto(index)"></image>
  131. <!-- 删除按钮仅在编辑模式下显示 -->
  132. <view v-if="isEditMode" class="photo-delete" @click="deletePhoto(index)">
  133. <text class="photo-delete-icon">×</text>
  134. </view>
  135. </view>
  136. <!-- 添加照片按钮仅在编辑模式下显示 -->
  137. <view
  138. v-if="isEditMode && orderPhotos.length < 6"
  139. class="photo-add-btn"
  140. @click="choosePhoto"
  141. >
  142. <text class="photo-add-icon">+</text>
  143. <text class="photo-add-text">添加照片</text>
  144. </view>
  145. </view>
  146. <view class="photo-tips" v-if="isEditMode">最多可上传6张照片</view>
  147. </view>
  148. </view>
  149. </view>
  150. <uni-popup ref="popup" type="bottom">
  151. <view class="popup_mask">
  152. <view class="popup_mask_tit">
  153. <text class="pop_t1">配送清单</text>
  154. <text class="pop_t2">共{{ count }}件</text>
  155. <image @click="closePop()" src="../../static/order/mask_close.png"></image>
  156. </view>
  157. <view class="pop_item" v-for="(item,index) in details.riderItemVoList" :key="'dt'+index">
  158. <view class="pop_item_l">
  159. <view class="item_l_l">
  160. <image mode="aspectFit" class="pil_img" :src="JSON.parse(item.url)[0].url"></image>
  161. </view>
  162. <view class="item_l_r">
  163. <view>{{ item.spuName }}</view>
  164. <view style="padding-top: 10rpx;">x{{ item.amount }}</view>
  165. </view>
  166. <!-- <image class="pil_img" src="../../static/login/logo.png"></image>
  167. <text>上海小白菜\n<text>x2</text> </text> -->
  168. </view>
  169. <view class="pop_item_r">
  170. ¥{{ item.unitPrice * item.amount }}
  171. </view>
  172. </view>
  173. </view>
  174. </uni-popup>
  175. </view>
  176. </template>
  177. <script>
  178. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  179. import {
  180. mapState,
  181. mapMutations
  182. } from 'vuex';
  183. export default {
  184. components: {
  185. uniPopup
  186. },
  187. computed: {
  188. ...mapState(['token', 'userInfo'])
  189. },
  190. data() {
  191. return {
  192. goods: [1, 2, 3, 4, 5],
  193. id: '',
  194. details: '',
  195. preTime: '',
  196. count: 0,
  197. sdTime: '',
  198. orderCreateTime: '',
  199. payTime: '',
  200. interval: '',
  201. flag: false,
  202. orderPhotos: [], // 订单照片数组
  203. isEditMode: false, // 照片编辑模式标志
  204. userOrderPhotos: [],
  205. }
  206. },
  207. onLoad(e) {
  208. this.getDetails(e.id)
  209. },
  210. onHide() {
  211. clearInterval(this.interval)
  212. },
  213. methods: {
  214. closePop() {
  215. this.$refs.popup.close()
  216. },
  217. open() {
  218. this.$refs.popup.open()
  219. },
  220. copy(msg) {
  221. uni.setClipboardData({
  222. data: msg,
  223. success: function () {
  224. uni.showToast({
  225. title: '复制成功',
  226. icon: 'none',
  227. duration: 1500
  228. })
  229. }
  230. });
  231. },
  232. // 切换照片编辑模式
  233. togglePhotoMode() {
  234. this.isEditMode = !this.isEditMode
  235. },
  236. // 选择照片
  237. choosePhoto() {
  238. const remainingCount = 6 - this.orderPhotos.length
  239. uni.chooseImage({
  240. count: remainingCount,
  241. sizeType: ['compressed'],
  242. sourceType: ['album', 'camera'],
  243. success: (res) => {
  244. const tempFilePaths = res.tempFilePaths
  245. // 依次上传选中的照片
  246. tempFilePaths.forEach(filePath => {
  247. this.uploadPhoto(filePath)
  248. })
  249. },
  250. fail: (err) => {
  251. if (err.errMsg !== 'chooseImage:fail cancel') {
  252. console.error('选择照片失败:', err)
  253. uni.showToast({
  254. title: '选择照片失败',
  255. icon: 'none'
  256. })
  257. }
  258. }
  259. })
  260. },
  261. // 上传照片
  262. uploadPhoto(filePath) {
  263. const that = this
  264. that.$api.uploadImgByPath(filePath, that.token, (url) => {
  265. that.orderPhotos.push(url)
  266. uni.showToast({
  267. title: '上传成功',
  268. icon: 'success'
  269. })
  270. })
  271. },
  272. // 预览照片
  273. previewPhoto(index) {
  274. uni.previewImage({
  275. urls: this.orderPhotos,
  276. current: index
  277. })
  278. },
  279. // 删除照片
  280. deletePhoto(index) {
  281. const that = this
  282. uni.showModal({
  283. title: '确认删除',
  284. content: '确定要删除这张照片吗?',
  285. success: (res) => {
  286. if (res.confirm) {
  287. that.orderPhotos.splice(index, 1)
  288. }
  289. }
  290. })
  291. },
  292. addScreenshot() {
  293. if (this.orderPhotos.length === 0) {
  294. return
  295. }
  296. const req = {
  297. orderId: this.details.orderId,
  298. screenshotType: 4,
  299. imageUrls: this.orderPhotos,
  300. userType: 2,
  301. uploadBy: this.userInfo.id
  302. }
  303. this.request('post', 'order/screenshot/add', this.token, req)
  304. .then(res => {
  305. if (res.code === 200) {
  306. uni.showToast({
  307. title: '添加成功',
  308. icon: 'success'
  309. })
  310. } else {
  311. uni.showToast({
  312. title: res.msg,
  313. icon: 'error'
  314. })
  315. }
  316. })
  317. .catch(err => {
  318. uni.showToast({
  319. title: '添加失败',
  320. icon: 'error'
  321. })
  322. })
  323. .catc
  324. },
  325. getDetails(id) {
  326. let that = this
  327. let params = {
  328. riderOrderId: id
  329. }
  330. that.request("get", "rider/task/detail", that.token, params).then(res => {
  331. if (res.code === 200) {
  332. let num = 0
  333. for (let i = 0; i < res.data.riderItemVoList.length; i++) {
  334. res.data.riderItemVoList[i].amount = parseInt(res.data.riderItemVoList[i].amount)
  335. num = num + parseInt(res.data.riderItemVoList[i].amount)
  336. }
  337. that.details = res.data
  338. if (res.data.imageUrls) {
  339. that.orderPhotos.push(...res.data.imageUrls)
  340. }
  341. if (res.data.userImageUrls) {
  342. that.userOrderPhotos.push(...res.data.userImageUrls)
  343. }
  344. // console.log(that.details)
  345. that.count = num
  346. that.orderCreateTime = that.dateFtt("yyyy-MM-dd hh:mm:ss", new Date(that.details.orderCreateTime))
  347. that.payTime = that.dateFtt("yyyy-MM-dd hh:mm:ss", new Date(that.details.payTime))
  348. that.sdTime = that.dateFtt("hh:mm", new Date(that.details.predictTime))
  349. // console.log(that.dateFtt("yyyy-MM-dd hh:mm:ss", new Date(that.details.predictTime)))
  350. that.preTime = new Date(that.details.predictTime).getTime() >= new Date().getTime() ? that.dateFtt("hh:mm:ss", new Date(that.details.predictTime)) : 0
  351. if (new Date(that.details.predictTime).getTime() >= new Date().getTime()) {
  352. that.preTime = true
  353. }
  354. }
  355. })
  356. that.interval = setInterval(function () {
  357. // console.log(new Date(that.details.predictTime).getTime()>=new Date().getTime())
  358. if (new Date(that.details.predictTime).getTime() > new Date().getTime()) {
  359. let d = new Date(that.details.predictTime).getTime() - new Date().getTime()
  360. // that.preTime = that.dateFtt("hh:mm:ss", d)
  361. //计算出相差天数
  362. var days = Math.floor(d / (24 * 3600 * 1000))
  363. //计算出小时数
  364. var leave1 = d % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  365. var hours = Math.floor(leave1 / (3600 * 1000))
  366. //计算相差分钟数
  367. var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
  368. var minutes = Math.floor(leave2 / (60 * 1000))
  369. //计算相差秒数
  370. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  371. var seconds = Math.round(leave3 / 1000)
  372. that.preTime = days > 0 ? (days + ":" + hours + ":" + minutes + ":" + seconds) : (hours > 0 ? (hours + ":" + minutes + ":" + seconds) : (minutes + ":" + seconds))
  373. } else {
  374. that.preTime = 0
  375. if (that.flag) {
  376. let nav_index = 2
  377. uni.redirectTo({
  378. url: '../task/task?nav_index=' + nav_index
  379. })
  380. }
  381. clearInterval(that.interval)
  382. }
  383. }, 1000)
  384. }
  385. }
  386. }
  387. </script>
  388. <style scoped>
  389. scroll-view {
  390. white-space: nowrap;
  391. height: 110rpx;
  392. width: 100%;
  393. margin-top: 42rpx;
  394. box-sizing: border-box;
  395. }
  396. .popup_mask {
  397. width: 690rpx;
  398. padding: 0 30rpx;
  399. height: 500rpx;
  400. background-color: #FFFFFF;
  401. border-top-left-radius: 24rpx;
  402. border-top-right-radius: 24rpx;
  403. padding-bottom: 6rpx;
  404. }
  405. .popup_mask_tit {
  406. height: 104rpx;
  407. line-height: 104rpx;
  408. position: relative;
  409. }
  410. .pop_t1 {
  411. font-size: 32rpx;
  412. color: #333333;
  413. font-weight: bold;
  414. }
  415. .pop_t2 {
  416. font-size: 28rpx;
  417. color: #1B1C33;
  418. margin-left: 40rpx;
  419. }
  420. .popup_mask_tit image {
  421. width: 30rpx;
  422. height: 30rpx;
  423. position: absolute;
  424. right: 20rpx;
  425. top: 38rpx;
  426. }
  427. .pop_item {
  428. height: 184rpx;
  429. border-bottom: 2rpx solid #F1F1F1;
  430. display: flex;
  431. flex-direction: row;
  432. }
  433. .pop_item_l {
  434. width: 520rpx;
  435. height: 184rpx;
  436. display: flex;
  437. flex-direction: row;
  438. }
  439. .item_l_l {
  440. width: 168rpx;
  441. height: 148rpx;
  442. padding-top: 36rpx;
  443. }
  444. .item_l_r {
  445. width: 452rpx;
  446. height: 148rpx;
  447. padding-top: 36rpx;
  448. }
  449. .pop_item_r {
  450. width: 150rpx;
  451. height: 148rpx;
  452. padding-top: 36rpx;
  453. font-size: 32rpx;
  454. color: #333333;
  455. font-weight: bold;
  456. text-align: right;
  457. }
  458. .pil_img {
  459. width: 118rpx;
  460. height: 110rpx;
  461. }
  462. .item_l_r view {
  463. font-size: 32rpx;
  464. color: #333333;
  465. }
  466. .test {
  467. width: 220upx;
  468. height: 220upx;
  469. display: inline-block;
  470. background-color: red;
  471. }
  472. .app {
  473. background-color: #F6F6F6;
  474. }
  475. .header {
  476. text-align: center;
  477. background-color: #FFFFFF;
  478. }
  479. .header_inner {
  480. display: inline-block;
  481. padding-top: 90rpx;
  482. }
  483. .header_inner image {
  484. width: 48rpx;
  485. height: 48rpx;
  486. position: relative;
  487. top: 8rpx;
  488. }
  489. .txt1 {
  490. font-size: 40rpx;
  491. color: #000000;
  492. font-weight: bold;
  493. margin-left: 24rpx;
  494. }
  495. .txt2 {
  496. color: #3662DD;
  497. padding-left: 20rpx;
  498. }
  499. .tip {
  500. text-align: center;
  501. font-size: 32rpx;
  502. color: #717171;
  503. padding-top: 24rpx;
  504. padding-bottom: 70rpx;
  505. }
  506. .goods {
  507. height: 282rpx;
  508. margin-top: 20rpx;
  509. background-color: #FFFFFF;
  510. padding: 0 30rpx;
  511. }
  512. .goods_tit {
  513. height: 86rpx;
  514. line-height: 86rpx;
  515. border-bottom: 2rpx solid #F1F1F1;
  516. font-size: 32rpx;
  517. color: #333333;
  518. font-weight: bold;
  519. }
  520. .goods_details {
  521. height: 194rpx;
  522. display: flex;
  523. flex-direction: row;
  524. }
  525. .detials_l {
  526. width: 496rpx;
  527. height: 194rpx;
  528. }
  529. .detials_r {
  530. width: 174rpx;
  531. height: 194rpx;
  532. }
  533. .details_img {
  534. display: inline-block;
  535. width: 118rpx;
  536. height: 110rpx;
  537. margin-right: 36rpx;
  538. }
  539. .detials_r_inner {
  540. height: 110rpx;
  541. margin-top: 42rpx;
  542. line-height: 110rpx;
  543. font-size: 28rpx;
  544. color: #1B1C33;
  545. position: relative;
  546. }
  547. .detials_r_inner image {
  548. width: 44rpx;
  549. height: 10rpx;
  550. position: absolute;
  551. right: 0;
  552. top: 48rpx;
  553. }
  554. .count {
  555. margin-top: 20rpx;
  556. padding: 0 30rpx;
  557. background-color: #FFFFFF;
  558. }
  559. .count_item {
  560. height: 99rpx;
  561. line-height: 99rpx;
  562. border-bottom: 2rpx solid #F1F1F1;
  563. font-size: 28rpx;
  564. }
  565. .txt3,
  566. .txt5 {
  567. font-weight: bold;
  568. color: #333333;
  569. }
  570. .txt4 {
  571. color: #666666;
  572. float: right;
  573. }
  574. .nobor {
  575. border: none;
  576. }
  577. .txt6 {
  578. color: #999999;
  579. font-weight: normal;
  580. }
  581. .txt7 {
  582. font-weight: normal;
  583. color: #333333;
  584. word-wrap: break-word;
  585. word-break: break-all;
  586. white-space: normal;
  587. }
  588. /* 照片上传相关样式 */
  589. .photo-upload-section {
  590. flex-direction: row !important; /* 改为横向布局 */
  591. align-items: flex-start !important;
  592. height: auto !important; /* 覆盖count_item的固定高度 */
  593. line-height: normal !important; /* 覆盖count_item的固定行高 */
  594. padding: 30rpx 0 !important; /* 添加上下内边距 */
  595. display: flex !important;
  596. }
  597. .distribution-text {
  598. width: 200upx;
  599. float: left;
  600. color: #333333;
  601. display: flex; /* 使用 flex 布局 */
  602. align-items: center; /* 垂直居中 */
  603. }
  604. .photo-upload-container {
  605. flex: 1; /* 占据剩余空间 */
  606. margin-top: 20rpx;
  607. margin-left: 20rpx; /* 与文案保持间距 */
  608. min-height: 200rpx; /* 确保至少有200rpx高度 */
  609. }
  610. .photo-list {
  611. display: flex;
  612. flex-wrap: wrap;
  613. gap: 20rpx;
  614. align-content: flex-start;
  615. width: 100%;
  616. }
  617. .photo-item {
  618. position: relative;
  619. width: 200rpx; /* 固定正方形宽度 */
  620. height: 200rpx; /* 固定正方形高度 */
  621. margin-bottom: 20rpx; /* 行间距 */
  622. }
  623. .photo-preview {
  624. width: 100%;
  625. height: 100%;
  626. border-radius: 8rpx;
  627. border: 2rpx solid #e5e5e5;
  628. }
  629. .photo-delete {
  630. position: absolute;
  631. top: -10rpx;
  632. right: -10rpx;
  633. width: 40rpx;
  634. height: 40rpx;
  635. background-color: #ff4757;
  636. border-radius: 50%;
  637. display: flex;
  638. align-items: center;
  639. justify-content: center;
  640. }
  641. .photo-delete-icon {
  642. color: #fff;
  643. font-size: 24rpx;
  644. font-weight: bold;
  645. }
  646. .photo-add-btn {
  647. width: 200rpx; /* 与photo-item保持一致 */
  648. height: 200rpx; /* 与photo-item保持一致 */
  649. margin-bottom: 20rpx; /* 与photo-item保持一致的行间距 */
  650. border: 2rpx dashed #ccc;
  651. border-radius: 8rpx;
  652. display: flex;
  653. flex-direction: column;
  654. align-items: center;
  655. justify-content: center;
  656. background-color: #fafafa;
  657. }
  658. .photo-add-icon {
  659. font-size: 32rpx; /* 调小图标尺寸 */
  660. color: #999;
  661. margin-bottom: 4rpx; /* 减少间距 */
  662. }
  663. .photo-add-text {
  664. font-size: 20rpx; /* 调小文字尺寸 */
  665. color: #999;
  666. }
  667. .photo-tips {
  668. margin-top: 20rpx;
  669. font-size: 24rpx;
  670. color: #999;
  671. }
  672. /* 照片模式切换按钮样式 */
  673. .photo-mode-btn {
  674. float: right;
  675. margin-top: 20rpx;
  676. margin-right: 10rpx;
  677. }
  678. .btn-text {
  679. color: #FFFFFF;
  680. font-size: 24rpx;
  681. font-weight: 500;
  682. }
  683. </style>