order_detail.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="page-container">
  3. <view class="info-card">
  4. <view class="card-header">
  5. <view class="card-title">基本信息</view>
  6. </view>
  7. <view class="card-body">
  8. <view class="detail-row">
  9. <text class="label">订单编号</text>
  10. <text class="value">{{ orderDetails.orderNo }}</text>
  11. </view>
  12. <view class="detail-row">
  13. <text class="label">订单状态</text>
  14. <text class="value status">{{ getStatusText(orderDetails.status) }}</text>
  15. </view>
  16. <view class="detail-row">
  17. <text class="label">商品种类</text>
  18. <text class="value">{{ orderDetails.items.length }}种</text>
  19. </view>
  20. <view class="detail-row">
  21. <text class="label">创建时间</text>
  22. <text class="value">{{ orderDetails.createTime }}</text>
  23. </view>
  24. <view class="detail-row no-border">
  25. <text class="label">订单备注</text>
  26. <text class="value">{{ orderDetails.remark || '无' }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="info-card">
  31. <view class="card-header">
  32. <view class="card-title">收货信息</view>
  33. </view>
  34. <view class="card-body">
  35. <view class="address-info">
  36. <view class="address-text">{{ orderDetails.delivery.address }}</view>
  37. <view class="user-info">
  38. <text>{{ orderDetails.delivery.receiverName }}</text>
  39. <text>{{ orderDetails.delivery.receiverPhone }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="info-card" v-if="orderDetails.status ===2 || orderDetails.status === 3">
  45. <view class="card-header">
  46. <view class="card-title">发货信息</view>
  47. </view>
  48. <view class="card-body">
  49. <view class="address-info">
  50. <view class="address-text">{{ orderDetails.delivery.logisticsCompany }}</view>
  51. <view class="user-info">
  52. <text>{{ orderDetails.delivery.logisticsNo}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="info-card">
  58. <view class="card-header">
  59. <view class="card-title">商品信息</view>
  60. </view>
  61. <view class="card-body product-list">
  62. <view class="product-item" v-for="(item, index) in orderDetails.items" :key="item.id">
  63. <view class="product-name">
  64. <text class="product-index">{{ index + 1 }}.</text>
  65. <text>{{ item.productName }}</text>
  66. </view>
  67. <view class="product-quantity">
  68. 订货数量:{{ item.quantity }}
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="footer-action" v-if="orderDetails.status == 0 || orderDetails.status == 4">
  74. <button class="action-btn" @click="modifyOrder">修改订单</button>
  75. </view>
  76. <view class="footer-action" v-if="orderDetails.status == 2">
  77. <button class="action-btn" @click="confirmOrder">确认收货</button>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import {getOrderDetail,confirmDealerOrder } from "@/api/hexiao";
  83. export default {
  84. data() {
  85. return {
  86. // 订单详情数据,通常从API获取
  87. orderDetails: {
  88. orderId: '',
  89. status: 'rejected',
  90. statusText: '已驳回',
  91. productTypes: 0,
  92. creationTime: '',
  93. remarks: '',
  94. shippingInfo: {
  95. address: '',
  96. name: '',
  97. phone: ''
  98. },
  99. items: [],
  100. id: '',
  101. }
  102. };
  103. },
  104. onLoad(options) {
  105. // 页面加载时,会传入一个订单ID
  106. console.log('加载的订单ID:', options.id);
  107. this.id = options.id;
  108. // 根据ID从服务器获取订单详情
  109. this.fetchOrderDetails();
  110. },
  111. methods: {
  112. getStatusText(status) {
  113. const statusMap = {
  114. 0: '待审核',
  115. 1: '待审核',
  116. 2: '已发货',
  117. 3: '已完成',
  118. 4: '已驳回'
  119. };
  120. return statusMap[status] || '未知';
  121. },
  122. // 模拟从API获取数据
  123. fetchOrderDetails() {
  124. let orderId = this.id;
  125. uni.showLoading({ title: '加载中...' });
  126. // 模拟网络请求
  127. getOrderDetail(orderId).then(res=>{
  128. this.orderDetails = res.data;
  129. uni.hideLoading();
  130. })
  131. },
  132. // 点击订单状态
  133. viewStatusReason() {
  134. if (this.orderDetails.status === 'rejected') {
  135. uni.showModal({
  136. title: '驳回原因',
  137. content: '库存不足,请修改订单后重新提交。',
  138. showCancel: false
  139. });
  140. }
  141. },
  142. // 修改订单
  143. modifyOrder() {
  144. // 跳转到下单页面,并带上订单ID,以便复用数据
  145. uni.navigateTo({ url: `/pages/hexiao/jxs/add_order?id=`+ this.id});
  146. },
  147. confirmOrder(){
  148. confirmDealerOrder(this.id).then(res=>{
  149. this.fetchOrderDetails();
  150. })
  151. },
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .page-container {
  157. min-height: 100vh;
  158. background: linear-gradient(to bottom, #e4efff, #f5f6fa 60%);
  159. padding: 30rpx;
  160. box-sizing: border-box;
  161. padding-bottom: 180rpx; // 为底部按钮留出空间
  162. }
  163. .info-card {
  164. background-color: #ffffff;
  165. border-radius: 20rpx;
  166. padding: 30rpx;
  167. margin-bottom: 30rpx;
  168. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  169. position: relative;
  170. &::before {
  171. content: '';
  172. position: absolute;
  173. left: 0;
  174. top: 35rpx;
  175. width: 8rpx;
  176. height: 30rpx;
  177. background-color: #3c82f8;
  178. border-radius: 0 4rpx 4rpx 0;
  179. }
  180. }
  181. .card-header {
  182. padding-bottom: 20rpx;
  183. .card-title {
  184. font-size: 32rpx;
  185. font-weight: bold;
  186. }
  187. }
  188. .card-body {
  189. padding-top: 20rpx;
  190. border-top: 1rpx solid #f5f5f5;
  191. }
  192. .detail-row {
  193. display: flex;
  194. justify-content: space-between;
  195. align-items: center;
  196. padding: 15rpx 0;
  197. font-size: 28rpx;
  198. border-bottom: 1rpx solid #f9f9f9;
  199. .label { color: #666; }
  200. .value { color: #333; }
  201. .status {
  202. color: #3c82f8;
  203. text-decoration: underline;
  204. cursor: pointer;
  205. }
  206. &.no-border {
  207. border-bottom: none;
  208. }
  209. }
  210. .address-info {
  211. .address-text {
  212. font-size: 30rpx;
  213. color: #333;
  214. font-weight: 500;
  215. }
  216. .user-info {
  217. margin-top: 15rpx;
  218. font-size: 28rpx;
  219. color: #666;
  220. text { margin-right: 20rpx; }
  221. }
  222. }
  223. .product-list {
  224. .product-item {
  225. padding: 20rpx 0;
  226. border-bottom: 1rpx solid #f9f9f9;
  227. &:last-child {
  228. border-bottom: none;
  229. }
  230. .product-name {
  231. font-size: 30rpx;
  232. font-weight: 500;
  233. display: flex;
  234. align-items: center;
  235. .product-index {
  236. color: #999;
  237. margin-right: 15rpx;
  238. }
  239. }
  240. .product-quantity {
  241. font-size: 26rpx;
  242. color: #666;
  243. margin-top: 10rpx;
  244. padding-left: 38rpx;
  245. }
  246. }
  247. }
  248. .footer-action {
  249. position: fixed;
  250. left: 0;
  251. bottom: 0;
  252. width: 100%;
  253. padding: 20rpx 30rpx;
  254. background-color: #f5f6fa;
  255. box-sizing: border-box;
  256. padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  257. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  258. z-index: 100;
  259. }
  260. .action-btn {
  261. background-color: #3c82f8;
  262. color: #ffffff;
  263. border-radius: 50rpx;
  264. font-size: 32rpx;
  265. height: 90rpx;
  266. line-height: 90rpx;
  267. &::after { border: none; }
  268. }
  269. </style>