detail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. let picUrlArr = item.picUrl.split(',')
  114. item.picUrl = env.filePublic + picUrlArr[0]
  115. })
  116. this.list = res.data.items
  117. }).catch(() => {
  118. uni.hideLoading();
  119. })
  120. },
  121. cancelOrder() {
  122. uni.showModal({
  123. title: '提示',
  124. content: '您确认要取消订单吗?',
  125. success(res) {
  126. if (res.confirm) {
  127. $http.post('/api/v1/mp/user/deliver/order/cancel', {
  128. orderId: this.orderId
  129. }).then(res => {
  130. if (res.code == 0) {
  131. uni.$u.toast('订单取消成功');
  132. setTimeout(() => {
  133. uni.navigateBack({
  134. delta: 1
  135. })
  136. }, 500)
  137. }
  138. })
  139. }
  140. }
  141. })
  142. },
  143. payOrder() {
  144. let _this = this
  145. let payIng = false
  146. if (payIng) return
  147. uni.showLoading({
  148. title: '加载中'
  149. });
  150. $http.post('/api/v1/mp/user/deliver/order/pay', {
  151. orderId: _this.info.orderId,
  152. payType: 2
  153. }).then(ele => {
  154. payIng = true
  155. uni.hideLoading();
  156. if (ele.code == 0) {
  157. uni.requestPayment({
  158. timeStamp: ele.data.timeStamp,
  159. nonceStr: ele.data.nonceStr,
  160. package: ele.data.package,
  161. signType: ele.data.signType,
  162. paySign: ele.data.paySign,
  163. success() {
  164. uni.showToast({
  165. title: '支付成功',
  166. icon: 'success',
  167. duration: 2000
  168. })
  169. setTimeout(() => {
  170. uni.navigateBack({
  171. delta: 1
  172. })
  173. }, 500)
  174. },
  175. fail() {
  176. payIng = false
  177. }
  178. })
  179. } else {
  180. payIng = false
  181. uni.$u.toast('支付失败!');
  182. }
  183. }).catch(() => {
  184. payIng = false
  185. uni.$u.toast('支付失败!');
  186. uni.hideLoading();
  187. })
  188. },
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .detail {
  194. margin: 10rpx;
  195. padding-bottom: 160rpx;
  196. &-state {
  197. padding: 28rpx;
  198. margin-bottom: 20rpx;
  199. background-color: #FFFFFF;
  200. &-title {
  201. line-height: 40rpx;
  202. font-weight: bold;
  203. }
  204. }
  205. &-info {
  206. margin-bottom: 20rpx;
  207. padding: 20rpx 28rpx;
  208. background-color: #FFFFFF;
  209. &-title {
  210. line-height: 40rpx;
  211. font-weight: bold;
  212. }
  213. &-content {
  214. &-goods {
  215. &__detail {
  216. padding: 20rpx 0;
  217. justify-content: space-between;
  218. border-bottom: 1px solid rgba(236, 236, 236, 100);
  219. &__left {
  220. display: flex;
  221. height: 170rpx;
  222. .img {
  223. image {
  224. width: 134rpx;
  225. height: 170rpx;
  226. margin-right: 20rpx;
  227. }
  228. }
  229. }
  230. &__right {
  231. flex: 1;
  232. display: flex;
  233. height: 170rpx;
  234. flex-direction: column;
  235. justify-content: space-between;
  236. align-items: flex-end;
  237. }
  238. }
  239. &__detail:last-child {
  240. border: none;
  241. }
  242. }
  243. &-money {
  244. margin-top: 40rpx;
  245. &__item {
  246. display: flex;
  247. align-items: center;
  248. justify-content: space-between;
  249. line-height: 40rpx;
  250. margin-bottom: 24rpx;
  251. }
  252. }
  253. &-toatl {
  254. padding-top: 24rpx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: flex-end;
  258. font-weight: bold;
  259. }
  260. &-desc {
  261. display: flex;
  262. line-height: 40rpx;
  263. margin-top: 20rpx;
  264. margin-bottom: 24rpx;
  265. view:first-child {
  266. width: 150rpx;
  267. }
  268. view:last-child {
  269. width: calc(100% - 150rpx)
  270. }
  271. }
  272. &-desc:last-child {
  273. margin-bottom: 0;
  274. }
  275. }
  276. }
  277. }
  278. .detail-btn {
  279. display: flex;
  280. align-items: center;
  281. justify-content: flex-end;
  282. position: fixed;
  283. bottom: var(--window-bottom);
  284. left: 0;
  285. right: 0;
  286. // min-height: 120rpx;
  287. z-index: 11;
  288. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  289. background: #fff;
  290. // margin-bottom: 40rpx;
  291. // 设置ios刘海屏底部横线安全区域
  292. padding-bottom: constant(safe-area-inset-bottom);
  293. padding-bottom: env(safe-area-inset-bottom);
  294. box-shadow: 0 -5rpx 5rpx #ececec;
  295. padding: 20rpx 20rpx;
  296. text {
  297. display: block;
  298. box-sizing: border-box;
  299. margin: 0 0 0 40rpx;
  300. width: 160rpx;
  301. height: 60rpx;
  302. line-height: 60rpx;
  303. text-align: center;
  304. font-size: 24rpx;
  305. border-radius: 8rpx;
  306. border: none;
  307. }
  308. text:first-child {
  309. background-color: #fff;
  310. line-height: 56rpx;
  311. border: 2rpx solid $uni-bg-color;
  312. }
  313. text:last-child {
  314. background-color: $uni-bg-color;
  315. color: #FFFFFF;
  316. }
  317. }
  318. </style>