Commit 132a5c67 by liimin

refactor(order): 重构订单相关页面和组件

- 移除了多处 console.log 语句
- 优化了订单详情和售后流程中的数量和价格计算逻辑
- 删除了未使用的 mock 数据文件
- 调整了订单列表项的样式和布局
1 parent 9baf52ca
...@@ -19,7 +19,6 @@ Page({ ...@@ -19,7 +19,6 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
wx.p.router.getRouterParams(options).then((params) => { wx.p.router.getRouterParams(options).then((params) => {
console.log("🚀 ~ params:", params)
if (params) { if (params) {
this.setData({ this.setData({
...params, ...params,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- 退款信息组件 --> <!-- 退款信息组件 -->
<refund-info-box <refund-info-box
orderObj="{{orderObj}}" orderObj="{{orderObj}}"
refund-count="{{orderObj.applyQty||orderObj.sellQty}}" refund-count="{{orderObj.___qty}}"
max-refund-count="{{maxRefundCount}}" max-refund-count="{{maxRefundCount}}"
refund-price="{{orderObj.refundPoints}}" refund-price="{{orderObj.refundPoints}}"
show-refund-count="{{showRefundCount}}" show-refund-count="{{showRefundCount}}"
......
const { mockDeliveryInfoData } = require("./mock.js");
Component({ Component({
properties: { properties: {
showExpress: { showExpress: {
...@@ -11,6 +9,4 @@ Component({ ...@@ -11,6 +9,4 @@ Component({
value: {} value: {}
} }
}, },
data: {
},
}); });
\ No newline at end of file \ No newline at end of file
const mockDeliveryInfoData = {
orderInfo: {
deliveryCompany: '深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层深圳广联赛讯有限公司',
deliveryNumber: 'SF1234567890',
deliveryStatus: 2
},
deliveryStatus: {
1: "待发货",
2: "已发货",
3: "已收货",
}
};
module.exports = {
mockDeliveryInfoData
};
\ No newline at end of file \ No newline at end of file
...@@ -3,21 +3,21 @@ Component({ ...@@ -3,21 +3,21 @@ Component({
orderInfo: { orderInfo: {
type: Object, type: Object,
value: {}, value: {},
observer: function (v) { // observer: function (v) {
this.compute(v); // this.compute(v);
} // }
} }
}, },
methods: { methods: {
compute(info) { // compute(info) {
let { freightAmount = 0, sellQty,applyQty, redeemPoints } = info; // let { freightAmount = 0, sellQty,applyQty, redeemPoints } = info;
const total = +redeemPoints * +(sellQty||applyQty) + +freightAmount; // const total = +redeemPoints * +(sellQty||applyQty) + +freightAmount;
this.setData({ // this.setData({
total, // total,
freightAmount, // freightAmount,
info // info
}) // })
console.log(this.data.orderInfo) // console.log(this.data.orderInfo)
} // }
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
</block> --> </block> -->
<view class="item"> <view class="item">
<view class="label">实付款:</view> <view class="label">实付款:</view>
<view class="value fontColor">{{total}}积分</view> <view class="value fontColor">{{orderInfo.___totalPrice}}积分</view>
</view> </view>
<view class="item"> <view class="item">
<view class="label">运费:</view> <view class="label">运费:</view>
<view class="value">{{freightAmount}}</view> <view class="value">{{orderInfo.freightAmount||0}}</view>
</view> </view>
<view class="item"> <view class="item">
<view class="label">订单编号:</view> <view class="label">订单编号:</view>
......
// 整合所有组件的mock数据,用于页面整体调试
const { mockDeliveryInfoData } = require('./components/DeliveryInfo/mock.js');
const { mockOrderInfoData } = require('./components/OrderInfo/mock.js');
const { mockOrderGoodsData } = require('./components/OrderGoods/mock.js');
const { mockOrderAmountData } = require('./components/OrderAmount/mock.js');
const mockOrderDetailData = {
orderInfo: {
...mockDeliveryInfoData.orderInfo,
...mockOrderInfoData.orderInfo,
...mockOrderGoodsData.orderInfo,
...mockOrderAmountData.orderInfo,
merchantName: '官方旗舰店',
orderSource: 1
},
orderObj: mockOrderInfoData.orderObj,
statusEnum: mockOrderInfoData.statusEnum,
deliveryStatus: mockDeliveryInfoData.deliveryStatus
};
module.exports = {
mockOrderDetailData
};
\ No newline at end of file \ No newline at end of file
...@@ -7,9 +7,9 @@ Component({ ...@@ -7,9 +7,9 @@ Component({
item: { item: {
type: Object, type: Object,
value: {}, value: {},
observer: function (v) { // observer: function (v) {
this.compute(v); // this.compute(v);
}, // },
}, },
}, },
...@@ -17,14 +17,14 @@ Component({ ...@@ -17,14 +17,14 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
compute(item) { // compute(item) {
let { applyQty, sellQty, redeemPoints, freightAmount = 0 } = item; // let { applyQty, sellQty, redeemPoints, freightAmount = 0 } = item;
const total = sellQty || applyQty || 0; // const total = sellQty || applyQty || 0;
let sum = redeemPoints * total + +freightAmount; // let sum = redeemPoints * total + +freightAmount;
this.setData({ // this.setData({
sum, // sum,
total, // total,
}); // });
}, // },
}, },
}); });
<view class="bottom"> <view class="bottom">
<view class="total"> <view class="total">
共{{total}}件,实付款 共{{item.___qty}}件,实付款
<text class="price">{{sum||'--'}}积分</text> <text class="price">{{item.___totalPrice||'--'}}积分</text>
</view> </view>
<order-action-buttons order="{{item}}" has-user-info="{{hasUserInfo}}" /> <order-action-buttons order="{{item}}" has-user-info="{{hasUserInfo}}" />
</view> </view>
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<view class="info-top"> <view class="info-top">
<view class="name text-hide">{{item.goodsSkuName}}</view> <view class="name text-hide">{{item.goodsSkuName}}</view>
<view class="number"> <view class="number">
<mp-icon icon="close" color="#656566" size="{{12}}"></mp-icon>{{item.sellQty||item.applyQty}} <mp-icon icon="close" color="#656566" size="{{12}}"></mp-icon>{{item.___qty}}
</view> </view>
</view> </view>
<view class="info-bottom"> <view class="info-bottom">
......
...@@ -140,7 +140,7 @@ Component({ ...@@ -140,7 +140,7 @@ Component({
// 售后 // 售后
onAfterSale(e) { onAfterSale(e) {
let { subOrderCode, redeemPoints, goodsSource, sellQty,applyQty,goodsSkuCode } = let { subOrderCode, redeemPoints, goodsSource,goodsSkuCode,___qty } =
this.data.order; this.data.order;
console.log(this.data.order) console.log(this.data.order)
wx.p.router.go( wx.p.router.go(
...@@ -149,7 +149,7 @@ Component({ ...@@ -149,7 +149,7 @@ Component({
subOrderCode, subOrderCode,
refundPoints: redeemPoints, refundPoints: redeemPoints,
goodsSource, goodsSource,
applyQty: applyQty || sellQty, applyQty: ___qty,
goodsSkuCode goodsSkuCode
} }
); );
......
/* packageMine/pages/order/index/index.wxss */
.sticky-box {
background-color: #F9F7F7;
}
.tab {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #F9F7F7;
z-index: 2;
transition: all 0.4s;
}
.navigation {
width: 100%;
height: 100%;
position: relative;
}
.navigation .back {
width: 64rpx;
height: 64rpx;
background: rgba(255, 255, 255, 0.5);
border-radius: var(--margin);
position: absolute;
left: 20rpx;
}
.navigation .back .icon {
width: 36rpx;
height: 36rpx;
}
.search-box {
position: absolute;
left: 80rpx;
width: 420rpx;
height: 72rpx;
background: #F7F8FA;
border-radius: 36rpx;
display: flex;
align-items: center;
box-sizing: border-box;
padding: 0 16rpx 0 var(--margin);
}
.search-box .icon {
width: 40rpx;
height: 100%;
margin-right: 10rpx;
}
.search-box .input {
width: calc(100% - 98rpx);
}
.search-box .clear-box {
width: 58rpx;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.search-box .clear-box .clear {
width: 32rpx;
height: 32rpx;
opacity: 0.7;
}
.placeholder-class {
color: #C8C9CC;
}
.layout {
padding: 24rpx var(--margin) 40rpx;
}
.layout .item {
position: relative;
padding-left: 24rpx;
margin-bottom: 20rpx;
background-color: #fff;
box-sizing: border-box;
border-radius: var(--borderRadius);
display: flex;
flex-direction: column;
}
.layout .item .top {
height: 82rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding-right: 24rpx;
position: relative;
}
.layout .item .top .name {
width: 410rpx;
height: 40rpx;
font-size: 28rpx;
color: #2D2D2E;
}
.layout .item .goods {
height: 208rpx;
padding: 24rpx 24rpx 24rpx 0;
box-sizing: border-box;
display: flex;
}
.addTo {
border-bottom: 2rpx solid #eff0f2;
}
.layout .item .goods .btn {
display: flex;
align-items: center;
justify-content: center;
width: 124rpx;
height: 46rpx;
border-radius: 25rpx;
border: 2rpx solid #b1b1b3;
font-size: 24rpx;
margin-left: 12rpx;
color: #656566;
position: absolute;
bottom: 0;
right: 0;
}
.layout .item .goods .confirm {
border-color: var(--btnColor);
color: var(--btnColor);
font-weight: 500;
}
.layout .item .icon {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
border-radius: 8rpx;
overflow: hidden;
}
.background-X {
background-color: rgb(244, 244, 244);
}
.layout .item .info {
width: calc(100% - 180rpx);
height: 160rpx;
display: flex;
flex-direction: column;
position: relative;
}
.layout .item .info .info-top,
.layout .item .info .info-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.layout .item .info .info-top .number {
color: #656566;
font-size: 24rpx;
}
.layout .item .info .info-bottom {
margin-top: 4rpx;
font-size: 24rpx;
color: #707071;
display: flex;
flex-direction: column;
align-items:flex-start;
gap: 8rpx;
}
.layout .item .info .info-bottom .price {
color: var(--themeColor);
font-size: 26rpx;
font-weight: 500;
}
.layout .item .info .info-bottom .specification {
color: #b1b1b3;
}
.layout .item .status {
font-size: 28rpx;
color: #282829;
font-weight: 400;
}
.layout .item .bottom {
margin-top: 36rpx;
height: 64rpx;
display: flex;
align-items: flex-start;
font-size: 24rpx;
color: #656566;
}
.layout .item .bottom .total {
position: relative;
bottom: 16rpx;
}
.layout .item .bottom .price {
color: var(--themeColor);
font-weight: 600;
margin-left: 10rpx;
}
.layout .item .btn-box {
position: absolute;
right: 24rpx;
bottom: 16rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.layout .item .btn-box .btn {
display: flex;
align-items: center;
justify-content: center;
width: 144rpx;
height: 64rpx;
border-radius: 16rpx;
border: 1rpx solid #DCDFE6;
font-size: 24rpx;
margin-left: 12rpx;
color: #1B233D;
}
.layout .item .btn-box .pay {
background-color: var(--btnColor);
color: #fff;
border-color: var(--btnColor);
}
.layout .item .btn-box .empty{
color: var(--btnColor);
background-color: #fff;
}
.layout .item .btn-box .confirm {
border-color: var(--btnColor);
color: var(--btnColor);
font-weight: 500;
}
.userProfile {
background-color: #fff;
font-size: 24rpx;
margin: 0;
padding: 0;
font-weight: 500;
line-height: 46rpx;
}
.layout .coupon-item {
height: 202rpx;
background: #fefffe;
border-radius: 8rpx;
margin-bottom: 36rpx;
padding: 20rpx;
box-sizing: border-box;
position: relative;
}
.layout .coupon-item .orderPrices {
position: absolute;
color: var(--btnColor);
font-size: 48rpx;
right: 32rpx;
}
.layout .coupon-item .orderPrices text {
font-size: 36rpx;
}
.layout .coupon-item .icon {
width: 162rpx;
height: 162rpx;
margin-right: 20rpx;
}
.layout .coupon-item .info {
width: 360rpx;
height: 100%;
color: #b1b1b3;
font-size: 24rpx;
}
.layout .coupon-item .info .name {
font-size: 28rpx;
font-weight: 500;
color: #282829;
}
.layout .coupon-item .info .order-btn {
width: 138rpx;
height: 48rpx;
background: var(--btnColor);
border-radius: 24rpx;
margin-top: 40rpx;
color: #ffffff;
font-size: 24rpx;
}
.imageHeight {
height: 99rpx !important;
}
.imageStraight {
width: 92rpx;
height: 92rpx;
border-radius: 50%;
}
\ No newline at end of file \ No newline at end of file
...@@ -164,29 +164,16 @@ Page({ ...@@ -164,29 +164,16 @@ Page({
let list = []; let list = [];
wx.p.api.mineApi[requestMethod](obj).then((data) => { wx.p.api.mineApi[requestMethod](obj).then((data) => {
wx.hideLoading(); wx.hideLoading();
data?.list?.map((e) => { data?.list?.forEach((e) => {
// let { const { applyQty, sellQty, redeemPoints, freightAmount = 0 } = e;
// orderGoods, const ___qty = sellQty || applyQty || 0;
// createdDate, const ___price = (redeemPoints || 0) * ___qty;
// orderClassify const ___totalPrice = (redeemPoints || 0) * ___qty + +freightAmount;
// } = e;
// let goodsNumber = 0;
// let expiredTime = 0;
// orderGoods?.map((i) => {
// i.retailPrice = Number(i.retailPrice).toFixed(2);
// if (i.activityPrice)
// i.activityPrice = Number(i.activityPrice).toFixed(2);
// goodsNumber += i.goodsNumber;
// expiredTime = new Date(i.warrantyDate).format("yyyy-MM-dd hh:mm:ss");
// if (orderClassify == 5) {
// e.payPrice = NP.times(i.retailPrice, i.goodsNumber);
// }
// });
list.push({ list.push({
...e, ...e,
// goodsNumber, ___price,
// time: new Date(createdDate).format("yyyy-MM-dd hh:mm:ss"), ___totalPrice,
// expiredTime, ___qty,
}); });
}); });
this.setData({ this.setData({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!