detail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view>
  3. <u-navbar title="订单详情" :border="true" :placeholder="true" :autoBack="true" leftIconColor="#fff"
  4. bgColor="#E96737" />
  5. <view class="detail">
  6. <view class="detail-state">
  7. <view class="detail-state-title">
  8. <text>订单状态:</text>
  9. <text>{{ status.desc }}</text>
  10. </view>
  11. </view>
  12. <view class="detail-info">
  13. <view class="detail-info-title">商品信息</view>
  14. <view class="detail-info-content">
  15. <view class="detail-info-content-goods">
  16. <view class="flex detail-info-content-goods__detail" v-for="(item, index) in list" :key="index">
  17. <view class="detail-info-content-goods__detail__left">
  18. <view class="img">
  19. <image class="img" :src="item.picUrl" mode="aspectFill">
  20. </image>
  21. </view>
  22. <view class="info">
  23. <text>{{ item.title }}</text>
  24. <text>面值:{{ $numberFormat(item.facePrice) }}元</text>
  25. <text>规格:{{ item.pkgUnit }}张/包 </text>
  26. </view>
  27. </view>
  28. <view class="detail-info-content-goods__detail__right">
  29. <text>¥{{ $numberFormat(item.pkgSalePrice) }}</text>
  30. <text>x {{ item.orderNum }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="detail-info-content-money">
  35. <view class="detail-info-content-money__item">
  36. <text>商品金额</text>
  37. <text>¥{{ $numberFormat(info.orderAmt) }}</text>
  38. </view>
  39. <view class="detail-info-content-money__item">
  40. <text>运费</text>
  41. <text>¥{{ $numberFormat(info.freightAmt) }}</text>
  42. </view>
  43. </view>
  44. <view class="detail-info-content-toatl">
  45. <text v-if="status.value == 0">需付款:</text>
  46. <text v-else>实付:</text>
  47. <text>¥{{ $numberFormat(info.payAmt) }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="detail-info">
  52. <view class="detail-info-title">订单信息</view>
  53. <view class="detail-info-content">
  54. <view class="detail-info-content-desc">
  55. <view>收货信息:</view>
  56. <view>
  57. {{ info.receiver }},{{ info.tel }},{{ info.province }}{{ info.city }}{{ info.area }}{{ info.address }}
  58. </view>
  59. </view>
  60. <view class="detail-info-content-desc">
  61. <view>订单编号:</view>
  62. <view>{{ info.orderId }}</view>
  63. </view>
  64. <view class="detail-info-content-desc">
  65. <view>下单时间:</view>
  66. <view>{{ $parseTime(info.createdTime) }}</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="detail-info" v-if="status.value == 2">
  71. <view class="detail-info-title">发货信息</view>
  72. <view class="detail-info-content">
  73. <view class="detail-info-content-desc">
  74. <view>快递公司:</view>
  75. <view>快递123</view>
  76. </view>
  77. <view class="detail-info-content-desc">
  78. <view>物流单号:</view>
  79. <view>123456789</view>
  80. </view>
  81. <view class="detail-info-content-desc">
  82. <view>发货时间:</view>
  83. <view>2345-234-234</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="detail-btn" v-if="status.value == 0">
  89. <text @click="cancelOrder">取消订单</text>
  90. <text @click="payOrder">去支付</text>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import env from '../../config/env.js'
  96. import $http from '@/utils/request.js'
  97. export default {
  98. data() {
  99. return {
  100. orderId: '',
  101. status: {},
  102. info: {},
  103. addr: {},
  104. list: [],
  105. };
  106. },
  107. onLoad(opthios) {
  108. console.log(opthios);
  109. this.orderId = opthios.id
  110. this.getDetail()
  111. },
  112. methods: {
  113. getDetail() {
  114. $http.post('/api/v1/mp/channel/mall/order/detail', {
  115. orderId: this.orderId
  116. }).then(res => {
  117. console.log(res);
  118. this.info = res.data
  119. this.status = JSON.parse(res.data.status)
  120. res.data.items.forEach(item => {
  121. let picUrlArr = item.picUrl.split(',')
  122. item.picUrl = env.filePublic + picUrlArr[0]
  123. })
  124. this.list = res.data.items
  125. console.log(this.info, this.addr, this.list);
  126. })
  127. },
  128. cancelOrder() {
  129. $http.post('/api/v1/mp/channel/mall/order/cancel', {
  130. orderId: this.orderId
  131. }).then(res => {
  132. if (res.code == 0) {
  133. uni.$u.toast('订单取消成功');
  134. setTimeout(() => {
  135. uni.navigateBack({
  136. delta: 1
  137. })
  138. }, 1000)
  139. }
  140. })
  141. },
  142. payOrder() {
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. /deep/ .u-navbar__content__title.u-navbar__content__title {
  149. color: #FFFFFF;
  150. }
  151. </style>
  152. <style lang="scss" scoped>
  153. .detail {
  154. margin: 10rpx;
  155. padding-bottom: 160rpx;
  156. &-state {
  157. padding: 28rpx;
  158. margin-bottom: 20rpx;
  159. background-color: #FFFFFF;
  160. &-title {
  161. line-height: 40rpx;
  162. font-weight: bold;
  163. }
  164. }
  165. &-info {
  166. margin-bottom: 20rpx;
  167. padding: 20rpx 28rpx;
  168. background-color: #FFFFFF;
  169. &-title {
  170. line-height: 40rpx;
  171. font-weight: bold;
  172. }
  173. &-content {
  174. &-goods {
  175. &__detail {
  176. padding: 20rpx 0;
  177. justify-content: space-between;
  178. border-bottom: 1px solid rgba(236, 236, 236, 100);
  179. &__left {
  180. display: flex;
  181. height: 170rpx;
  182. .img {
  183. image {
  184. width: 134rpx;
  185. height: 170rpx;
  186. margin-right: 20rpx;
  187. }
  188. }
  189. .info {
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: space-between;
  193. text {
  194. font-size: 24rpx;
  195. color: #9D9D9D;
  196. }
  197. text:first-child {
  198. color: rgba(16, 16, 16, 100);
  199. font-size: 28rpx;
  200. }
  201. }
  202. }
  203. &__right {
  204. display: flex;
  205. height: 170rpx;
  206. flex-direction: column;
  207. justify-content: space-between;
  208. align-items: flex-end;
  209. text:first-child {
  210. font-size: 32rpx;
  211. color: $uni-text-color;
  212. }
  213. }
  214. }
  215. &__detail:last-child {
  216. border: none;
  217. }
  218. }
  219. &-money {
  220. margin-top: 40rpx;
  221. &__item {
  222. display: flex;
  223. align-items: center;
  224. justify-content: space-between;
  225. line-height: 40rpx;
  226. margin-bottom: 24rpx;
  227. }
  228. }
  229. &-toatl {
  230. padding-top: 24rpx;
  231. display: flex;
  232. align-items: center;
  233. justify-content: flex-end;
  234. font-weight: bold;
  235. }
  236. &-desc {
  237. display: flex;
  238. line-height: 40rpx;
  239. margin-top: 20rpx;
  240. margin-bottom: 24rpx;
  241. view:first-child {
  242. width: 150rpx;
  243. }
  244. view:last-child {
  245. width: calc(100% - 150rpx)
  246. }
  247. }
  248. &-desc:last-child {
  249. margin-bottom: 0;
  250. }
  251. }
  252. }
  253. }
  254. .detail-btn {
  255. display: flex;
  256. align-items: center;
  257. justify-content: flex-end;
  258. position: fixed;
  259. bottom: var(--window-bottom);
  260. left: 0;
  261. right: 0;
  262. // min-height: 120rpx;
  263. z-index: 11;
  264. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  265. background: #fff;
  266. // margin-bottom: 40rpx;
  267. // 设置ios刘海屏底部横线安全区域
  268. padding-bottom: constant(safe-area-inset-bottom);
  269. padding-bottom: env(safe-area-inset-bottom);
  270. box-shadow: 0 -5rpx 5rpx #ececec;
  271. padding: 20rpx 20rpx;
  272. text {
  273. display: block;
  274. box-sizing: border-box;
  275. margin: 0 0 0 40rpx;
  276. width: 160rpx;
  277. height: 60rpx;
  278. line-height: 60rpx;
  279. text-align: center;
  280. font-size: 24rpx;
  281. border-radius: 8rpx;
  282. border: none;
  283. }
  284. text:first-child {
  285. background-color: #fff;
  286. line-height: 56rpx;
  287. border: 2rpx solid $uni-bg-color;
  288. }
  289. text:last-child {
  290. background-color: $uni-bg-color;
  291. color: #FFFFFF;
  292. }
  293. }
  294. </style>