detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view>
  3. <u-navbar title="订单详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="detail">
  5. <view class="detail-state">
  6. <view class="detail-state-title">
  7. <text>订单状态:</text>
  8. <text>{{ status.desc }}</text>
  9. </view>
  10. <view class="detail-state-time" v-if="status.value == 2">
  11. 还剩 {{ autoConfirmTime || "--" }} 自动确认
  12. </view>
  13. </view>
  14. <view class="detail-info">
  15. <view class="detail-info-title">商品信息</view>
  16. <view class="detail-info-content">
  17. <view class="detail-info-content-goods">
  18. <view class="flex detail-info-content-goods__detail" v-for="(item, index) in list" :key="index">
  19. <view class="detail-info-content-goods__detail__left">
  20. <view class="img">
  21. <image class="img" :src="item.picUrl" mode="aspectFill">
  22. </image>
  23. </view>
  24. </view>
  25. <view class="detail-info-content-goods__detail__right">
  26. <view class="ells title">{{ item.title }}</view>
  27. <view class="sku" v-if="item.properties">规格:{{ item.properties }}</view>
  28. <view class="num">数量:{{ item.goodsNum }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="detail-info-content-money">
  33. <view class="detail-info-content-money__item">
  34. <text>运费</text>
  35. <text>¥{{ $numberFormat(info.freightAmt) }}</text>
  36. </view>
  37. </view>
  38. <view class="detail-info-content-toatl">
  39. <text v-if="status.value == 0">应付:</text>
  40. <text v-else>实付:</text>
  41. <text>¥{{ $numberFormat(info.payAmt) }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="detail-info">
  46. <view class="detail-info-title">订单信息</view>
  47. <view class="detail-info-content">
  48. <view class="detail-info-content-desc">
  49. <view>收货信息:</view>
  50. <view>
  51. {{ info.receiver }},{{ info.tel }},{{ info.province }}{{ info.city }}{{ info.area }}{{ info.address }}
  52. </view>
  53. </view>
  54. <view class="detail-info-content-desc">
  55. <view>订单编号:</view>
  56. <view class="copy" @click="copyOrderId" v-if="status.value == 2 || status.value == 4">复制</view>
  57. <view>{{ info.orderId }}</view>
  58. </view>
  59. <view class="detail-info-content-desc">
  60. <view>下单时间:</view>
  61. <view>{{ $parseTime(info.createdTime) }}</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="freight" v-if="info.memo != ''">
  66. <view style="width: 150rpx;display: inline-block;">留言:</view>
  67. <view style="display: inline-block;width: 524rpx;vertical-align: top;">{{info.memo}}</view>
  68. </view>
  69. <!-- <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length > 1">
  70. <view class="detail-info-title">发货信息</view>
  71. <view class="detail-info-content border" v-for="(item, index) in deliverList" :key="index">
  72. <view class="detail-info-content-desc">
  73. <view>配送方式:</view>
  74. <view>{{ item.companyName ? "快递发货" : "无需物流" }}</view>
  75. </view>
  76. <view class="detail-info-content-desc" v-if="item.companyName">
  77. <view>快递公司:</view>
  78. <view>{{ item.companyName || '-' }}</view>
  79. </view>
  80. <view class="detail-info-content-desc" v-if="item.deliveryFlowId">
  81. <view>物流单号:</view>
  82. <view class="copy" @click="copyDeliveryFlowId(item.deliveryFlowId)">复制</view>
  83. <view>{{ item.deliveryFlowId || '-' }}</view>
  84. </view>
  85. <view class="detail-info-content-desc">
  86. <view>发货时间:</view>
  87. <view>{{ $parseTime(item.deliveryTime) }}</view>
  88. </view>
  89. <view class="detail-info-content-deliver">
  90. <view class="flex detail-info-content-deliver__detail" v-for="(items, indexs) in item.items"
  91. :key="indexs">
  92. <view class="detail-info-content-deliver__detail__left">
  93. <view class="img">
  94. <image class="img" :src="items.picUrl" mode="aspectFill">
  95. </image>
  96. </view>
  97. </view>
  98. <view class="detail-info-content-deliver__detail__right">
  99. <view class="title">{{ items.title }}</view>
  100. <view class="flex num">
  101. <view class="sku" v-if="!items.properties"></view>
  102. <view class="sku" v-if="items.properties">规格:{{ items.properties }}</view>
  103. <view class="">数量:{{ items.goodsNum }}</view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. -->
  111. <!-- <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length == 1">
  112. <view class="detail-info-title">发货信息</view>
  113. <view class="detail-info-content" v-for="(item, index) in deliverList" :key="index">
  114. <view class="detail-info-content-desc">
  115. <view>配送方式:</view>
  116. <view>{{ item.companyName ? "快递发货" : "无需物流" }}</view>
  117. </view>
  118. <view class="detail-info-content-desc" v-if="item.companyName">
  119. <view>快递公司:</view>
  120. <view>{{ item.companyName || '-' }}</view>
  121. </view>
  122. <view class="detail-info-content-desc" v-if="item.deliveryFlowId">
  123. <view>物流单号:</view>
  124. <view class="copy" @click="copyDeliveryFlowId(item.deliveryFlowId)">复制</view>
  125. <view>{{ item.deliveryFlowId || '-' }}</view>
  126. </view>
  127. <view class="detail-info-content-desc">
  128. <view>发货时间:</view>
  129. <view>{{ $parseTime(item.deliveryTime) }}</view>
  130. </view>
  131. </view>
  132. </view> -->
  133. </view>
  134. <view class="footer-fixed" v-if="status.value == 2 || status.value == 3">
  135. <view class="flex btn">
  136. <view class="btn-right">
  137. <text class="logistics" @click="getLogistics">查看物流</text>
  138. </view>
  139. <view class="btn-right">
  140. <text class="confirm" @click="confirmOne" v-if="status.value == 2">确认收货</text>
  141. </view>
  142. </view>
  143. </view>
  144. <view class="footer-fixed" v-if="status.value == 0">
  145. <view class="flex btn">
  146. <view class="btn-right">
  147. <text class="logisticsCancel" @click="cancelOrder">取消订单</text>
  148. </view>
  149. <view class="btn-right">
  150. <text class="confirmPay" @click="payOrder">去支付</text>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import env from '../../config/env.js'
  158. import $http from '@/utils/request.js'
  159. export default {
  160. data() {
  161. return {
  162. orderId: '',
  163. status: {},
  164. info: {},
  165. addr: {},
  166. list: [],
  167. deliverList: [],
  168. autoConfirmTime: '',
  169. };
  170. },
  171. onLoad(opthios) {
  172. this.orderId = opthios.id
  173. this.getDetail()
  174. },
  175. methods: {
  176. getDetail() {
  177. uni.showLoading({
  178. title: '加载中'
  179. });
  180. $http.post('/api/v1/mp/user/deliver/order/detail', {
  181. orderId: this.orderId
  182. }).then(res => {
  183. uni.hideLoading();
  184. this.info = res.data
  185. this.status = JSON.parse(res.data.status)
  186. this.autoConfirmTime = res.data.autoConfirmTime
  187. res.data.items.forEach(item => {
  188. let picUrlArr = item.picUrl.split(',')
  189. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  190. })
  191. res.data.deliverList && res.data.deliverList.forEach((item) => {
  192. item.items.forEach((ele) => {
  193. let picUrlArr = ele.picUrl.split(",");
  194. ele.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170';
  195. });
  196. });
  197. this.deliverList = res.data.deliverList;
  198. this.list = res.data.items
  199. }).catch(() => {
  200. uni.hideLoading();
  201. })
  202. },
  203. cancelOrder() {
  204. let orderId = this.orderId
  205. uni.showModal({
  206. title: '提示',
  207. content: '您确认要取消订单吗?',
  208. success(res) {
  209. if (res.confirm) {
  210. $http.post('/api/v1/mp/user/deliver/order/cancel', {
  211. orderId
  212. }).then(res => {
  213. if (res.code == 0) {
  214. uni.$u.toast('订单取消成功');
  215. setTimeout(() => {
  216. uni.navigateBack({
  217. delta: 1
  218. })
  219. }, 500)
  220. }
  221. })
  222. }
  223. }
  224. })
  225. },
  226. payOrder() {
  227. let _this = this
  228. let payIng = false
  229. if (payIng) return
  230. uni.showLoading({
  231. title: '加载中'
  232. });
  233. $http.post('/api/v1/mp/user/deliver/order/pay', {
  234. orderId: _this.info.orderId,
  235. payType: 2
  236. }).then(ele => {
  237. payIng = true
  238. uni.hideLoading();
  239. if (ele.code == 0) {
  240. uni.requestPayment({
  241. timeStamp: ele.data.timeStamp,
  242. nonceStr: ele.data.nonceStr,
  243. package: ele.data.package,
  244. signType: ele.data.signType,
  245. paySign: ele.data.paySign,
  246. success() {
  247. uni.showToast({
  248. title: '支付成功',
  249. icon: 'success',
  250. duration: 2000
  251. })
  252. setTimeout(() => {
  253. uni.navigateBack({
  254. delta: 1
  255. })
  256. }, 500)
  257. },
  258. fail() {
  259. payIng = false
  260. }
  261. })
  262. } else {
  263. payIng = false
  264. uni.$u.toast('支付失败!');
  265. }
  266. }).catch(() => {
  267. payIng = false
  268. uni.$u.toast('支付失败!');
  269. uni.hideLoading();
  270. })
  271. },
  272. copyOrderId() {
  273. uni.setClipboardData({
  274. data: this.info.orderId,
  275. });
  276. },
  277. copyDeliveryFlowId(id) {
  278. uni.setClipboardData({
  279. data: id,
  280. });
  281. },
  282. // 查看物流
  283. getLogistics() {
  284. uni.navigateTo({
  285. url: `/packageGoods/order/logistics?id=${ this.orderId }`
  286. // url:`/pages/order/logistics?id=96666733329055749370`
  287. });
  288. },
  289. // 确认收货
  290. confirmOne() {
  291. let orderId = this.orderId
  292. uni.showModal({
  293. title: '提示',
  294. content: '确定已经收到货了吗?',
  295. success(res) {
  296. if (res.confirm) {
  297. $http.post('/api/v1/mp/user/deliver/order/confirm', {
  298. orderId
  299. }).then(res => {
  300. if (res.code == 0) {
  301. uni.$u.toast('确认收货成功');
  302. setTimeout(() => {
  303. uni.navigateBack({
  304. delta: 1
  305. })
  306. }, 500)
  307. }
  308. })
  309. }
  310. }
  311. })
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .footer-fixed {
  318. position: fixed;
  319. bottom: var(--window-bottom);
  320. left: 0;
  321. right: 0;
  322. z-index: 11;
  323. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  324. background: #fff;
  325. // 设置ios刘海屏底部横线安全区域
  326. padding-bottom: constant(safe-area-inset-bottom);
  327. padding-bottom: env(safe-area-inset-bottom);
  328. .btn {
  329. justify-content: flex-end;
  330. padding: 20rpx 40rpx;
  331. &-right {
  332. display: flex;
  333. align-items: center;
  334. justify-content: right;
  335. .value {
  336. color: $uni-text-color;
  337. }
  338. @mixin btn {
  339. width: 160rpx;
  340. height: 60rpx;
  341. line-height: 60rpx;
  342. border-radius: 8rpx;
  343. text-align: center;
  344. margin-left: 20rpx;
  345. }
  346. .logistics {
  347. @include btn border: 1px solid #bbbbbb;
  348. color: #414141;
  349. }
  350. .logisticsCancel {
  351. @include btn border: 2rpx solid #666;
  352. }
  353. .confirm {
  354. @include btn border: 2rpx solid rgba(236, 112, 9, 100);
  355. color: rgba(236, 112, 9, 100);
  356. }
  357. .confirmPay {
  358. @include btn background-color: $uni-bg-color;
  359. border: 2rpx solid $uni-bg-color;
  360. color: #FFFFFF;
  361. }
  362. }
  363. }
  364. }
  365. </style>
  366. <style lang="scss" scoped>
  367. .freight {
  368. margin-bottom: 20rpx;
  369. background-color: #fff;
  370. // justify-content: space-between;
  371. padding: 20rpx 28rpx;
  372. }
  373. .detail {
  374. margin: 10rpx;
  375. padding-bottom: 160rpx;
  376. &-state {
  377. padding: 28rpx;
  378. margin-bottom: 20rpx;
  379. background-color: #FFFFFF;
  380. &-title {
  381. line-height: 40rpx;
  382. font-weight: bold;
  383. display: inline-block;
  384. }
  385. &-time {
  386. line-height: 40rpx;
  387. color: #b1b1b1;
  388. float: right;
  389. }
  390. }
  391. &-info {
  392. margin-bottom: 20rpx;
  393. padding: 20rpx 28rpx;
  394. background-color: #FFFFFF;
  395. &-title {
  396. line-height: 40rpx;
  397. font-weight: bold;
  398. }
  399. &-content {
  400. &-goods {
  401. &__detail {
  402. padding: 20rpx 0;
  403. justify-content: space-between;
  404. border-bottom: 1px solid rgba(236, 236, 236, 100);
  405. &__left {
  406. display: flex;
  407. height: 170rpx;
  408. .img {
  409. image {
  410. width: 170rpx;
  411. height: 170rpx;
  412. margin-right: 20rpx;
  413. }
  414. }
  415. }
  416. &__right {
  417. flex: 1;
  418. display: flex;
  419. height: 170rpx;
  420. flex-direction: column;
  421. justify-content: space-between;
  422. align-items: flex-start;
  423. font-size: 30rpx;
  424. .title {
  425. font-weight: bold;
  426. }
  427. .sku {
  428. color: #8C8C8C;
  429. }
  430. }
  431. }
  432. &__detail:last-child {
  433. border: none;
  434. }
  435. }
  436. &-money {
  437. margin-top: 40rpx;
  438. &__item {
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. line-height: 40rpx;
  443. margin-bottom: 24rpx;
  444. }
  445. }
  446. &-toatl {
  447. padding-top: 24rpx;
  448. display: flex;
  449. align-items: center;
  450. justify-content: flex-end;
  451. font-weight: bold;
  452. }
  453. &-desc {
  454. position: relative;
  455. display: flex;
  456. line-height: 40rpx;
  457. margin-top: 20rpx;
  458. margin-bottom: 24rpx;
  459. view:first-child {
  460. width: 150rpx;
  461. }
  462. view:last-child {
  463. width: calc(100% - 150rpx)
  464. }
  465. .copy {
  466. position: absolute;
  467. right: 0;
  468. top: -6rpx;
  469. width: 136rpx;
  470. height: 52rpx;
  471. line-height: 52rpx;
  472. text-align: center;
  473. color: rgba(149, 149, 149, 100);
  474. border: 1px solid rgba(187, 187, 187, 100);
  475. border-radius: 10rpx;
  476. }
  477. }
  478. &-desc:last-child {
  479. margin-bottom: 0;
  480. }
  481. &-deliver {
  482. &__detail {
  483. padding: 20rpx 0;
  484. justify-content: space-between;
  485. border-bottom: 1px solid rgba(236, 236, 236, 100);
  486. &__left {
  487. display: flex;
  488. height: 170rpx;
  489. .img {
  490. image {
  491. width: 170rpx;
  492. height: 170rpx;
  493. margin-right: 20rpx;
  494. }
  495. }
  496. }
  497. &__right {
  498. flex: 1;
  499. display: flex;
  500. height: 170rpx;
  501. flex-direction: column;
  502. justify-content: space-between;
  503. align-items: flex-end;
  504. .num {
  505. width: 100%;
  506. justify-content: space-between;
  507. .sku {
  508. color: #8C8C8C;
  509. }
  510. }
  511. }
  512. }
  513. &__detail:last-child {
  514. border: none;
  515. }
  516. }
  517. }
  518. .border {
  519. border-bottom: 1px solid rgba(236, 236, 236, 100);
  520. }
  521. .border:last-child {
  522. border: none;
  523. }
  524. }
  525. }
  526. .detail-btn {
  527. display: flex;
  528. align-items: center;
  529. justify-content: flex-end;
  530. position: fixed;
  531. bottom: var(--window-bottom);
  532. left: 0;
  533. right: 0;
  534. // min-height: 120rpx;
  535. z-index: 11;
  536. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  537. background: #fff;
  538. // margin-bottom: 40rpx;
  539. // 设置ios刘海屏底部横线安全区域
  540. padding-bottom: constant(safe-area-inset-bottom);
  541. padding-bottom: env(safe-area-inset-bottom);
  542. box-shadow: 0 -5rpx 5rpx #ececec;
  543. padding: 20rpx 20rpx;
  544. text {
  545. display: block;
  546. box-sizing: border-box;
  547. margin: 0 0 0 40rpx;
  548. width: 160rpx;
  549. height: 60rpx;
  550. line-height: 60rpx;
  551. text-align: center;
  552. font-size: 24rpx;
  553. border-radius: 8rpx;
  554. border: none;
  555. }
  556. text:first-child {
  557. background-color: #fff;
  558. line-height: 56rpx;
  559. border: 2rpx solid $uni-bg-color;
  560. }
  561. text:last-child {
  562. background-color: $uni-bg-color;
  563. color: #FFFFFF;
  564. }
  565. }
  566. </style>