detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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 || status.value == 4">
  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. confirmOne() {
  269. let orderId = this.orderId
  270. uni.showModal({
  271. title: '提示',
  272. content: '确定已经收到货了吗?',
  273. success(res) {
  274. if (res.confirm) {
  275. $http.post('/api/v1/mp/user/deliver/order/confirm', {
  276. orderId
  277. }).then(res => {
  278. if (res.code == 0) {
  279. uni.$u.toast('确认收货成功');
  280. setTimeout(() => {
  281. uni.navigateBack({
  282. delta: 1
  283. })
  284. }, 500)
  285. }
  286. })
  287. }
  288. }
  289. })
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .footer-fixed {
  296. position: fixed;
  297. bottom: var(--window-bottom);
  298. left: 0;
  299. right: 0;
  300. z-index: 11;
  301. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  302. background: #fff;
  303. // 设置ios刘海屏底部横线安全区域
  304. padding-bottom: constant(safe-area-inset-bottom);
  305. padding-bottom: env(safe-area-inset-bottom);
  306. .btn {
  307. justify-content: flex-end;
  308. padding: 20rpx 40rpx;
  309. &-right {
  310. display: flex;
  311. align-items: center;
  312. justify-content: right;
  313. .value {
  314. color: $uni-text-color;
  315. }
  316. .logistics {
  317. width: 160rpx;
  318. height: 60rpx;
  319. line-height: 60rpx;
  320. border-radius: 8rpx;
  321. text-align: center;
  322. margin-left: 20rpx;
  323. border: 1px solid #bbbbbb;
  324. color: #414141;
  325. }
  326. .confirm {
  327. width: 160rpx;
  328. height: 60rpx;
  329. line-height: 60rpx;
  330. border-radius: 8rpx;
  331. text-align: center;
  332. margin-left: 20rpx;
  333. border: 1px solid rgba(236, 112, 9, 100);
  334. color: rgba(236, 112, 9, 100);
  335. }
  336. }
  337. }
  338. }
  339. </style>
  340. <style lang="scss" scoped>
  341. .detail {
  342. margin: 10rpx;
  343. padding-bottom: 160rpx;
  344. &-state {
  345. padding: 28rpx;
  346. margin-bottom: 20rpx;
  347. background-color: #FFFFFF;
  348. &-title {
  349. line-height: 40rpx;
  350. font-weight: bold;
  351. display: inline-block;
  352. }
  353. &-time {
  354. line-height: 40rpx;
  355. color: #b1b1b1;
  356. float: right;
  357. }
  358. }
  359. &-info {
  360. margin-bottom: 20rpx;
  361. padding: 20rpx 28rpx;
  362. background-color: #FFFFFF;
  363. &-title {
  364. line-height: 40rpx;
  365. font-weight: bold;
  366. }
  367. &-content {
  368. &-goods {
  369. &__detail {
  370. padding: 20rpx 0;
  371. justify-content: space-between;
  372. border-bottom: 1px solid rgba(236, 236, 236, 100);
  373. &__left {
  374. display: flex;
  375. height: 170rpx;
  376. .img {
  377. image {
  378. width: 170rpx;
  379. height: 170rpx;
  380. margin-right: 20rpx;
  381. }
  382. }
  383. }
  384. &__right {
  385. flex: 1;
  386. display: flex;
  387. height: 170rpx;
  388. flex-direction: column;
  389. justify-content: space-between;
  390. align-items: flex-start;
  391. font-size: 30rpx;
  392. .title {
  393. font-weight: bold;
  394. }
  395. .sku {
  396. color: #8C8C8C;
  397. }
  398. }
  399. }
  400. &__detail:last-child {
  401. border: none;
  402. }
  403. }
  404. &-money {
  405. margin-top: 40rpx;
  406. &__item {
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. line-height: 40rpx;
  411. margin-bottom: 24rpx;
  412. }
  413. }
  414. &-toatl {
  415. padding-top: 24rpx;
  416. display: flex;
  417. align-items: center;
  418. justify-content: flex-end;
  419. font-weight: bold;
  420. }
  421. &-desc {
  422. position: relative;
  423. display: flex;
  424. line-height: 40rpx;
  425. margin-top: 20rpx;
  426. margin-bottom: 24rpx;
  427. view:first-child {
  428. width: 150rpx;
  429. }
  430. view:last-child {
  431. width: calc(100% - 150rpx)
  432. }
  433. .copy {
  434. position: absolute;
  435. right: 0;
  436. top: -6rpx;
  437. width: 136rpx;
  438. height: 52rpx;
  439. line-height: 52rpx;
  440. text-align: center;
  441. color: rgba(149, 149, 149, 100);
  442. border: 1px solid rgba(187, 187, 187, 100);
  443. border-radius: 10rpx;
  444. }
  445. }
  446. &-desc:last-child {
  447. margin-bottom: 0;
  448. }
  449. &-deliver {
  450. &__detail {
  451. padding: 20rpx 0;
  452. justify-content: space-between;
  453. border-bottom: 1px solid rgba(236, 236, 236, 100);
  454. &__left {
  455. display: flex;
  456. height: 170rpx;
  457. .img {
  458. image {
  459. width: 170rpx;
  460. height: 170rpx;
  461. margin-right: 20rpx;
  462. }
  463. }
  464. }
  465. &__right {
  466. flex: 1;
  467. display: flex;
  468. height: 170rpx;
  469. flex-direction: column;
  470. justify-content: space-between;
  471. align-items: flex-end;
  472. .num {
  473. width: 100%;
  474. justify-content: space-between;
  475. .sku {
  476. color: #8C8C8C;
  477. }
  478. }
  479. }
  480. }
  481. &__detail:last-child {
  482. border: none;
  483. }
  484. }
  485. }
  486. .border {
  487. border-bottom: 1px solid rgba(236, 236, 236, 100);
  488. }
  489. .border:last-child {
  490. border: none;
  491. }
  492. }
  493. }
  494. .detail-btn {
  495. display: flex;
  496. align-items: center;
  497. justify-content: flex-end;
  498. position: fixed;
  499. bottom: var(--window-bottom);
  500. left: 0;
  501. right: 0;
  502. // min-height: 120rpx;
  503. z-index: 11;
  504. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  505. background: #fff;
  506. // margin-bottom: 40rpx;
  507. // 设置ios刘海屏底部横线安全区域
  508. padding-bottom: constant(safe-area-inset-bottom);
  509. padding-bottom: env(safe-area-inset-bottom);
  510. box-shadow: 0 -5rpx 5rpx #ececec;
  511. padding: 20rpx 20rpx;
  512. text {
  513. display: block;
  514. box-sizing: border-box;
  515. margin: 0 0 0 40rpx;
  516. width: 160rpx;
  517. height: 60rpx;
  518. line-height: 60rpx;
  519. text-align: center;
  520. font-size: 24rpx;
  521. border-radius: 8rpx;
  522. border: none;
  523. }
  524. text:first-child {
  525. background-color: #fff;
  526. line-height: 56rpx;
  527. border: 2rpx solid $uni-bg-color;
  528. }
  529. text:last-child {
  530. background-color: $uni-bg-color;
  531. color: #FFFFFF;
  532. }
  533. }
  534. </style>