feat(master): 完善师傅实名认证拦截及提示逻辑
- 移除登录时的草稿状态跳转逻辑 - 新增API接口未登录时返回401错误处理 - 新增实名认证状态判断及提示弹窗 - 优化师傅工作台信息加载逻辑 - 完善接单、报价等操作的实名认证拦截
这个提交包含在:
@@ -1231,7 +1231,10 @@ class Master extends MasterBase
|
||||
|
||||
public function orders()
|
||||
{
|
||||
$master = $this->requireMasterProfile();
|
||||
$master = $this->masterInfo();
|
||||
if (!$master) {
|
||||
$this->error(__('Please login first'), null, 401);
|
||||
}
|
||||
$status = $this->request->param('status', 'active');
|
||||
$page = max(1, (int)$this->request->param('page', 1));
|
||||
$limit = min(30, max(1, (int)$this->request->param('limit', 10)));
|
||||
@@ -1844,7 +1847,10 @@ class Master extends MasterBase
|
||||
*/
|
||||
public function quotes()
|
||||
{
|
||||
$master = $this->requireMasterProfile();
|
||||
$master = $this->masterInfo();
|
||||
if (!$master) {
|
||||
$this->error(__('Please login first'), null, 401);
|
||||
}
|
||||
$list = Db::name('order_quote')->alias('q')
|
||||
->join('order o', 'o.id = q.order_id', 'LEFT')
|
||||
->field('q.*, o.order_no, o.service_name, o.pay_amount as order_amount, o.status as order_status')
|
||||
|
||||
@@ -588,11 +588,33 @@
|
||||
uni.navigateTo({ url: '/pages/master/certs' });
|
||||
}
|
||||
|
||||
function promptMasterAuth(status) {
|
||||
const isPending = status === 'pending';
|
||||
const isReject = status === 'reject';
|
||||
uni.showModal({
|
||||
title: isPending ? '实名认证审核中' : (isReject ? '实名认证未通过' : '请先完成实名认证'),
|
||||
content: isPending
|
||||
? '您的师傅实名认证正在审核中,审核通过后即可接单。'
|
||||
: (isReject ? '您的实名认证未通过,请修改资料并重新提交后方可接单。' : '完成实名认证后方可接单,是否立即前往认证?'),
|
||||
confirmText: isPending ? '查看进度' : (isReject ? '去修改' : '去认证'),
|
||||
confirmColor: '#F0710D',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({ url: '/pages/master/apply' });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openGrabConfirm(o) {
|
||||
if (!isLogin()) {
|
||||
toLogin('/pages/master/hall');
|
||||
return;
|
||||
}
|
||||
if (info.value && info.value.verify_status !== 'pass') {
|
||||
promptMasterAuth(info.value.verify_status);
|
||||
return;
|
||||
}
|
||||
if (info.value && info.value.work_status === 'off') {
|
||||
uni.showModal({
|
||||
title: '当前已暂停接单',
|
||||
@@ -632,6 +654,11 @@
|
||||
timers.push(t);
|
||||
} catch (e) {
|
||||
grabbing.value = false;
|
||||
if (e && (e.code === 2001 || e.code === 2002 || e.code === 2003)) {
|
||||
selectedOrder.value = null;
|
||||
promptMasterAuth(e.code === 2002 ? 'pending' : (e.code === 2003 ? 'reject' : 'draft'));
|
||||
return;
|
||||
}
|
||||
uni.showToast({ title: e?.msg || e?.message || '手慢了,该订单已被接走', icon: 'none' });
|
||||
}
|
||||
}
|
||||
@@ -791,11 +818,7 @@
|
||||
|
||||
if (loggedIn.value && meResult.status === 'fulfilled' && meResult.value) {
|
||||
const meRes = meResult.value;
|
||||
if (!meRes.applied || !meRes.master) {
|
||||
uni.redirectTo({ url: '/pages/master/apply' });
|
||||
return;
|
||||
}
|
||||
info.value = meRes.master;
|
||||
info.value = meRes.master || null;
|
||||
} else if (!loggedIn.value) {
|
||||
info.value = null;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<view class="avatar-clip">
|
||||
<image class="avatar-img" :src="(info && info.avatar) || '/static/icons/avatar-master.svg'" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="v-auth-badge">
|
||||
<view class="v-auth-badge" v-if="verifyStatusMeta.text">
|
||||
<image class="v-badge-ico" src="/static/icons/v-auth.svg" mode="aspectFit" />
|
||||
<text class="v-badge-txt">{{ verifyStatusMeta.text }}</text>
|
||||
</view>
|
||||
@@ -321,7 +321,12 @@
|
||||
const masterTitleName = computed(() => {
|
||||
if (!info.value) return '';
|
||||
const rn = String(info.value.realname || '').trim();
|
||||
if (!rn) return '认证师傅';
|
||||
if (!rn) {
|
||||
if (info.value.verify_status === 'draft') {
|
||||
return String(info.value.nickname || '').trim() || '未认证师傅';
|
||||
}
|
||||
return '认证师傅';
|
||||
}
|
||||
if (rn.indexOf('师傅') > -1) return rn;
|
||||
return rn.slice(0, 1) + '师傅';
|
||||
});
|
||||
@@ -359,6 +364,7 @@
|
||||
if (status === 'pass') return { text: '已认证', cls: 'is-success' };
|
||||
if (status === 'pending') return { text: '审核中', cls: 'is-warning' };
|
||||
if (status === 'reject') return { text: '未通过', cls: 'is-danger' };
|
||||
if (status === 'draft') return { text: '未认证', cls: 'is-warning' };
|
||||
return { text: '', cls: '' };
|
||||
});
|
||||
|
||||
@@ -499,40 +505,44 @@
|
||||
loadError.value = '';
|
||||
|
||||
try {
|
||||
const [infoRes, incomeRes, creditRes] = await Promise.allSettled([
|
||||
api.masterInfo(),
|
||||
api.masterIncome(),
|
||||
api.masterCredit()
|
||||
]);
|
||||
const res = await api.masterInfo();
|
||||
if (seq !== loadSeq) return;
|
||||
|
||||
if (infoRes.status === 'fulfilled' && infoRes.value) {
|
||||
const res = infoRes.value;
|
||||
if (!res.applied || !res.master) {
|
||||
uni.redirectTo({ url: '/pages/master/apply' });
|
||||
return;
|
||||
if (!res || !res.master) {
|
||||
if (!info.value) {
|
||||
loadError.value = '工作台信息加载失败';
|
||||
}
|
||||
info.value = res.master;
|
||||
skills.value = res.skills || [];
|
||||
certSummary.value = res.cert_summary || null;
|
||||
} else if (!info.value) {
|
||||
const reason = infoRes.status === 'rejected' ? infoRes.reason : null;
|
||||
loadError.value = (reason && (reason.msg || reason.message)) || '网络异常,请稍后重试';
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomeRes.status === 'fulfilled' && incomeRes.value) {
|
||||
const inc = incomeRes.value;
|
||||
todayIncome.value = Number(inc.today_income || 0).toFixed(2);
|
||||
totalIncome.value = Number(inc.total_income || 0).toFixed(2);
|
||||
} else if (incomeRes.status === 'rejected') {
|
||||
console.warn('获取收入统计失败', incomeRes.reason);
|
||||
}
|
||||
info.value = res.master;
|
||||
skills.value = res.skills || [];
|
||||
certSummary.value = res.cert_summary || null;
|
||||
|
||||
if (creditRes.status === 'fulfilled' && creditRes.value) {
|
||||
credit.value = creditRes.value;
|
||||
} else if (creditRes.status === 'rejected') {
|
||||
console.warn('获取信用信息失败', creditRes.reason);
|
||||
if (!res.applied) {
|
||||
credit.value = null;
|
||||
todayIncome.value = '0.00';
|
||||
totalIncome.value = '0.00';
|
||||
} else {
|
||||
const [incomeRes, creditRes] = await Promise.allSettled([
|
||||
api.masterIncome(),
|
||||
api.masterCredit()
|
||||
]);
|
||||
if (seq !== loadSeq) return;
|
||||
|
||||
if (incomeRes.status === 'fulfilled' && incomeRes.value) {
|
||||
const inc = incomeRes.value;
|
||||
todayIncome.value = Number(inc.today_income || 0).toFixed(2);
|
||||
totalIncome.value = Number(inc.total_income || 0).toFixed(2);
|
||||
} else if (incomeRes.status === 'rejected') {
|
||||
console.warn('获取收入统计失败', incomeRes.reason);
|
||||
}
|
||||
|
||||
if (creditRes.status === 'fulfilled' && creditRes.value) {
|
||||
credit.value = creditRes.value;
|
||||
} else if (creditRes.status === 'rejected') {
|
||||
console.warn('获取信用信息失败', creditRes.reason);
|
||||
}
|
||||
}
|
||||
|
||||
if (!servicePhone.value) {
|
||||
@@ -564,6 +574,24 @@
|
||||
|
||||
async function toggleWork() {
|
||||
if (!info.value || togglingWork.value) return;
|
||||
if (info.value.verify_status !== 'pass') {
|
||||
const isPending = info.value.verify_status === 'pending';
|
||||
const isReject = info.value.verify_status === 'reject';
|
||||
uni.showModal({
|
||||
title: isPending ? '实名认证审核中' : (isReject ? '实名认证未通过' : '请先完成实名认证'),
|
||||
content: isPending
|
||||
? '您的师傅实名认证正在审核中,审核通过后即可开启听单接单。'
|
||||
: (isReject ? '您的实名认证未通过,请修改资料并重新提交。' : '完成实名认证后方可开启听单接单,是否立即前往认证?'),
|
||||
confirmText: isPending ? '查看进度' : (isReject ? '去修改' : '去认证'),
|
||||
confirmColor: '#F0710D',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({ url: '/pages/master/apply' });
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
togglingWork.value = true;
|
||||
const next = info.value.work_status === 'off' ? 'on' : 'off';
|
||||
try {
|
||||
|
||||
@@ -335,11 +335,6 @@
|
||||
}
|
||||
|
||||
function finishLogin(info) {
|
||||
if (info && info.verify_status === 'draft') {
|
||||
uni.reLaunch({ url: '/pages/master/apply' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (redirectUrl && (redirectUrl.startsWith('/pages/master/') || redirectUrl.startsWith('/pages/message/'))) {
|
||||
if (
|
||||
redirectUrl.startsWith('/pages/master/hall') ||
|
||||
|
||||
@@ -1192,6 +1192,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleAuthRequiredError(e) {
|
||||
if (!e || (e.code !== 2001 && e.code !== 2002 && e.code !== 2003)) {
|
||||
return false;
|
||||
}
|
||||
const isPending = e.code === 2002;
|
||||
const isReject = e.code === 2003;
|
||||
uni.showModal({
|
||||
title: isPending ? '实名认证审核中' : (isReject ? '实名认证未通过' : '请先完成实名认证'),
|
||||
content: isPending
|
||||
? '您的师傅实名认证正在审核中,审核通过后即可接单或报价。'
|
||||
: (isReject ? '您的实名认证未通过,请修改资料并重新提交后方可接单或报价。' : '完成实名认证后方可接单或报价,是否立即前往认证?'),
|
||||
confirmText: isPending ? '查看进度' : (isReject ? '去修改' : '去认证'),
|
||||
confirmColor: '#F0710D',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({ url: '/pages/master/apply' });
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
async function doGrab() {
|
||||
if (!isLogin()) {
|
||||
toLogin();
|
||||
@@ -1207,6 +1229,7 @@
|
||||
});
|
||||
} catch (e) {
|
||||
submitting.value = false;
|
||||
handleAuthRequiredError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1241,6 +1264,9 @@
|
||||
uni.showToast({ title: '报价已发送,等待客户选择' });
|
||||
loadDetail();
|
||||
} catch (e) {
|
||||
if (handleAuthRequiredError(e)) {
|
||||
showQuote.value = false;
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户