detail.vue 14 KB

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