feat: 新增账号安全模块及资质校验功能

- 新增账号安全页面及支付密码验证组件
- 新增用户类型选择流程及商家资质管理
- 新增订单资质校验逻辑,师傅需满足订单证书要求
- 新增企业资质认证相关数据库表及接口
- 优化用户列表展示,区分个人与商家用户类型
这个提交包含在:
2026-11-21 15:37:01 +08:00
父节点 8a35d93a15
当前提交 b71980dd6b
共有 58 个文件被更改,包括 1515 次插入 和 169 次删除

查看文件

@@ -0,0 +1,37 @@
<template>
<view v-if="visible" class="mask">
<view class="panel">
<text class="title">请输入支付密码</text>
<input v-model="password" class="input" type="number" password maxlength="6" focus placeholder="6位支付密码" />
<view class="actions"><button class="cancel" @tap="finish('')">取消</button><button class="confirm" @tap="submit">确认</button></view>
</view>
</view>
</template>
<script setup>
import { ref, onBeforeUnmount } from 'vue';
import api from '@/utils/api.js';
import { beginPaymentSetup } from '@/utils/payment-setup.mjs';
const visible = ref(false), password = ref('');
let resolvePrompt = null;
async function open(options = {}) {
const status = await api.securityStatus();
if (!status.has_payment_password) {
const navigated = await beginPaymentSetup(uni, options.createdOrderId);
throw Object.assign(new Error(navigated ? '正在设置支付密码' : '已取消设置支付密码'), {
handledToast: navigated, cancelled: !navigated, paymentSetupNavigation: navigated,
});
}
if (resolvePrompt) return '';
password.value = ''; visible.value = true;
return new Promise(resolve => { resolvePrompt = resolve; });
}
function finish(value) { visible.value = false; password.value = ''; const resolve = resolvePrompt; resolvePrompt = null; if (resolve) resolve(value); }
function submit() { if (!/^\d{6}$/.test(password.value)) { uni.showToast({ title: '请输入6位支付密码', icon: 'none' }); return; } finish(password.value); }
onBeforeUnmount(() => finish(''));
defineExpose({ open });
</script>
<style lang="scss" scoped>
@import '@/uni.scss';
.mask { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 48rpx; background: rgba(0,0,0,.5); }
.panel { width: 100%; padding: 40rpx; border-radius: 20rpx; background: $yjyf-bg-card; }.title { display: block; text-align: center; font-size: 32rpx; font-weight: 600; color: $yjyf-text-main; }.input { margin: 30rpx 0; height: 88rpx; text-align: center; background: $yjyf-bg-page; border-radius: 12rpx; }.actions { display: flex; gap: 20rpx; }.actions button { flex: 1; font-size: 28rpx; }.cancel { color: $yjyf-text-regular; background: $yjyf-bg-page; }.confirm { color: $yjyf-bg-card; background: $yjyf-gradient-primary; }
</style>

查看文件

