文件
yjyf/yjyf-master-app/utils/api.js
MiAn c664d0a5de feat(sms): 集成腾讯云短信插件并打通双端短信验证码业务链路
- 插件管理:集成 qcloudsms 腾讯云短信发送插件,配置应用AppID/AppKey、短信签名及各业务模板ID(登录、修改密码、重置密码、支付密码、订单核销通知)
- 业务封装:新增 SmsService 统一业务短信服务,实现防刷限流、冷却控制、短信验证码发送与防重放校验,支持完工订单自动下发客户核销码
- 接口层:恢复并升级 Sms 控制器,并在 Auth/MasterAuth/Security 控制器中支持手机验证码登录、找回登录密码及短信验证设置/修改支付密码
- 小程序端:用户端与师傅端登录页、账号安全中心、支付密码组件全面适配短信验证码交互,优化用户找回密码与支付密码安全操作流程
- 部署脚本:优化 deploy_all.py 打包剪枝逻辑,全局过滤深层 .git 目录并规范打包相对路径
2026-11-26 15:54:15 +08:00

153 行
6.9 KiB
JavaScript

/**
* 师傅端接口清单(仅保留师傅端与公共字典/协议/上传接口)
*/
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 }),
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'),
sendPasswordSms: () => post('/master_auth/sendPasswordSms', {}),
sendPaymentPasswordSms: () => post('/master_auth/sendPaymentPasswordSms', {}),
changeLoginPassword: (data) => post('/master_auth/changeLoginPassword', data),
sendResetPasswordSms: (data) => post('/master_auth/sendResetPasswordSms', data),
resetPasswordBySms: (data) => post('/master_auth/resetPasswordBySms', 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
}
};