detail.vue 15 KB

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