detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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="title">{{ item.title }}</view>
  24. <view class="flex num">
  25. <view class="sku" v-if="!item.properties"></view>
  26. <view class="sku" v-if="item.properties">规格:{{ item.properties }}</view>
  27. <view class="">数量:{{ item.goodsNum }}</view>
  28. </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 || status.value == -1">应付:</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>{{ info.orderId }}</view>
  57. </view>
  58. <view class="detail-info-content-desc">
  59. <view>下单时间:</view>
  60. <view>{{ $parseTime(info.createdTime) }}</view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length > 1">
  65. <view class="detail-info-title">发货信息</view>
  66. <view class="detail-info-content border" v-for="(item, index) in deliverList" :key="index">
  67. <view class="detail-info-content-desc">
  68. <view>快递公司:</view>
  69. <view>{{ item.companyName || '-' }}</view>
  70. </view>
  71. <view class="detail-info-content-desc">
  72. <view>物流单号:</view>
  73. <view>{{ item.deliveryFlowId || '-' }}</view>
  74. </view>
  75. <view class="detail-info-content-desc">
  76. <view>发货时间:</view>
  77. <view>{{ $parseTime(item.deliveryTime) }}</view>
  78. </view>
  79. <view class="detail-info-content-deliver">
  80. <view class="flex detail-info-content-deliver__detail" v-for="(items, indexs) in item.items"
  81. :key="indexs">
  82. <view class="detail-info-content-deliver__detail__left">
  83. <view class="img">
  84. <image class="img" :src="items.picUrl" mode="aspectFill">
  85. </image>
  86. </view>
  87. </view>
  88. <view class="detail-info-content-deliver__detail__right">
  89. <view class="title">{{ items.title }}</view>
  90. <view class="flex num">
  91. <view class="sku" v-if="!items.properties"></view>
  92. <view class="sku" v-if="items.properties">规格:{{ items.properties }}</view>
  93. <view class="">数量:{{ items.goodsNum }}</view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="detail-info" v-if="(status.value == 2 || status.value == 4) && deliverList.length == 1">
  101. <view class="detail-info-title">发货信息</view>
  102. <view class="detail-info-content" v-for="(item, index) in deliverList" :key="index">
  103. <view class="detail-info-content-desc">
  104. <view>快递公司:</view>
  105. <view>{{ item.companyName || '-' }}</view>
  106. </view>
  107. <view class="detail-info-content-desc">
  108. <view>物流单号:</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]
  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];
  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. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .detail {
  242. margin: 10rpx;
  243. padding-bottom: 160rpx;
  244. &-state {
  245. padding: 28rpx;
  246. margin-bottom: 20rpx;
  247. background-color: #FFFFFF;
  248. &-title {
  249. line-height: 40rpx;
  250. font-weight: bold;
  251. }
  252. }
  253. &-info {
  254. margin-bottom: 20rpx;
  255. padding: 20rpx 28rpx;
  256. background-color: #FFFFFF;
  257. &-title {
  258. line-height: 40rpx;
  259. font-weight: bold;
  260. }
  261. &-content {
  262. &-goods {
  263. &__detail {
  264. padding: 20rpx 0;
  265. justify-content: space-between;
  266. border-bottom: 1px solid rgba(236, 236, 236, 100);
  267. &__left {
  268. display: flex;
  269. height: 170rpx;
  270. .img {
  271. image {
  272. width: 170rpx;
  273. height: 170rpx;
  274. margin-right: 20rpx;
  275. }
  276. }
  277. }
  278. &__right {
  279. flex: 1;
  280. display: flex;
  281. height: 170rpx;
  282. flex-direction: column;
  283. justify-content: space-between;
  284. align-items: flex-end;
  285. .num {
  286. width: 100%;
  287. justify-content: space-between;
  288. .sku {
  289. color: #8C8C8C;
  290. }
  291. }
  292. }
  293. }
  294. &__detail:last-child {
  295. border: none;
  296. }
  297. }
  298. &-money {
  299. margin-top: 40rpx;
  300. &__item {
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. line-height: 40rpx;
  305. margin-bottom: 24rpx;
  306. }
  307. }
  308. &-toatl {
  309. padding-top: 24rpx;
  310. display: flex;
  311. align-items: center;
  312. justify-content: flex-end;
  313. font-weight: bold;
  314. }
  315. &-desc {
  316. display: flex;
  317. line-height: 40rpx;
  318. margin-top: 20rpx;
  319. margin-bottom: 24rpx;
  320. view:first-child {
  321. width: 150rpx;
  322. }
  323. view:last-child {
  324. width: calc(100% - 150rpx)
  325. }
  326. }
  327. &-desc:last-child {
  328. margin-bottom: 0;
  329. }
  330. &-deliver {
  331. &__detail {
  332. padding: 20rpx 0;
  333. justify-content: space-between;
  334. border-bottom: 1px solid rgba(236, 236, 236, 100);
  335. &__left {
  336. display: flex;
  337. height: 170rpx;
  338. .img {
  339. image {
  340. width: 170rpx;
  341. height: 170rpx;
  342. margin-right: 20rpx;
  343. }
  344. }
  345. }
  346. &__right {
  347. flex: 1;
  348. display: flex;
  349. height: 170rpx;
  350. flex-direction: column;
  351. justify-content: space-between;
  352. align-items: flex-end;
  353. .num {
  354. width: 100%;
  355. justify-content: space-between;
  356. .sku {
  357. color: #8C8C8C;
  358. }
  359. }
  360. }
  361. }
  362. &__detail:last-child {
  363. border: none;
  364. }
  365. }
  366. }
  367. .border{
  368. border-bottom: 1px solid rgba(236, 236, 236, 100);
  369. }
  370. .border:last-child{
  371. border: none;
  372. }
  373. }
  374. }
  375. .detail-btn {
  376. display: flex;
  377. align-items: center;
  378. justify-content: flex-end;
  379. position: fixed;
  380. bottom: var(--window-bottom);
  381. left: 0;
  382. right: 0;
  383. // min-height: 120rpx;
  384. z-index: 11;
  385. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  386. background: #fff;
  387. // margin-bottom: 40rpx;
  388. // 设置ios刘海屏底部横线安全区域
  389. padding-bottom: constant(safe-area-inset-bottom);
  390. padding-bottom: env(safe-area-inset-bottom);
  391. box-shadow: 0 -5rpx 5rpx #ececec;
  392. padding: 20rpx 20rpx;
  393. text {
  394. display: block;
  395. box-sizing: border-box;
  396. margin: 0 0 0 40rpx;
  397. width: 160rpx;
  398. height: 60rpx;
  399. line-height: 60rpx;
  400. text-align: center;
  401. font-size: 24rpx;
  402. border-radius: 8rpx;
  403. border: none;
  404. }
  405. text:first-child {
  406. background-color: #fff;
  407. line-height: 56rpx;
  408. border: 2rpx solid $uni-bg-color;
  409. }
  410. text:last-child {
  411. background-color: $uni-bg-color;
  412. color: #FFFFFF;
  413. }
  414. }
  415. </style>