- 安全校验提示:优化 AccountSecurity 与 MasterSecurity 密码错误提示,区分登录密码与支付密码,并增加剩余可重试次数提示 - 接口响应对齐:优化 Auth、MasterAuth、Security、Sms 控制器在短信验证码发送与密码校验时的异常处理与返回格式 - 腾讯云短信SDK:优化 SmsSingleSender::sendWithParam 方法入参默认值 - 双端小程序:优化用户端与师傅端登录页及账号安全中心的密码修改与找回交互逻辑
710 行
30 KiB
Vue
710 行
30 KiB
Vue
<template>
|
||
<view class="page">
|
||
<YjyfNavBar theme="white" :title="setupFromPayment ? '设置支付密码' : mode === 'cert' ? '企业资质认证' : '账号安全'" :border="true" :showBack="mode === 'cert' || setupFromPayment ? true : null" :customBack="mode === 'cert' || setupFromPayment" @back="handleBack" />
|
||
|
||
<template v-if="mode !== 'cert' && !setupFromPayment">
|
||
<view v-if="!loaded" class="loading-box">
|
||
<text class="loading-txt">加载安全信息中...</text>
|
||
</view>
|
||
<view v-else class="security-body">
|
||
<!-- 安全状态概览 -->
|
||
<view class="hero-card">
|
||
<image class="hero-ico" :src="isAccountSafe ? '/static/icons/shield-green.svg' : '/static/icons/info-orange.svg'" mode="aspectFit" />
|
||
<view class="hero-info">
|
||
<text class="hero-title">{{ isAccountSafe ? '账号安全保护中' : '建议完善支付密码' }}</text>
|
||
<text class="hero-sub">绑定手机:{{ status.mobile || '未绑定' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 账号与资质 -->
|
||
<view class="card">
|
||
<view class="card-head">
|
||
<text class="card-title">账号与认证</text>
|
||
</view>
|
||
<view class="row">
|
||
<text class="row-label">绑定手机号</text>
|
||
<view class="row-right">
|
||
<text class="row-val">{{ status.mobile || '-' }}</text>
|
||
<text v-if="status.mobile" class="tag tag-success">已绑定</text>
|
||
</view>
|
||
</view>
|
||
<view class="row clickable-hover" @tap="openCert">
|
||
<text class="row-label">企业资质认证</text>
|
||
<view class="row-right">
|
||
<text class="tag" :class="certTagClass">{{ certText }}</text>
|
||
<image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 安全凭证管理 -->
|
||
<view class="card">
|
||
<view class="card-head">
|
||
<text class="card-title">安全凭证</text>
|
||
</view>
|
||
<view class="row clickable-hover" @tap="openPassword('login')">
|
||
<view class="row-left">
|
||
<text class="row-label">登录密码</text>
|
||
<text class="row-desc">用于 H5 网页端手机号密码登录</text>
|
||
</view>
|
||
<view class="row-right">
|
||
<text class="row-val" :class="{ unset: !status.has_login_password }">{{ status.has_login_password ? '已设置' : '未设置' }}</text>
|
||
<image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<view class="row clickable-hover" @tap="openPassword('payment')">
|
||
<view class="row-left">
|
||
<text class="row-label">支付密码</text>
|
||
<text class="row-desc">用于账户余额支付安全验证</text>
|
||
</view>
|
||
<view class="row-right">
|
||
<text class="row-val" :class="{ unset: !status.has_payment_password }">{{ status.has_payment_password ? '已设置' : '未设置' }}</text>
|
||
<image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="logout clickable-hover" @tap="logout">
|
||
<text>退出登录</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<!-- 企业资质认证 -->
|
||
<view v-else-if="mode === 'cert'" class="cert-page">
|
||
<view class="cert-accent"></view>
|
||
<view class="cert-card">
|
||
<view class="cert-notice">为保障账号和交易安全,请上传真实有效的营业执照进行企业资质认证。<text>企业信息仅用于资质审核。</text></view>
|
||
<view class="cert-content">
|
||
<view class="cert-heading"><text class="required">*</text>上传营业执照照片</view>
|
||
<view class="cert-description">上传后将自动识别企业信息,请核对识别结果。若识别有误或识别失败,可手动修改;请确保照片清晰完整。</view>
|
||
<text v-if="cert && cert.verify_status === 'reject'" class="reject">审核未通过:{{ cert.audit_msg }}</text>
|
||
<view class="upload" @tap="chooseLicense">
|
||
<image v-if="imagePreview" :src="imagePreview" mode="aspectFit" class="license" />
|
||
<image v-else src="/static/icons/enterprise-license.svg" mode="aspectFit" class="license-illustration" />
|
||
<text>{{ busy ? '处理中...' : licenseImage ? '重新上传营业执照' : '上传营业执照' }}</text>
|
||
</view>
|
||
<view v-if="licenseImage" class="cert-fields">
|
||
<view class="field"><text>企业名称</text><input v-model="companyName" placeholder="请输入企业名称" /></view>
|
||
<view class="field"><text>营业执照号码</text><input v-model="licenseNo" placeholder="请输入营业执照号码" maxlength="18" /></view>
|
||
<view class="field"><text>法人姓名</text><input v-model="legalPerson" placeholder="请输入法人姓名(选填)" /></view>
|
||
<button class="primary" :disabled="busy" @tap="submitCert">{{ busy ? '提交中...' : '提交审核' }}</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 登录密码 / 支付密码设置与修改底部弹窗 -->
|
||
<view v-if="mode && mode !== 'cert'" class="mask" @tap="cancelSheet">
|
||
<view class="sheet" @tap.stop>
|
||
<view class="sheet-handle"></view>
|
||
<view class="sheet-head">
|
||
<view class="sheet-head-meta">
|
||
<text class="title">{{ sheetTitle }}</text>
|
||
<text class="sheet-sub">{{ sheetDesc }}</text>
|
||
</view>
|
||
<view class="sheet-close-btn clickable-hover" @tap="cancelSheet">
|
||
<image class="sheet-close-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="sheet-body">
|
||
<view v-if="hasCurrentPassword && currentVerifyMode === 'old_password'" class="field-group">
|
||
<view class="field-label-row">
|
||
<text class="field-label">{{ isPaymentMode ? '原支付密码' : '原登录密码' }}</text>
|
||
</view>
|
||
<view class="input-box" :class="{ 'is-error': !!oldPasswordError }">
|
||
<image class="input-prefix-ico" src="/static/icons/login-lock.svg" mode="aspectFit" />
|
||
<input
|
||
v-if="isPaymentMode"
|
||
v-model="oldPassword"
|
||
class="input-field"
|
||
type="number"
|
||
:password="!showOldPwd"
|
||
maxlength="6"
|
||
placeholder="请输入原6位数字支付密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="oldPasswordError = ''; verifyLocked = false"
|
||
/>
|
||
<input
|
||
v-else
|
||
v-model="oldPassword"
|
||
class="input-field"
|
||
:password="!showOldPwd"
|
||
maxlength="30"
|
||
placeholder="请输入当前登录密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="oldPasswordError = ''; verifyLocked = false"
|
||
/>
|
||
<view class="eye-btn clickable-hover" @tap="showOldPwd = !showOldPwd">
|
||
<image class="eye-ico" :src="showOldPwd ? '/static/icons/login-eye-open.svg' : '/static/icons/login-eye-close.svg'" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<text v-if="oldPasswordError" class="field-error">{{ oldPasswordError }}</text>
|
||
</view>
|
||
|
||
<view class="field-group">
|
||
<view class="field-label-row">
|
||
<text class="field-label">{{ isPaymentMode ? '新支付密码' : '新登录密码' }}</text>
|
||
<text class="field-rule">{{ isPaymentMode ? '6位纯数字' : '6至30位非空字符' }}</text>
|
||
</view>
|
||
<view class="input-box" :class="{ 'is-error': !!newPasswordError }">
|
||
<image class="input-prefix-ico" src="/static/icons/login-lock.svg" mode="aspectFit" />
|
||
<input
|
||
v-if="isPaymentMode"
|
||
v-model="newPassword"
|
||
class="input-field"
|
||
type="number"
|
||
:password="!showNewPwd"
|
||
maxlength="6"
|
||
placeholder="请输入6位数字支付密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="newPasswordError = ''; confirmPasswordError = ''"
|
||
/>
|
||
<input
|
||
v-else
|
||
v-model="newPassword"
|
||
class="input-field"
|
||
:password="!showNewPwd"
|
||
maxlength="30"
|
||
placeholder="请设置新登录密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="newPasswordError = ''; confirmPasswordError = ''"
|
||
/>
|
||
<view class="eye-btn clickable-hover" @tap="showNewPwd = !showNewPwd">
|
||
<image class="eye-ico" :src="showNewPwd ? '/static/icons/login-eye-open.svg' : '/static/icons/login-eye-close.svg'" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<text v-if="newPasswordError" class="field-error">{{ newPasswordError }}</text>
|
||
</view>
|
||
|
||
<view class="field-group">
|
||
<view class="field-label-row">
|
||
<text class="field-label">{{ isPaymentMode ? '确认支付密码' : '确认新密码' }}</text>
|
||
</view>
|
||
<view class="input-box" :class="{ 'is-error': passwordMismatch || !!confirmPasswordError }">
|
||
<image class="input-prefix-ico" src="/static/icons/login-lock.svg" mode="aspectFit" />
|
||
<input
|
||
v-if="isPaymentMode"
|
||
v-model="confirmPassword"
|
||
class="input-field"
|
||
type="number"
|
||
:password="!showConfirmPwd"
|
||
maxlength="6"
|
||
placeholder="请再次输入6位数字支付密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="confirmPasswordError = ''"
|
||
/>
|
||
<input
|
||
v-else
|
||
v-model="confirmPassword"
|
||
class="input-field"
|
||
:password="!showConfirmPwd"
|
||
maxlength="30"
|
||
placeholder="请再次输入新登录密码"
|
||
placeholder-class="field-placeholder"
|
||
@input="confirmPasswordError = ''"
|
||
/>
|
||
<view class="eye-btn clickable-hover" @tap="showConfirmPwd = !showConfirmPwd">
|
||
<image class="eye-ico" :src="showConfirmPwd ? '/static/icons/login-eye-open.svg' : '/static/icons/login-eye-close.svg'" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<text v-if="confirmPasswordError || passwordMismatch" class="field-error">{{ confirmPasswordError || '两次输入的密码不一致' }}</text>
|
||
</view>
|
||
|
||
<template v-if="hasCurrentPassword && currentVerifyMode === 'sms'">
|
||
<view class="field-group">
|
||
<view class="field-label-row">
|
||
<text class="field-label">短信验证码</text>
|
||
<text class="field-rule">将发送至 {{ status.mobile || '绑定手机号' }}</text>
|
||
</view>
|
||
<view class="input-box sms-box" :class="{ 'is-error': !!smsCodeError }">
|
||
<input
|
||
v-model="smsCode"
|
||
class="input-field"
|
||
type="number"
|
||
maxlength="6"
|
||
placeholder="请输入6位短信验证码"
|
||
placeholder-class="field-placeholder"
|
||
@input="smsCodeError = ''"
|
||
/>
|
||
<view class="sms-divider"></view>
|
||
<button class="inline-sms-btn clickable-hover" :disabled="sendingSms || smsCountdown > 0" @tap="sendPwdSms">
|
||
{{ smsCountdown > 0 ? smsCountdown + 's 后重发' : (sendingSms ? '发送中...' : '获取验证码') }}
|
||
</button>
|
||
</view>
|
||
<text v-if="smsCodeError" class="field-error">{{ smsCodeError }}</text>
|
||
</view>
|
||
</template>
|
||
|
||
<button class="primary sheet-submit clickable-hover" :disabled="busy" @tap="savePassword">
|
||
{{ busy ? '提交中...' : (hasCurrentPassword ? '确认修改' : '确认设置') }}
|
||
</button>
|
||
|
||
<view v-if="hasCurrentPassword" class="switch-row">
|
||
<text
|
||
class="switch-link clickable-hover"
|
||
:class="{ 'is-highlight': verifyLocked && currentVerifyMode === 'old_password' }"
|
||
@tap="switchVerifyMode(currentVerifyMode === 'old_password' ? 'sms' : 'old_password')"
|
||
>{{ currentVerifyMode === 'old_password' ? (isPaymentMode ? '忘记原支付密码?改用短信验证码' : '忘记原密码?改用短信验证码') : (isPaymentMode ? '记得原支付密码?改用原密码验证' : '记得原密码?改用原密码验证') }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<script setup>
|
||
import { ref, computed } from 'vue';
|
||
import { onLoad, onShow, onBackPress, onUnload } from '@dcloudio/uni-app';
|
||
import YjyfNavBar from '@/components/YjyfNavBar.vue';
|
||
import api from '@/utils/api.js';
|
||
import { clearAuth, toLogin } from '@/utils/request.js';
|
||
import { finishPaymentSetup } from '@/utils/payment-setup.mjs';
|
||
|
||
const loaded = ref(false), busy = ref(false), mode = ref('');
|
||
const returnOrder = ref('');
|
||
const setupFromPayment = ref(false);
|
||
const initialOpen = ref('');
|
||
let setupOpened = false;
|
||
|
||
const status = ref({}), oldPassword = ref(''), newPassword = ref(''), confirmPassword = ref('');
|
||
const showOldPwd = ref(false), showNewPwd = ref(false), showConfirmPwd = ref(false);
|
||
const loginVerifyMode = ref('old_password'), paymentVerifyMode = ref('old_password');
|
||
const smsCode = ref(''), smsCountdown = ref(0), sendingSms = ref(false);
|
||
const oldPasswordError = ref(''), newPasswordError = ref(''), confirmPasswordError = ref(''), smsCodeError = ref(''), verifyLocked = ref(false);
|
||
let smsTimer = null;
|
||
|
||
const companyName = ref(''), licenseNo = ref(''), legalPerson = ref(''), licenseImage = ref(''), imagePreview = ref('');
|
||
|
||
const cert = computed(() => status.value.enterprise_cert || null);
|
||
const certText = computed(() => cert.value ? ({ pending: '审核中', pass: '已认证', reject: '未通过,可重提' }[cert.value.verify_status] || '') : '未认证');
|
||
const certTagClass = computed(() => {
|
||
const st = cert.value && cert.value.verify_status;
|
||
if (st === 'pass') return 'tag-success';
|
||
if (st === 'pending') return 'tag-warning';
|
||
if (st === 'reject') return 'tag-danger';
|
||
return 'tag-muted';
|
||
});
|
||
const isAccountSafe = computed(() => !!(status.value.mobile && status.value.has_payment_password));
|
||
const isPaymentMode = computed(() => mode.value === 'payment');
|
||
const hasCurrentPassword = computed(() => isPaymentMode.value ? !!status.value.has_payment_password : !!status.value.has_login_password);
|
||
const currentVerifyMode = computed(() => isPaymentMode.value ? paymentVerifyMode.value : loginVerifyMode.value);
|
||
const sheetTitle = computed(() => {
|
||
if (isPaymentMode.value) return status.value.has_payment_password ? '修改支付密码' : '设置支付密码';
|
||
return status.value.has_login_password ? '修改登录密码' : '设置登录密码';
|
||
});
|
||
const sheetDesc = computed(() => isPaymentMode.value ? '用于账户余额支付安全验证' : '用于 H5 网页端手机号密码登录');
|
||
const passwordMismatch = computed(() => confirmPassword.value.length > 0 && newPassword.value !== confirmPassword.value);
|
||
|
||
async function load() { try { status.value = await api.securityStatus(); loaded.value = true; } catch (e) {} }
|
||
function clearSmsTimer() { if (smsTimer) { clearInterval(smsTimer); smsTimer = null; } }
|
||
function startSmsCountdown(sec = 60) {
|
||
clearSmsTimer();
|
||
smsCountdown.value = sec;
|
||
smsTimer = setInterval(() => {
|
||
if (smsCountdown.value <= 1) { smsCountdown.value = 0; clearSmsTimer(); }
|
||
else { smsCountdown.value -= 1; }
|
||
}, 1000);
|
||
}
|
||
function clearFieldErrors() {
|
||
oldPasswordError.value = '';
|
||
newPasswordError.value = '';
|
||
confirmPasswordError.value = '';
|
||
smsCodeError.value = '';
|
||
}
|
||
function resetPwdFields() {
|
||
oldPassword.value = '';
|
||
newPassword.value = '';
|
||
confirmPassword.value = '';
|
||
smsCode.value = '';
|
||
showOldPwd.value = false;
|
||
showNewPwd.value = false;
|
||
showConfirmPwd.value = false;
|
||
verifyLocked.value = false;
|
||
clearFieldErrors();
|
||
}
|
||
function switchVerifyMode(nextMode) {
|
||
if (isPaymentMode.value) paymentVerifyMode.value = nextMode;
|
||
else loginVerifyMode.value = nextMode;
|
||
oldPassword.value = '';
|
||
smsCode.value = '';
|
||
verifyLocked.value = false;
|
||
clearFieldErrors();
|
||
}
|
||
async function sendPwdSms() {
|
||
if (sendingSms.value || smsCountdown.value > 0) return;
|
||
sendingSms.value = true;
|
||
try {
|
||
const res = isPaymentMode.value ? await api.sendPaymentPasswordSms() : await api.sendPasswordSms();
|
||
uni.showToast({ title: '验证码已发送', icon: 'none' });
|
||
startSmsCountdown((res && res.cooldown) || 60);
|
||
} catch (e) {} finally { sendingSms.value = false; }
|
||
}
|
||
function close() {
|
||
if (busy.value) return;
|
||
mode.value = '';
|
||
loginVerifyMode.value = 'old_password';
|
||
paymentVerifyMode.value = 'old_password';
|
||
resetPwdFields();
|
||
}
|
||
function openPassword(which) {
|
||
loginVerifyMode.value = 'old_password';
|
||
paymentVerifyMode.value = 'old_password';
|
||
resetPwdFields();
|
||
mode.value = which;
|
||
}
|
||
function openCert() {
|
||
if (cert.value && cert.value.verify_status !== 'reject') { uni.showToast({ title: certText.value, icon: 'none' }); return; }
|
||
if (cert.value) { companyName.value = cert.value.company_name; licenseNo.value = cert.value.license_no; legalPerson.value = cert.value.legal_person; }
|
||
mode.value = 'cert';
|
||
}
|
||
function applyServerFieldError(e) {
|
||
if (e && e.code === 401) {
|
||
uni.showToast({ title: '登录已失效,请重新登录', icon: 'none' });
|
||
setTimeout(() => toLogin(), 800);
|
||
return;
|
||
}
|
||
const msg = String((e && e.message) || '操作失败,请稍后重试');
|
||
if (/验证码/.test(msg) && !/改用短信验证码/.test(msg)) {
|
||
smsCodeError.value = msg;
|
||
return;
|
||
}
|
||
if (/原登录密码|原支付密码|原密码|密码不正确|次数过多|15分钟|旧密码/.test(msg)) {
|
||
oldPasswordError.value = msg;
|
||
if (/15分钟|次数过多/.test(msg)) verifyLocked.value = true;
|
||
return;
|
||
}
|
||
if (/6位|6至30位|非空字符|新密码/.test(msg)) {
|
||
newPasswordError.value = msg;
|
||
return;
|
||
}
|
||
uni.showToast({ title: msg, icon: 'none' });
|
||
}
|
||
function validPassword() {
|
||
clearFieldErrors();
|
||
let ok = true;
|
||
if (hasCurrentPassword.value) {
|
||
if (currentVerifyMode.value === 'sms') {
|
||
if (!/^\d{4,6}$/.test(smsCode.value.trim())) {
|
||
smsCodeError.value = '请输入有效的6位短信验证码';
|
||
ok = false;
|
||
}
|
||
} else if (isPaymentMode.value && !/^\d{6}$/.test(oldPassword.value)) {
|
||
oldPasswordError.value = '请输入原6位数字支付密码';
|
||
ok = false;
|
||
} else if (!isPaymentMode.value && !oldPassword.value) {
|
||
oldPasswordError.value = '请输入原登录密码';
|
||
ok = false;
|
||
}
|
||
}
|
||
if (isPaymentMode.value && !/^\d{6}$/.test(newPassword.value)) {
|
||
newPasswordError.value = '新支付密码须为6位纯数字';
|
||
ok = false;
|
||
} else if (!isPaymentMode.value && !/^\S{6,30}$/.test(newPassword.value)) {
|
||
newPasswordError.value = '新登录密码须为6至30位非空字符';
|
||
ok = false;
|
||
}
|
||
if (!confirmPassword.value) {
|
||
confirmPasswordError.value = isPaymentMode.value ? '请再次输入新支付密码' : '请再次输入新登录密码';
|
||
ok = false;
|
||
} else if (newPassword.value !== confirmPassword.value) {
|
||
confirmPasswordError.value = '两次输入的新密码不一致';
|
||
ok = false;
|
||
}
|
||
return ok;
|
||
}
|
||
async function savePassword() {
|
||
if (busy.value || !validPassword()) return;
|
||
busy.value = true;
|
||
try {
|
||
if (!isPaymentMode.value) {
|
||
const payload = currentVerifyMode.value === 'sms' && hasCurrentPassword.value
|
||
? { verify_mode: 'sms', sms_code: smsCode.value.trim(), new_password: newPassword.value }
|
||
: { verify_mode: 'old_password', old_password: oldPassword.value, new_password: newPassword.value };
|
||
await api.changeLoginPassword(payload, { silent: true });
|
||
clearAuth(); uni.showToast({ title: '密码已更新,请重新登录', icon: 'none' });
|
||
setTimeout(() => uni.reLaunch({ url: '/pages/login/login' }), 700); return;
|
||
}
|
||
const firstSetup = !status.value.has_payment_password;
|
||
if (!firstSetup) {
|
||
const payPayload = currentVerifyMode.value === 'sms'
|
||
? { verify_mode: 'sms', sms_code: smsCode.value.trim(), new_password: newPassword.value }
|
||
: { verify_mode: 'old_password', old_password: oldPassword.value, new_password: newPassword.value };
|
||
await api.changePaymentPassword(payPayload, { silent: true });
|
||
}
|
||
else await api.setPaymentPassword({ new_password: newPassword.value }, { silent: true });
|
||
busy.value = false; close(); uni.showToast({ title: firstSetup ? '设置成功' : '修改成功', icon: 'success' });
|
||
if (setupFromPayment.value && firstSetup) {
|
||
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
|
||
} else await load();
|
||
} catch (e) {
|
||
applyServerFieldError(e);
|
||
} finally { busy.value = false; }
|
||
}
|
||
function chooseLicense() { if (busy.value) return; uni.chooseImage({ count: 1, sizeType: ['compressed'], success: async res => {
|
||
busy.value = true; try {
|
||
const uploaded = await api.upload(res.tempFilePaths[0], 'cert'); licenseImage.value = uploaded.url; imagePreview.value = uploaded.fullurl || res.tempFilePaths[0];
|
||
companyName.value = ''; licenseNo.value = ''; legalPerson.value = '';
|
||
try { const recognized = await api.recognizeEnterpriseLicense({ license_image: uploaded.url }); companyName.value = recognized.company_name; licenseNo.value = recognized.license_no; legalPerson.value = recognized.legal_person; }
|
||
catch (e) { /* Recognition errors are displayed by the request layer; manual entry remains available. */ }
|
||
} catch (e) {} finally { busy.value = false; }
|
||
} }); }
|
||
async function submitCert() {
|
||
if (busy.value) return;
|
||
if (!companyName.value.trim() || !licenseNo.value.trim() || !licenseImage.value) { uni.showToast({ title: '请填写企业信息并上传营业执照', icon: 'none' }); return; }
|
||
busy.value = true;
|
||
try { await api.submitEnterpriseCert({ company_name: companyName.value.trim(), license_no: licenseNo.value.trim(), legal_person: legalPerson.value.trim(), license_image: licenseImage.value }); busy.value = false; close(); await load(); uni.showToast({ title: '提交成功' }); } catch (e) {} finally { busy.value = false; }
|
||
}
|
||
function handleBack() { if (mode.value === 'cert') { close(); return; } if (!busy.value) leaveSetup(); }
|
||
function cancelSheet() { if (busy.value) return; if (setupFromPayment.value) leaveSetup(); else close(); }
|
||
function logout() { uni.showModal({ title: '退出登录', content: '确认退出当前登录账号?', confirmColor: '#F0710D', success: (result) => { if (result.confirm) { clearAuth(); uni.reLaunch({ url: '/pages/login/login' }); } } }); }
|
||
async function leaveSetup() {
|
||
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
|
||
}
|
||
onLoad((options) => {
|
||
setupFromPayment.value = !!(options && options.setupPayment === '1');
|
||
initialOpen.value = (options && options.open) ? String(options.open) : '';
|
||
const id = String((options && options.returnOrder) || '');
|
||
if (setupFromPayment.value && /^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id))) returnOrder.value = id;
|
||
});
|
||
onBackPress(() => {
|
||
if (mode.value === 'cert') { if (!busy.value) close(); return true; }
|
||
if (!setupFromPayment.value) return false;
|
||
if (!busy.value) leaveSetup();
|
||
return true;
|
||
});
|
||
onShow(async () => {
|
||
await load();
|
||
if (!loaded.value || setupOpened) return;
|
||
if (setupFromPayment.value) {
|
||
setupOpened = true;
|
||
if (status.value.has_payment_password) await leaveSetup();
|
||
else openPassword('payment');
|
||
} else if (initialOpen.value === 'payment') {
|
||
setupOpened = true;
|
||
openPassword('payment');
|
||
if (status.value.has_payment_password) switchVerifyMode('sms');
|
||
}
|
||
});
|
||
onUnload(() => {
|
||
clearSmsTimer();
|
||
});
|
||
</script>
|
||
<style lang="scss" scoped>
|
||
@import '@/uni.scss';
|
||
.page { min-height: 100vh; background: $yjyf-bg-page; padding-bottom: calc(48rpx + env(safe-area-inset-bottom)); }
|
||
.loading-box { padding: 120rpx 0; text-align: center; }
|
||
.loading-txt { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
|
||
.security-body { padding-top: 24rpx; }
|
||
|
||
.hero-card {
|
||
margin: 0 $yjyf-space-md 24rpx;
|
||
padding: 28rpx 32rpx;
|
||
background: $yjyf-bg-card;
|
||
border-radius: $yjyf-radius-md;
|
||
box-shadow: $yjyf-shadow-card;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 20rpx;
|
||
}
|
||
.hero-ico { width: 52rpx; height: 52rpx; flex-shrink: 0; }
|
||
.hero-info { display: flex; flex-direction: column; gap: 6rpx; min-width: 0; }
|
||
.hero-title { font-size: $yjyf-font-title; font-weight: 700; color: $yjyf-text-main; }
|
||
.hero-sub { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
|
||
|
||
.card {
|
||
margin: 0 $yjyf-space-md 24rpx;
|
||
padding: 0 32rpx;
|
||
background: $yjyf-bg-card;
|
||
border-radius: $yjyf-radius-md;
|
||
box-shadow: $yjyf-shadow-card;
|
||
}
|
||
.card-head { padding: 26rpx 0 12rpx; }
|
||
.card-title { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; font-weight: 600; }
|
||
|
||
.row {
|
||
min-height: 108rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16rpx;
|
||
border-top: 1rpx solid $yjyf-border-color;
|
||
}
|
||
.row-left { display: flex; flex-direction: column; gap: 4rpx; min-width: 0; }
|
||
.row-label { font-size: $yjyf-font-body; color: $yjyf-text-main; }
|
||
.row-desc { font-size: $yjyf-font-micro; color: $yjyf-text-muted; }
|
||
.row-right { display: flex; align-items: center; gap: 12rpx; flex-shrink: 0; }
|
||
.row-val { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
|
||
.row-val.unset { color: $yjyf-warning; font-weight: 600; }
|
||
.arrow { width: 24rpx; height: 24rpx; }
|
||
|
||
.tag {
|
||
padding: 6rpx 16rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 600;
|
||
line-height: 1.2;
|
||
}
|
||
.tag-success { background: rgba(47, 168, 79, 0.1); color: $yjyf-success; }
|
||
.tag-warning { background: rgba(249, 141, 37, 0.12); color: $yjyf-warning; }
|
||
.tag-danger { background: rgba(232, 51, 27, 0.1); color: $yjyf-danger; }
|
||
.tag-muted { background: $yjyf-bg-page; color: $yjyf-text-secondary; }
|
||
|
||
.logout {
|
||
margin: 40rpx $yjyf-space-md 0;
|
||
height: 92rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-bg-card;
|
||
box-shadow: $yjyf-shadow-card;
|
||
color: $yjyf-danger;
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.cert-page { position: relative; padding: 64rpx 24rpx 48rpx; }
|
||
.cert-accent { position: absolute; top: 0; left: 0; right: 0; height: 200rpx; background: $yjyf-gradient-primary; }
|
||
.cert-card { position: relative; overflow: hidden; border-radius: $yjyf-radius-md; background: $yjyf-bg-card; box-shadow: $yjyf-shadow-card; }
|
||
.cert-notice { padding: 28rpx; background: $yjyf-primary-bg; color: $yjyf-text-regular; font-size: 27rpx; line-height: 1.7; }
|
||
.cert-notice text { color: $yjyf-danger; }
|
||
.cert-content { padding: 32rpx 28rpx 40rpx; }
|
||
.cert-heading { color: $yjyf-text-main; font-size: $yjyf-font-title; font-weight: 600; }
|
||
.required, .reject { color: $yjyf-danger; }
|
||
.cert-description { margin-top: 16rpx; color: $yjyf-text-regular; font-size: 27rpx; line-height: 1.65; }
|
||
.reject { display: block; margin-top: 20rpx; font-size: 26rpx; }
|
||
.upload { width: 300rpx; min-height: 260rpx; box-sizing: border-box; margin: 32rpx auto 0; padding: 24rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16rpx; color: $yjyf-primary; background: $yjyf-primary-bg; border: 2rpx dashed $yjyf-primary; border-radius: $yjyf-radius-sm; font-size: $yjyf-font-body; font-weight: 600; }
|
||
.license-illustration { width: 200rpx; height: 140rpx; }
|
||
.license { width: 240rpx; height: 160rpx; }
|
||
.cert-fields { margin-top: 32rpx; }
|
||
.cert-fields .primary { margin-top: 32rpx; }
|
||
.field { display: flex; align-items: center; min-height: 92rpx; border-bottom: 1rpx solid $yjyf-border-color; color: $yjyf-text-regular; font-size: 27rpx; }
|
||
.field text { width: 200rpx; flex-shrink: 0; }
|
||
.field input { flex: 1; min-width: 0; font-size: 27rpx; }
|
||
|
||
.mask { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, 0.5); display: flex; align-items: flex-end; }
|
||
.sheet {
|
||
width: 100%;
|
||
max-height: 90vh;
|
||
overflow-y: auto;
|
||
box-sizing: border-box;
|
||
padding: 16rpx 0 calc(36rpx + env(safe-area-inset-bottom));
|
||
border-radius: 36rpx 36rpx 0 0;
|
||
background: $yjyf-bg-card;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
.sheet-handle {
|
||
width: 72rpx;
|
||
height: 8rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: #E5E6EB;
|
||
margin: 0 auto 20rpx;
|
||
}
|
||
.sheet-head {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: flex-start;
|
||
padding: 0 32rpx 24rpx;
|
||
border-bottom: 1rpx solid $yjyf-border-color;
|
||
}
|
||
.sheet-head-meta { display: flex; flex-direction: column; gap: 6rpx; }
|
||
.title { color: $yjyf-text-main; font-size: 36rpx; font-weight: 700; line-height: 1.25; }
|
||
.sheet-sub { color: $yjyf-text-secondary; font-size: $yjyf-font-sub; }
|
||
.sheet-close-btn {
|
||
width: 60rpx;
|
||
height: 60rpx;
|
||
border-radius: 50%;
|
||
background: $yjyf-bg-page;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
.sheet-close-ico { width: 26rpx; height: 26rpx; opacity: 0.65; }
|
||
|
||
.sheet-body {
|
||
padding: 28rpx 32rpx 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 24rpx;
|
||
}
|
||
|
||
.field-group { display: flex; flex-direction: column; gap: 10rpx; }
|
||
.field-label-row { display: flex; align-items: center; justify-content: space-between; padding: 0 4rpx; }
|
||
.field-label { font-size: 26rpx; font-weight: 600; color: $yjyf-text-main; }
|
||
.field-rule { font-size: $yjyf-font-micro; color: $yjyf-text-secondary; }
|
||
.field-error { font-size: $yjyf-font-micro; color: $yjyf-danger; padding-left: 4rpx; }
|
||
|
||
.input-box {
|
||
height: 92rpx;
|
||
box-sizing: border-box;
|
||
padding: 0 18rpx 0 24rpx;
|
||
border-radius: 16rpx;
|
||
background: #F7F8FA;
|
||
border: 1.5rpx solid #EBEDF0;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 14rpx;
|
||
transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
|
||
}
|
||
.input-box:focus-within {
|
||
background: $yjyf-bg-card;
|
||
border-color: $yjyf-primary;
|
||
box-shadow: 0 0 0 4rpx rgba(240, 113, 13, 0.1);
|
||
}
|
||
.input-box.is-error {
|
||
background: #FFF8F7;
|
||
border-color: $yjyf-danger;
|
||
}
|
||
.input-prefix-ico { width: 34rpx; height: 34rpx; flex-shrink: 0; opacity: 0.75; }
|
||
.input-field { flex: 1; min-width: 0; height: 92rpx; font-size: $yjyf-font-body; color: $yjyf-text-main; }
|
||
.field-placeholder { font-size: 26rpx; color: $yjyf-text-muted; }
|
||
.eye-btn { width: 64rpx; height: 64rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
||
.eye-ico { width: 34rpx; height: 34rpx; }
|
||
|
||
.sms-box { padding-right: 8rpx; }
|
||
.sms-divider { width: 1.5rpx; height: 36rpx; background: #E5E6EB; flex-shrink: 0; }
|
||
.inline-sms-btn {
|
||
flex-shrink: 0;
|
||
height: 76rpx;
|
||
padding: 0 20rpx;
|
||
margin: 0;
|
||
background: transparent;
|
||
border: none;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: $yjyf-primary;
|
||
font-size: 26rpx;
|
||
font-weight: 700;
|
||
}
|
||
.inline-sms-btn::after { border: none; }
|
||
.inline-sms-btn[disabled] { color: $yjyf-text-muted; font-weight: 500; }
|
||
|
||
.primary {
|
||
width: 100%;
|
||
height: 92rpx;
|
||
margin: 8rpx 0 0;
|
||
padding: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-gradient-primary;
|
||
box-shadow: $yjyf-shadow-button;
|
||
color: $yjyf-text-inverse;
|
||
font-size: 30rpx;
|
||
font-weight: 700;
|
||
border: none;
|
||
}
|
||
.primary::after { border: none; }
|
||
.primary[disabled] { opacity: 0.65; }
|
||
.sheet-submit { margin-top: 8rpx; }
|
||
|
||
.switch-row { display: flex; justify-content: center; padding-top: 2rpx; }
|
||
.switch-link { padding: 12rpx 24rpx; font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
|
||
.switch-link.is-highlight { color: $yjyf-primary; font-weight: 600; }
|
||
</style>
|