detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <view class="detail">
  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">应付:</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="freight" v-if="info.memo != ''">
  66. <view style="width: 150rpx;display: inline-block;">留言:</view>
  67. <view style="display: inline-block;width: 524rpx;vertical-align: top;">{{info.memo}}</view>
  68. </view>
  69. </view> -->
  70. <!-- 订单状态 -->
  71. <view class="status">
  72. <image src="../../packageGoods/static/ordr/bg.png" mode="scaleToFill"></image>
  73. <view class="status-info">
  74. <image src="../../packageGoods/static/ordr/car.png" mode=""></image>
  75. <view class="status-info-contet">
  76. <view class="status-info-contet-txt" :class="{'status-info-contet-one': status.value != 2 }">{{ status.desc }}</view>
  77. <view class="status-info-contet-time" v-if="status.value == 2">还剩 {{ autoConfirmTime || "--" }} 自动确认</view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 地址 -->
  82. <view class="address">
  83. <view class="address-content">
  84. <image src="../static/ordr/addr.png" mode="scaleToFill"></image>
  85. <view class="address-content-txt">
  86. <view class="name">{{ info.receiver }} <text> {{ info.tel }}</text></view>
  87. <view class="city ells">{{ info.province }} {{ info.city }} {{ info.area }} {{ info.address }}</view>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 商品 -->
  92. <view class="goods">
  93. <view class="goods-title">商品信息</view>
  94. <view class="goods-item" v-for="(item, index) in list" :key="index">
  95. <image :src="item.picUrl" mode="aspectFit"></image>
  96. <view class="info">
  97. <view class="info-title ells">{{ item.title }}</view>
  98. <view class="info-num flex">
  99. <view class="info-num-sku ells-one">规格:{{ item.properties || '-' }}</view>
  100. <view class="info-num-goods">共{{ item.goodsNum }}件</view>
  101. </view>
  102. </view>
  103. </view>
  104. <!-- 运费 -->
  105. <view class="goods-freight">
  106. <view class="freight-title">运费</view>
  107. <view class="freight-price">¥{{ $numberFormat(info.freightAmt) }}</view>
  108. </view>
  109. <!-- 总价 -->
  110. <view class="goods-total flex">
  111. <view class="goods-total-price">应付:<text>¥{{ $numberFormat(info.payAmt) }}</text></view>
  112. </view>
  113. </view>
  114. <!-- 订单信息 -->
  115. <view class="order">
  116. <view class="order-title">订单信息</view>
  117. <view class="order-item flex">
  118. <view class="order-item-title">订单编号</view>
  119. <view class="order-item-content flex" @click="copyOrderId" v-if="status.value == 2 || status.value == 4">
  120. <text>{{ info.orderId }}</text>
  121. <view class="copy flex">
  122. <text>复制</text>
  123. </view>
  124. </view>
  125. <view class="order-item-content flex" v-else>{{ info.orderId }}</view>
  126. </view>
  127. <view class="order-item flex">
  128. <view class="order-item-title">下单时间</view>
  129. <view class="order-item-content">{{ $parseTime(info.createdTime) }}</view>
  130. </view>
  131. </view>
  132. <!-- 发货信息 -->
  133. <view class="order">
  134. <view class="order-title">发货信息</view>
  135. <view class="order-item flex">
  136. <view class="order-item-title">配送方式</view>
  137. <view class="order-item-content">无需物流</view>
  138. </view>
  139. <view class="order-item flex">
  140. <view class="order-item-title">发货时间</view>
  141. <view class="order-item-content">{{ $parseTime(info.createdTime) }}</view>
  142. </view>
  143. </view>
  144. <!-- 留言 -->
  145. <view class="order" v-if="info.memo != ''">
  146. <view class="order-title">留言</view>
  147. <view class="order-item flex">
  148. <view class="order-item-content">{{ info.memo }}</view>
  149. </view>
  150. </view>
  151. <!-- 操作按钮 -->
  152. <view class="footer-fixed" v-if="status.value == 2 || status.value == 3">
  153. <view class="btn flex">
  154. <view class="btn-item flex logistics" v-if="status.value == 2 || status.value == 3" @click="getLogistics"><text>查看物流</text></view>
  155. <view class="btn-item flex pay" v-if="status.value == 2" @click="confirmOne"><text>确认收货</text></view>
  156. <view class="btn-item flex cancel" v-if="status.value == 0" @click="cancelOrder"><text>取消订单</text></view>
  157. <view class="btn-item flex pay"v-if="status.value == 0" @click="payOrder"><text>去支付</text></view>
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script>
  163. import env from '../../config/env.js'
  164. import $http from '@/utils/request.js'
  165. export default {
  166. data() {
  167. return {
  168. orderId: '',
  169. status: {},
  170. info: {},
  171. addr: {},
  172. list: [],
  173. deliverList: [],
  174. autoConfirmTime: '',
  175. };
  176. },
  177. onLoad(opthios) {
  178. this.orderId = opthios.id
  179. this.getDetail()
  180. },
  181. methods: {
  182. getDetail() {
  183. uni.showLoading({
  184. title: '加载中'
  185. });
  186. $http.post('/api/v1/mp/user/deliver/order/detail', {
  187. orderId: this.orderId
  188. }).then(res => {
  189. uni.hideLoading();
  190. this.info = res.data
  191. this.status = JSON.parse(res.data.status)
  192. this.autoConfirmTime = res.data.autoConfirmTime
  193. res.data.items.forEach(item => {
  194. let picUrlArr = item.picUrl.split(',')
  195. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  196. })
  197. res.data.deliverList && res.data.deliverList.forEach((item) => {
  198. item.items.forEach((ele) => {
  199. let picUrlArr = ele.picUrl.split(",");
  200. ele.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170';
  201. });
  202. });
  203. this.deliverList = res.data.deliverList;
  204. this.list = res.data.items
  205. }).catch(() => {
  206. uni.hideLoading();
  207. })
  208. },
  209. cancelOrder() {
  210. let orderId = this.orderId
  211. uni.showModal({
  212. title: '提示',
  213. content: '您确认要取消订单吗?',
  214. success(res) {
  215. if (res.confirm) {
  216. $http.post('/api/v1/mp/user/deliver/order/cancel', {
  217. orderId
  218. }).then(res => {
  219. if (res.code == 0) {
  220. uni.$u.toast('订单取消成功');
  221. setTimeout(() => {
  222. uni.navigateBack({
  223. delta: 1
  224. })
  225. }, 500)
  226. }
  227. })
  228. }
  229. }
  230. })
  231. },
  232. payOrder() {
  233. let _this = this
  234. let payIng = false
  235. if (payIng) return
  236. uni.showLoading({
  237. title: '加载中'
  238. });
  239. $http.post('/api/v1/mp/user/deliver/order/pay', {
  240. orderId: _this.info.orderId,
  241. payType: 2
  242. }).then(ele => {
  243. payIng = true
  244. uni.hideLoading();
  245. if (ele.code == 0) {
  246. uni.requestPayment({
  247. timeStamp: ele.data.timeStamp,
  248. nonceStr: ele.data.nonceStr,
  249. package: ele.data.package,
  250. signType: ele.data.signType,
  251. paySign: ele.data.paySign,
  252. success() {
  253. uni.showToast({
  254. title: '支付成功',
  255. icon: 'success',
  256. duration: 2000
  257. })
  258. setTimeout(() => {
  259. uni.navigateBack({
  260. delta: 1
  261. })
  262. }, 500)
  263. },
  264. fail() {
  265. payIng = false
  266. }
  267. })
  268. } else {
  269. payIng = false
  270. uni.$u.toast('支付失败!');
  271. }
  272. }).catch(() => {
  273. payIng = false
  274. uni.$u.toast('支付失败!');
  275. uni.hideLoading();
  276. })
  277. },
  278. copyOrderId() {
  279. uni.setClipboardData({
  280. data: this.info.orderId,
  281. });
  282. },
  283. copyDeliveryFlowId(id) {
  284. uni.setClipboardData({
  285. data: id,
  286. });
  287. },
  288. // 查看物流
  289. getLogistics() {
  290. uni.navigateTo({
  291. url: `/packageGoods/order/logistics?id=${ this.orderId }`
  292. // url:`/pages/order/logistics?id=96666733329055749370`
  293. });
  294. },
  295. // 确认收货
  296. confirmOne() {
  297. let orderId = this.orderId
  298. uni.showModal({
  299. title: '提示',
  300. content: '确定已经收到货了吗?',
  301. success(res) {
  302. if (res.confirm) {
  303. $http.post('/api/v1/mp/user/deliver/order/confirm', {
  304. orderId
  305. }).then(res => {
  306. if (res.code == 0) {
  307. uni.$u.toast('确认收货成功');
  308. setTimeout(() => {
  309. uni.navigateBack({
  310. delta: 1
  311. })
  312. }, 500)
  313. }
  314. })
  315. }
  316. }
  317. })
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .detail {
  324. padding-bottom: 100rpx;
  325. }
  326. // 订单状态
  327. .status {
  328. position: relative;
  329. height: 216rpx;
  330. image {
  331. width: 100%;
  332. height: 100%;
  333. }
  334. &-info {
  335. position: absolute;
  336. top: 0;
  337. display: flex;
  338. width: 100%;
  339. height: 100%;
  340. padding: 56rpx 0 0 34rpx;
  341. image {
  342. width: 74rpx;
  343. height: 62rpx;
  344. margin: 18rpx 22rpx 0 0;
  345. }
  346. &-contet {
  347. &-txt {
  348. font-size: 38rpx;
  349. font-weight: 800;
  350. color: #FFFFFF;
  351. line-height: 60rpx;
  352. }
  353. &-one {
  354. margin-top: 18rpx;
  355. height: 62rpx;
  356. line-height: 62rpx;
  357. }
  358. &-time {
  359. font-size: 30rpx;
  360. font-weight: 500;
  361. color: #FFFFFF;
  362. line-height: 44rpx;
  363. }
  364. }
  365. }
  366. }
  367. // 地址
  368. .address {
  369. position: relative;
  370. margin-top: -34rpx;
  371. background-color: #fff;
  372. border-radius: 34rpx 34rpx 0 0;
  373. z-index: 10;
  374. padding-top: 34rpx;
  375. margin-bottom: 22rpx;
  376. &-content {
  377. display: flex;
  378. align-items: center;
  379. border-top: 1px dashed rgb(254, 143, 62);
  380. padding: 18rpx 0 36rpx 34rpx;
  381. image {
  382. width: 30rpx;
  383. height: 38rpx;
  384. margin-right: 34rpx;
  385. }
  386. &-txt {
  387. flex: 1;
  388. .name {
  389. font-size: 30rpx;
  390. line-height: 30rpx;
  391. margin-bottom: 20rpx;
  392. text {
  393. padding: 0 8rpx;
  394. font-size: 26rpx;
  395. color: #414141;
  396. }
  397. }
  398. .city {
  399. color: #999999;
  400. line-height: 28rpx;
  401. }
  402. }
  403. }
  404. }
  405. // 商品
  406. .goods {
  407. padding: 34rpx;
  408. background-color: #fff;
  409. margin-bottom: 22rpx;
  410. &-title {
  411. font-size: 30rpx;
  412. line-height: 30rpx;
  413. margin-bottom: 22rpx;
  414. }
  415. // 商品列表
  416. &-item{
  417. display: flex;
  418. padding: 34rpx 32rpx 34rpx 22rpx;
  419. box-shadow: 0px 0px 8px 0px rgba(26, 35, 113, 0.08);
  420. border-radius: 4rpx;
  421. margin-bottom: 20rpx;
  422. image {
  423. width: 176rpx;
  424. height: 176rpx;
  425. border-radius: 12rpx;
  426. margin-right: 22rpx;
  427. }
  428. .info {
  429. display: flex;
  430. flex-direction: column;
  431. justify-content: space-between;
  432. flex: 1;
  433. padding: 8rpx 0;
  434. &-title {
  435. font-weight: bold;
  436. line-height: 40rpx;
  437. }
  438. &-num {
  439. justify-content: space-between;
  440. &-sku {
  441. flex: 1;
  442. color: #666666;
  443. font-size: 26rpx;
  444. }
  445. &-goods {
  446. color: #666666;
  447. font-size: 26rpx;
  448. }
  449. }
  450. }
  451. }
  452. &-item:last-child {
  453. margin-bottom: 0;
  454. }
  455. // 运费
  456. &-freight {
  457. display: flex;
  458. align-items: center;
  459. justify-content: space-between;
  460. padding-bottom: 18rpx;
  461. border-bottom: 1px solid #eee;
  462. margin-bottom: 20rpx;
  463. &-title {
  464. line-height: 28rpx;
  465. color: #999;
  466. }
  467. &-price {
  468. line-height: 28rpx;
  469. }
  470. }
  471. // 总价
  472. &-total {
  473. justify-content: flex-end;
  474. &-price {
  475. font-size: 30rpx;
  476. color: #F24E4E;
  477. }
  478. }
  479. }
  480. // 订单信息
  481. .order {
  482. padding: 34rpx;
  483. background-color: #fff;
  484. margin-bottom: 22rpx;
  485. &-title {
  486. font-size: 30rpx;
  487. line-height: 30rpx;
  488. margin-bottom: 22rpx;
  489. }
  490. &-item {
  491. justify-content: space-between;
  492. margin-bottom: 28rpx;
  493. &-title {
  494. color: #999999;
  495. line-height: 28rpx;
  496. }
  497. &-content {
  498. .copy {
  499. height: 100%;
  500. margin-left: 8rpx;
  501. text-align: center;
  502. border-radius: 12rpx;
  503. font-size: 24rpx;
  504. line-height: 24rpx;
  505. padding: 0 6rpx;
  506. background-color: rgba(153, 153, 153, .1);
  507. text {
  508. display: inline-block;
  509. transform: scale(0.8);
  510. }
  511. }
  512. }
  513. }
  514. &-item:last-child {
  515. margin-bottom: 0;
  516. }
  517. }
  518. // 操作按钮
  519. .footer-fixed {
  520. position: fixed;
  521. bottom: var(--window-bottom);
  522. left: 0;
  523. right: 0;
  524. z-index: 11;
  525. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  526. background: #fff;
  527. // 设置ios刘海屏底部横线安全区域
  528. padding-bottom: constant(safe-area-inset-bottom);
  529. padding-bottom: env(safe-area-inset-bottom);
  530. .btn {
  531. justify-content: flex-end;
  532. padding: 20rpx 34rpx;
  533. &-item {
  534. width: 200rpx;
  535. height: 66rpx;
  536. font-size: 30rpx;
  537. border-radius: 33rpx;
  538. margin-left: 44rpx;
  539. text {
  540. line-height: 30rpx;
  541. }
  542. }
  543. .logistics {
  544. border: 1px solid #F9822C;
  545. color: #F9822C;
  546. }
  547. .detail {
  548. background-color: rgb(249, 130, 44);
  549. color: #FFFFFF;
  550. }
  551. .cancel {
  552. border: 1px solid #c4c6c9;
  553. color: #c4c6c9;
  554. }
  555. .pay {
  556. background-color: #5ac725;
  557. color: #fff;
  558. }
  559. &-item:first-child {
  560. margin-left: 0;
  561. }
  562. }
  563. }
  564. </style>