feat(security): 三端闭环加固 + 微信提现打款/订阅消息落地
后端: 身份与归属鉴权收口; 资金安全(结算闸门/支付防篡改/报名费真实扣款/赠金/结算唯一入账/提现打款); 数据泄露与隐私; 登录与密钥安全(默认密钥闸门/登录限流); 可观测性; 启动自检. 微信: 商家转账到零钱提现打款闭环(含回调/查单/失败退回佣金); 订阅消息真实下发闭环与后台模板字段对齐. 后台: 财务/微信支付配置读取失败锁定; 看板/待办/走势去假数据; 打款与测试推送文案修正. 小程序: 请求层错误透传与登录过期提示; 多页失败反馈与乐观回滚; 帮助中心FAQ页面化. 测试: 新增 40+ 回归护栏与真实 MySQL 冒烟(75 套件/599 用例全绿).
这个提交包含在:
@@ -17,7 +17,7 @@ export function formatActivityData(raw) {
|
||||
userId: p.userId,
|
||||
nickname: p.nickname || `搭子_${p.userId || p.id}`,
|
||||
avatar: p.avatar || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=100',
|
||||
verifyCode: p.verifyCode || '8392',
|
||||
verifyCode: p.verifyCode || '',
|
||||
checkedIn: Boolean(p.checkinStatus || p.checkedIn),
|
||||
payAmount: p.payAmountCents != null ? p.payAmountCents / 100 : (p.payAmount || 0),
|
||||
}));
|
||||
@@ -68,7 +68,7 @@ export async function getActivities() {
|
||||
*/
|
||||
export async function getActivityDetail(id) {
|
||||
try {
|
||||
const detail = await http.get(`/activities/${id}`);
|
||||
const detail = await http.get(`/activities/${id}?userId=${normalizeUserId()}`);
|
||||
if (detail) {
|
||||
return formatActivityData(detail);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export async function getActivityDetail(id) {
|
||||
*/
|
||||
export async function createActivity(payload) {
|
||||
const body = {
|
||||
creatorId: payload.creatorId || 1001,
|
||||
creatorId: normalizeUserId(payload.creatorId),
|
||||
title: payload.title,
|
||||
gameCategory: payload.game || payload.gameCategory || '美食陪吃',
|
||||
location: payload.location,
|
||||
@@ -110,7 +110,7 @@ export async function createActivity(payload) {
|
||||
*/
|
||||
export async function joinActivity(activityId, params = {}) {
|
||||
const body = {
|
||||
userId: params.userId || 2008,
|
||||
userId: normalizeUserId(params.userId),
|
||||
payAmountCents: Math.round((Number(params.payAmount) || 50) * 100),
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ export async function adjustActivityPrice(activityId, newPriceYuan, operatorId)
|
||||
*/
|
||||
export async function cancelActivity(activityId, hostId = 1001, reason = '房主主动解散') {
|
||||
return http.post(`/activities/${activityId}/cancel`, {
|
||||
hostId,
|
||||
hostId: normalizeUserId(hostId),
|
||||
reason,
|
||||
});
|
||||
}
|
||||
@@ -165,7 +165,7 @@ export async function cancelActivity(activityId, hostId = 1001, reason = '房主
|
||||
*/
|
||||
export async function leaveActivity(activityId, userId = 2001) {
|
||||
return http.post(`/activities/${activityId}/leave`, {
|
||||
userId,
|
||||
userId: normalizeUserId(userId),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ export function formatOrderData(raw) {
|
||||
*/
|
||||
export async function getOrders() {
|
||||
try {
|
||||
const list = await http.get('/orders');
|
||||
const list = await http.get(`/orders?userId=${normalizeUserId()}`);
|
||||
if (Array.isArray(list) && list.length > 0) {
|
||||
return list.map(formatOrderData);
|
||||
}
|
||||
@@ -334,8 +334,9 @@ export async function cancelOrder(orderId) {
|
||||
return formatOrderData(res);
|
||||
} catch (err) {
|
||||
console.warn('[API] 取消订单网络异常:', err.message);
|
||||
// 写操作失败必须抛出,供调用方提示并阻止"假成功"
|
||||
throw err;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +344,7 @@ export async function cancelOrder(orderId) {
|
||||
*/
|
||||
export async function payOrder(orderId, payload = {}) {
|
||||
try {
|
||||
const res = await http.post(`/orders/${orderId}/pay`, payload);
|
||||
const res = await http.post(`/orders/${orderId}/pay`, { ...payload, userId: normalizeUserId(payload.userId) });
|
||||
return formatOrderData(res);
|
||||
} catch (err) {
|
||||
console.warn('[API] 支付订单网络异常:', err.message);
|
||||
@@ -386,8 +387,9 @@ export async function completeOrder(orderId) {
|
||||
return formatOrderData(res);
|
||||
} catch (err) {
|
||||
console.warn('[API] 确认完成网络异常:', err.message);
|
||||
// 写操作失败必须抛出,供调用方提示并阻止"假成功"
|
||||
throw err;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,7 +423,7 @@ export async function submitReport(payload = {}) {
|
||||
*/
|
||||
export async function queryCheckinCode(code) {
|
||||
try {
|
||||
const res = await http.get(`/verify/query/${code}`);
|
||||
const res = await http.get(`/verify/query/${code}?userId=${normalizeUserId()}`);
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 反查核销码失败:', err.message);
|
||||
@@ -502,7 +504,7 @@ export async function getPosts(category, userId) {
|
||||
*/
|
||||
export async function createPost(payload) {
|
||||
try {
|
||||
const res = await http.post('/posts', payload);
|
||||
const res = await http.post('/posts', { ...(payload || {}), userId: normalizeUserId(payload && payload.userId) });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 发布动态异常:', err.message);
|
||||
@@ -524,7 +526,8 @@ export async function likePost(id, action, userId) {
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 点赞动态异常:', err.message);
|
||||
return null;
|
||||
// 点赞是写操作,失败必须向上抛出,避免调用方误以为已落盘
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,7 +690,7 @@ export async function getOrdersPool() {
|
||||
*/
|
||||
export async function claimOrder(orderId, expertData = {}) {
|
||||
try {
|
||||
const res = await http.post(`/orders/${orderId}/claim`, expertData);
|
||||
const res = await http.post(`/orders/${orderId}/claim`, { ...expertData, userId: normalizeUserId(expertData.userId) });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 大神抢单异常:', err.message);
|
||||
@@ -780,7 +783,7 @@ export async function getMarketingCoupons(category) {
|
||||
*/
|
||||
export async function submitOrderReview(orderId, reviewData = {}) {
|
||||
try {
|
||||
const res = await http.post(`/orders/${orderId}/review`, reviewData);
|
||||
const res = await http.post(`/orders/${orderId}/review`, { ...reviewData, userId: normalizeUserId(reviewData.userId) });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 提交订单评价异常:', err.message);
|
||||
@@ -836,7 +839,7 @@ export async function addPostComment(postId, commentData = {}) {
|
||||
*/
|
||||
export async function applyPostParty(postId, applyData = {}) {
|
||||
try {
|
||||
const res = await http.post(`/posts/${postId}/apply`, applyData);
|
||||
const res = await http.post(`/posts/${postId}/apply`, { ...applyData, applicantId: normalizeUserId(applyData.applicantId) });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 申请搭子上车异常:', err.message);
|
||||
@@ -996,7 +999,7 @@ export async function replyOrderReview(reviewId, replyContent) {
|
||||
*/
|
||||
export async function deletePost(postId, userId) {
|
||||
try {
|
||||
const uid = userId || uni.getStorageSync('userId') || 1001;
|
||||
const uid = normalizeUserId(userId);
|
||||
const res = await http.delete(`/posts/${postId}?userId=${uid}`);
|
||||
return res;
|
||||
} catch (err) {
|
||||
@@ -1129,7 +1132,7 @@ export async function bindInviteCode(userId, inviteCode) {
|
||||
*/
|
||||
export async function getPostApplies(postId) {
|
||||
try {
|
||||
const res = await http.get(`/posts/${postId}/applies`);
|
||||
const res = await http.get(`/posts/${postId}/applies?userId=${normalizeUserId()}`);
|
||||
return res || [];
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取搭子上车申请列表异常:', err.message);
|
||||
@@ -1196,6 +1199,19 @@ export async function getUserSettings(userId) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信订阅消息模板ID (用于 wx.requestSubscribeMessage 请求用户授权;模板ID非敏感)
|
||||
*/
|
||||
export async function getSubscribeTemplates() {
|
||||
try {
|
||||
const res = await http.get('/message/subscribe-templates');
|
||||
return res || { enablePush: false };
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取订阅消息模板异常:', err.message);
|
||||
return { enablePush: false };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户隐私与通知订阅设置 (同步落盘服务端与本地存储)
|
||||
*/
|
||||
@@ -1210,12 +1226,9 @@ export async function updateUserSettings(userId, settings = {}) {
|
||||
try {
|
||||
const res = await http.post(`/users/${uid}/settings`, settings);
|
||||
return res;
|
||||
} catch (_) {
|
||||
return {
|
||||
userId: uid,
|
||||
privacyHidePhone: uni.getStorageSync('privacy_hide_phone') === '1',
|
||||
noticeSubscribe: uni.getStorageSync('notice_subscribe') !== '0'
|
||||
};
|
||||
} catch (err) {
|
||||
// 写入失败必须向上抛出,避免调用方误以为已保存
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,27 @@ const BASE_URL = (() => {
|
||||
* @param {Object} options 请求参数
|
||||
* @returns {Promise} 返回请求结果
|
||||
*/
|
||||
// 登录过期提示仅一次,避免并发请求重复弹窗
|
||||
let authExpiredNotified = false;
|
||||
function handleAuthExpired() {
|
||||
try {
|
||||
uni.removeStorageSync('userToken');
|
||||
uni.removeStorageSync('userId');
|
||||
uni.removeStorageSync('userInfo');
|
||||
uni.removeStorageSync('PW_USER_INFO');
|
||||
} catch (_) {
|
||||
// 忽略本地存储清理异常
|
||||
}
|
||||
if (!authExpiredNotified) {
|
||||
authExpiredNotified = true;
|
||||
try {
|
||||
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none' });
|
||||
} catch (_) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function request(options = {}) {
|
||||
let url = options.url || '';
|
||||
if (!url.startsWith('http')) {
|
||||
@@ -50,14 +71,22 @@ export function request(options = {}) {
|
||||
if (res.data.code === 20000) {
|
||||
resolve(res.data.data);
|
||||
} else {
|
||||
reject(new Error(res.data.message || '业务请求失败'));
|
||||
const bizErr = new Error(res.data.message || '业务请求失败');
|
||||
bizErr.code = res.data.code;
|
||||
bizErr.statusCode = res.statusCode;
|
||||
if (res.data.code === 40100) handleAuthExpired();
|
||||
reject(bizErr);
|
||||
}
|
||||
} else {
|
||||
resolve(res.data);
|
||||
}
|
||||
} else {
|
||||
const errMsg = (res.data && res.data.message) ? res.data.message : `HTTP请求失败: ${res.statusCode}`;
|
||||
reject(new Error(errMsg));
|
||||
const httpErr = new Error(errMsg);
|
||||
httpErr.statusCode = res.statusCode;
|
||||
httpErr.code = (res.data && res.data.code) || res.statusCode;
|
||||
if (res.statusCode === 401) handleAuthExpired();
|
||||
reject(httpErr);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
@@ -192,6 +192,15 @@
|
||||
"backgroundColor": "#0A0F1D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/help-faq",
|
||||
"style": {
|
||||
"navigationBarTitleText": "帮助中心与常见问题",
|
||||
"navigationBarBackgroundColor": "#0A0F1D",
|
||||
"navigationBarTextStyle": "white",
|
||||
"backgroundColor": "#0A0F1D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/activity/create",
|
||||
"style": {
|
||||
|
||||
@@ -446,7 +446,20 @@ const toggleLike = async () => {
|
||||
}
|
||||
uni.setStorageSync('ACTIVE_COMMUNITY_POST', post.value);
|
||||
} catch (err) {
|
||||
// 回滚乐观更新,避免"已点赞"却未落盘
|
||||
console.warn('[PostDetail] 点赞同步异常:', err.message);
|
||||
post.value.liked = !willLike;
|
||||
post.value.likes = Math.max(0, (Number(post.value.likes) || 0) + (willLike ? -1 : 1));
|
||||
let revertIds = uni.getStorageSync('COMMUNITY_LIKED_POST_IDS') || [];
|
||||
if (!Array.isArray(revertIds)) revertIds = [];
|
||||
if (willLike) {
|
||||
revertIds = revertIds.filter(id => id !== strId);
|
||||
} else if (!revertIds.includes(strId)) {
|
||||
revertIds.push(strId);
|
||||
}
|
||||
uni.setStorageSync('COMMUNITY_LIKED_POST_IDS', revertIds);
|
||||
uni.setStorageSync('ACTIVE_COMMUNITY_POST', post.value);
|
||||
uni.showToast({ title: (err && err.message) || '操作失败,请重试', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -530,7 +543,11 @@ const handleJoinParty = () => {
|
||||
applicantName,
|
||||
applicantAvatar
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: (err && err.message) || '申请失败,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
post.value.hasApplied = true;
|
||||
post.value.myApplyStatus = 'PENDING';
|
||||
@@ -624,10 +641,7 @@ const handleDeletePost = () => {
|
||||
}, 500);
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '动态已删除', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
handleBack();
|
||||
}, 500);
|
||||
uni.showToast({ title: (err && err.message) || '删除失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +729,19 @@ const toggleLike = async (post) => {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// 回滚乐观更新,避免"已点赞"却未落盘
|
||||
console.warn('[Community] 点赞落盘异常:', err.message);
|
||||
post.liked = !willLike;
|
||||
post.likes += willLike ? -1 : 1;
|
||||
let revertIds = uni.getStorageSync('COMMUNITY_LIKED_POST_IDS') || [];
|
||||
if (!Array.isArray(revertIds)) revertIds = [];
|
||||
if (willLike) {
|
||||
revertIds = revertIds.filter(id => id !== strId);
|
||||
} else if (!revertIds.includes(strId)) {
|
||||
revertIds.push(strId);
|
||||
}
|
||||
uni.setStorageSync('COMMUNITY_LIKED_POST_IDS', revertIds);
|
||||
uni.showToast({ title: (err && err.message) || '操作失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -914,8 +926,7 @@ const handleDeletePost = (post) => {
|
||||
uni.showToast({ title: '动态已删除', icon: 'success' });
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
posts.value = posts.value.filter(p => p.id !== post.id);
|
||||
uni.showToast({ title: '动态已删除', icon: 'success' });
|
||||
uni.showToast({ title: (err && err.message) || '删除失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1005,7 +1016,11 @@ const handleJoinParty = (post) => {
|
||||
applicantName,
|
||||
applicantAvatar
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: (err && err.message) || '申请失败,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
post.hasApplied = true;
|
||||
post.myApplyStatus = 'PENDING';
|
||||
|
||||
@@ -594,7 +594,6 @@ const submitReportTicket = async () => {
|
||||
uni.showLoading({ title: '正在提交举报...' });
|
||||
try {
|
||||
await submitReportApi({
|
||||
reporterId: 1001,
|
||||
targetType: 'EXPERT',
|
||||
targetId: String(expert.value.id || '101'),
|
||||
targetName: expert.value.nickname || '同城陪伴师',
|
||||
|
||||
@@ -491,7 +491,14 @@ const handleGrabOrder = (order) => {
|
||||
expenseBurden: order.payMethod,
|
||||
status: '履约中'
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: (err && err.message) || '接单失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '接单成功!请准时履约',
|
||||
|
||||
@@ -417,8 +417,8 @@ const handleTakeOrder = (order) => {
|
||||
companionName: '我 (接单大神)',
|
||||
expertAvatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150'
|
||||
});
|
||||
} catch (_) {
|
||||
// 若为新需求单,自动落盘创建
|
||||
} catch (claimErr) {
|
||||
// 若为新需求单,尝试自动落盘创建
|
||||
try {
|
||||
await createOrder({
|
||||
buyerId: 2001,
|
||||
@@ -434,7 +434,14 @@ const handleTakeOrder = (order) => {
|
||||
expenseBurden: '费用AA',
|
||||
status: '履约中'
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (createErr) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: (createErr && createErr.message) || (claimErr && claimErr.message) || '抢单失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
|
||||
@@ -591,14 +591,21 @@ const activeOrders = ref([
|
||||
]);
|
||||
|
||||
const toggleReceivingStatus = async () => {
|
||||
isReceivingOrders.value = !isReceivingOrders.value;
|
||||
const newStatusStr = isReceivingOrders.value ? '接单中' : '休息中';
|
||||
uni.setStorageSync('EXPERT_RECEIVING_STATUS', isReceivingOrders.value ? '1' : '0');
|
||||
const next = !isReceivingOrders.value;
|
||||
const newStatusStr = next ? '接单中' : '休息中';
|
||||
try {
|
||||
await updateCompanionProfile(expert.value.id || 101, { status: newStatusStr });
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({
|
||||
title: (err && err.message) || '接单状态切换失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
isReceivingOrders.value = next;
|
||||
uni.setStorageSync('EXPERT_RECEIVING_STATUS', next ? '1' : '0');
|
||||
uni.showToast({
|
||||
title: isReceivingOrders.value ? '已开启在线接单通道!' : '已打烊停止接单',
|
||||
title: next ? '已开启在线接单通道!' : '已打烊停止接单',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
@@ -766,7 +773,14 @@ const grabOrder = async (order) => {
|
||||
companionName: '我 (接单大神)',
|
||||
expertAvatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150'
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({
|
||||
title: (err && err.message) || '抢单失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
loadWorkspaceOrders();
|
||||
return;
|
||||
}
|
||||
uni.showToast({
|
||||
title: '抢单成功已接单',
|
||||
icon: 'success'
|
||||
@@ -787,7 +801,14 @@ const handleRejectOrder = (order) => {
|
||||
expertId: expert.value.id || 101,
|
||||
reason: '大神当前档期冲突拒单'
|
||||
});
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({
|
||||
title: (err && err.message) || '拒单失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
loadWorkspaceOrders();
|
||||
return;
|
||||
}
|
||||
poolOrders.value = poolOrders.value.filter(o => o.id !== order.id);
|
||||
uni.showToast({
|
||||
title: '已拒单并自动退款',
|
||||
@@ -833,10 +854,13 @@ const completeOrder = (id) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await applyCompleteOrder(id, { expertId: expert.value.id || 101 });
|
||||
} catch (_) {
|
||||
try {
|
||||
await completeOrderApi(id);
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({
|
||||
title: (err && err.message) || '提交失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
loadWorkspaceOrders();
|
||||
return;
|
||||
}
|
||||
activeOrders.value = activeOrders.value.filter(o => o.id !== id);
|
||||
uni.showToast({ title: '已提交待买家确认', icon: 'success' });
|
||||
|
||||
@@ -495,7 +495,11 @@ const cancelOrder = (id) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await cancelOrderApi(id);
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: (err && err.message) || '取消失败,请稍后重试', icon: 'none' });
|
||||
loadLiveOrders();
|
||||
return;
|
||||
}
|
||||
const o = orders.value.find(item => item.id === id);
|
||||
if (o) o.status = 'CANCELLED';
|
||||
else orders.value = orders.value.filter(o => o.id !== id);
|
||||
@@ -751,7 +755,6 @@ const submitReportTicket = async () => {
|
||||
const expertId = order.expert ? order.expert.id : (order.expertId || 101);
|
||||
const expertName = order.expert ? order.expert.nickname : (order.companionName || '陪玩大神');
|
||||
await submitReportApi({
|
||||
reporterId: 1001,
|
||||
targetType: 'EXPERT',
|
||||
targetId: String(expertId),
|
||||
targetName: expertName,
|
||||
@@ -788,7 +791,11 @@ const confirmComplete = (id) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await completeOrderApi(id);
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: (err && err.message) || '确认验收失败,请稍后重试', icon: 'none' });
|
||||
loadLiveOrders();
|
||||
return;
|
||||
}
|
||||
const o = orders.value.find(item => item.id === id);
|
||||
if (o) o.status = 'COMPLETED';
|
||||
uni.showToast({ title: '已确认验收,感谢您的支持!', icon: 'success' });
|
||||
|
||||
285
pwuniapp/pages/user/help-faq.vue
普通文件
285
pwuniapp/pages/user/help-faq.vue
普通文件
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<view class="faq-page" :class="{ 'theme-warm': currentThemeKey === 'warm' }">
|
||||
<!-- 顶部标题区 -->
|
||||
<view class="faq-header">
|
||||
<view class="faq-badge">帮助中心</view>
|
||||
<text class="faq-title">常见问题解答</text>
|
||||
<text class="faq-meta">点击问题查看解答;如仍有疑问,可联系官方在线客服</text>
|
||||
</view>
|
||||
|
||||
<!-- 问答列表 -->
|
||||
<scroll-view class="faq-scroll" scroll-y enable-flex>
|
||||
<view v-if="isLoading" class="faq-state">
|
||||
<text class="state-text">正在加载…</text>
|
||||
</view>
|
||||
|
||||
<view v-else-if="faqList.length === 0" class="faq-state">
|
||||
<text class="state-text">暂无常见问题,请稍后再试,或联系官方客服。</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="faq-list">
|
||||
<view
|
||||
v-for="(item, idx) in faqList"
|
||||
:key="item.id || idx"
|
||||
class="faq-item"
|
||||
@click="toggle(idx)"
|
||||
>
|
||||
<view class="faq-q-row">
|
||||
<text class="faq-index">{{ idx + 1 }}</text>
|
||||
<text class="faq-question">{{ item.question }}</text>
|
||||
<text class="faq-arrow" :class="{ open: activeIndex === idx }">›</text>
|
||||
</view>
|
||||
<view v-if="activeIndex === idx" class="faq-answer-box">
|
||||
<text v-if="item.category" class="faq-category">【{{ item.category }}】</text>
|
||||
<text class="faq-answer">{{ item.answer }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="faq-footer">
|
||||
<text class="footer-tip">仍未解决?请在「个人中心 → 官方在线客服」联系我们</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
import { getPlatformConfigs } from '@/common/api.js';
|
||||
|
||||
const currentThemeKey = ref(getCurrentThemeKey());
|
||||
const isLoading = ref(true);
|
||||
const faqList = ref([]);
|
||||
const activeIndex = ref(-1);
|
||||
|
||||
const toggle = (idx) => {
|
||||
activeIndex.value = activeIndex.value === idx ? -1 : idx;
|
||||
};
|
||||
|
||||
const loadFaq = async () => {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const res = await getPlatformConfigs();
|
||||
const list = (res && res.faq_list) || [];
|
||||
faqList.value = Array.isArray(list) ? list : [];
|
||||
} catch (e) {
|
||||
console.warn('[FAQ] 加载帮助中心配置失败:', e && e.message);
|
||||
faqList.value = [];
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
currentThemeKey.value = getCurrentThemeKey();
|
||||
applyThemeToNativeUI(currentThemeKey.value);
|
||||
loadFaq();
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
currentThemeKey.value = getCurrentThemeKey();
|
||||
applyThemeToNativeUI(currentThemeKey.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.faq-page {
|
||||
min-height: 100vh;
|
||||
background-color: #0A0F1D;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.faq-header {
|
||||
padding: 40rpx 36rpx 24rpx;
|
||||
background: #10172A;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
|
||||
.faq-badge {
|
||||
display: inline-block;
|
||||
font-size: 20rpx;
|
||||
font-weight: 600;
|
||||
color: #10B981;
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.faq-title {
|
||||
display: block;
|
||||
font-size: 38rpx;
|
||||
font-weight: 800;
|
||||
color: #F8FAFC;
|
||||
letter-spacing: 1rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.faq-meta {
|
||||
display: block;
|
||||
font-size: 22rpx;
|
||||
color: #64748B;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-scroll {
|
||||
flex: 1;
|
||||
padding: 28rpx 32rpx calc(60rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.faq-state {
|
||||
padding: 80rpx 20rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
.state-text {
|
||||
font-size: 26rpx;
|
||||
color: #64748B;
|
||||
text-align: center;
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.faq-item {
|
||||
background: #151D30;
|
||||
border-radius: 20rpx;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
padding: 28rpx 28rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.faq-q-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.faq-index {
|
||||
flex-shrink: 0;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
color: #818CF8;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.faq-question {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #F8FAFC;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.faq-arrow {
|
||||
flex-shrink: 0;
|
||||
margin-left: 12rpx;
|
||||
font-size: 40rpx;
|
||||
color: #64748B;
|
||||
transition: transform 0.2s ease;
|
||||
transform: rotate(90deg);
|
||||
|
||||
&.open {
|
||||
transform: rotate(-90deg);
|
||||
color: #10B981;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.faq-answer-box {
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
|
||||
.faq-category {
|
||||
display: block;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
color: #818CF8;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.faq-answer {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #94A3B8;
|
||||
line-height: 1.75;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-footer {
|
||||
margin-top: 36rpx;
|
||||
padding: 0 8rpx;
|
||||
|
||||
.footer-tip {
|
||||
font-size: 22rpx;
|
||||
color: #475569;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
/* 浅色暖阳模式适配 */
|
||||
.theme-warm {
|
||||
background-color: #FAF8F5;
|
||||
|
||||
.faq-header {
|
||||
background: #FFFFFF;
|
||||
border-bottom-color: #E7E5E4;
|
||||
|
||||
.faq-title {
|
||||
color: #1C1917;
|
||||
}
|
||||
.faq-meta {
|
||||
color: #78716C;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-state .state-text {
|
||||
color: #78716C;
|
||||
}
|
||||
|
||||
.faq-item {
|
||||
background: #FFFFFF;
|
||||
border-color: #E7E5E4;
|
||||
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.faq-q-row {
|
||||
.faq-question {
|
||||
color: #1C1917;
|
||||
}
|
||||
.faq-arrow {
|
||||
color: #A8A29E;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-answer-box {
|
||||
border-top-color: #F5F5F4;
|
||||
|
||||
.faq-category {
|
||||
color: #EA580C;
|
||||
}
|
||||
.faq-answer {
|
||||
color: #57534E;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-footer .footer-tip {
|
||||
color: #A8A29E;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -602,8 +602,9 @@ const loadUserProfile = async (targetId) => {
|
||||
user.value.inviterId = res.inviterId;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
uni.removeStorageSync('PENDING_INVITER_CODE');
|
||||
.catch((err) => {
|
||||
// 绑定失败保留待绑定码以便下次登录重试,避免静默丢失邀请关系
|
||||
console.warn('[User] 邀请码绑定失败,将于下次登录重试:', err && err.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1179,31 +1180,12 @@ const openNotice = () => {
|
||||
};
|
||||
|
||||
const openFaq = () => {
|
||||
const list = platformConfigs.value.faq_list || [];
|
||||
if (Array.isArray(list) && list.length > 0) {
|
||||
const questions = list.map((item, idx) => `${idx + 1}. ${item.question}`);
|
||||
uni.showActionSheet({
|
||||
itemList: questions,
|
||||
success: (res) => {
|
||||
const item = list[res.tapIndex];
|
||||
if (item) {
|
||||
uni.showModal({
|
||||
title: item.question,
|
||||
content: `【${item.category || '常见问题'}】\n${item.answer}`,
|
||||
showCancel: false,
|
||||
confirmText: '我知道了',
|
||||
confirmColor: '#6366F1'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '帮助中心与常见问题',
|
||||
content: '1. 什么是4位核销码?\n到达活动现场后出示给陪伴师或房主签到核销,保障真实履约。\n2. 如何申请退款?\n在未接单或未核销前可随时全额退款,或发起争议仲裁由官方判定。',
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/help-faq',
|
||||
fail: () => {
|
||||
uni.showToast({ title: '页面打开失败,请稍后重试', icon: 'none' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const openAbout = () => {
|
||||
|
||||
@@ -186,7 +186,7 @@ import { onShow } from '@dcloudio/uni-app';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
import { getNavBarInfo } from '@/common/nav.js';
|
||||
import { getUserSettings, updateUserSettings } from '@/common/api.js';
|
||||
import { getUserSettings, updateUserSettings, getSubscribeTemplates } from '@/common/api.js';
|
||||
|
||||
const currentThemeKey = ref(getCurrentThemeKey());
|
||||
const navInfo = ref(getNavBarInfo());
|
||||
@@ -287,41 +287,76 @@ const syncSettingsFromServer = async () => {
|
||||
// 切换手机号脱敏隐藏(同步本地与后端并广播全站脱敏事件)
|
||||
const onToggleHidePhone = async (e) => {
|
||||
const val = !!e.detail.value;
|
||||
const prev = privacyHidePhone.value;
|
||||
privacyHidePhone.value = val;
|
||||
uni.setStorageSync('privacy_hide_phone', val ? '1' : '0');
|
||||
uni.$emit('privacy-settings-change', { privacyHidePhone: val });
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: val,
|
||||
noticeSubscribe: noticeSubscribe.value
|
||||
});
|
||||
try {
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: val,
|
||||
noticeSubscribe: noticeSubscribe.value
|
||||
});
|
||||
} catch (err) {
|
||||
// 同步失败回滚本地状态并提示,避免"未同步却显示已保存"
|
||||
privacyHidePhone.value = prev;
|
||||
uni.setStorageSync('privacy_hide_phone', prev ? '1' : '0');
|
||||
uni.$emit('privacy-settings-change', { privacyHidePhone: prev });
|
||||
uni.showToast({ title: (err && err.message) || '设置同步失败,请稍后重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showToast({
|
||||
title: val ? '已开启手机号脱敏保护' : '已关闭手机号脱敏保护',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
|
||||
// 使用后台配置的真实模板ID 请求微信订阅授权(过滤占位模板ID)
|
||||
const requestNoticeSubscribe = async () => {
|
||||
try {
|
||||
const tpl = await getSubscribeTemplates();
|
||||
if (!tpl || tpl.enablePush === false) return;
|
||||
const ids = [
|
||||
tpl.orderStatusTemplateId,
|
||||
tpl.activityJoinTemplateId,
|
||||
tpl.withdrawSuccessTemplateId,
|
||||
tpl.verifyCodeTemplateId
|
||||
].filter((x) => x && !String(x).startsWith('tmpl_'));
|
||||
if (ids.length === 0) return;
|
||||
if (typeof uni.requestSubscribeMessage === 'function') {
|
||||
uni.requestSubscribeMessage({ tmplIds: ids, complete: () => {} });
|
||||
}
|
||||
} catch (_) {
|
||||
// 订阅授权失败不影响主流程
|
||||
}
|
||||
};
|
||||
|
||||
// 切换通知订阅(微信小程序端支持唤起订阅授权,并同步服务端)
|
||||
const onToggleNotice = async (e) => {
|
||||
const val = !!e.detail.value;
|
||||
const prev = noticeSubscribe.value;
|
||||
noticeSubscribe.value = val;
|
||||
uni.setStorageSync('notice_subscribe', val ? '1' : '0');
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (val && typeof uni.requestSubscribeMessage === 'function') {
|
||||
try {
|
||||
uni.requestSubscribeMessage({
|
||||
tmplIds: ['ORDER_STATUS_NOTICE_TMPL', 'ACTIVITY_TEAM_NOTICE_TMPL'],
|
||||
complete: () => {}
|
||||
});
|
||||
} catch (_) {}
|
||||
if (val) {
|
||||
await requestNoticeSubscribe();
|
||||
}
|
||||
// #endif
|
||||
|
||||
uni.$emit('notice-subscribe-change', val);
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: privacyHidePhone.value,
|
||||
noticeSubscribe: val
|
||||
});
|
||||
try {
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: privacyHidePhone.value,
|
||||
noticeSubscribe: val
|
||||
});
|
||||
} catch (err) {
|
||||
// 同步失败回滚本地状态并提示
|
||||
noticeSubscribe.value = prev;
|
||||
uni.setStorageSync('notice_subscribe', prev ? '1' : '0');
|
||||
uni.$emit('notice-subscribe-change', prev);
|
||||
uni.showToast({ title: (err && err.message) || '设置同步失败,请稍后重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showToast({
|
||||
title: val ? '已开启订单与组局动态提醒' : '已关闭订单与组局动态提醒',
|
||||
icon: 'none'
|
||||
|
||||
在新工单中引用
屏蔽一个用户