detail.vue 12 KB

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