detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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="flex freight" v-if="info.memo != ''">
  46. <text style="margin-right: 30rpx;">留言:</text>
  47. <text>{{info.memo}}</text>
  48. </view>
  49. <view class="detail-info">
  50. <view class="detail-info-title">订单信息</view>
  51. <view class="detail-info-content">
  52. <view class="detail-info-content-desc">
  53. <view>收货信息:</view>
  54. <view>
  55. {{ info.receiver }},{{ info.tel }},{{ info.province }}{{ info.city }}{{ info.area }}{{ info.address }}
  56. </view>
  57. </view>
  58. <view class="detail-info-content-desc">
  59. <view>订单编号:</view>
  60. <view class="copy" @click="copyOrderId" v-if="status.value == 2 || status.value == 4">复制</view>
  61. <view>{{ info.orderId }}</view>
  62. </view>
  63. <view class="detail-info-content-desc">
  64. <view>下单时间:</view>
  65. <view>{{ $parseTime(info.createdTime) }}</view>
  66. </view>
  67. </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
  348. border: 1px solid #bbbbbb;
  349. color: #414141;
  350. }
  351. .logisticsCancel {
  352. @include btn
  353. border: 2rpx solid $uni-bg-color;
  354. }
  355. .confirm {
  356. @include btn
  357. border: 2rpx solid rgba(236, 112, 9, 100);
  358. color: rgba(236, 112, 9, 100);
  359. }
  360. .confirmPay {
  361. @include btn
  362. background-color: $uni-bg-color;
  363. border: 2rpx solid $uni-bg-color;
  364. color: #FFFFFF;
  365. }
  366. }
  367. }
  368. }
  369. </style>
  370. <style lang="scss" scoped>
  371. .freight {
  372. margin-bottom: 20rpx;
  373. background-color: #fff;
  374. justify-content: space-between;
  375. padding: 20rpx 16rpx;
  376. }
  377. .detail {
  378. margin: 10rpx;
  379. padding-bottom: 160rpx;
  380. &-state {
  381. padding: 28rpx;
  382. margin-bottom: 20rpx;
  383. background-color: #FFFFFF;
  384. &-title {
  385. line-height: 40rpx;
  386. font-weight: bold;
  387. display: inline-block;
  388. }
  389. &-time {
  390. line-height: 40rpx;
  391. color: #b1b1b1;
  392. float: right;
  393. }
  394. }
  395. &-info {
  396. margin-bottom: 20rpx;
  397. padding: 20rpx 28rpx;
  398. background-color: #FFFFFF;
  399. &-title {
  400. line-height: 40rpx;
  401. font-weight: bold;
  402. }
  403. &-content {
  404. &-goods {
  405. &__detail {
  406. padding: 20rpx 0;
  407. justify-content: space-between;
  408. border-bottom: 1px solid rgba(236, 236, 236, 100);
  409. &__left {
  410. display: flex;
  411. height: 170rpx;
  412. .img {
  413. image {
  414. width: 170rpx;
  415. height: 170rpx;
  416. margin-right: 20rpx;
  417. }
  418. }
  419. }
  420. &__right {
  421. flex: 1;
  422. display: flex;
  423. height: 170rpx;
  424. flex-direction: column;
  425. justify-content: space-between;
  426. align-items: flex-start;
  427. font-size: 30rpx;
  428. .title {
  429. font-weight: bold;
  430. }
  431. .sku {
  432. color: #8C8C8C;
  433. }
  434. }
  435. }
  436. &__detail:last-child {
  437. border: none;
  438. }
  439. }
  440. &-money {
  441. margin-top: 40rpx;
  442. &__item {
  443. display: flex;
  444. align-items: center;
  445. justify-content: space-between;
  446. line-height: 40rpx;
  447. margin-bottom: 24rpx;
  448. }
  449. }
  450. &-toatl {
  451. padding-top: 24rpx;
  452. display: flex;
  453. align-items: center;
  454. justify-content: flex-end;
  455. font-weight: bold;
  456. }
  457. &-desc {
  458. position: relative;
  459. display: flex;
  460. line-height: 40rpx;
  461. margin-top: 20rpx;
  462. margin-bottom: 24rpx;
  463. view:first-child {
  464. width: 150rpx;
  465. }
  466. view:last-child {
  467. width: calc(100% - 150rpx)
  468. }
  469. .copy {
  470. position: absolute;
  471. right: 0;
  472. top: -6rpx;
  473. width: 136rpx;
  474. height: 52rpx;
  475. line-height: 52rpx;
  476. text-align: center;
  477. color: rgba(149, 149, 149, 100);
  478. border: 1px solid rgba(187, 187, 187, 100);
  479. border-radius: 10rpx;
  480. }
  481. }
  482. &-desc:last-child {
  483. margin-bottom: 0;
  484. }
  485. &-deliver {
  486. &__detail {
  487. padding: 20rpx 0;
  488. justify-content: space-between;
  489. border-bottom: 1px solid rgba(236, 236, 236, 100);
  490. &__left {
  491. display: flex;
  492. height: 170rpx;
  493. .img {
  494. image {
  495. width: 170rpx;
  496. height: 170rpx;
  497. margin-right: 20rpx;
  498. }
  499. }
  500. }
  501. &__right {
  502. flex: 1;
  503. display: flex;
  504. height: 170rpx;
  505. flex-direction: column;
  506. justify-content: space-between;
  507. align-items: flex-end;
  508. .num {
  509. width: 100%;
  510. justify-content: space-between;
  511. .sku {
  512. color: #8C8C8C;
  513. }
  514. }
  515. }
  516. }
  517. &__detail:last-child {
  518. border: none;
  519. }
  520. }
  521. }
  522. .border {
  523. border-bottom: 1px solid rgba(236, 236, 236, 100);
  524. }
  525. .border:last-child {
  526. border: none;
  527. }
  528. }
  529. }
  530. .detail-btn {
  531. display: flex;
  532. align-items: center;
  533. justify-content: flex-end;
  534. position: fixed;
  535. bottom: var(--window-bottom);
  536. left: 0;
  537. right: 0;
  538. // min-height: 120rpx;
  539. z-index: 11;
  540. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  541. background: #fff;
  542. // margin-bottom: 40rpx;
  543. // 设置ios刘海屏底部横线安全区域
  544. padding-bottom: constant(safe-area-inset-bottom);
  545. padding-bottom: env(safe-area-inset-bottom);
  546. box-shadow: 0 -5rpx 5rpx #ececec;
  547. padding: 20rpx 20rpx;
  548. text {
  549. display: block;
  550. box-sizing: border-box;
  551. margin: 0 0 0 40rpx;
  552. width: 160rpx;
  553. height: 60rpx;
  554. line-height: 60rpx;
  555. text-align: center;
  556. font-size: 24rpx;
  557. border-radius: 8rpx;
  558. border: none;
  559. }
  560. text:first-child {
  561. background-color: #fff;
  562. line-height: 56rpx;
  563. border: 2rpx solid $uni-bg-color;
  564. }
  565. text:last-child {
  566. background-color: $uni-bg-color;
  567. color: #FFFFFF;
  568. }
  569. }
  570. </style>