1. 账号体系与数据库解耦: - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表; - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read; - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。 2. 服务端(Server): - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken); - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token; - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环; - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换); - 系统业务配置全面收敛至数据库 fa_config 及 site.php。 3. 小程序端: - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块; - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
221 行
9.8 KiB
JavaScript
221 行
9.8 KiB
JavaScript
/**
|
|
* 接口清单(与后端 application/api/controller 一一对应)
|
|
*/
|
|
import { get, post, uploadFile } from './request';
|
|
import config from '@/config/config.js';
|
|
|
|
export default {
|
|
/* ---------- 公共 / 上传 / 字典 ---------- */
|
|
upload: (filePath, category = 'other') => uploadFile(filePath, category),
|
|
areas: (data = {}) => get('/common/areas', data, { silent: true }),
|
|
expressCompanies: () => get('/common/expressCompanies', {}, { silent: true }),
|
|
commonDicts: () => get('/common/dicts', {}, { silent: true }),
|
|
|
|
/* ---------- 鉴权 ---------- */
|
|
login: (data) => post('/auth/login', data, { silent: true }),
|
|
wxLogin: (data) => post('/auth/wxlogin', data, { silent: true }),
|
|
wxPhoneLogin: (data) => post('/auth/wxPhoneLogin', data, { silent: true }),
|
|
profile: () => get('/auth/profile'),
|
|
selectIdentity: (data) => post('/auth/selectIdentity', data),
|
|
securityStatus: () => get('/security/status'),
|
|
changeLoginPassword: (data) => post('/security/changeLoginPassword', data),
|
|
setPaymentPassword: (data) => post('/security/setPaymentPassword', data),
|
|
changePaymentPassword: (data) => post('/security/changePaymentPassword', data),
|
|
submitEnterpriseCert: (data) => post('/security/submitEnterpriseCert', data),
|
|
recognizeEnterpriseLicense: (data) => post('/security/recognizeEnterpriseLicense', data),
|
|
saveAccount: (data) => post('/auth/saveAccount', data),
|
|
|
|
/* ---------- 用户钱包与充值 ---------- */
|
|
userWallet: () => get('/user/wallet'),
|
|
userWalletLogs: (params) => get('/user/walletLogs', params),
|
|
userRecharge: (data) => post('/user/recharge', data),
|
|
userConfirmRecharge: (data) => post('/user/confirmRecharge', data),
|
|
|
|
/* ---------- 首页 / 服务 ---------- */
|
|
home: () => get('/home/index', {}, { silent: true }),
|
|
homeFeed: (data) => get('/home/feed', data, { silent: true }),
|
|
cats: () => get('/home/cats'),
|
|
services: (data, opt) => get('/home/services', data, opt),
|
|
specs: (data) => get('/home/specs', data),
|
|
systemGallery: (data) => get('/home/systemGallery', data),
|
|
serviceDetail: (id) => get('/home/detail', { id: id }),
|
|
calc: (data, opt) => post('/home/calc', data, Object.assign({ silent: true, allowConcurrent: true }, opt || {})),
|
|
masterCount: (data) => get('/home/masterCount', data),
|
|
orderCase: (id) => get('/home/orderCase', { id: id }, { silent: true }),
|
|
agreement: (type, opt) => get('/home/agreement', { type: type }, opt || { silent: true }),
|
|
agreementRead: (data, opt) => post('/home/agreementRead', data, Object.assign({ silent: true, allowConcurrent: true }, opt || {})),
|
|
|
|
/* ---------- 地址 ---------- */
|
|
addressList: () => get('/address/index'),
|
|
addressDetail: (id) => get('/address/detail', { id: id }),
|
|
addressSave: (data) => post('/address/save', data),
|
|
addressDelete: (id) => post('/address/delete', { id: id }),
|
|
addressDefault: (id) => post('/address/setDefault', { id: id }),
|
|
|
|
/* ---------- 订单(用户端) ---------- */
|
|
orderCreate: (data) => post('/order/create', data),
|
|
detectExpress: (data) => get('/order/detectExpress', data),
|
|
orderPay: (data) => post('/order/pay', data),
|
|
orderConfirmPay: (data) => post('/order/confirmPay', data, { silent: true, allowConcurrent: true }),
|
|
orderPaymentResult: (data) => get('/order/paymentResult', data, { silent: true }),
|
|
orderCancel: (data) => post('/order/cancel', data),
|
|
orderDelete: (data) => post('/order/delete', data),
|
|
orderVerify: (data) => post('/order/verify', data),
|
|
orderList: (data) => get('/order/index', data),
|
|
orderDetail: (id) => get('/order/detail', { id: id }),
|
|
orderQuotes: (orderId) => get('/order/quotes', { order_id: orderId }),
|
|
orderChooseQuote: (data) => post('/order/chooseQuote', data),
|
|
orderPayDiff: (data) => post('/order/payDiff', data),
|
|
orderShowcase: (data) => post('/order/showcase', data),
|
|
orderUpdateNote: (data) => post('/order/updateNote', data),
|
|
orderComplaint: (data) => post('/order/complaint', data),
|
|
// 用户售后退款申请(已完成订单,提交后进入平台售后仲裁)
|
|
orderAfterSaleApply: (data) => post('/order/aftersaleapply', data),
|
|
// 我的售后申请记录(含仲裁进度与平台答复)
|
|
orderMyAfterSales: (data) => post('/order/myaftersales', data, { allowConcurrent: true }),
|
|
goodsGallery: (data) => get('/order/goodsGallery', data),
|
|
saveGoodsGallery: (data) => post('/order/saveGoodsGallery', data),
|
|
deleteGoodsGallery: (data) => post('/order/deleteGoodsGallery', data),
|
|
goodsTemplates: (data) => get('/order/goodsTemplates', data),
|
|
saveGoodsTemplate: (data) => post('/order/saveGoodsTemplate', data),
|
|
deleteGoodsTemplate: (data) => post('/order/deleteGoodsTemplate', data),
|
|
remarkTemplates: () => get('/order/remarkTemplates'),
|
|
saveRemarkTemplate: (data) => post('/order/saveRemarkTemplate', data),
|
|
deleteRemarkTemplate: (data) => post('/order/deleteRemarkTemplate', data),
|
|
|
|
/* ---------- 评价 ---------- */
|
|
reviewCreate: (data) => post('/review/create', data),
|
|
reviewList: (masterId) => get('/review/masterList', masterId ? { master_id: masterId } : {}),
|
|
|
|
/* ---------- 优惠券 ---------- */
|
|
couponCenter: () => get('/coupon/center'),
|
|
couponMy: (data, opt) => get('/coupon/my', data, opt),
|
|
couponReceive: (data) => post('/coupon/receive', data),
|
|
|
|
/* ---------- 消息中心 ---------- */
|
|
messageList: (data) => get('/message/index', data),
|
|
messageRead: (data) => post('/message/read', data),
|
|
messageReadAll: (data) => post('/message/readAll', data),
|
|
messageUnread: (data) => get('/message/unread', data, { silent: true }),
|
|
|
|
/* ---------- 发票与抬头中心(个人与商家通用) ---------- */
|
|
invoiceSummary: () => get('/invoice/summary'),
|
|
invoiceOrders: (data) => get('/invoice/orders', data),
|
|
invoiceApply: (data) => post('/invoice/apply', data),
|
|
invoiceRecords: (data) => get('/invoice/records', data),
|
|
invoiceDetail: (id) => get('/invoice/detail', { id: id }),
|
|
invoiceCancel: (id) => post('/invoice/cancel', { id: id }),
|
|
invoiceTitles: () => get('/invoice/titles'),
|
|
invoiceTitleDetail: (id) => get('/invoice/titleDetail', { id: id }),
|
|
invoiceTitleSave: (data) => post('/invoice/titleSave', data),
|
|
invoiceTitleDefault: (id) => post('/invoice/titleDefault', { id: id }),
|
|
invoiceTitleDelete: (id) => post('/invoice/titleDelete', { id: id }),
|
|
|
|
/* ---------- 平台客服配置读取与统一助手(仅读取后端真实配置,杜绝假号码与并发连击) ---------- */
|
|
getCachedServiceConfig: function () {
|
|
try {
|
|
const cached = uni.getStorageSync('yjyf_service_config');
|
|
if (cached && typeof cached === 'object') {
|
|
return {
|
|
service_phone: String(cached.service_phone || '').trim(),
|
|
service_work_time: String(cached.service_work_time || '').trim(),
|
|
service_corp_id: String(cached.service_corp_id || '').trim(),
|
|
service_kf_url: String(cached.service_kf_url || '').trim(),
|
|
master_appid: String(cached.master_appid || '').trim(),
|
|
};
|
|
}
|
|
} catch (e) {}
|
|
const legacyPhone = String(uni.getStorageSync('yjyf_service_phone') || '').trim();
|
|
return {
|
|
service_phone: legacyPhone,
|
|
service_work_time: '',
|
|
service_corp_id: '',
|
|
service_kf_url: '',
|
|
master_appid: '',
|
|
};
|
|
},
|
|
getServiceConfig: async function (force = false) {
|
|
const cached = this.getCachedServiceConfig();
|
|
if (!force && (cached.service_phone || cached.service_corp_id || cached.service_kf_url) && cached.master_appid) {
|
|
return cached;
|
|
}
|
|
try {
|
|
const res = await get('/home/serviceConfig', {}, { silent: true });
|
|
if (res && typeof res === 'object') {
|
|
const cfg = {
|
|
service_phone: String(res.service_phone || '').trim(),
|
|
service_work_time: String(res.service_work_time || '').trim(),
|
|
service_corp_id: String(res.service_corp_id || '').trim(),
|
|
service_kf_url: String(res.service_kf_url || '').trim(),
|
|
master_appid: String(res.master_appid || '').trim(),
|
|
};
|
|
uni.setStorageSync('yjyf_service_config', cfg);
|
|
if (cfg.service_phone) {
|
|
uni.setStorageSync('yjyf_service_phone', cfg.service_phone);
|
|
} else {
|
|
uni.removeStorageSync('yjyf_service_phone');
|
|
}
|
|
return cfg;
|
|
}
|
|
} catch (e) {
|
|
console.warn('获取客服配置失败', e);
|
|
}
|
|
return cached;
|
|
},
|
|
openMasterMiniProgram: async function (path = 'pages/master/hall') {
|
|
let cfg = await this.getServiceConfig();
|
|
if (!cfg.master_appid) {
|
|
cfg = await this.getServiceConfig(true);
|
|
}
|
|
const targetAppId = cfg.master_appid;
|
|
// #ifdef MP-WEIXIN
|
|
if (!targetAppId) {
|
|
uni.showModal({
|
|
title: '优匠优服师傅端',
|
|
content: '后台暂未配置师傅端小程序 AppID,请在微信搜索打开「优匠师傅端」小程序或联系平台管理员在后台系统配置中完善。',
|
|
showCancel: false,
|
|
confirmText: '知道了',
|
|
confirmColor: '#F0710D'
|
|
});
|
|
return;
|
|
}
|
|
uni.navigateToMiniProgram({
|
|
appId: targetAppId,
|
|
path: path,
|
|
fail: (err) => {
|
|
if (err && err.errMsg && err.errMsg.indexOf('cancel') !== -1) return;
|
|
uni.showToast({ title: '打开师傅端小程序失败,请稍后重试', icon: 'none' });
|
|
}
|
|
});
|
|
// #endif
|
|
// #ifndef MP-WEIXIN
|
|
uni.showModal({
|
|
title: '前往优匠优服师傅端',
|
|
content: '请在微信中搜索「优匠优服师傅端」小程序进行师傅实名入驻与接单。',
|
|
showCancel: false,
|
|
confirmText: '知道了',
|
|
confirmColor: '#F0710D'
|
|
});
|
|
// #endif
|
|
},
|
|
_contactingService: false,
|
|
contactService: async function () {
|
|
if (this._contactingService) return;
|
|
this._contactingService = true;
|
|
const cfg = await this.getServiceConfig(true);
|
|
const phone = cfg.service_phone || '';
|
|
setTimeout(() => { this._contactingService = false; }, 500);
|
|
if (phone) {
|
|
uni.makePhoneCall({ phoneNumber: phone, fail: () => {} });
|
|
} else {
|
|
uni.showModal({
|
|
title: '平台在线客服',
|
|
content: '请在微信小程序客服会话中直接留言,或在工单详情中提交售后反馈,客服专员将第一时间跟进处理。',
|
|
showCancel: false,
|
|
confirmText: '知道了',
|
|
confirmColor: '#F0710D'
|
|
});
|
|
}
|
|
}
|
|
};
|