前端: - utils/request.js 统一请求层(token/错误码/401 引导登录) - utils/api.js 接口清单(与后端控制器一一对应) - pages/login 登录(手机号+验证码+角色选择) - pages/service/list|detail 服务列表/详情 - pages/order/create 下单(地址/预约/急单/费用试算/自动支付) - pages/order/list|detail|review 订单列表/详情轨迹/评价 - pages/master/apply|hall|orders 师傅入驻/订单大厅/接单履约 - YJYF/YJYF 首页接 home/index 真实类目 + 路由跳转 后端 Bug 修复(严重): - TP5 中 count() 会重置查询条件,导致 Order::index / Master::hall / Master::orders 在 select 时丢失 where 条件 → 泄漏全部用户订单/跨用户数据 - 改为闭包重建查询,已验证修复
138 行
6.4 KiB
Vue
138 行
6.4 KiB
Vue
<template>
|
||
<view class="page">
|
||
<view class="hero">
|
||
<text class="hero-t">师傅入驻</text>
|
||
<text class="hero-s">实名认证 + 技能认证,审核通过即可接单</text>
|
||
</view>
|
||
|
||
<view class="status" v-if="info">
|
||
<text class="st-t">当前状态:{{ statusText }}</text>
|
||
<text class="st-m" v-if="info.master.audit_msg">审核意见:{{ info.master.audit_msg }}</text>
|
||
</view>
|
||
|
||
<view class="card" v-if="canEdit">
|
||
<view class="fi"><text class="fk">真实姓名</text><input class="fv" v-model="form.realname" placeholder="与身份证一致" /></view>
|
||
<view class="fi"><text class="fk">手机号</text><input class="fv" v-model="form.mobile" type="number" maxlength="11" placeholder="接单联系电话" /></view>
|
||
<view class="fi"><text class="fk">身份证号</text><input class="fv" v-model="form.idcard_no" maxlength="18" placeholder="18 位身份证号" /></view>
|
||
<view class="fi"><text class="fk">服务城市</text><input class="fv" v-model="form.city" placeholder="如:遵义市" /></view>
|
||
|
||
<view class="block-title">选择服务类目(可多选)</view>
|
||
<view class="cats">
|
||
<view v-for="c in cats" :key="c.id" class="cat" :class="{ on: skills.indexOf(c.id) > -1 }" @tap="toggleSkill(c.id)">
|
||
<text class="cat-txt">{{ c.name }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="hint">证件与技能证书照片上传将在正式版接入 chooseMedia</view>
|
||
<view class="submit" :class="{ disabled: submitting }" @tap="submit">{{ submitting ? '提交中...' : '提交审核' }}</view>
|
||
</view>
|
||
|
||
<view class="card" v-else>
|
||
<view class="li"><text class="k">真实姓名</text><text class="v">{{ info.master.realname }}</text></view>
|
||
<view class="li"><text class="k">服务城市</text><text class="v">{{ info.master.city }}</text></view>
|
||
<view class="li"><text class="k">综合评分</text><text class="v">{{ info.master.score }}</text></view>
|
||
<view class="li"><text class="k">累计订单</text><text class="v">{{ info.master.order_count }}</text></view>
|
||
<view class="go" @tap="goHall">进入订单大厅 ›</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, reactive, computed } from 'vue';
|
||
import { onShow } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin, getUser } from '@/utils/request.js';
|
||
|
||
const info = ref(null);
|
||
const cats = ref([]);
|
||
const skills = ref([]);
|
||
const submitting = ref(false);
|
||
const form = reactive({ realname: '', mobile: '', idcard_no: '', city: '遵义市' });
|
||
|
||
const statusText = computed(() => {
|
||
if (!info.value || !info.value.master) return '未入驻';
|
||
const m = info.value.master;
|
||
return { pending: '待审核', pass: '已通过', reject: '未通过' }[m.verify_status] || m.verify_status;
|
||
});
|
||
const canEdit = computed(() => !info.value || !info.value.applied || info.value.master.verify_status === 'reject');
|
||
|
||
function toggleSkill(id) {
|
||
const i = skills.value.indexOf(id);
|
||
if (i > -1) skills.value.splice(i, 1);
|
||
else skills.value.push(id);
|
||
}
|
||
function goHall() { uni.redirectTo({ url: '/pages/master/hall' }); }
|
||
|
||
async function load() {
|
||
if (!isLogin()) { toLogin(); return; }
|
||
const res = await api.masterInfo();
|
||
info.value = res.applied ? res : null;
|
||
if (res.applied) {
|
||
form.realname = res.master.realname;
|
||
form.mobile = res.master.mobile;
|
||
form.city = res.master.city;
|
||
skills.value = (res.skills || []).map(s => s.cat_id);
|
||
} else {
|
||
const u = getUser();
|
||
if (u) form.mobile = u.mobile || '';
|
||
}
|
||
}
|
||
|
||
async function submit() {
|
||
if (submitting.value) return;
|
||
if (!form.realname || !form.mobile || !form.idcard_no) {
|
||
uni.showToast({ title: '请填写完整实名信息', icon: 'none' });
|
||
return;
|
||
}
|
||
if (!skills.value.length) {
|
||
uni.showToast({ title: '请至少选择一个服务类目', icon: 'none' });
|
||
return;
|
||
}
|
||
submitting.value = true;
|
||
try {
|
||
const payload = { realname: form.realname, mobile: form.mobile, idcard_no: form.idcard_no, city: form.city };
|
||
skills.value.forEach((id, i) => { payload['skills[' + i + ']'] = id; });
|
||
await api.masterApply(payload);
|
||
uni.showToast({ title: '已提交,等待审核' });
|
||
load();
|
||
} catch (e) {
|
||
} finally {
|
||
submitting.value = false;
|
||
}
|
||
}
|
||
|
||
onShow(async () => {
|
||
await load();
|
||
const res = await api.cats();
|
||
cats.value = res.list || [];
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 60rpx; }
|
||
.hero { padding: 40rpx 36rpx; background: linear-gradient(160deg, #FFB85C 0%, #F98D25 60%, #ED6F0E 100%); }
|
||
.hero-t { display: block; font-size: 40rpx; font-weight: 700; color: #fff; }
|
||
.hero-s { display: block; margin-top: 10rpx; font-size: 24rpx; color: rgba(255,255,255,0.9); }
|
||
.status { margin: 22rpx 28rpx 0; padding: 20rpx 24rpx; background: #FFF7F0; border-radius: 16rpx; display: flex; flex-direction: column; }
|
||
.st-t { font-size: 26rpx; color: #C4580A; font-weight: 600; }
|
||
.st-m { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
|
||
.card { margin: 22rpx 28rpx 0; padding: 22rpx 24rpx; background: #fff; border-radius: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06); }
|
||
.fi { display: flex; align-items: center; min-height: 88rpx; border-bottom: 1rpx solid #F4F4F4; }
|
||
.fk { width: 160rpx; font-size: 26rpx; color: #666; }
|
||
.fv { flex: 1; height: 88rpx; font-size: 28rpx; color: #222; }
|
||
.block-title { margin-top: 20rpx; font-size: 26rpx; font-weight: 700; color: #1F1F1F; }
|
||
.cats { display: flex; flex-wrap: wrap; padding-top: 12rpx; }
|
||
.cat { padding: 0 20rpx; line-height: 56rpx; margin: 0 12rpx 12rpx 0; border-radius: 28rpx; background: #F5F5F5; }
|
||
.cat.on { background: #FFF3E6; }
|
||
.cat-txt { font-size: 24rpx; color: #666; }
|
||
.cat.on .cat-txt { color: #E36B0C; font-weight: 600; }
|
||
.hint { margin-top: 14rpx; font-size: 20rpx; color: #BDBDBD; line-height: 30rpx; }
|
||
.submit { height: 92rpx; margin-top: 26rpx; display: flex; align-items: center; justify-content: center; border-radius: 46rpx; color: #fff; font-size: 30rpx; font-weight: 600; background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%); }
|
||
.submit.disabled { opacity: 0.7; }
|
||
.li { display: flex; justify-content: space-between; padding: 14rpx 0; border-bottom: 1rpx solid #F4F4F4; }
|
||
.k { font-size: 26rpx; color: #666; }
|
||
.v { font-size: 26rpx; color: #333; }
|
||
.go { margin-top: 24rpx; height: 84rpx; display: flex; align-items: center; justify-content: center; border-radius: 42rpx; background: #FFF3E6; color: #E36B0C; font-size: 28rpx; font-weight: 600; }
|
||
</style>
|
||
|