detail.vue 12 KB

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