detail.vue 14 KB

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