文件
yjyf/pages/login/login.vue
linda 78722b3912 feat(ui): 登录起全链路页面接通 + 逐页面验证(47 项)+ 修复订单列表越权泄漏
前端:
- 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 条件 → 泄漏全部用户订单/跨用户数据
- 改为闭包重建查询,已验证修复
2026-10-28 15:52:39 +08:00

166 行
5.9 KiB
Vue

<template>
<view class="page">
<view class="top">
<view class="deco d1"></view>
<view class="deco d2"></view>
<text class="brand">优匠优服</text>
<text class="slogan">专业师傅 · 上门到家</text>
</view>
<view class="card">
<view class="role">
<view class="role-item" :class="{ on: role === 'user' }" @tap="role = 'user'">
<text class="role-name">我是业主</text>
<text class="role-desc">下单找师傅</text>
</view>
<view class="role-item" :class="{ on: role === 'master' }" @tap="role = 'master'">
<text class="role-name">我是师傅</text>
<text class="role-desc">接单赚收入</text>
</view>
</view>
<view class="field">
<text class="label">手机号</text>
<input class="input" v-model="mobile" type="number" maxlength="11" placeholder="请输入手机号" placeholder-class="ph" />
</view>
<view class="field">
<text class="label">验证码</text>
<input class="input" v-model="code" type="number" maxlength="6" placeholder="联调验证码 123456" placeholder-class="ph" />
<view class="code-btn" :class="{ disabled: counting }" @tap="sendCode">{{ codeText }}</view>
</view>
<view class="submit" :class="{ disabled: loading }" @tap="doLogin">{{ loading ? '登录中...' : '登录 / 注册' }}</view>
<text class="tip">未注册的手机号将自动创建账号</text>
</view>
<text class="agree">登录即代表同意《用户服务协议》与《隐私政策》</text>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import api from '@/utils/api.js';
import { setToken, setUser } from '@/utils/request.js';
const role = ref('user');
const mobile = ref('');
const code = ref('');
const loading = ref(false);
const countdown = ref(0);
let timer = null;
const counting = computed(() => countdown.value > 0);
const codeText = computed(() => (countdown.value > 0 ? countdown.value + 's' : '获取验证码'));
function toast(title) {
uni.showToast({ title: title, icon: 'none' });
}
function sendCode() {
if (counting.value) return;
if (!/^1\d{10}$/.test(mobile.value)) {
toast('请输入正确的手机号');
return;
}
countdown.value = 60;
timer = setInterval(() => {
countdown.value -= 1;
if (countdown.value <= 0) {
clearInterval(timer);
timer = null;
}
}, 1000);
toast('联调环境验证码为 123456');
}
async function doLogin() {
if (loading.value) return;
if (!/^1\d{10}$/.test(mobile.value)) {
toast('请输入正确的手机号');
return;
}
if (!code.value) {
toast('请输入验证码');
return;
}
loading.value = true;
try {
const data = await api.login({ mobile: mobile.value, code: code.value });
setToken(data.token);
setUser(data.userinfo);
toast('登录成功');
setTimeout(() => routeAfterLogin(), 500);
} catch (e) {
toast(e.message || '登录失败');
} finally {
loading.value = false;
}
}
function routeAfterLogin() {
if (role.value === 'user') {
uni.reLaunch({ url: '/YJYF/YJYF' });
return;
}
api.masterInfo().then((res) => {
if (!res.applied || res.master.verify_status !== 'pass') {
uni.redirectTo({ url: '/pages/master/apply' });
} else {
uni.redirectTo({ url: '/pages/master/hall' });
}
}).catch(() => {
uni.redirectTo({ url: '/pages/master/hall' });
});
}
</script>
<style scoped>
.page { min-height: 100vh; background: #F5F6F8; }
.top {
position: relative; height: 420rpx; padding: 120rpx 0 0 48rpx; overflow: hidden;
background: linear-gradient(160deg, #FFB85C 0%, #F98D25 46%, #ED6F0E 100%);
border-radius: 0 0 48rpx 48rpx;
}
.deco { position: absolute; border-radius: 50%; }
.d1 { width: 360rpx; height: 360rpx; right: -120rpx; top: -160rpx; background: rgba(255,255,255,0.14); }
.d2 { width: 220rpx; height: 220rpx; left: -90rpx; bottom: -80rpx; background: rgba(255,255,255,0.10); }
.brand {
position: relative; display: block; font-size: 52rpx; font-weight: 700; color: #fff;
letter-spacing: 6rpx; text-shadow: 0 3rpx 12rpx rgba(180,80,10,0.3);
}
.slogan { position: relative; display: block; margin-top: 14rpx; font-size: 26rpx; color: rgba(255,255,255,0.88); letter-spacing: 2rpx; }
.card {
position: relative; margin: -120rpx 40rpx 0; padding: 40rpx 34rpx 34rpx;
background: #fff; border-radius: 24rpx; box-shadow: 0 16rpx 40rpx rgba(226,120,26,0.16);
}
.role { display: flex; margin-bottom: 34rpx; }
.role-item {
flex: 1; padding: 22rpx 0; border-radius: 16rpx; background: #F7F7F7;
display: flex; flex-direction: column; align-items: center; border: 2rpx solid transparent;
}
.role-item.on { background: linear-gradient(135deg, #FFF8EE 0%, #FFE9D2 100%); border-color: #F9A65B; }
.role-name { font-size: 30rpx; font-weight: 600; color: #333; }
.role-item.on .role-name { color: #C4580A; }
.role-desc { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
.field { display: flex; align-items: center; height: 100rpx; margin-top: 22rpx; padding: 0 24rpx; background: #F7F7F7; border-radius: 16rpx; }
.label { width: 110rpx; font-size: 28rpx; color: #666; }
.input { flex: 1; height: 100rpx; font-size: 30rpx; color: #222; }
.ph { color: #B5B5B5; }
.code-btn {
padding: 0 20rpx; line-height: 56rpx; border-radius: 28rpx;
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%); color: #fff; font-size: 24rpx;
}
.code-btn.disabled { opacity: 0.55; }
.submit {
height: 96rpx; margin-top: 40rpx; display: flex; align-items: center; justify-content: center;
border-radius: 48rpx; background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
color: #fff; font-size: 32rpx; font-weight: 600; letter-spacing: 2rpx;
box-shadow: 0 10rpx 24rpx rgba(240,113,13,0.32);
}
.submit.disabled { opacity: 0.7; }
.tip { display: block; margin-top: 22rpx; text-align: center; font-size: 22rpx; color: #B5B5B5; }
.agree { display: block; margin-top: 48rpx; text-align: center; font-size: 20rpx; color: #BDBDBD; }
</style>