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