detail.vue 14 KB

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