@@ -213,6 +213,11 @@
</view>
<!-- 客户工单特别要求 -->
<view class="qualification-row" v-if="o.qual_req">
<text>资质要求:{{ o.qual_req }}</text>
<text v-if="!o.qualification_allowed" class="qualification-warning">暂无有效认证证书</text>
<text v-if="!o.qualification_allowed" class="qualification-link" @tap.stop="goCerts">去上传证书</text>
</view>
<view class="remark-row" v-if="o.remark">
<text class="remark-tag">工单要求</text>
<text class="remark-txt">{{ o.remark }}</text>
@@ -238,9 +243,10 @@
</view>
<view class="ft-btns">
<view v-if="!o.qualification_allowed" class="qualification-disabled"><text class="btn-txt">{{ o.price_type === 'quote' ? '暂不可报价' : '暂不可接单' }}</text></view>
<view
class="quote-btn clickable-hover"
v-if="o.price_type === 'quote'"
v-else-if="o.price_type === 'quote'"
@tap="goDetail(o)"
>
<text class="btn-txt">立即报价</text>
@@ -570,6 +576,9 @@
function goSkills() {
uni.navigateTo({ url: '/pages/master/skills' });
}
function goCerts() {
uni.navigateTo({ url: '/pages/master/certs' });
}
function openGrabConfirm(o) {
if (info.value && info.value.work_status === 'off') {
@@ -889,6 +898,10 @@
</script>
<style lang="scss" scoped>
.qualification-row { display: flex; flex-wrap: wrap; gap: 12rpx; margin-top: 16rpx; color: $yjyf-text-regular; font-size: $yjyf-font-sub; }
.qualification-warning { color: $yjyf-danger; }
.qualification-link { color: $yjyf-primary; }
.qualification-disabled { padding: 14rpx 24rpx; border-radius: $yjyf-radius-pill; background: $yjyf-text-disabled; }
@import '@/uni.scss';
.hall-view {

查看文件

@@ -227,6 +227,10 @@
</view>
</view>
<view class="menu-item clickable-hover" @tap="go('/pages/mine/security')">
<view class="mi-left"><image class="mi-ico" src="/static/icons/master/menu-account-security.svg" mode="aspectFit" /><text class="mi-title">账号安全</text></view>
<view class="mi-right"><image class="mi-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
</view>
<view class="menu-item clickable-hover" @tap="openAgreementPicker">
<view class="mi-left">
<image class="mi-ico" src="/static/icons/master/menu-agreement.svg" mode="aspectFit" />
@@ -352,7 +356,7 @@
if (rejected > 0) {
return { text: `未通过 (${rejected})`, cls: 'is-danger' };
}
return { text: '认证可接资质要求订单', cls: 'is-warning' };
return { text: '上传证书展示专业资质', cls: 'is-warning' };
});
/**

查看文件

@@ -0,0 +1,34 @@
<template>
<view class="credentials">
<view class="credentials-row">
<text class="credentials-label">服务技能(师傅填写)</text>
<text class="credentials-value">{{ skillText }}</text>
</view>
<view class="credentials-row">
<text class="credentials-label">已认证证书</text>
<text class="credentials-value">{{ certText }}</text>
</view>
<text v-if="canExpand" class="credentials-toggle clickable-hover" @tap.stop="expanded = !expanded">{{ expanded ? '收起' : '查看全部' }}</text>
</view>
</template>
<script setup>
import { computed, ref } from 'vue';
const props = defineProps({
skills: { type: Array, default: () => [] },
certificates: { type: Array, default: () => [] }
});
const expanded = ref(false);
const canExpand = computed(() => props.skills.length > 3 || props.certificates.length > 3);
const display = (items, empty) => items.length ? (expanded.value ? items : items.slice(0, 3)).join('、') : empty;
const skillText = computed(() => display(props.skills, '暂无填写'));
const certText = computed(() => display(props.certificates, '暂无已认证证书'));
</script>
<style lang="scss" scoped>
.credentials { margin-top: 20rpx; }
.credentials-row { display: flex; align-items: flex-start; margin-top: 10rpx; font-size: $yjyf-font-sub; line-height: 1.5; }
.credentials-label { flex-shrink: 0; color: $yjyf-text-secondary; margin-right: 16rpx; }
.credentials-value { flex: 1; min-width: 0; color: $yjyf-text-regular; word-break: break-all; }
.credentials-toggle { display: block; margin-top: 8rpx; color: $yjyf-primary; font-size: $yjyf-font-sub; }
</style>

查看文件

@@ -103,6 +103,10 @@
<!-- 核心功能菜单 -->
<view class="card-panel">
<view class="menu-group">
<view class="menu-item clickable-hover" @tap="go('/pages/mine/security')">
<view class="menu-item-l"><image class="menu-ico" src="/static/icons/menu-account-security.svg" mode="aspectFit" /><text class="menu-txt">账号安全</text></view>
<view class="menu-item-r"><image class="arrow-ico" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
</view>
<view class="menu-item clickable-hover" @tap="go('/pages/coupon/coupon?tab=center')">
<view class="menu-item-l">
<image class="menu-ico" src="/static/icons/menu-coupon.svg" mode="aspectFit" />
@@ -250,15 +254,7 @@
return !!(master.value && master.value.verify_status === 'pass');
});
const roleText = computed(() => {
const curRole = currentRole.value;
if (curRole === 'master' && master.value && master.value.verify_status === 'pass') {
return '认证师傅';
}
if (master.value && master.value.verify_status === 'pass') return '认证师傅';
if (master.value && master.value.verify_status === 'pending') return '师傅审核中';
return '个人用户';
});
const roleText = computed(() => user.value && user.value.user_type === 'merchant' ? '商家用户' : '个人用户');
const masterCard = computed(() => {
const m = master.value;

查看文件

@@ -187,6 +187,10 @@
"path": "pages/mine/account",
"style": { "navigationStyle": "custom", "backgroundColor": "#F5F6F8" }
},
{
"path": "pages/mine/security",
"style": { "navigationStyle": "custom", "backgroundColor": "#F5F6F8" }
},
{
"path": "pages/user/wallet",
"style": {

查看文件

@@ -22,21 +22,38 @@
<!-- 全局统一底部导航 (方案 A:单母页组件化调度,0ms 极速秒切) -->
<YjyfTabBar :current="activeTab" @change="onTabChange" />
<view v-if="showIdentityPicker" class="identity-mask">
<view class="identity-dialog">
<text class="identity-title">请选择用户类型</text>
<text class="identity-description">请选择您的使用身份,确认后不可自行修改</text>
<view class="identity-option" :class="{ selected: identityChoice === 'personal' }" @tap="identityChoice = 'personal'">
<text class="identity-option-title">个人用户</text><text class="identity-option-desc">家庭或个人使用</text>
</view>
<view class="identity-option" :class="{ selected: identityChoice === 'merchant' }" @tap="identityChoice = 'merchant'">
<text class="identity-option-title">商家用户</text><text class="identity-option-desc">商家或企业使用</text>
</view>
<button class="identity-confirm" :disabled="!identityChoice || selectingIdentity" @tap="confirmIdentity">{{ selectingIdentity ? '提交中...' : '确认选择' }}</button>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app';
import UserHomeView from '@/components/user/UserHomeView.vue';
import UserOrdersView from '@/components/user/UserOrdersView.vue';
import UserMessageView from '@/components/user/UserMessageView.vue';
import UserMineView from '@/components/user/UserMineView.vue';
import YjyfTabBar from '@/components/YjyfTabBar.vue';
import { isLogin, toLogin } from '@/utils/request.js';
import { isLogin, toLogin, getUser, setUser } from '@/utils/request.js';
import api from '@/utils/api.js';
import { getRole, setRole } from '@/utils/role.js';
import { useShare } from '@/utils/share.js';
const showIdentityPicker = ref(false);
const identityChoice = ref('');
const selectingIdentity = ref(false);
const activeTab = ref(0);
const initialOrderStatus = ref('all');
const visitedTabs = reactive({ 0: true, 1: false, 2: false, 3: false });
@@ -110,6 +127,11 @@
}
onLoad((query) => {
const currentUser = getUser();
if (isLogin() && currentUser && currentUser.identity_selected === false) {
setRole('user');
return;
}
// 已登录且当前为师傅身份时,冷启动自动跳转到师傅工作台界面
if (isLogin() && getRole() === 'master' && (!query || !query.forceUser)) {
uni.reLaunch({ url: '/pages/master/workbench' });
@@ -135,7 +157,37 @@
}
});
async function confirmIdentity() {
if (!identityChoice.value || selectingIdentity.value) return;
selectingIdentity.value = true;
try {
const res = await api.selectIdentity({ user_type: identityChoice.value });
setUser(res.userinfo);
showIdentityPicker.value = false;
} catch (e) {
// A response can be lost after the selection has been saved.
try {
const current = await api.profile();
if (current.identity_selected) {
setUser(current);
showIdentityPicker.value = false;
}
} catch (profileError) {}
} finally {
selectingIdentity.value = false;
}
}
onBackPress(() => showIdentityPicker.value);
onShow(() => {
const currentUser = getUser();
if (isLogin() && currentUser && currentUser.identity_selected === false) {
activeTab.value = 0;
showIdentityPicker.value = true;
setRole('user');
return;
}
if (isLogin() && getRole() === 'master') {
uni.reLaunch({ url: '/pages/master/workbench' });
return;
@@ -149,7 +201,19 @@
});
</script>
<style scoped>
<style lang="scss" scoped>
@import '@/uni.scss';
.identity-mask { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 48rpx; }
.identity-dialog { width: 100%; background: $yjyf-bg-card; border-radius: 24rpx; padding: 40rpx; display: flex; flex-direction: column; }
.identity-title { font-size: 36rpx; font-weight: 700; color: $yjyf-text-main; text-align: center; }
.identity-description { margin: 16rpx 0 32rpx; font-size: 25rpx; color: $yjyf-text-secondary; text-align: center; }
.identity-option { display: flex; flex-direction: column; padding: 24rpx; margin-bottom: 20rpx; border: 2rpx solid $yjyf-border-color; border-radius: 16rpx; }
.identity-option.selected { border-color: $yjyf-primary; background: $yjyf-primary-bg; }
.identity-option-title { font-size: 30rpx; font-weight: 600; color: $yjyf-text-main; }
.identity-option-desc { margin-top: 8rpx; font-size: 24rpx; color: $yjyf-text-secondary; }
.identity-confirm { width: 100%; margin-top: 12rpx; background: $yjyf-gradient-primary; color: $yjyf-bg-card; border-radius: 16rpx; font-size: 30rpx; }
.identity-confirm[disabled] { opacity: .5; }
.user-container-page {
height: 100vh;
overflow: hidden;

查看文件

@@ -280,6 +280,12 @@
setUser(res.userinfo);
syncUserData(res);
if (res.userinfo.identity_selected === false) {
loading.value = false;
setRole('user');
uni.reLaunch({ url: '/pages/index/index' });
return;
}
toast('登录成功');
setTimeout(() => {
loading.value = false;
@@ -330,6 +336,12 @@
setUser(res.userinfo);
syncUserData(res);
if (res.userinfo.identity_selected === false) {
loading.value = false;
setRole('user');
uni.reLaunch({ url: '/pages/index/index' });
return;
}
toast(res.is_new ? '欢迎加入优匠优服' : '登录成功');
setTimeout(() => {
loading.value = false;
@@ -344,7 +356,7 @@
/** 同步更新全局角色状态(师傅通过审核后下次登录默认直接进入师傅工作台) */
function syncUserData(res) {
const userinfo = (res && res.userinfo) || {};
const isMasterPass = Boolean(userinfo.is_master && userinfo.master);
const isMasterPass = Boolean(userinfo.is_master && userinfo.master && userinfo.master.verify_status === 'pass');
// 检查是否有特定指向业主端具体业务页面的重定向(排除首页、我的、登录页等通用页面)
const isExplicitUserTarget = redirectUrl && (
@@ -431,6 +443,7 @@
</script>
<style scoped>
.page {
min-height: 100vh;
background: #FFFFFF;

查看文件

@@ -138,6 +138,14 @@
</view>
</view>
<view class="card qualification-card" v-if="order.qual_req">
<text>资质要求:{{ order.qual_req }}</text>
<template v-if="!order.qualification_allowed">
<text class="qualification-warning">暂无有效认证证书,不能接单或报价</text>
<text class="qualification-link clickable-hover" @tap="goCerts">去上传证书</text>
</template>
</view>
<!-- 我的报价状态卡(已报价时展示) -->
<view class="card quote-state-card" v-if="order.my_quote">
<view class="card-head">
@@ -452,7 +460,7 @@
@tap="openQuoteDrawer"
>立即提交报价</view>
<view v-else class="b-btn disabled-solid">
{{ order.my_quote ? '已提交报价,等待客户选标' : '当前暂不可接单' }}
{{ order.my_quote ? '已提交报价,等待客户选标' : (!order.qualification_allowed ? '暂无有效认证证书' : '当前暂不可接单') }}
</view>
</view>
</template>
@@ -1211,6 +1219,9 @@
quoteForm.description = '';
showQuote.value = true;
}
function goCerts() {
uni.navigateTo({ url: '/pages/master/certs' });
}
async function submitQuote() {
if (submitting.value || !order.value) return;
@@ -1294,6 +1305,9 @@
</script>
<style lang="scss" scoped>
.qualification-card { display: flex; flex-wrap: wrap; gap: 12rpx; color: $yjyf-text-regular; font-size: $yjyf-font-sub; }
.qualification-warning { color: $yjyf-danger; }
.qualification-link { color: $yjyf-primary; }
@import '@/uni.scss';
.page {
min-height: 100vh;

查看文件

@@ -131,7 +131,7 @@
<view class="empty-box" v-else>
<image class="empty-img" src="/static/icons/empty-orders.svg" mode="aspectFit" />
<text class="empty-txt">暂无提现申请记录</text>
</view>
</view>
</template>
<!-- 钱包收支流水视图 -->
@@ -364,11 +364,14 @@
</view>
</view>
</view>
<YjyfPaymentPassword ref="paymentPasswordDialog" />
</view>
</template>
<script setup>
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
import { ref, computed } from 'vue';
const paymentPasswordDialog = ref(null);
import { onShow } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { getSafeWxCode, invokeMerchantTransferConfirm } from '@/utils/pay.js';
@@ -594,9 +597,12 @@
const amt = parsedWithdraw.value;
withdrawing.value = true;
try {
const paymentPassword = await paymentPasswordDialog.value.open();
if (!paymentPassword) return;
const wxCode = selectedChannel.value === 'wechat' ? await getSafeWxCode() : '';
const res = await api.masterWithdraw({
amount: amt,
payment_password: paymentPassword,
channel: selectedChannel.value,
account: selectedChannel.value === 'bank' ? bankAccount.value.trim() : '微信零钱',
wx_code: wxCode

查看文件

@@ -8,6 +8,10 @@
<image class="profile-avatar" :src="avatarPreview || '/static/icons/user-avatar.svg'" mode="aspectFill" />
<text class="avatar-action">{{ uploading ? '上传中...' : '更换' }}</text>
</view>
<view class="row">
<text class="label">用户类型</text>
<text class="val-txt">{{ form.user_type === 'merchant' ? '商家' : '家庭/个人' }}</text>
</view>
<!-- 用户昵称 -->
<view class="row">
<text class="label">用户昵称</text>
@@ -19,6 +23,12 @@
/>
</view>
<template v-if="form.user_type === 'merchant'">
<view class="row"><text class="label">公司名称</text><input class="input" v-model="form.company_name" placeholder="请输入公司名称" /></view>
<view class="row"><text class="label">法人姓名</text><input class="input" v-model="form.legal_person" placeholder="请输入法人姓名" /></view>
<view class="row"><text class="label">法人手机号</text><input class="input" type="number" maxlength="11" v-model="form.legal_mobile" placeholder="请输入法人手机号" /></view>
<view class="row"><text class="label">技术手机号</text><input class="input" type="number" maxlength="11" v-model="form.tech_mobile" placeholder="请输入技术手机号" /></view>
</template>
<!-- 联系号码与灰底提示说明(对标图三、图四) -->
<view class="row no-border">
<text class="label">联系号码</text>
@@ -73,6 +83,7 @@
const form = reactive({
user_type: 'personal',
nickname: '',
company_name: '', legal_person: '', legal_mobile: '', tech_mobile: '',
contact_address: '',
email: ''
});
@@ -95,6 +106,11 @@
rawMobile.value = data.mobile || '';
avatarPreview.value = data.avatar || '';
newAvatar.value = '';
form.user_type = data.user_type;
form.company_name = data.company_name || '';
form.legal_person = data.legal_person || '';
form.legal_mobile = data.legal_mobile || '';
form.tech_mobile = data.tech_mobile || '';
form.nickname = data.nickname || '';
form.contact_address = data.contact_address || '';
form.email = data.email || '';
@@ -105,6 +121,7 @@
return {
...(newAvatar.value ? { avatar: newAvatar.value } : {}),
nickname: form.nickname.trim(),
...(form.user_type === 'merchant' ? { company_name: form.company_name.trim(), legal_person: form.legal_person.trim(), legal_mobile: form.legal_mobile.trim(), tech_mobile: form.tech_mobile.trim() } : {}),
contact_address: form.contact_address.trim(),
email: form.email.trim()
};

查看文件

@@ -0,0 +1,142 @@
<template>
<view class="page">
<YjyfNavBar theme="white" title="账号安全" :border="true" :showBack="returnOrder ? true : null" :customBack="!!returnOrder" @back="leaveSetup" />
<view v-if="loaded" class="card">
<view class="row" @tap="openPassword('login')"><text>登录密码</text><view class="value">{{ status.has_login_password ? '修改' : '设置' }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
<view class="row" @tap="openPassword('payment')"><text>支付密码</text><view class="value">{{ status.has_payment_password ? '修改' : '设置' }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
<view class="row" @tap="openCert"><text>企业资质认证</text><view class="value">{{ certText }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
</view>
<view v-if="mode" class="mask">
<view class="sheet">
<view class="sheet-head"><text class="title">{{ sheetTitle }}</text><text class="close" @tap="close">取消</text></view>
<template v-if="mode === 'login'">
<input v-if="status.has_login_password" v-model="oldPassword" class="input" password placeholder="请输入原登录密码" />
<input v-model="newPassword" class="input" password maxlength="30" placeholder="新登录密码(6至30位)" />
<input v-model="confirmPassword" class="input" password maxlength="30" placeholder="再次输入新登录密码" />
<text v-if="!status.has_login_password" class="hint">请使用绑定的微信手机号验证身份。</text>
<!-- #ifdef MP-WEIXIN -->
<button v-if="!status.has_login_password" class="primary" open-type="getPhoneNumber" :disabled="busy" @getphonenumber="onPhoneVerify">验证手机号并设置</button>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<text v-if="!status.has_login_password" class="hint">请在微信小程序中完成手机号验证后设置。</text>
<!-- #endif -->
<button v-if="status.has_login_password" class="primary" :disabled="busy" @tap="savePassword">确认修改</button>
</template>
<template v-else-if="mode === 'payment'">
<input v-if="status.has_payment_password" v-model="oldPassword" class="input" type="number" password maxlength="6" placeholder="请输入原支付密码" />
<input v-else-if="!status.has_payment_password" v-model="oldPassword" class="input" password placeholder="请输入登录密码以验证身份" />
<input v-model="newPassword" class="input" type="number" password maxlength="6" placeholder="设置6位支付密码" />
<input v-model="confirmPassword" class="input" type="number" password maxlength="6" placeholder="再次输入支付密码" />
<button class="primary" :disabled="busy" @tap="savePassword">确认</button>
</template>
<template v-else>
<text v-if="cert && cert.verify_status === 'reject'" class="hint">审核未通过:{{ cert.audit_msg }}</text>
<text class="hint">上传后将通过腾讯云识别营业执照,请核对识别信息后提交。</text>
<input v-model="companyName" class="input" placeholder="请输入企业名称" />
<input v-model="licenseNo" class="input" placeholder="请输入营业执照号码" maxlength="18" />
<input v-model="legalPerson" class="input" placeholder="请输入法人姓名(选填)" />
<view class="upload" @tap="chooseLicense"><image v-if="imagePreview" :src="imagePreview" mode="aspectFit" class="license"/><text>{{ licenseImage ? '重新上传营业执照' : '上传营业执照' }}</text></view>
<button class="primary" :disabled="busy" @tap="submitCert">提交审核</button>
</template>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import api from '@/utils/api.js';
import { clearAuth } from '@/utils/request.js';
import { finishPaymentSetup } from '@/utils/payment-setup.mjs';
const loaded = ref(false), busy = ref(false), mode = ref('');
const returnOrder = ref('');
let setupFromPayment = false, setupOpened = false;
const status = ref({}), oldPassword = ref(''), newPassword = ref(''), confirmPassword = ref('');
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 sheetTitle = computed(() => mode.value === 'login' ? '登录密码' : mode.value === 'payment' ? '支付密码' : '企业资质认证');
async function load() { try { status.value = await api.securityStatus(); loaded.value = true; } catch (e) {} }
function close() { if (busy.value) return; mode.value = ''; oldPassword.value = ''; newPassword.value = ''; confirmPassword.value = ''; }
function openPassword(which) { 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 validPassword() {
const valid = mode.value === 'payment' ? /^\d{6}$/.test(newPassword.value) : /^\S{6,30}$/.test(newPassword.value);
if (!valid || newPassword.value !== confirmPassword.value) { uni.showToast({ title: '请检查两次输入的密码', icon: 'none' }); return false; }
return true;
}
async function onPhoneVerify(event) {
const code = event.detail && event.detail.code;
if (!code) { uni.showToast({ title: '未完成手机号验证', icon: 'none' }); return; }
await savePassword(code);
}
async function savePassword(phoneCode = '') {
if (typeof phoneCode !== 'string') phoneCode = '';
if (busy.value || !validPassword()) return;
busy.value = true;
try {
if (mode.value === 'login') {
await api.changeLoginPassword({ old_password: oldPassword.value, new_password: newPassword.value, phone_code: phoneCode });
clearAuth(); uni.showToast({ title: '请重新登录', icon: 'none' });
setTimeout(() => uni.reLaunch({ url: '/pages/login/login' }), 700); return;
}
const firstSetup = !status.value.has_payment_password;
if (!firstSetup) await api.changePaymentPassword({ old_password: oldPassword.value, new_password: newPassword.value });
else await api.setPaymentPassword({ login_password: oldPassword.value, new_password: newPassword.value });
busy.value = false; close(); uni.showToast({ title: '保存成功' });
if (setupFromPayment && firstSetup) {
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
} else await load();
} catch (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];
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; }
}
async function leaveSetup() {
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
}
onLoad((options) => {
setupFromPayment = !!(options && options.setupPayment === '1');
const id = String((options && options.returnOrder) || '');
if (setupFromPayment && /^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id))) returnOrder.value = id;
});
onBackPress(() => {
if (!returnOrder.value) return false;
leaveSetup();
return true;
});
onShow(async () => {
await load();
if (!loaded.value || !setupFromPayment || setupOpened) return;
setupOpened = true;
if (status.value.has_payment_password) await leaveSetup();
else openPassword('payment');
});
</script>
<style lang="scss" scoped>
@import '@/uni.scss';
.page { min-height: 100vh; background: $yjyf-bg-page; }
.card { margin: 24rpx; padding: 0 28rpx; background: $yjyf-bg-card; border-radius: 20rpx; }
.row { min-height: 100rpx; display: flex; align-items: center; justify-content: space-between; border-bottom: 1rpx solid $yjyf-border-color; color: $yjyf-text-main; font-size: 30rpx; }
.row:last-child { border-bottom: 0; }.value { color: $yjyf-text-secondary; font-size: 26rpx; display: flex; align-items: center; }.arrow { width: 26rpx; height: 26rpx; margin-left: 10rpx; }
.mask { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 90vh; overflow-y: auto; padding: 30rpx 30rpx calc(30rpx + env(safe-area-inset-bottom)); border-radius: 24rpx 24rpx 0 0; background: $yjyf-bg-card; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24rpx; }.title { color: $yjyf-text-main; font-size: 32rpx; font-weight: 600; }.close { color: $yjyf-text-secondary; font-size: 28rpx; }
.input { height: 88rpx; padding: 0 20rpx; margin-bottom: 16rpx; background: $yjyf-bg-page; border-radius: 12rpx; font-size: 28rpx; }.hint { display: block; margin: 12rpx 0; color: $yjyf-text-secondary; font-size: 24rpx; }
.primary { margin-top: 22rpx; background: $yjyf-gradient-primary; color: $yjyf-bg-card; font-size: 30rpx; }.upload { display: flex; flex-direction: column; align-items: center; gap: 10rpx; padding: 24rpx; color: $yjyf-primary; border: 1rpx solid $yjyf-border-color; font-size: 26rpx; }.license { width: 300rpx; height: 180rpx; }
</style>

查看文件

@@ -226,11 +226,14 @@
@update:visible="showCreateRegion = $event"
@confirm="onCreateRegionDrawerConfirm"
/>
<YjyfPaymentPassword ref="paymentPasswordDialog" />
</view>
</template>
<script setup>
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
import { ref, reactive, watch, computed } from 'vue';
const paymentPasswordDialog = ref(null);
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { executeOrderWxPay, openOrderPaymentResult } from '@/utils/pay.js';
@@ -546,9 +549,10 @@
} catch (pe) {}
// 一口价或自主定价调起支付
const payment = await executeOrderWxPay(api.orderPay, { order_id: createdOrderId, pay_type: payType });
const payment = await executeOrderWxPay(api.orderPay, { order_id: createdOrderId, pay_type: payType }, () => paymentPasswordDialog.value.open({ createdOrderId }));
openOrderPaymentResult(createdOrderId, payment, true);
} catch (e) {
if (e && e.paymentSetupNavigation) { submitting.value = false; return; }
if (createdOrderId) {
if (!e || !e.unsupportedEnv) {
const reason = (e && e.message) ? `订单已创建(${e.message})` : '订单已创建,请在详情页完成支付';

查看文件

@@ -183,6 +183,7 @@
<text class="call-txt">拨打电话</text>
</view>
</view>
<MasterCredentials :skills="master.skills" :certificates="master.certificates" />
</view>
<!-- ==================== 业务联动:现场增项补差价待支付 ==================== -->
@@ -213,6 +214,7 @@
</view>
<text class="q-amt">¥{{ q.amount }}</text>
</view>
<MasterCredentials :skills="q.skills" :certificates="q.certificates" />
<text class="q-desc" v-if="q.description">{{ q.description }}</text>
<view class="q-foot">
<text class="q-expire">有效期至 {{ q.expire_text }}</text>
@@ -319,7 +321,7 @@
<view class="cs-btn clickable-hover" @tap="contactService">
<image class="cs-icon" src="/static/icons/customer-service-gray.svg" mode="aspectFit" />
<text class="cs-label">客服</text>
</view>
</view>
<!-- 按钮动作组合 (与对标图一致) -->
<view class="action-btns-wrap">
@@ -424,15 +426,19 @@
</view>
</view>
<YjyfServicePopup :visible="servicePopupVisible" @update:visible="servicePopupVisible = $event" />
<YjyfPaymentPassword ref="paymentPasswordDialog" />
</view>
</template>
<script setup>
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
import { ref, computed } from 'vue';
const paymentPasswordDialog = ref(null);
import { formatServiceItems } from '@/utils/order-service-items.mjs';
import { onLoad, onShow } from '@dcloudio/uni-app';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import YjyfServicePopup from '@/components/YjyfServicePopup.vue';
import MasterCredentials from '@/components/order/MasterCredentials.vue';
import api from '@/utils/api.js';
import { executeOrderWxPay, openOrderPaymentResult } from '@/utils/pay.js';
@@ -668,7 +674,7 @@
return;
}
}
const payment = await executeOrderWxPay(api.orderChooseQuote, { order_id: orderId, quote_id: q.id, pay_type: payType });
const payment = await executeOrderWxPay(api.orderChooseQuote, { order_id: orderId, quote_id: q.id, pay_type: payType }, () => paymentPasswordDialog.value.open());
if (payment.out_trade_no) {
openOrderPaymentResult(orderId, payment, true);
} else {
@@ -701,7 +707,7 @@
actionBusy.value = false;
return;
}
const payment = await executeOrderWxPay(api.orderPayDiff, { order_id: orderId, pay_type: payType });
const payment = await executeOrderWxPay(api.orderPayDiff, { order_id: orderId, pay_type: payType }, () => paymentPasswordDialog.value.open());
openOrderPaymentResult(orderId, payment, true);
} catch (e) {
if (e && e.code === undefined && !e.handledToast && !e.unsupportedEnv && e.message) {
@@ -745,7 +751,7 @@
actionBusy.value = true;
try {
const payment = await executeOrderWxPay(api.orderPay, { order_id: orderId, pay_type: payType });
const payment = await executeOrderWxPay(api.orderPay, { order_id: orderId, pay_type: payType }, () => paymentPasswordDialog.value.open());
openOrderPaymentResult(orderId, payment, true);
} catch (e) {
if (e && e.code === undefined && !e.handledToast && !e.unsupportedEnv && e.message) {

查看文件

@@ -154,7 +154,7 @@
<image class="dc-icon" src="/static/icons/add-env.svg" mode="aspectFit" />
<text class="dc-txt gray">安装环境图</text>
<text class="dc-sub gray">(非必填)</text>
</view>
</view>
</template>
<!-- 4. 紧跟末尾的橙色帮助问号图标 -->
@@ -1084,12 +1084,15 @@
</scroll-view>
</view>
</view>
<YjyfPaymentPassword ref="paymentPasswordDialog" />
</view>
</template>
<script setup>
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
import { serviceAddons } from '@/utils/productPricing.js';
import { ref, reactive, computed } from 'vue';
const paymentPasswordDialog = ref(null);
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { executeOrderWxPay, openOrderPaymentResult } from '@/utils/pay.js';
@@ -2594,9 +2597,10 @@
openOrderPaymentResult(createdOrderId, await executeOrderWxPay(api.orderPay, {
order_id: createdOrderId,
pay_type: (selectedPayType.value === 'balance' && isBalanceSufficient.value) ? 'balance' : 'wechat'
}), true);
}, () => paymentPasswordDialog.value.open({ createdOrderId })), true);
}
} catch (e) {
if (e && e.paymentSetupNavigation) { submitting.value = false; return; }
if (createdOrderId) {
if (!e || !e.unsupportedEnv) {
const reason = (e && e.message) ? `订单已创建(${e.message})` : '订单已创建,请在详情页完成支付';

查看文件

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none"><path d="M24 5 9 11v11c0 9 5.8 16.3 15 21 9.2-4.7 15-12 15-21V11L24 5Z" stroke="#F0710D" stroke-width="3"/><circle cx="24" cy="23" r="3" fill="#F0710D"/><path d="M24 26v5" stroke="#F0710D" stroke-width="3" stroke-linecap="round"/></svg>

之后

宽度:  |  高度:  |  大小: 309 B

查看文件

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none"><path d="M24 4 8 10v12c0 10 6.6 17.5 16 22 9.4-4.5 16-12 16-22V10L24 4Z" stroke="#F0710D" stroke-width="3" stroke-linejoin="round"/><rect x="17" y="21" width="14" height="11" rx="2" stroke="#F0710D" stroke-width="3"/><path d="M20 21v-3a4 4 0 0 1 8 0v3" stroke="#F0710D" stroke-width="3" stroke-linecap="round"/></svg>

之后

宽度:  |  高度:  |  大小: 390 B

查看文件

@@ -16,6 +16,13 @@ export default {
wxPhoneLogin: (data) => post('/auth/wxPhoneLogin', data, { silent: true }),
switchRole: (data) => post('/auth/switchRole', data),
profile: () => get('/auth/profile'),
selectIdentity: (data) => post('/auth/selectIdentity', data),
securityStatus: () => get('/security/status'),
changeLoginPassword: (data) => post('/security/changeLoginPassword', data),
setPaymentPassword: (data) => post('/security/setPaymentPassword', data),
changePaymentPassword: (data) => post('/security/changePaymentPassword', data),
submitEnterpriseCert: (data) => post('/security/submitEnterpriseCert', data),
recognizeEnterpriseLicense: (data) => post('/security/recognizeEnterpriseLicense', data),
saveAccount: (data) => post('/auth/saveAccount', data),
/* ---------- 用户钱包与充值 ---------- */

查看文件

@@ -61,8 +61,13 @@ export function getSafeWxCode() {
* @param {Object} params 业务入参(如 { order_id } 或 { order_id, quote_id })
* @returns {Promise<Object>}
*/
export async function executeOrderWxPay(createPayApiFn, params = {}) {
export async function executeOrderWxPay(createPayApiFn, params = {}, promptPaymentPassword) {
const payload = Object.assign({}, params);
if (payload.pay_type === 'balance') {
if (typeof promptPaymentPassword !== 'function') throw new Error('支付密码输入不可用');
payload.payment_password = await promptPaymentPassword();
if (!payload.payment_password) throw Object.assign(new Error('支付已取消'), { cancelled: true });
}
// 纯余额支付无需向微信换取登录凭证 code,直接请求后端原子核销入账
if (payload.pay_type !== 'balance') {

查看文件

@@ -0,0 +1,28 @@
/** Guide the user to set a payment password, without initiating a transaction. */
export async function beginPaymentSetup(device, createdOrderId = '') {
const orderId = String(createdOrderId || '');
if (orderId && (!/^[1-9]\d*$/.test(orderId) || !Number.isSafeInteger(Number(orderId)))) {
throw new Error('订单信息无效,无法打开支付密码设置');
}
const confirmed = await new Promise((resolve) => {
device.showModal({ title: '请先设置支付密码', content: '设置后将返回当前页面,请再次确认支付或提现。', confirmText: '去设置', success: (res) => resolve(!!res.confirm), fail: () => resolve(false) });
});
if (!confirmed) return false;
const url = '/pages/mine/security?setupPayment=1' + (orderId ? '&returnOrder=' + orderId : '');
await new Promise((resolve, reject) => {
const action = orderId ? 'redirectTo' : 'navigateTo';
device[action]({ url, success: resolve, fail: () => reject(new Error('无法打开支付密码设置,请稍后重试')) });
});
return true;
}
/** Return to the originating page, or to an already-created order. */
export function finishPaymentSetup(device, returnOrder = '') {
const orderId = String(returnOrder || '');
const valid = /^[1-9]\d*$/.test(orderId) && Number.isSafeInteger(Number(orderId));
return new Promise((resolve, reject) => {
const options = { success: resolve, fail: () => reject(new Error('返回页面失败,请手动返回')) };
if (valid) device.redirectTo({ ...options, url: '/pages/order/detail?id=' + orderId });
else device.navigateBack(options);
});
}