detail.vue 14 KB

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