detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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>
  11. <view class="detail-info">
  12. <view class="detail-info-title">商品信息</view>
  13. <view class="detail-info-content">
  14. <view class="detail-info-content-goods">
  15. <view class="flex detail-info-content-goods__detail" v-for="(item, index) in list" :key="index">
  16. <view class="detail-info-content-goods__detail__left">
  17. <view class="img">
  18. <image class="img" :src="item.picUrl" mode="aspectFill">
  19. </image>
  20. </view>
  21. </view>
  22. <view class="detail-info-content-goods__detail__right">
  23. <view class="ells title">{{ item.title }}</view>
  24. <view class="sku" v-if="item.properties">规格:{{ item.properties }}</view>
  25. <view class="num">数量:{{ item.goodsNum }}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="detail-info-content-money">
  30. <view class="detail-info-content-money__item">
  31. <text>运费</text>
  32. <text>¥{{ $numberFormat(info.freightAmt) }}</text>
  33. </view>
  34. </view>
  35. <view class="detail-info-content-toatl">
  36. <text v-if="status.value == 0 || status.value == -1">应付:</text>
  37. <text v-else>实付:</text>
  38. <text>¥{{ $numberFormat(info.payAmt) }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="detail-info">
  43. <view class="detail-info-title">订单信息</view>
  44. <view class="detail-info-content">
  45. <view class="detail-info-content-desc">
  46. <view>收货信息:</view>
  47. <view>
  48. {{ info.receiver }},{{ info.tel }},{{ info.province }}{{ info.city }}{{ info.area }}{{ info.address }}
  49. </view>
  50. </view>
  51. <view class="detail-info-content-desc">
  52. <view>订单编号:</view>
  53. <view class="copy" @click="copyOrderId" v-if="status.value == 2 || status.value == 4">复制</view>
  54. <view>{{ info.orderId }}</view>
  55. </view>
  56. <view class="detail-info-content-desc">
  57. <view>下单时间:</view>
  58. <view>{{ $parseTime(info.createdTime) }}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length > 1">
  63. <view class="detail-info-title">发货信息</view>
  64. <view class="detail-info-content border" v-for="(item, index) in deliverList" :key="index">
  65. <view class="detail-info-content-desc">
  66. <view>快递公司:</view>
  67. <view>{{ item.companyName || '-' }}</view>
  68. </view>
  69. <view class="detail-info-content-desc">
  70. <view>物流单号:</view>
  71. <view class="copy" @click="copyDeliveryFlowId(item.deliveryFlowId)">复制</view>
  72. <view>{{ item.deliveryFlowId || '-' }}</view>
  73. </view>
  74. <view class="detail-info-content-desc">
  75. <view>发货时间:</view>
  76. <view>{{ $parseTime(item.deliveryTime) }}</view>
  77. </view>
  78. <view class="detail-info-content-deliver">
  79. <view class="flex detail-info-content-deliver__detail" v-for="(items, indexs) in item.items"
  80. :key="indexs">
  81. <view class="detail-info-content-deliver__detail__left">
  82. <view class="img">
  83. <image class="img" :src="items.picUrl" mode="aspectFill">
  84. </image>
  85. </view>
  86. </view>
  87. <view class="detail-info-content-deliver__detail__right">
  88. <view class="title">{{ items.title }}</view>
  89. <view class="flex num">
  90. <view class="sku" v-if="!items.properties"></view>
  91. <view class="sku" v-if="items.properties">规格:{{ items.properties }}</view>
  92. <view class="">数量:{{ items.goodsNum }}</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length == 1">
  100. <view class="detail-info-title">发货信息</view>
  101. <view class="detail-info-content" v-for="(item, index) in deliverList" :key="index">
  102. <view class="detail-info-content-desc">
  103. <view>快递公司:</view>
  104. <view>{{ item.companyName || '-' }}</view>
  105. </view>
  106. <view class="detail-info-content-desc">
  107. <view>物流单号:</view>
  108. <view class="copy" @click="copyDeliveryFlowId(item.deliveryFlowId)">复制</view>
  109. <view>{{ item.deliveryFlowId || '-' }}</view>
  110. </view>
  111. <view class="detail-info-content-desc">
  112. <view>发货时间:</view>
  113. <view>{{ $parseTime(item.deliveryTime) }}</view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="detail-btn" v-if="status.value == 0">
  119. <text @click="cancelOrder">取消订单</text>
  120. <text @click="payOrder">去支付</text>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. import env from '../../config/env.js'
  126. import $http from '@/utils/request.js'
  127. export default {
  128. data() {
  129. return {
  130. orderId: '',
  131. status: {},
  132. info: {},
  133. addr: {},
  134. list: [],
  135. deliverList: []
  136. };
  137. },
  138. onLoad(opthios) {
  139. this.orderId = opthios.id
  140. this.getDetail()
  141. },
  142. methods: {
  143. getDetail() {
  144. uni.showLoading({
  145. title: '加载中'
  146. });
  147. $http.post('/api/v1/mp/user/deliver/order/detail', {
  148. orderId: this.orderId
  149. }).then(res => {
  150. uni.hideLoading();
  151. this.info = res.data
  152. this.status = JSON.parse(res.data.status)
  153. res.data.items.forEach(item => {
  154. let picUrlArr = item.picUrl.split(',')
  155. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  156. })
  157. res.data.deliverList && res.data.deliverList.forEach((item) => {
  158. item.items.forEach((ele) => {
  159. let picUrlArr = ele.picUrl.split(",");
  160. ele.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170';
  161. });
  162. });
  163. this.deliverList = res.data.deliverList;
  164. this.list = res.data.items
  165. }).catch(() => {
  166. uni.hideLoading();
  167. })
  168. },
  169. cancelOrder() {
  170. uni.showModal({
  171. title: '提示',
  172. content: '您确认要取消订单吗?',
  173. success(res) {
  174. if (res.confirm) {
  175. $http.post('/api/v1/mp/user/deliver/order/cancel', {
  176. orderId: this.orderId
  177. }).then(res => {
  178. if (res.code == 0) {
  179. uni.$u.toast('订单取消成功');
  180. setTimeout(() => {
  181. uni.navigateBack({
  182. delta: 1
  183. })
  184. }, 500)
  185. }
  186. })
  187. }
  188. }
  189. })
  190. },
  191. payOrder() {
  192. let _this = this
  193. let payIng = false
  194. if (payIng) return
  195. uni.showLoading({
  196. title: '加载中'
  197. });
  198. $http.post('/api/v1/mp/user/deliver/order/pay', {
  199. orderId: _this.info.orderId,
  200. payType: 2
  201. }).then(ele => {
  202. payIng = true
  203. uni.hideLoading();
  204. if (ele.code == 0) {
  205. uni.requestPayment({
  206. timeStamp: ele.data.timeStamp,
  207. nonceStr: ele.data.nonceStr,
  208. package: ele.data.package,
  209. signType: ele.data.signType,
  210. paySign: ele.data.paySign,
  211. success() {
  212. uni.showToast({
  213. title: '支付成功',
  214. icon: 'success',
  215. duration: 2000
  216. })
  217. setTimeout(() => {
  218. uni.navigateBack({
  219. delta: 1
  220. })
  221. }, 500)
  222. },
  223. fail() {
  224. payIng = false
  225. }
  226. })
  227. } else {
  228. payIng = false
  229. uni.$u.toast('支付失败!');
  230. }
  231. }).catch(() => {
  232. payIng = false
  233. uni.$u.toast('支付失败!');
  234. uni.hideLoading();
  235. })
  236. },
  237. copyOrderId() {
  238. uni.setClipboardData({
  239. data: this.info.orderId,
  240. });
  241. },
  242. copyDeliveryFlowId(id) {
  243. uni.setClipboardData({
  244. data: id,
  245. });
  246. },
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .detail {
  252. margin: 10rpx;
  253. padding-bottom: 160rpx;
  254. &-state {
  255. padding: 28rpx;
  256. margin-bottom: 20rpx;
  257. background-color: #FFFFFF;
  258. &-title {
  259. line-height: 40rpx;
  260. font-weight: bold;
  261. }
  262. }
  263. &-info {
  264. margin-bottom: 20rpx;
  265. padding: 20rpx 28rpx;
  266. background-color: #FFFFFF;
  267. &-title {
  268. line-height: 40rpx;
  269. font-weight: bold;
  270. }
  271. &-content {
  272. &-goods {
  273. &__detail {
  274. padding: 20rpx 0;
  275. justify-content: space-between;
  276. border-bottom: 1px solid rgba(236, 236, 236, 100);
  277. &__left {
  278. display: flex;
  279. height: 170rpx;
  280. .img {
  281. image {
  282. width: 170rpx;
  283. height: 170rpx;
  284. margin-right: 20rpx;
  285. }
  286. }
  287. }
  288. &__right {
  289. flex: 1;
  290. display: flex;
  291. height: 170rpx;
  292. flex-direction: column;
  293. justify-content: space-between;
  294. align-items: flex-start;
  295. font-size: 30rpx;
  296. .title {
  297. font-weight: bold;
  298. }
  299. .sku {
  300. color: #8C8C8C;
  301. }
  302. }
  303. }
  304. &__detail:last-child {
  305. border: none;
  306. }
  307. }
  308. &-money {
  309. margin-top: 40rpx;
  310. &__item {
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-between;
  314. line-height: 40rpx;
  315. margin-bottom: 24rpx;
  316. }
  317. }
  318. &-toatl {
  319. padding-top: 24rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: flex-end;
  323. font-weight: bold;
  324. }
  325. &-desc {
  326. position: relative;
  327. display: flex;
  328. line-height: 40rpx;
  329. margin-top: 20rpx;
  330. margin-bottom: 24rpx;
  331. view:first-child {
  332. width: 150rpx;
  333. }
  334. view:last-child {
  335. width: calc(100% - 150rpx)
  336. }
  337. .copy {
  338. position: absolute;
  339. right: 0;
  340. top: -6rpx;
  341. width: 136rpx;
  342. height: 52rpx;
  343. line-height: 52rpx;
  344. text-align: center;
  345. color: rgba(149, 149, 149, 100);
  346. border: 1px solid rgba(187, 187, 187, 100);
  347. border-radius: 10rpx;
  348. }
  349. }
  350. &-desc:last-child {
  351. margin-bottom: 0;
  352. }
  353. &-deliver {
  354. &__detail {
  355. padding: 20rpx 0;
  356. justify-content: space-between;
  357. border-bottom: 1px solid rgba(236, 236, 236, 100);
  358. &__left {
  359. display: flex;
  360. height: 170rpx;
  361. .img {
  362. image {
  363. width: 170rpx;
  364. height: 170rpx;
  365. margin-right: 20rpx;
  366. }
  367. }
  368. }
  369. &__right {
  370. flex: 1;
  371. display: flex;
  372. height: 170rpx;
  373. flex-direction: column;
  374. justify-content: space-between;
  375. align-items: flex-end;
  376. .num {
  377. width: 100%;
  378. justify-content: space-between;
  379. .sku {
  380. color: #8C8C8C;
  381. }
  382. }
  383. }
  384. }
  385. &__detail:last-child {
  386. border: none;
  387. }
  388. }
  389. }
  390. .border {
  391. border-bottom: 1px solid rgba(236, 236, 236, 100);
  392. }
  393. .border:last-child {
  394. border: none;
  395. }
  396. }
  397. }
  398. .detail-btn {
  399. display: flex;
  400. align-items: center;
  401. justify-content: flex-end;
  402. position: fixed;
  403. bottom: var(--window-bottom);
  404. left: 0;
  405. right: 0;
  406. // min-height: 120rpx;
  407. z-index: 11;
  408. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  409. background: #fff;
  410. // margin-bottom: 40rpx;
  411. // 设置ios刘海屏底部横线安全区域
  412. padding-bottom: constant(safe-area-inset-bottom);
  413. padding-bottom: env(safe-area-inset-bottom);
  414. box-shadow: 0 -5rpx 5rpx #ececec;
  415. padding: 20rpx 20rpx;
  416. text {
  417. display: block;
  418. box-sizing: border-box;
  419. margin: 0 0 0 40rpx;
  420. width: 160rpx;
  421. height: 60rpx;
  422. line-height: 60rpx;
  423. text-align: center;
  424. font-size: 24rpx;
  425. border-radius: 8rpx;
  426. border: none;
  427. }
  428. text:first-child {
  429. background-color: #fff;
  430. line-height: 56rpx;
  431. border: 2rpx solid $uni-bg-color;
  432. }
  433. text:last-child {
  434. background-color: $uni-bg-color;
  435. color: #FFFFFF;
  436. }
  437. }
  438. </style>