detail.vue 7.3 KB

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