From 4ab722a118d41f1999c2203d12742ace922b176d Mon Sep 17 00:00:00 2001
From: cyh666666 <2398882793@qq.com>
Date: Tue, 27 Jan 2026 17:33:39 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E5=AE=8C=E5=96=84=E8=B4=AD?=
=?UTF-8?q?=E7=89=A9=E9=80=BB=E8=BE=91=E9=97=AD=E7=8E=AF=EF=BC=8Cconsumer?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=AE=8C=E6=88=90=E5=BA=A680%?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages.json | 35 +-
pages/mall/consumer/address-list.uvue | 66 +-
pages/mall/consumer/cart.uvue | 90 +-
pages/mall/consumer/category.uvue | 2 +-
pages/mall/consumer/checkout.uvue | 446 +++++--
pages/mall/consumer/favorites.uvue | 4 +-
pages/mall/consumer/footprint.uvue | 2 +-
pages/mall/consumer/index.uvue | 2 +-
pages/mall/consumer/order-detail.uvue | 139 +--
pages/mall/consumer/orders.uvue | 244 +++-
pages/mall/consumer/ordersgood.uvue | 996 ++++++++++++++++
.../{orders - 副本.uvue => orderss.uvue} | 277 +++--
pages/mall/consumer/ordersx.uvue | 1046 +++++++++++++++++
pages/mall/consumer/payment-success.uvue | 27 +-
pages/mall/consumer/payment.uvue | 277 ++++-
pages/mall/consumer/product-detail.uvue | 284 ++++-
pages/mall/consumer/profile.uvue | 109 +-
pages/mall/consumer/search.uvue | 2 +-
pages/mall/consumer/settings - 副本.uvue | 702 +++++++++++
pages/mall/consumer/settings.uvue | 57 +-
pages/mall/consumer/wallet - 副本.uvue | 950 +++++++++++++++
pages/mall/consumer/wallet.uvue | 48 +
22 files changed, 5290 insertions(+), 515 deletions(-)
create mode 100644 pages/mall/consumer/ordersgood.uvue
rename pages/mall/consumer/{orders - 副本.uvue => orderss.uvue} (79%)
create mode 100644 pages/mall/consumer/ordersx.uvue
create mode 100644 pages/mall/consumer/settings - 副本.uvue
create mode 100644 pages/mall/consumer/wallet - 副本.uvue
diff --git a/pages.json b/pages.json
index 1fdcb2c0..a6b8041f 100644
--- a/pages.json
+++ b/pages.json
@@ -1,20 +1,32 @@
{
"pages": [
{
- "path": "pages/user/login",
- "style": {
- "navigationBarTitleText": "用户登录",
- "navigationStyle": "custom"
- }
- },
- {
- "path": "pages/mall/consumer/index",
+ "path": "pages/mall/consumer/index",
"style": {
"navigationBarTitleText": "首页",
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
+ {
+ "path": "pages/mall/consumer/settings",
+ "style": {
+ "navigationBarTitleText": "设置"
+ }
+ },
+ {
+ "path": "pages/mall/consumer/wallet",
+ "style": {
+ "navigationBarTitleText": "我的钱包"
+ }
+ },
+ {
+ "path": "pages/user/login",
+ "style": {
+ "navigationBarTitleText": "用户登录",
+ "navigationStyle": "custom"
+ }
+ },
{
"path": "pages/mall/consumer/category",
"style": {
@@ -150,6 +162,13 @@
"style": {
"navigationBarTitleText": "服务评价"
}
+ },
+ {
+ "path": "pages/mall/consumer/chat",
+ "style": {
+ "navigationBarTitleText": "客服聊天",
+ "navigationStyle": "custom"
+ }
}
],
"tabBar": {
diff --git a/pages/mall/consumer/address-list.uvue b/pages/mall/consumer/address-list.uvue
index 6e9f5b11..67c6133d 100644
--- a/pages/mall/consumer/address-list.uvue
+++ b/pages/mall/consumer/address-list.uvue
@@ -16,8 +16,13 @@
{{ getFullAddress(item) }}
-
- 📝
+
+
+ 📝
+
+
+ �️
+
@@ -104,6 +109,27 @@ const addAddress = () => {
})
}
+// 删除地址
+const deleteAddress = (id: string) => {
+ uni.showModal({
+ title: '提示',
+ content: '确定要删除该地址吗?',
+ success: (res) => {
+ if (res.confirm) {
+ const index = addresses.value.findIndex(addr => addr.id === id)
+ if (index !== -1) {
+ addresses.value.splice(index, 1)
+ uni.setStorageSync('addresses', JSON.stringify(addresses.value))
+ uni.showToast({
+ title: '删除成功',
+ icon: 'success'
+ })
+ }
+ }
+ }
+ })
+}
+
const editAddress = (id: string) => {
uni.navigateTo({
url: `/pages/mall/consumer/address-edit?id=${id}`
@@ -130,6 +156,26 @@ const selectAddress = (item: Address) => {
\ No newline at end of file
+
diff --git a/pages/mall/consumer/category.uvue b/pages/mall/consumer/category.uvue
index 324ce61b..5c02cd56 100644
--- a/pages/mall/consumer/category.uvue
+++ b/pages/mall/consumer/category.uvue
@@ -702,7 +702,7 @@ const navigateToSearch = () => uni.navigateTo({ url: '/pages/mall/consumer/searc
const navigateToCart = () => uni.navigateTo({ url: '/pages/medicine/cart' })
const navigateToProduct = (product: any) => {
uni.navigateTo({
- url: `/pages/mall/consumer/product-detail?productId=${product.id}`
+ url: `/pages/mall/consumer/product-detail?productId=${product.id}&price=${product.price}&originalPrice=${product.originalPrice || ''}`
})
}
diff --git a/pages/mall/consumer/checkout.uvue b/pages/mall/consumer/checkout.uvue
index bae5a127..57f3d413 100644
--- a/pages/mall/consumer/checkout.uvue
+++ b/pages/mall/consumer/checkout.uvue
@@ -22,17 +22,26 @@
-
-
-
- {{ item.product_name }}
- {{ getSpecText(item.sku_specifications) }}
-
- ¥{{ item.price }}
- ×{{ item.quantity }}
+
+
+ 调试:共{{ checkoutItems.length }}件商品,总价计算:{{ totalAmount }}
+
+
+
+
+
+ {{ item.product_name }}
+ {{ getSpecText(item.sku_specifications) }}
+
+ ¥{{ item.price }}
+ ×{{ item.quantity }}
+
+
+ 暂无商品信息
+
@@ -210,11 +219,28 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/mall/consumer/orders - 副本.uvue b/pages/mall/consumer/orderss.uvue
similarity index 79%
rename from pages/mall/consumer/orders - 副本.uvue
rename to pages/mall/consumer/orderss.uvue
index e4c08188..9bf2a0ee 100644
--- a/pages/mall/consumer/orders - 副本.uvue
+++ b/pages/mall/consumer/orderss.uvue
@@ -2,11 +2,14 @@
-
@@ -259,8 +259,8 @@ type UserStatsType = {
type OrderCountsType = {
total: number
pending: number
+ toship: number
shipped: number
- review: number
}
type ServiceCountsType = {
@@ -302,9 +302,9 @@ export default {
orderCounts: {
total: 0,
pending: 0,
+ toship: 0,
shipped: 0,
- review: 0
- } as OrderCountsType,
+ } as any,
serviceCounts: {
coupons: 0,
favorites: 0
@@ -332,10 +332,17 @@ export default {
this.initPage()
this.loadUserProfile()
this.loadOrders()
+
+ // 监听订单更新事件
+ uni.$on('orderUpdated', this.handleOrderUpdated)
},
onShow() {
this.refreshData()
},
+ onUnload() {
+ // 移除事件监听
+ uni.$off('orderUpdated', this.handleOrderUpdated)
+ },
computed: {
// 根据当前Tab筛选订单
filteredOrders(): Array {
@@ -343,8 +350,10 @@ export default {
return this.allOrders
} else if (this.currentOrderTab === 'pending') {
return this.allOrders.filter((order: OrderType): boolean => order.status === 1)
+ } else if (this.currentOrderTab === 'toship') {
+ return this.allOrders.filter((order: OrderType): boolean => order.status === 2)
} else if (this.currentOrderTab === 'shipped') {
- return this.allOrders.filter((order: OrderType): boolean => order.status === 2 || order.status === 3)
+ return this.allOrders.filter((order: OrderType): boolean => order.status === 3)
} else if (this.currentOrderTab === 'review') {
return this.allOrders.filter((order: OrderType): boolean => order.status === 4)
}
@@ -355,40 +364,32 @@ export default {
// 加载订单数据
async loadOrders() {
const userStore = uni.getStorageSync('userInfo')
- const userId = userStore?.id
- if (!userId) return
+ // const userId = userStore?.id
+ // if (!userId) return
try {
- /* const { data, error } = await supa
- .from('orders')
- .select('*')
- .eq('user_id', userId)
- .order('created_at', { ascending: false })
-
- if (error != null) {
- console.error('加载订单失败', error)
- return
+ // 从本地存储加载订单数据
+ const storedOrders = uni.getStorageSync('orders')
+ let orders: any[] = []
+ if (storedOrders) {
+ orders = JSON.parse(storedOrders as string) as any[]
}
-
- if (data != null) {
- this.allOrders = data as any[]
- this.recentOrders = this.allOrders
-
- // 更新角标统计
- this.orderCounts = {
- total: this.allOrders.length,
- pending: this.allOrders.filter((o: any) => o.status === 1).length,
- shipped: this.allOrders.filter((o: any) => o.status === 2 || o.status === 3).length,
- review: this.allOrders.filter((o: any) => o.status === 4).length
- }
- } */
- // MOCK ORDERS
- this.allOrders = this.recentOrders
+ this.allOrders = orders
+ // 按时间倒序
+ this.allOrders.sort((a: any, b: any) => {
+ return new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
+ })
+
+ // 过滤最近的订单
+ this.recentOrders = this.allOrders.slice(0, 5)
+
+ // 更新角标统计 (确保状态码一致: 1=待支付, 2=待发货, 3=待收货, 4=待评价)
this.orderCounts = {
total: this.allOrders.length,
pending: this.allOrders.filter((o: any) => o.status === 1).length,
- shipped: this.allOrders.filter((o: any) => o.status === 2 || o.status === 3).length,
+ toship: this.allOrders.filter((o: any) => o.status === 2).length, // 修复:仅计算状态2为待发货
+ shipped: this.allOrders.filter((o: any) => o.status === 3).length, // 修复:仅计算状态3为待收货
review: this.allOrders.filter((o: any) => o.status === 4).length
}
} catch (e) {
@@ -581,12 +582,20 @@ export default {
})
},
+ // 跳转设置
goToSettings() {
uni.navigateTo({
url: '/pages/mall/consumer/settings'
})
},
+ // 跳转钱包
+ goToWallet() {
+ uni.navigateTo({
+ url: '/pages/mall/consumer/wallet'
+ })
+ },
+
goToOrders(type: string) {
uni.navigateTo({
url: `/pages/mall/consumer/orders?type=${type}`
@@ -696,6 +705,26 @@ export default {
uni.navigateTo({
url: '/pages/mall/consumer/bind-email'
})
+ },
+
+ // 处理订单更新事件
+ handleOrderUpdated(data: any) {
+ // 当收到订单更新事件时,刷新订单数据
+ console.log('收到订单更新事件:', data)
+ this.refreshData()
+
+ // 显示提示
+ if (data.status === 1) {
+ uni.showToast({
+ title: '订单已保存到待支付',
+ icon: 'success'
+ })
+ } else if (data.status === 2) {
+ uni.showToast({
+ title: '支付成功,订单待发货',
+ icon: 'success'
+ })
+ }
}
}
}
diff --git a/pages/mall/consumer/search.uvue b/pages/mall/consumer/search.uvue
index 753ffcb9..ddf5d0f4 100644
--- a/pages/mall/consumer/search.uvue
+++ b/pages/mall/consumer/search.uvue
@@ -537,7 +537,7 @@ const viewProductDetail = (item: any) => {
// 跳转详情页逻辑
console.log('查看商品', item)
uni.navigateTo({
- url: `/pages/mall/consumer/product-detail?productId=${item.id}`
+ url: `/pages/mall/consumer/product-detail?productId=${item.id}&price=${item.price}&originalPrice=${item.originalPrice || ''}`
})
}
diff --git a/pages/mall/consumer/settings - 副本.uvue b/pages/mall/consumer/settings - 副本.uvue
new file mode 100644
index 00000000..6d9d4ec3
--- /dev/null
+++ b/pages/mall/consumer/settings - 副本.uvue
@@ -0,0 +1,702 @@
+
+
+
+
+
+
+
+
+
+ 账户设置
+
+
+ 👤
+ 个人资料
+ ›
+
+
+ 📍
+ 收货地址
+ ›
+
+
+ 🔒
+ 修改密码
+ ›
+
+
+ 📱
+ 手机绑定
+
+
+ {{ userInfo.phone ? '已绑定' : '未绑定' }}
+
+ ›
+
+
+
+ 📧
+ 邮箱绑定
+
+
+ {{ userInfo.email ? '已绑定' : '未绑定' }}
+
+ ›
+
+
+
+
+
+
+
+ 消息通知
+
+
+ 🔔
+ 订单消息
+
+
+
+ 🎁
+ 促销活动
+
+
+
+ ⭐
+ 评价提醒
+
+
+
+
+
+
+
+ 隐私设置
+
+
+ 👁️
+ 隐藏购物记录
+
+
+
+ 🔍
+ 允许通过手机号找到我
+
+
+
+ 💬
+ 接收商家消息
+
+
+
+
+
+
+
+ 通用设置
+
+
+ 🗑️
+ 清除缓存
+
+ {{ cacheSize }}
+ ›
+
+
+
+ 🌐
+ 语言设置
+
+ {{ currentLanguage }}
+ ›
+
+
+
+ 🎨
+ 主题设置
+
+ {{ currentTheme }}
+ ›
+
+
+
+
+
+
+
+ 关于我们
+
+
+ ℹ️
+ 关于商城
+ ›
+
+
+ 📜
+ 用户协议
+ ›
+
+
+ 🛡️
+ 隐私政策
+ ›
+
+
+ 🔄
+ 检查更新
+
+ {{ appVersion }}
+ ›
+
+
+
+
+
+
+
+ 客服与反馈
+
+
+ 💬
+ 联系客服
+ ›
+
+
+ 📝
+ 意见反馈
+ ›
+
+
+ ⭐
+ 给个好评
+ ›
+
+
+
+
+
+
+
+
+
+
+
+ 注销账号
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/mall/consumer/settings.uvue b/pages/mall/consumer/settings.uvue
index ad787f66..d62bb723 100644
--- a/pages/mall/consumer/settings.uvue
+++ b/pages/mall/consumer/settings.uvue
@@ -17,7 +17,7 @@
个人资料
›
-
+
📍
收货地址
›
@@ -192,7 +192,7 @@
\ No newline at end of file
diff --git a/pages/mall/consumer/wallet.uvue b/pages/mall/consumer/wallet.uvue
index f51846ce..715e894f 100644
--- a/pages/mall/consumer/wallet.uvue
+++ b/pages/mall/consumer/wallet.uvue
@@ -486,6 +486,54 @@ const goBack = () => {