refactor(api): 优化商品收藏接口调用并统一数据解包
- 新增 unwrap 函数统一处理响应数据解包 - 将收藏相关接口改为 async 函数,显式等待请求结果 - 统一调用 unwrap 提取响应中的 data 字段,保障数据一致性 - 确保收藏状态接口返回纯布尔值,避免类型不确定 - 收藏列表接口添加空数组和空对象默认值处理,防止异常 refactor(shop): 简化购物车和客服页面跳转逻辑 - 购物车跳转采用 navigateTo,确保非 tabBar 页面正常打开 - 客服跳转直接进入客服页面,去除复杂客服会话功能调用逻辑
This commit is contained in:
@@ -164,22 +164,13 @@ const ProductDetailPage: React.FC = () => {
|
||||
}
|
||||
|
||||
const handleGoCart = () => {
|
||||
// 购物车不是 tabBar 页面,使用 navigateTo;路径与 app.config.ts 中注册的 'pages/shop/cart' 对应
|
||||
Taro.navigateTo({ url: '/pages/shop/cart' })
|
||||
}
|
||||
|
||||
const handleContactService = () => {
|
||||
// 微信小程序客服:优先尝试打开客服会话
|
||||
if (Taro.openCustomerServiceChat) {
|
||||
Taro.openCustomerServiceChat({
|
||||
extInfo: { url: '' }, // 需要在小程序后台配置客服链接
|
||||
fail: () => {
|
||||
// 降级:跳转到客服页面
|
||||
Taro.navigateTo({ url: '/pages/user/customer-service/index' })
|
||||
},
|
||||
})
|
||||
} else {
|
||||
Taro.navigateTo({ url: '/pages/user/customer-service/index' })
|
||||
}
|
||||
// 直接跳转到在线客服页面(已实现完整功能:微信客服按钮 + 历史消息 + 热线 + 微信留言)
|
||||
Taro.navigateTo({ url: '/pages/user/customer-service/index' })
|
||||
}
|
||||
|
||||
if (!product) {
|
||||
|
||||
Reference in New Issue
Block a user