detail.vue 14 KB

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