diff --git a/pages.json b/pages.json
index a6b8041f..c07e0e02 100644
--- a/pages.json
+++ b/pages.json
@@ -169,6 +169,24 @@
"navigationBarTitleText": "客服聊天",
"navigationStyle": "custom"
}
+ },
+ {
+ "path": "pages/user/change-password",
+ "style": {
+ "navigationBarTitleText": "修改密码"
+ }
+ },
+ {
+ "path": "pages/user/bind-phone",
+ "style": {
+ "navigationBarTitleText": "绑定手机"
+ }
+ },
+ {
+ "path": "pages/user/bind-email",
+ "style": {
+ "navigationBarTitleText": "绑定邮箱"
+ }
}
],
"tabBar": {
diff --git a/pages/info/settings.uvue b/pages/info/settings.uvue
index 6a96b7f5..465042e1 100644
--- a/pages/info/settings.uvue
+++ b/pages/info/settings.uvue
@@ -1033,4 +1033,94 @@ import i18n from '@/uni_modules/i18n/index.uts' // 保留用于语言切换
.action-btn.primary .action-text {
color: #ffffff;
}
+
+/* 响应式布局优化 */
+@media screen and (min-width: 480px) and (max-width: 767px) {
+ .settings-section {
+ margin: 12px 20px;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: flex-start;
+ }
+
+ .section-header {
+ width: 100%;
+ }
+
+ .setting-item {
+ flex: 1 0 calc(50% - 20px);
+ margin: 10px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ padding: 16px;
+ box-sizing: border-box;
+ border-bottom: none;
+ flex-direction: column;
+ align-items: flex-start;
+ }
+
+ .item-content {
+ width: 100%;
+ margin-bottom: 10px;
+ }
+
+ .item-label, .item-desc, .item-value {
+ display: block;
+ width: 100%;
+ }
+
+ .toggle-switch, .item-arrow {
+ align-self: flex-end;
+ margin-top: auto;
+ }
+}
+
+@media screen and (min-width: 768px) {
+ .settings-page {
+ padding: 20px;
+ background-color: #f5f5f5;
+ }
+
+ .settings-section {
+ margin: 0 auto 20px;
+ max-width: 800px;
+ border-radius: 12px;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: flex-start;
+ }
+
+ .section-header {
+ width: 100%;
+ }
+
+ .setting-item {
+ flex: 1 0 calc(33.333% - 20px);
+ margin: 10px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ padding: 16px;
+ box-sizing: border-box;
+ border-bottom: none;
+ flex-direction: column;
+ align-items: flex-start;
+ }
+
+ .item-content {
+ width: 100%;
+ margin-bottom: 10px;
+ }
+
+ .item-label, .item-desc, .item-value {
+ display: block;
+ width: 100%;
+ }
+
+ .toggle-switch, .item-arrow {
+ align-self: flex-end;
+ margin-top: auto;
+ }
+}
diff --git a/pages/mall/consumer/cart copy.uvue b/pages/mall/consumer/cart copy.uvue
new file mode 100644
index 00000000..7d6e20f8
--- /dev/null
+++ b/pages/mall/consumer/cart copy.uvue
@@ -0,0 +1,1220 @@
+
+
+
+
+
+
+ 购物车
+
+
+ {{ isManageMode ? '✓' : '⚙️' }}
+ {{ isManageMode ? '完成' : '管理' }}
+
+
+
+
+
+
+
+
+
+
+
+
+ 🛒
+ 购物车是空的
+ 快去挑选喜欢的商品吧
+
+
+
+
+
+
+
+
+
+
+
+
+ ✓
+
+
+
+
+
+
+
+ {{ item.name }}
+ {{ item.spec }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ✓
+
+ 全选
+
+
+
+
+
+ 合计:
+ ¥{{ totalPrice }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ product.name }}
+
+ ¥{{ product.price }}
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/mall/consumer/cart.uvue b/pages/mall/consumer/cart.uvue
index 69346032..5809cc95 100644
--- a/pages/mall/consumer/cart.uvue
+++ b/pages/mall/consumer/cart.uvue
@@ -82,6 +82,32 @@
+
+
+
+
+
+ ✓
+
+ 全选
+
+
+
+
+
+ 合计:
+ ¥{{ totalPrice }}
+
+
+
+
+
+
+
-
-
-
+ -->
@@ -415,15 +439,18 @@ const addToCart = (product: any) => {
}
}
- // 检查商品是否已存在
- const existingItem = currentItems.find((item: any) => item.id === product.id)
+ // 检查商品是否已存在 (使用商品ID匹配,因为推荐商品没有SKU)
+ const existingItem = currentItems.find((item: any) =>
+ item.productId === product.id || item.id === product.id
+ )
if (existingItem) {
existingItem.quantity++
} else {
// 添加新商品
currentItems.push({
- id: product.id,
+ id: product.id, // 商品ID(因为没有SKU)
+ productId: product.id, // 同样存储商品ID
shopId: product.shopId || 'shop_recommend',
shopName: product.shopName || '推荐好物',
name: product.name,
@@ -453,7 +480,11 @@ const goShopping = () => {
}
const navigateToProduct = (product: any) => {
- uni.navigateTo({ url: `/pages/mall/consumer/product-detail?id=${product.id}` })
+ // 使用productId(如果存在)作为跳转的商品ID,否则使用id
+ const productId = product.productId || product.id
+ uni.navigateTo({
+ url: `/pages/mall/consumer/product-detail?id=${productId}&name=${encodeURIComponent(product.name)}&price=${product.price}&image=${encodeURIComponent(product.image)}`
+ })
}
const goToCheckout = () => {
@@ -465,7 +496,10 @@ const goToCheckout = () => {
return
}
- // 获取选中的商品
+ // 确保最新状态已保存到本地存储
+ saveCartData()
+
+ // 获取选中的商品 (直接过滤cartItems,不依赖cartGroups)
const selectedItems = cartItems.value
.filter(item => item.selected)
.map(item => ({
@@ -475,10 +509,14 @@ const goToCheckout = () => {
product_name: item.name,
product_image: item.image,
sku_specifications: item.spec,
- price: item.price,
- quantity: item.quantity
+ price: Number(item.price), // 确保是数字
+ quantity: Number(item.quantity) // 确保是数字
}))
+ // 关键修复:将结算数据写入 Storage,确保 checkout 页面能稳定获取
+ uni.setStorageSync('checkout_type', 'cart')
+ uni.setStorageSync('checkout_items', JSON.stringify(selectedItems))
+
// 跳转到结算页面并传递数据
uni.navigateTo({
url: '/pages/mall/consumer/checkout',
@@ -1059,83 +1097,171 @@ const goToCheckout = () => {
}
}
-/* 底部结算栏 */
-.cart-footer {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- height: 60px;
- background-color: white;
- border-top: 1px solid #eee;
- display: flex;
- align-items: center;
- justify-content: center; /* 居中内容 */
- padding: 0 15px;
- z-index: 900;
- padding-bottom: env(safe-area-inset-bottom);
-}
+ /* 购物车操作栏样式 - 自适应横向排列 */
+ .cart-action-bar {
+ background-color: white;
+ margin: 10px;
+ border-radius: 12px;
+ padding: 15px;
+ box-shadow: 0 2px 8px rgba(0,0,0,0.05);
+ }
-.footer-content {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
-}
+ .action-bar-content {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ }
-.footer-left {
- display: flex;
- align-items: center;
-}
+ .action-left, .action-right {
+ display: flex;
+ align-items: center;
+ flex-wrap: nowrap;
+ }
-.select-all {
- display: flex;
- align-items: center;
-}
-
-.select-all-text {
- margin-left: 8px;
- font-size: 14px;
- color: #333;
-}
-
-.footer-right {
- display: flex;
- align-items: center;
-}
-
-.total-info {
- margin-right: 15px;
- text-align: right;
-}
-
-.total-text {
- font-size: 14px;
- color: #333;
- margin-right: 5px;
-}
-
-.total-price {
- font-size: 18px;
- color: #ff5000;
- font-weight: bold;
-}
-
-.checkout-btn {
- background-color: #ff5000;
- color: white;
- border: none;
- border-radius: 25px;
- padding: 8px 20px;
- font-size: 14px;
-}
-
-.delete-btn {
- background-color: #ff3b30; /* 红色删除按钮 */
- color: white;
- border: none;
- border-radius: 25px;
- padding: 8px 25px;
- font-size: 14px;
-}
+ .action-right {
+ justify-content: flex-end;
+ flex: 1;
+ min-width: 0; /* 防止溢出 */
+ }
+
+ /* 合计信息区域 - 自适应横向排列 */
+ .total-info {
+ display: flex;
+ align-items: center;
+ margin-right: 12px;
+ flex-shrink: 0;
+ }
+
+ .total-text {
+ font-size: 14px;
+ color: #333;
+ margin-right: 5px;
+ white-space: nowrap;
+ }
+
+ .total-price {
+ font-size: 18px;
+ color: #ff5000;
+ font-weight: bold;
+ white-space: nowrap;
+ }
+
+ /* 结算按钮 */
+ .checkout-btn, .delete-btn {
+ background-color: #ff5000;
+ color: white;
+ border: none;
+ border-radius: 25px;
+ padding: 8px 20px;
+ font-size: 14px;
+ white-space: nowrap;
+ flex-shrink: 0;
+ }
+
+ .delete-btn {
+ background-color: #ff3b30; /* 红色删除按钮 */
+ padding: 8px 25px;
+ }
+
+ /* 全选区域 */
+ .select-all {
+ display: flex;
+ align-items: center;
+ }
+
+ .select-all-text {
+ margin-left: 8px;
+ font-size: 14px;
+ color: #333;
+ white-space: nowrap;
+ }
+
+ /* 响应式调整 */
+ /* 手机端小屏幕优化 */
+ @media screen and (max-width: 375px) {
+ .action-bar-content {
+ gap: 8px;
+ }
+
+ .total-text {
+ font-size: 13px;
+ }
+
+ .total-price {
+ font-size: 16px;
+ }
+
+ .checkout-btn, .delete-btn {
+ padding: 8px 15px;
+ font-size: 13px;
+ }
+
+ .select-all-text {
+ font-size: 13px;
+ }
+ }
+
+ /* 平板端优化 */
+ @media screen and (min-width: 768px) {
+ .cart-action-bar {
+ margin: 20px auto;
+ max-width: 95%;
+ padding: 20px;
+ }
+
+ .action-bar-content {
+ gap: 20px;
+ }
+
+ .total-price {
+ font-size: 20px;
+ }
+
+ .checkout-btn, .delete-btn {
+ padding: 10px 30px;
+ font-size: 16px;
+ }
+ }
+
+ /* 桌面端优化 */
+ @media screen and (min-width: 1024px) {
+ .cart-action-bar {
+ max-width: 1200px;
+ padding: 20px 30px;
+ }
+
+ .action-bar-content {
+ justify-content: space-between;
+ }
+
+ .total-info {
+ margin-right: 30px;
+ }
+
+ .total-text {
+ font-size: 16px;
+ }
+
+ .total-price {
+ font-size: 22px;
+ }
+
+ .checkout-btn, .delete-btn {
+ padding: 12px 40px;
+ font-size: 16px;
+ }
+
+ .select-all-text {
+ font-size: 16px;
+ }
+ }
+
+ /* 大屏幕优化 */
+ @media screen and (min-width: 1400px) {
+ .cart-action-bar {
+ max-width: 1400px;
+ }
+ }
diff --git a/pages/mall/consumer/checkout copy.uvue b/pages/mall/consumer/checkout copy.uvue
new file mode 100644
index 00000000..7318fbf1
--- /dev/null
+++ b/pages/mall/consumer/checkout copy.uvue
@@ -0,0 +1,1730 @@
+
+
+
+
+
+
+
+
+ {{ getFullAddress(selectedAddress) }}
+
+
+ 请选择收货地址
+ ›
+
+
+
+
+
+
+
+ 调试:共{{ checkoutItems.length }}件商品,总价计算:{{ totalAmount }}
+
+
+
+
+
+ {{ item.product_name }}
+ {{ getSpecText(item.sku_specifications) }}
+
+ ¥{{ item.price }}
+ ×{{ item.quantity }}
+
+
+
+
+
+ 暂无商品信息
+
+
+
+
+
+ 配送方式
+
+
+ {{ option.name }}
+ ¥{{ option.price }}
+ ✓
+
+
+
+
+
+
+ 优惠券
+
+ {{ selectedCoupon.template?.name || '优惠券' }}
+ 选择优惠券
+ ›
+
+
+
+
+
+
+
+
+ 价格明细
+
+
+ 商品总价
+ ¥{{ totalAmount.toFixed(2) }}
+
+
+ 运费
+ +¥{{ deliveryFee.toFixed(2) }}
+
+
+ 优惠减免
+ -¥{{ discountAmount.toFixed(2) }}
+
+
+ 应付金额
+ ¥{{ actualAmount.toFixed(2) }}
+
+
+
+
+
+
+
+
+ 合计:
+ ¥{{ actualAmount.toFixed(2) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/mall/consumer/checkout.uvue b/pages/mall/consumer/checkout.uvue
index 57f3d413..3c744516 100644
--- a/pages/mall/consumer/checkout.uvue
+++ b/pages/mall/consumer/checkout.uvue
@@ -394,45 +394,49 @@ onLoad(() => {
// 从上一页获取数据
const eventChannel = uni.getEventChannel ? uni.getEventChannel() : null
+
+ // 默认先尝试从本地存储加载(确保有数据)
+ loadFromLocalStorage()
+
if (eventChannel) {
eventChannel.on('acceptData', (data: any) => {
console.log('接收到商品数据:', data)
let items = data.selectedItems || []
- processCheckoutItems(items)
+ if (items.length > 0) {
+ processCheckoutItems(items)
+ }
loadDefaultAddress()
})
- } else {
- // 如果没有eventChannel,尝试从本地存储加载(例如从购物车进入)
- loadFromLocalStorage()
}
})
// 处理商品数据清洗
const processCheckoutItems = (items: any[]) => {
- // 数据清洗:确保价格和数量是数字类型
+ // 数据清洗:确保价格和数量是数字类型
if (items && items.length > 0) {
items = items.map((item: any) => {
// 确保价格是数字
- let price = item.price
- if (price !== undefined && price !== null) {
- price = typeof price === 'string' ? parseFloat(price) : Number(item.price)
+ let price = 0
+ if (item.price !== undefined && item.price !== null) {
+ price = typeof item.price === 'string' ? parseFloat(item.price) : Number(item.price)
if (isNaN(price)) price = 0
- } else {
- price = 0
}
// 确保数量是数字
- let quantity = item.quantity
- if (quantity !== undefined && quantity !== null) {
- quantity = typeof quantity === 'string' ? parseInt(quantity) : Number(item.quantity)
+ let quantity = 1
+ if (item.quantity !== undefined && item.quantity !== null) {
+ quantity = typeof item.quantity === 'string' ? parseInt(item.quantity) : Number(item.quantity)
if (isNaN(quantity) || quantity < 1) quantity = 1
- } else {
- quantity = 1
}
return {
- ...item,
- price: Number(price.toFixed(2)), // 保留两位小数
+ id: item.id,
+ product_id: item.product_id || item.id,
+ sku_id: item.sku_id || item.id,
+ product_name: item.product_name || item.name || '',
+ product_image: item.product_image || item.image || '',
+ sku_specifications: item.sku_specifications || item.spec || {},
+ price: Number(price.toFixed(2)),
quantity: quantity
}
})
@@ -466,6 +470,9 @@ onMounted(() => {
// 组件卸载时移除事件监听
onUnmounted(() => {
uni.$off('addressUpdated')
+ // 离开页面时清除结算数据,防止下次进入时显示旧数据
+ uni.removeStorageSync('checkout_type')
+ uni.removeStorageSync('checkout_items')
})
// 从本地存储加载结算数据(例如从购物车进入)
@@ -479,17 +486,27 @@ const loadFromLocalStorage = () => {
const selectedCartItems = cartItems.filter(item => item.selected === true)
if (selectedCartItems.length > 0) {
// 转换为CheckoutItemType格式
- const convertedItems: CheckoutItemType[] = selectedCartItems.map(item => ({
- id: item.id,
- product_id: item.productId,
- sku_id: item.id, // 购物车中item.id就是SKU ID
- product_name: item.name,
- product_image: item.image,
- sku_specifications: item.spec ? { spec: item.spec } : {},
- price: item.price,
- quantity: item.quantity
- }))
- checkoutItems.value = convertedItems
+ const convertedItems: CheckoutItemType[] = selectedCartItems.map(item => {
+ // 确保价格和数量是数字
+ let price = typeof item.price === 'string' ? parseFloat(item.price) : Number(item.price)
+ if (isNaN(price)) price = 0
+
+ let quantity = typeof item.quantity === 'string' ? parseInt(item.quantity) : Number(item.quantity)
+ if (isNaN(quantity) || quantity < 1) quantity = 1
+
+ return {
+ id: item.id,
+ product_id: item.product_id || item.productId || item.id,
+ sku_id: item.sku_id || item.id,
+ product_name: item.name || '',
+ product_image: item.image || '',
+ sku_specifications: item.spec ? { spec: item.spec } : {},
+ price: price,
+ quantity: quantity
+ }
+ })
+ // 再次经过process处理确保类型正确
+ processCheckoutItems(convertedItems)
}
} catch (e) {
console.error('解析购物车数据失败:', e)
diff --git a/pages/mall/consumer/checkoutgood.uvue b/pages/mall/consumer/checkoutgood.uvue
new file mode 100644
index 00000000..3c744516
--- /dev/null
+++ b/pages/mall/consumer/checkoutgood.uvue
@@ -0,0 +1,1733 @@
+
+
+
+
+
+
+
+
+ {{ getFullAddress(selectedAddress) }}
+
+
+ 请选择收货地址
+ ›
+
+
+
+
+
+
+
+ 调试:共{{ checkoutItems.length }}件商品,总价计算:{{ totalAmount }}
+
+
+
+
+
+ {{ item.product_name }}
+ {{ getSpecText(item.sku_specifications) }}
+
+ ¥{{ item.price }}
+ ×{{ item.quantity }}
+
+
+
+
+
+ 暂无商品信息
+
+
+
+
+
+ 配送方式
+
+
+ {{ option.name }}
+ ¥{{ option.price }}
+ ✓
+
+
+
+
+
+
+ 优惠券
+
+ {{ selectedCoupon.template?.name || '优惠券' }}
+ 选择优惠券
+ ›
+
+
+
+
+
+
+
+
+ 价格明细
+
+
+ 商品总价
+ ¥{{ totalAmount.toFixed(2) }}
+
+
+ 运费
+ +¥{{ deliveryFee.toFixed(2) }}
+
+
+ 优惠减免
+ -¥{{ discountAmount.toFixed(2) }}
+
+
+ 应付金额
+ ¥{{ actualAmount.toFixed(2) }}
+
+
+
+
+
+
+
+
+ 合计:
+ ¥{{ actualAmount.toFixed(2) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/mall/consumer/product-detail.uvue b/pages/mall/consumer/product-detail.uvue
index fc8a8495..ef3baf52 100644
--- a/pages/mall/consumer/product-detail.uvue
+++ b/pages/mall/consumer/product-detail.uvue
@@ -234,21 +234,27 @@ export default {
// 原价比现价高20%左右
const originalPrice = options.originalPrice ? parseFloat(options.originalPrice) : parseFloat((basePrice * 1.2).toFixed(2))
- // 根据商品ID生成不同的商品名称,使其更真实
- const productNames = [
- '高品质运动休闲鞋',
- '时尚简约双肩背包',
- '多功能智能手环',
- '便携式蓝牙音箱',
- '全自动雨伞',
- '抗菌防螨床上四件套',
- '不锈钢保温杯',
- '无线充电器',
- '高清行车记录仪',
- '智能体脂秤'
- ]
- const nameIndex = Math.abs(productId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0)) % productNames.length
- const productName = options.name ? options.name : productNames[nameIndex]
+ // 优先使用传入的商品名称,否则根据商品ID生成名称
+ const productName = options.name ? decodeURIComponent(options.name) : (() => {
+ // 如果options.name未传入,使用默认的商品名称生成逻辑
+ const productNames = [
+ '高品质运动休闲鞋',
+ '时尚简约双肩背包',
+ '多功能智能手环',
+ '便携式蓝牙音箱',
+ '全自动雨伞',
+ '抗菌防螨床上四件套',
+ '不锈钢保温杯',
+ '无线充电器',
+ '高清行车记录仪',
+ '智能体脂秤'
+ ]
+ const nameIndex = Math.abs(productId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0)) % productNames.length
+ return productNames[nameIndex]
+ })()
+
+ // 优先使用传入的图片,否则使用默认图片
+ const productImage = options.image ? decodeURIComponent(options.image) : '/static/product1.jpg'
// 模拟销量和库存,使其更真实
const sales = 1000 + Math.abs(productId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0)) % 5000
@@ -261,7 +267,7 @@ export default {
name: productName,
description: '这是一个高品质的商品,具有优秀的性能和优美的外观设计。采用环保材料,经过严格质检,保证用户的使用体验。',
images: [
- '/static/product1.jpg',
+ productImage,
'/static/product2.jpg',
'/static/product3.jpg'
],
@@ -307,9 +313,10 @@ export default {
// 模拟加载商品SKU数据
const basePrice = this.product.price
+ // 使用 productId 作为前缀生成唯一的 SKU ID,防止不同商品的 SKU ID 冲突
this.productSkus = [
{
- id: 'sku_001',
+ id: `${productId}_sku_001`,
product_id: productId,
sku_code: 'SKU001',
specifications: { color: '红色', size: 'M' },
@@ -319,7 +326,7 @@ export default {
status: 1
},
{
- id: 'sku_002',
+ id: `${productId}_sku_002`,
product_id: productId,
sku_code: 'SKU002',
specifications: { color: '蓝色', size: 'L' },
diff --git a/pages/mall/consumer/settings.uvue b/pages/mall/consumer/settings.uvue
index d62bb723..5c113dc3 100644
--- a/pages/mall/consumer/settings.uvue
+++ b/pages/mall/consumer/settings.uvue
@@ -2,10 +2,10 @@
-
-
+
🔒
修改密码
@@ -283,7 +283,7 @@ const calculateCacheSize = () => {
// 跳转到个人资料
const goToProfile = () => {
uni.navigateTo({
- url: '/pages/mall/consumer/profile'
+ url: '/pages/user/profile'
})
}
@@ -573,47 +573,126 @@ const goBack = () => {
\ No newline at end of file
+
diff --git a/pages/mall/consumer/wallet.uvue b/pages/mall/consumer/wallet.uvue
index 715e894f..8b638472 100644
--- a/pages/mall/consumer/wallet.uvue
+++ b/pages/mall/consumer/wallet.uvue
@@ -2,11 +2,9 @@
-