diff --git a/api/request.js b/api/request.js
index 52e56bb..ea29477 100644
--- a/api/request.js
+++ b/api/request.js
@@ -22,10 +22,10 @@ function request(url, method = 'GET', data = {}) {
if (res.data.code) {
if (res.data.code == 10103 || res.data.code == 10101) {
wx.removeStorageSync('access_token');
- wx.navigateTo({
- url: '/pages/login/index',
- });
- reject(res.data);
+ // wx.navigateTo({
+ // url: '/pages/login/index',
+ // });
+ // reject(res.data);
return;
}
wx.showToast({
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 8892cd7..0358835 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -500,6 +500,8 @@ export default {
}
.shop-cart {
+
+ color: #fff;
flex: 3;
margin-left: 30rpx;
// color: #fff;
diff --git a/pages/my/index.vue b/pages/my/index.vue
index b2de1ed..f5ca9b5 100644
--- a/pages/my/index.vue
+++ b/pages/my/index.vue
@@ -101,31 +101,37 @@
查看全部
-
+
- {{ order.no }}
+ {{ order.order_id || '-' }}
- {{ order.type }}
- {{ order.status }}
+
+ {{ order.statusText }}
- {{ order.date }}
+ {{ order.displayDate }}
- 60x60
+
+
+ 60x60
+
- {{ order.product }}
- {{ order.spec }}
+ {{ order.productName }}
+ {{ order.productSpec }}
@@ -319,41 +325,7 @@ export default {
{ icon: '📄', title: '隐私政策', desc: '查看隐私条款' },
{ icon: '❓', title: '帮助中心', desc: '常见问题解答' }
],
- orders: [
- {
- no: 'ORD20250402001',
- type: '拼团订单',
- status: '已完成',
- statusClass: 'success',
- date: '2025-04-02',
- product: '经典玫瑰香水30ml',
- spec: '¥199 × 1',
- amount: '¥199.00',
- actions: [{ label: '查看详情' }, { label: '再次购买' }]
- },
- {
- no: 'ORD20250401001',
- type: '秒杀订单',
- status: '待收货',
- statusClass: 'warning',
- date: '2025-04-01',
- product: '小样体验包',
- spec: '¥1 × 1',
- amount: '¥1.00',
- actions: [{ label: '查看详情' }]
- },
- {
- no: 'ORD20250328001',
- type: '普通订单',
- status: '待付款',
- statusClass: 'pending',
- date: '2025-03-28',
- product: '薰衣草精油礼盒',
- spec: '¥299 × 1',
- amount: '¥299.00',
- actions: [{ label: '查看详情' }]
- }
- ]
+ orders: []
};
},
computed: {
@@ -381,6 +353,42 @@ export default {
}
},
methods: {
+ async handleOrderAction(action, order) {
+ if (!order) return;
+
+ if (action.label === '查看详情') {
+ const orderId = order.order_id || order.id || order.order_no || order.no;
+ if (!orderId) {
+ console.warn('缺少订单ID,无法跳转详情', order);
+ return;
+ }
+ uni.navigateTo({
+ url: `/pages/order/detail?id=${orderId}`
+ });
+ } else if (action.label === '加入购物车') {
+ const skuList = order.product_list || order.productList || [];
+ if (!Array.isArray(skuList) || !skuList.length) {
+ console.warn('订单中没有商品列表,无法加入购物车', order);
+ return;
+ }
+
+ for (const sku of skuList) {
+ try {
+ await request('xcx/cart', 'POST', {
+ product_id: sku.product_id || order.product_id,
+ sku_id: sku.sku_id,
+ quantity: sku.quantity || 1
+ });
+ } catch (error) {
+ console.error('加入购物车失败', error);
+ }
+ }
+ uni.showToast({
+ title: '已加入购物车',
+ icon: 'success'
+ });
+ }
+ },
handleImageError(e) {
// 图片加载失败时,使用默认头像
console.log('头像加载失败,使用默认头像', e);
@@ -413,60 +421,139 @@ export default {
// 只取前三条
orderList = orderList.slice(0, 3);
+ // 订单状态映射(后端:1待支付 2支付失败 3待发货 4待收货 5已完成 6已取消 7已退款)
+ const statusMap = {
+ // 兼容旧的字符串状态
+ 'pending': { text: '待支付', class: 'pending' },
+ 'paid': { text: '待发货', class: 'warning' },
+ 'shipped': { text: '待收货', class: 'warning' },
+ 'completed': { text: '已完成', class: 'success' },
+ 'cancelled': { text: '已取消', class: 'cancelled' },
+ 'refunded': { text: '已退款', class: 'cancelled' },
+ // 数字状态(你提供的规范)
+ '1': { text: '待支付', class: 'pending' },
+ '2': { text: '支付失败', class: 'cancelled' },
+ '3': { text: '待发货', class: 'warning' },
+ '4': { text: '待收货', class: 'warning' },
+ '5': { text: '已完成', class: 'success' },
+ '6': { text: '已取消', class: 'cancelled' },
+ '7': { text: '已退款', class: 'cancelled' }
+ };
+
+ const formatPrice = (price) => {
+ if (price === null || price === undefined || price === '') return '0.00';
+ const numericPrice = Number(price);
+ if (Number.isNaN(numericPrice)) return '0.00';
+ // if (numericPrice >= 1000 && numericPrice % 100 === 0) {
+ // return (numericPrice / 100).toFixed(2);
+ // }
+ return (numericPrice / 100).toFixed(2);
+ };
+
+ const formatDate = (dateStr) => {
+ if (!dateStr) return '';
+ const date = new Date(dateStr.replace(/-/g, '/'));
+ if (Number.isNaN(date.getTime())) {
+ return dateStr.split(' ')[0] || dateStr;
+ }
+ const year = date.getFullYear();
+ const month = this.padZero(date.getMonth() + 1);
+ const day = this.padZero(date.getDate());
+ return `${year}-${month}-${day}`;
+ };
+
+ const getActions = (status) => {
+ const statusNumber = typeof status === 'number' ? status : parseInt(status, 10);
+
+ // 1: 待支付
+ if (status === 'pending' || statusNumber === 1) {
+ return [{ label: '查看详情' }, { label: '立即付款' }];
+ }
+ // 4: 待收货
+ if (status === 'shipped' || statusNumber === 4) {
+ return [{ label: '查看详情' }, { label: '确认收货' }];
+ }
+ // 5: 已完成
+ if (status === 'completed' || statusNumber === 5) {
+ return [{ label: '查看详情' }, { label: '加入购物车' }];
+ }
+ // 其他状态统一只有「查看详情」
+ return [{ label: '查看详情' }];
+ };
+
+ const getFirstProduct = (order) => {
+ if (Array.isArray(order.product_list) && order.product_list.length) {
+ return order.product_list[0];
+ }
+ if (Array.isArray(order.productList) && order.productList.length) {
+ return order.productList[0];
+ }
+ if (Array.isArray(order.items) && order.items.length) {
+ return order.items[0];
+ }
+ return order || {};
+ };
+
+ const getFirstValidNumber = (...values) => {
+ for (let i = 0; i < values.length; i++) {
+ const value = values[i];
+ if (value !== undefined && value !== null && value !== '') {
+ return value;
+ }
+ }
+ return 0;
+ };
+
// 转换为页面需要的格式
this.orders = orderList.map(order => {
- // 获取第一个商品信息
- const firstItem = (order.items && order.items.length > 0) ? order.items[0] : order;
+ const firstItem = getFirstProduct(order);
+ const orderId = order.order_id || order.orderId || order.order_no || order.no || order.id || '';
- // 格式化状态
- const statusMap = {
- 'pending': { text: '待付款', class: 'pending' },
- 'paid': { text: '待发货', class: 'warning' },
- 'shipped': { text: '待收货', class: 'warning' },
- 'completed': { text: '已完成', class: 'success' },
- 'cancelled': { text: '已取消', class: 'cancelled' },
- 'refunded': { text: '已退款', class: 'cancelled' }
+ // 兼容多种后端状态字段:status / order_status / orderStatus / state / order_state
+ const rawStatus =
+ order.status !== undefined && order.status !== null
+ ? order.status
+ : (order.order_status !== undefined && order.order_status !== null
+ ? order.order_status
+ : (order.orderStatus !== undefined && order.orderStatus !== null
+ ? order.orderStatus
+ : (order.state !== undefined && order.state !== null
+ ? order.state
+ : (order.order_state !== undefined && order.order_state !== null
+ ? order.order_state
+ : ''))));
+ const statusKey = rawStatus !== '' && rawStatus !== undefined && rawStatus !== null ? String(rawStatus) : '';
+ const statusInfo = statusMap[statusKey] || statusMap[rawStatus] || {
+ text: rawStatus === '' || rawStatus === undefined || rawStatus === null ? '未知状态' : String(rawStatus),
+ class: ''
};
- const statusInfo = statusMap[order.status] || { text: order.status || '未知', class: '' };
+ const quantity = firstItem && firstItem.quantity ? firstItem.quantity : (order.quantity || 1);
+ const skuLabel = firstItem && (firstItem.sku_name || firstItem.spec) ? (firstItem.sku_name || firstItem.spec) : '';
+ const specParts = [];
+ if (skuLabel) {
+ specParts.push(skuLabel);
+ }
+ specParts.push(`x${quantity}`);
- // 格式化价格
- const formatPrice = (price) => {
- if (!price && price !== 0) return '0.00';
- if (price < 1000) return parseFloat(price).toFixed(2);
- return (price / 100).toFixed(2);
- };
-
- // 格式化日期
- const formatDate = (dateStr) => {
- if (!dateStr) return '';
- const date = new Date(dateStr);
- const year = date.getFullYear();
- const month = this.padZero(date.getMonth() + 1);
- const day = this.padZero(date.getDate());
- return `${year}-${month}-${day}`;
- };
-
- // 获取操作按钮
- const getActions = (status) => {
- if (status === 'pending') {
- return [{ label: '查看详情' }, { label: '立即付款' }];
- } else if (status === 'shipped') {
- return [{ label: '查看详情' }, { label: '确认收货' }];
- } else if (status === 'completed') {
- return [{ label: '查看详情' }, { label: '再次购买' }];
- }
- return [{ label: '查看详情' }];
- };
+ const amountSource = getFirstValidNumber(
+ order.payable_amount,
+ order.total_amount,
+ order.final_price,
+ order.total_price,
+ order.amount
+ );
return {
- no: order.order_no || order.no || order.id,
- type: order.order_type || '普通订单',
- status: statusInfo.text,
+ ...order,
+ order_id: orderId,
+ typeLabel: (firstItem && firstItem.category_name) || order.order_type || '普通订单',
+ statusText: statusInfo.text,
statusClass: statusInfo.class,
- date: formatDate(order.created_at || order.date),
- product: firstItem.product_name || firstItem.name || order.product_name || '商品',
- spec: firstItem.sku_name || firstItem.spec || `¥${formatPrice(firstItem.price || order.price)} × ${firstItem.quantity || order.quantity || 1}`,
- amount: `¥${formatPrice(order.final_price || order.total_price || order.amount)}`,
+ displayDate: formatDate(order.created_at || order.date),
+ productName: (firstItem && (firstItem.product_name || firstItem.name)) || order.product_name || '商品',
+ productSpec: specParts.join(' · '),
+ productImage: (firstItem && (firstItem.product_main_image_url || firstItem.image_url)) || '',
+ amountText: formatPrice(amountSource),
actions: getActions(order.status)
};
});
@@ -1558,6 +1645,11 @@ export default {
color: #5a3b00;
}
+.order-tag.status.cancelled {
+ background-color: #c9ced8;
+ color: #ffffff;
+}
+
.order-date {
margin-left: auto;
font-size: 24rpx;
@@ -1581,6 +1673,12 @@ export default {
color: #8c94a3;
}
+.order-thumb image {
+ width: 100%;
+ height: 100%;
+ border-radius: 16rpx;
+}
+
.order-info {
display: flex;
flex-direction: column;
diff --git a/pages/order/detail.vue b/pages/order/detail.vue
index 4691f47..f13abfa 100644
--- a/pages/order/detail.vue
+++ b/pages/order/detail.vue
@@ -16,7 +16,7 @@
应付金额
- ¥{{ orderInfo.payableAmount }}
+ ¥{{ formatPrice(orderInfo.payableAmount) }}
@@ -47,7 +47,7 @@
{{ item.skuName }}
{{ item.desc }}
- ¥{{ item.price }}
+ ¥{{ formatPrice(item.price) }}
x{{ item.quantity }}
@@ -93,19 +93,19 @@
商品总额
- ¥{{ orderInfo.originalAmount }}
+ ¥{{ formatPrice(orderInfo.originalAmount) }}
优惠券抵扣
- -¥{{ orderInfo.couponAmount }}
+ -¥{{ formatPrice(orderInfo.couponAmount) }}
积分抵扣({{ orderInfo.pointsUsed }}积分)
- -¥{{ orderInfo.pointsAmount }}
+ -¥{{ formatPrice(orderInfo.pointsAmount) }}
实付金额
- ¥{{ orderInfo.payableAmount }}
+ ¥{{ formatPrice(orderInfo.payableAmount) }}
@@ -137,10 +137,10 @@ const STATUS_META = {
};
const SHIPPING_STATUS_META = {
- 0: '待发货',
- 1: '已发货',
- 2: '运输中',
- 3: '派送中',
+ 1: '待发货',
+ 2: '已发货',
+ 3: '运输中',
+ // 4: '派送中',
4: '已签收'
};
@@ -192,6 +192,19 @@ export default {
this.clearCountdown();
},
methods: {
+ // 格式化价格(分转元)
+ formatPrice(value) {
+ if (!value && value !== 0) {
+ return '0.00';
+ }
+ // 如果已经是元为单位,直接返回
+ // if (value < 1000) {
+ // return parseFloat(value).toFixed(2);
+ // }
+ // 分转换为元
+ value = value / 100;
+ return value.toFixed(2);
+ },
async loadOrderDetail(orderId) {
try {
const res = await request(`xcx/order/${orderId}`, 'get');
diff --git a/pages/order/index.vue b/pages/order/index.vue
index 5419537..9f9854b 100644
--- a/pages/order/index.vue
+++ b/pages/order/index.vue
@@ -163,9 +163,9 @@ export default {
return '0.00';
}
// 如果已经是元为单位,直接返回
- if (value < 1000) {
- return parseFloat(value).toFixed(2);
- }
+ // if (value < 1000) {
+ // return parseFloat(value).toFixed(2);
+ // }
// 分转换为元
value = value / 100;
return value.toFixed(2);
diff --git a/pages/shoppingCart/index.vue b/pages/shoppingCart/index.vue
index 2363765..8a8af04 100644
--- a/pages/shoppingCart/index.vue
+++ b/pages/shoppingCart/index.vue
@@ -19,7 +19,8 @@
¥
- {{ formatPrice(item.price) || formatPrice(item.sku_price) }}
+ {{ formatPrice(item.price) || formatPrice(item.sku_price)
+ }}
-
@@ -101,27 +102,37 @@ export default {
}
},
onLoad() {
- this.loadCartList();
+ this.getUserIsLogin();
},
onShow() {
- // 页面显示时刷新购物车
- this.loadCartList();
+ this.getUserIsLogin();
},
methods: {
- formatPrice(value) {
- if(!value) {
- return 0.00;
- }
- // 分转换为元
- value = value / 100;
- // 保留两位小数
- return value.toFixed(2);
- },
+ async getUserIsLogin() {
+ const token = await uni.getStorageSync('access_token')
+ if (token) {
+ // 页面显示时刷新购物车
+ this.loadCartList();
+ } else {
+ uni.navigateTo({
+ url: '/pages/login/index'
+ })
+ }
+ },
+ formatPrice(value) {
+ if (!value) {
+ return 0.00;
+ }
+ // 分转换为元
+ value = value / 100;
+ // 保留两位小数
+ return value.toFixed(2);
+ },
// 加载购物车列表
async loadCartList() {
try {
this.loading = true;
- const res = await request('xcx/carts', 'GET', {page: 1, page_size: 99});
+ const res = await request('xcx/carts', 'GET', { page: 1, page_size: 99 });
// 根据实际返回数据结构调整
const list = res.list || res.data || res || [];
// 为每个商品添加selected属性,1表示选中,2表示不选中
@@ -291,7 +302,7 @@ export default {
margin-bottom: 20rpx;
padding: 30rpx 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
- position: relative;
+ position: relative;
}
.item-checkbox {
@@ -425,9 +436,9 @@ export default {
margin-left: 20rpx;
padding: 10rpx;
box-sizing: border-box;
- position: absolute;
- top: 20rpx;
- right: 20rpx;
+ position: absolute;
+ top: 20rpx;
+ right: 20rpx;
}
.item-delete:active {
diff --git a/static/tabBar/create.png b/static/tabBar/create.png
index 0b022f3..2dc2933 100644
Binary files a/static/tabBar/create.png and b/static/tabBar/create.png differ
diff --git a/static/tabBar/create1.png b/static/tabBar/create1.png
new file mode 100644
index 0000000..0b022f3
Binary files /dev/null and b/static/tabBar/create1.png differ
diff --git a/static/tabBar/createAct.png b/static/tabBar/createAct.png
index 4f527ab..c50b24a 100644
Binary files a/static/tabBar/createAct.png and b/static/tabBar/createAct.png differ
diff --git a/static/tabBar/createAct2.png b/static/tabBar/createAct2.png
new file mode 100644
index 0000000..4f527ab
Binary files /dev/null and b/static/tabBar/createAct2.png differ
diff --git a/static/tabBar/distribution.png b/static/tabBar/distribution.png
index e5cca1d..65a3749 100644
Binary files a/static/tabBar/distribution.png and b/static/tabBar/distribution.png differ
diff --git a/static/tabBar/distribution3.png b/static/tabBar/distribution3.png
new file mode 100644
index 0000000..e5cca1d
Binary files /dev/null and b/static/tabBar/distribution3.png differ
diff --git a/static/tabBar/distributionAct.png b/static/tabBar/distributionAct.png
index 444fc31..cb779c9 100644
Binary files a/static/tabBar/distributionAct.png and b/static/tabBar/distributionAct.png differ
diff --git a/static/tabBar/distributionAct4.png b/static/tabBar/distributionAct4.png
new file mode 100644
index 0000000..444fc31
Binary files /dev/null and b/static/tabBar/distributionAct4.png differ
diff --git a/static/tabBar/home.png b/static/tabBar/home.png
index 8cbceca..22904cc 100644
Binary files a/static/tabBar/home.png and b/static/tabBar/home.png differ
diff --git a/static/tabBar/home5.png b/static/tabBar/home5.png
new file mode 100644
index 0000000..8cbceca
Binary files /dev/null and b/static/tabBar/home5.png differ
diff --git a/static/tabBar/homeAct.png b/static/tabBar/homeAct.png
index b832111..48eb7b5 100644
Binary files a/static/tabBar/homeAct.png and b/static/tabBar/homeAct.png differ
diff --git a/static/tabBar/homeAct11.png b/static/tabBar/homeAct11.png
new file mode 100644
index 0000000..b832111
Binary files /dev/null and b/static/tabBar/homeAct11.png differ
diff --git a/static/tabBar/my.png b/static/tabBar/my.png
index a524a02..ae49883 100644
Binary files a/static/tabBar/my.png and b/static/tabBar/my.png differ
diff --git a/static/tabBar/my6.png b/static/tabBar/my6.png
new file mode 100644
index 0000000..a524a02
Binary files /dev/null and b/static/tabBar/my6.png differ
diff --git a/static/tabBar/myAct.png b/static/tabBar/myAct.png
index eafc1ec..ed51342 100644
Binary files a/static/tabBar/myAct.png and b/static/tabBar/myAct.png differ
diff --git a/static/tabBar/myAct7.png b/static/tabBar/myAct7.png
new file mode 100644
index 0000000..eafc1ec
Binary files /dev/null and b/static/tabBar/myAct7.png differ
diff --git a/static/tabBar/subscribe.png b/static/tabBar/subscribe.png
index 7c2f15b..46f7569 100644
Binary files a/static/tabBar/subscribe.png and b/static/tabBar/subscribe.png differ
diff --git a/static/tabBar/subscribe8.png b/static/tabBar/subscribe8.png
new file mode 100644
index 0000000..7c2f15b
Binary files /dev/null and b/static/tabBar/subscribe8.png differ
diff --git a/static/tabBar/subscribeAct.png b/static/tabBar/subscribeAct.png
index 925a6db..55989f7 100644
Binary files a/static/tabBar/subscribeAct.png and b/static/tabBar/subscribeAct.png differ
diff --git a/static/tabBar/subscribeAct9.png b/static/tabBar/subscribeAct9.png
new file mode 100644
index 0000000..925a6db
Binary files /dev/null and b/static/tabBar/subscribeAct9.png differ