feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
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),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
这个提交包含在:
149
yjyf-master-app/utils/api.js
普通文件
149
yjyf-master-app/utils/api.js
普通文件
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* 师傅端接口清单(仅保留师傅端与公共字典/协议/上传接口)
|
||||
*/
|
||||
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 }),
|
||||
cats: () => get('/home/cats'),
|
||||
agreement: (type, opt) => get('/home/agreement', { type: type, side: 'master' }, opt || { silent: true }),
|
||||
agreementRead: (data, opt) => post('/home/agreementRead', Object.assign({ side: 'master' }, data || {}), Object.assign({ silent: true, allowConcurrent: true }, opt || {})),
|
||||
|
||||
/* ---------- 师傅端独立鉴权与安全 ---------- */
|
||||
login: (data) => post('/master_auth/login', data, { silent: true }),
|
||||
wxLogin: (data) => post('/master_auth/wxlogin', data, { silent: true }),
|
||||
wxPhoneLogin: (data) => post('/master_auth/wxPhoneLogin', data, { silent: true }),
|
||||
logout: () => post('/master_auth/logout', {}, { silent: true }),
|
||||
profile: () => get('/master_auth/profile'),
|
||||
securityStatus: () => get('/master_auth/securityStatus'),
|
||||
changeLoginPassword: (data) => post('/master_auth/changeLoginPassword', data),
|
||||
setPaymentPassword: (data) => post('/master_auth/setPaymentPassword', data),
|
||||
changePaymentPassword: (data) => post('/master_auth/changePaymentPassword', data),
|
||||
|
||||
/* ---------- 师傅业务 ---------- */
|
||||
masterApply: (data) => post('/master/apply', data),
|
||||
masterOcrIdCard: (data) => post('/master/ocrIdCard', data),
|
||||
masterInfo: () => get('/master/info'),
|
||||
masterSaveProfile: (data) => post('/master/saveProfile', data),
|
||||
masterHall: (data) => get('/master/hall', data),
|
||||
masterOrderDetail: (id, params) => get('/master/orderDetail', { id: id, ...(params || {}) }),
|
||||
masterGrab: (data) => post('/master/grab', data),
|
||||
masterOrders: (data) => get('/master/orders', data),
|
||||
masterContact: (data) => post('/master/contact', data),
|
||||
masterSchedule: (data) => post('/master/schedule', data),
|
||||
masterArrive: (data) => post('/master/arrive', data),
|
||||
masterStart: (data) => post('/master/startJob', data),
|
||||
masterFinish: (data) => post('/master/finish', data),
|
||||
masterVerifyCode: (data) => post('/master/verifyCode', data),
|
||||
masterRequestDiff: (data) => post('/master/requestDiff', data),
|
||||
masterIncome: () => get('/master/income'),
|
||||
masterToggle: (data) => post('/master/toggleWork', data),
|
||||
masterUpdateLocation: (data) => post('/master/updateLocation', data),
|
||||
masterResolveLocation: (data) => get('/master/resolveLocation', data, { silent: true }),
|
||||
masterSearchLocation: (data) => get('/master/searchLocation', data, { silent: true }),
|
||||
masterLocationContext: (data) => get('/master/locationContext', data, { silent: true }),
|
||||
masterLocationStats: (data) => get('/master/locationOrderStats', data, { silent: true }),
|
||||
masterLocateCity: (data) => get('/master/locateCity', data),
|
||||
masterCredit: () => get('/master/credit'),
|
||||
masterAppeals: () => get('/master/appeals'),
|
||||
masterAppeal: (data) => post('/master/appeal', data),
|
||||
masterQuotes: () => get('/master/quotes'),
|
||||
masterQuote: (data) => post('/master/quote', data),
|
||||
masterWithdraw: (data) => post('/master/withdraw', data),
|
||||
masterTransferPackage: (data) => post('/master/transferPackage', data),
|
||||
masterSyncWithdraw: (data) => post('/master/syncWithdraw', data, { silent: true, allowConcurrent: true }),
|
||||
masterSkillDict: () => get('/master/skillDict'),
|
||||
masterSaveSkills: (data) => post('/master/saveSkills', data),
|
||||
masterCerts: () => get('/master/certs'),
|
||||
masterCertDetail: (params) => get('/master/certDetail', params),
|
||||
masterSaveCert: (data) => post('/master/saveCert', data),
|
||||
masterDeleteCert: (data) => post('/master/deleteCert', data),
|
||||
reviewList: () => get('/master/reviews'),
|
||||
|
||||
/* ---------- 师傅端独立消息中心 ---------- */
|
||||
messageList: (data) => get('/master_message/index', data),
|
||||
messageRead: (data) => post('/master_message/read', data),
|
||||
messageReadAll: (data) => post('/master_message/readAll', data),
|
||||
messageUnread: (data) => get('/master_message/unread', data, { silent: true }),
|
||||
|
||||
/* ---------- 客服配置与跨小程序跳转 ---------- */
|
||||
getCachedServiceConfig: function () {
|
||||
try {
|
||||
const cached = uni.getStorageSync('yjyf_master_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(),
|
||||
user_appid: String(cached.user_appid || '').trim(),
|
||||
};
|
||||
}
|
||||
} catch (e) {}
|
||||
return {
|
||||
service_phone: String(uni.getStorageSync('yjyf_service_phone') || '').trim(),
|
||||
service_work_time: '',
|
||||
service_corp_id: '',
|
||||
service_kf_url: '',
|
||||
user_appid: '',
|
||||
};
|
||||
},
|
||||
getServiceConfig: async function (force = false) {
|
||||
const cached = this.getCachedServiceConfig();
|
||||
if (!force && (cached.service_phone || cached.service_corp_id || cached.service_kf_url) && cached.user_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(),
|
||||
user_appid: String(res.user_appid || '').trim(),
|
||||
};
|
||||
uni.setStorageSync('yjyf_master_service_config', cfg);
|
||||
if (cfg.service_phone) {
|
||||
uni.setStorageSync('yjyf_service_phone', cfg.service_phone);
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
} catch (e) {}
|
||||
return cached;
|
||||
},
|
||||
openUserMiniProgram: async function (path = 'pages/index/index') {
|
||||
let cfg = await this.getServiceConfig();
|
||||
if (!cfg.user_appid) {
|
||||
cfg = await this.getServiceConfig(true);
|
||||
}
|
||||
const targetAppId = cfg.user_appid;
|
||||
// #ifdef MP-WEIXIN
|
||||
if (!targetAppId) {
|
||||
uni.showToast({ title: '后台暂未配置用户端小程序 AppID', icon: 'none' });
|
||||
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: '知道了'
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
};
|
||||
在新工单中引用
屏蔽一个用户