detail.vue 12 KB

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