detail.vue 7.6 KB

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