detail.vue 15 KB

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