order_detail.vue 6.6 KB

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