detail.vue 11 KB

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