- 插件管理:集成 qcloudsms 腾讯云短信发送插件,配置应用AppID/AppKey、短信签名及各业务模板ID(登录、修改密码、重置密码、支付密码、订单核销通知) - 业务封装:新增 SmsService 统一业务短信服务,实现防刷限流、冷却控制、短信验证码发送与防重放校验,支持完工订单自动下发客户核销码 - 接口层:恢复并升级 Sms 控制器,并在 Auth/MasterAuth/Security 控制器中支持手机验证码登录、找回登录密码及短信验证设置/修改支付密码 - 小程序端:用户端与师傅端登录页、账号安全中心、支付密码组件全面适配短信验证码交互,优化用户找回密码与支付密码安全操作流程 - 部署脚本:优化 deploy_all.py 打包剪枝逻辑,全局过滤深层 .git 目录并规范打包相对路径
205 行
7.1 KiB
Vue
205 行
7.1 KiB
Vue
<template>
|
|
<view v-if="visible" class="mask" @tap="finish('')">
|
|
<view class="panel" @tap.stop>
|
|
<view class="panel-head">
|
|
<text class="title">请输入支付密码</text>
|
|
<view class="close-btn clickable-hover" @tap="finish('')">
|
|
<image class="close-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
|
</view>
|
|
</view>
|
|
|
|
<view class="sub-bar">
|
|
<text class="sub-tip">请输入 6 位数字支付密码</text>
|
|
<view class="eye-toggle clickable-hover" @tap="showPlain = !showPlain">
|
|
<image
|
|
class="eye-ico"
|
|
:src="showPlain ? '/static/icons/login-eye-open.svg' : '/static/icons/login-eye-close.svg'"
|
|
mode="aspectFit"
|
|
/>
|
|
<text class="eye-txt">{{ showPlain ? '隐藏' : '显示' }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="cells-wrap" @tap="refocusInput">
|
|
<input
|
|
class="hidden-input"
|
|
type="number"
|
|
maxlength="6"
|
|
:value="password"
|
|
:focus="focused"
|
|
@input="onInput"
|
|
@focus="isInputFocused = true"
|
|
@blur="isInputFocused = false"
|
|
/>
|
|
<view class="cells">
|
|
<view
|
|
v-for="n in 6"
|
|
:key="n"
|
|
class="cell"
|
|
:class="{
|
|
filled: n - 1 < password.length,
|
|
active: isInputFocused && n - 1 === Math.min(password.length, 5) && password.length < 6
|
|
}"
|
|
>
|
|
<text v-if="n - 1 < password.length && showPlain" class="cell-num">{{ password[n - 1] }}</text>
|
|
<view v-else-if="n - 1 < password.length" class="cell-dot"></view>
|
|
<view v-else-if="isInputFocused && n - 1 === password.length" class="cell-cursor"></view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="forgot-bar">
|
|
<text class="forgot-link clickable-hover" @tap="goForgotPassword">忘记支付密码?</text>
|
|
</view>
|
|
|
|
<view class="actions">
|
|
<button class="cancel clickable-hover" @tap="finish('')">取消</button>
|
|
<button class="confirm clickable-hover" :class="{ muted: password.length < 6 }" @tap="submit">确认</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script setup>
|
|
import { ref, nextTick, onBeforeUnmount } from 'vue';
|
|
import api from '@/utils/api.js';
|
|
import { beginPaymentSetup } from '@/utils/payment-setup.mjs';
|
|
|
|
const visible = ref(false);
|
|
const password = ref('');
|
|
const showPlain = ref(false);
|
|
const focused = ref(false);
|
|
const isInputFocused = ref(false);
|
|
let resolvePrompt = null;
|
|
let focusTimer = null;
|
|
|
|
function clearFocusTimer() {
|
|
if (focusTimer) {
|
|
clearTimeout(focusTimer);
|
|
focusTimer = null;
|
|
}
|
|
}
|
|
|
|
function refocusInput() {
|
|
focused.value = false;
|
|
nextTick(() => {
|
|
focused.value = true;
|
|
});
|
|
}
|
|
|
|
function onInput(e) {
|
|
const raw = (e && e.detail && e.detail.value !== undefined) ? e.detail.value : password.value;
|
|
password.value = String(raw || '').replace(/\D/g, '').slice(0, 6);
|
|
}
|
|
|
|
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 = '';
|
|
showPlain.value = false;
|
|
focused.value = false;
|
|
isInputFocused.value = false;
|
|
visible.value = true;
|
|
clearFocusTimer();
|
|
focusTimer = setTimeout(() => {
|
|
focused.value = true;
|
|
}, 80);
|
|
return new Promise(resolve => { resolvePrompt = resolve; });
|
|
}
|
|
|
|
function finish(value) {
|
|
clearFocusTimer();
|
|
focused.value = false;
|
|
isInputFocused.value = false;
|
|
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' });
|
|
refocusInput();
|
|
return;
|
|
}
|
|
finish(password.value);
|
|
}
|
|
|
|
function goForgotPassword() {
|
|
finish('');
|
|
uni.navigateTo({ url: '/pages/mine/security?open=payment' });
|
|
}
|
|
|
|
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, 0.5); }
|
|
.panel { width: 100%; box-sizing: border-box; padding: 36rpx 32rpx 32rpx; border-radius: $yjyf-radius-lg; background: $yjyf-bg-card; box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.14); }
|
|
.panel-head { position: relative; display: flex; align-items: center; justify-content: center; margin-bottom: 24rpx; }
|
|
.title { font-size: $yjyf-font-title; font-weight: 700; color: $yjyf-text-main; }
|
|
.close-btn { position: absolute; right: -8rpx; top: 50%; transform: translateY(-50%); width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: center; }
|
|
.close-ico { width: 28rpx; height: 28rpx; opacity: 0.55; }
|
|
|
|
.sub-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx; }
|
|
.sub-tip { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
|
|
.eye-toggle { display: inline-flex; align-items: center; gap: 8rpx; padding: 4rpx 8rpx; }
|
|
.eye-ico { width: 30rpx; height: 30rpx; }
|
|
.eye-txt { font-size: $yjyf-font-micro; color: $yjyf-text-secondary; }
|
|
|
|
.cells-wrap { position: relative; width: 100%; height: 92rpx; overflow: hidden; }
|
|
.hidden-input { position: absolute; top: 0; bottom: 0; left: -200%; width: 300%; height: 92rpx; opacity: 0; color: transparent; background: transparent; z-index: 2; }
|
|
.cells { display: flex; align-items: center; gap: 14rpx; width: 100%; height: 92rpx; }
|
|
.cell {
|
|
flex: 1;
|
|
height: 92rpx;
|
|
box-sizing: border-box;
|
|
border-radius: $yjyf-radius-sm;
|
|
background: $yjyf-bg-page;
|
|
border: 1.5rpx solid $yjyf-border-color;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: border-color 0.15s ease, background 0.15s ease;
|
|
}
|
|
.cell.filled { background: $yjyf-bg-card; border-color: #DCDDE0; }
|
|
.cell.active { background: $yjyf-bg-card; border-color: $yjyf-primary; box-shadow: 0 0 0 4rpx rgba(240, 113, 13, 0.12); }
|
|
.cell-dot { width: 18rpx; height: 18rpx; border-radius: 50%; background: $yjyf-text-main; }
|
|
.cell-num { font-size: 36rpx; font-weight: 700; color: $yjyf-text-main; }
|
|
.cell-cursor { width: 3rpx; height: 34rpx; background: $yjyf-primary; border-radius: 2rpx; animation: blink-cursor 1s infinite; }
|
|
@keyframes blink-cursor {
|
|
0%, 49% { opacity: 1; }
|
|
50%, 100% { opacity: 0; }
|
|
}
|
|
|
|
.forgot-bar { display: flex; justify-content: flex-end; margin: 16rpx 0 28rpx; }
|
|
.forgot-link { font-size: $yjyf-font-sub; color: $yjyf-info; }
|
|
|
|
.actions { display: flex; gap: 20rpx; }
|
|
.actions button {
|
|
flex: 1;
|
|
height: 86rpx;
|
|
margin: 0;
|
|
padding: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: $yjyf-radius-pill;
|
|
font-size: $yjyf-font-body;
|
|
font-weight: 600;
|
|
border: none;
|
|
}
|
|
.actions button::after { border: none; }
|
|
.cancel { color: $yjyf-text-regular; background: $yjyf-bg-page; }
|
|
.confirm { color: $yjyf-text-inverse; background: $yjyf-gradient-primary; box-shadow: $yjyf-shadow-button; }
|
|
.confirm.muted { opacity: 0.6; }
|
|
</style>
|