文件
yjyf/yjyf-master-app/components/YjyfRefreshScroll.vue
MiAn 14533eadb7 feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
1. 账号体系与数据库解耦:
   - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表;
   - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read;
   - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。

2. 服务端(Server):
   - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken);
   - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token;
   - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环;
   - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换);
   - 系统业务配置全面收敛至数据库 fa_config 及 site.php。

3. 小程序端:
   - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块;
   - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
2026-11-23 15:10:30 +08:00

589 行
14 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view
class="yjyf-refresh-wrap"
:class="'theme-' + theme"
@touchend="onTouchRelease"
@touchcancel="onTouchRelease"
>
<!-- 1. 顶部无缝背景延展幕布(彻底消灭下拉白缝与纯色深橙补丁断层) -->
<view
class="refresh-backdrop"
:class="'backdrop-' + theme"
:style="backdropStyle"
></view>
<!-- 2. 灵动阻尼下拉动效舞台(60fps 跟手缩放旋转 + 双轨流光加载 + 成功勾选回弹) -->
<view
class="refresh-stage"
:class="{ 'is-animating': !isPulling }"
:style="stageStyle"
>
<view
class="refresh-capsule"
:class="[
'capsule-' + theme,
'st-' + status,
{ 'is-ready': status === 'ready', 'is-animating': !isPulling }
]"
:style="capsuleStyle"
>
<view class="icon-ring" :class="'ring-' + status">
<!-- 阶段 A:下拉蓄力 & 达标翻转箭头 -->
<image
v-if="status === 'pulling' || status === 'ready' || status === 'idle' || status === 'closing'"
class="rf-icon arrow-icon"
:class="{ 'is-flipped': status === 'ready', 'is-smooth': status === 'ready' || !isPulling }"
:style="arrowStyle"
:src="theme === 'orange' ? '/static/icons/refresh/pull-arrow-white.svg' : '/static/icons/refresh/pull-arrow-orange.svg'"
mode="aspectFit"
/>
<!-- 阶段 B:双轨流光匀速旋转环 -->
<image
v-else-if="status === 'refreshing'"
class="rf-icon spin-icon"
:src="theme === 'orange' ? '/static/icons/refresh/spinner-white.svg' : '/static/icons/refresh/spinner-orange.svg'"
mode="aspectFit"
/>
<!-- 阶段 C:刷新完成微弹对勾 -->
<image
v-else-if="status === 'done'"
class="rf-icon done-icon"
:src="theme === 'orange' ? '/static/icons/refresh/check-white.svg' : '/static/icons/refresh/check-orange.svg'"
mode="aspectFit"
/>
</view>
<text class="rf-text" :class="'txt-' + theme">{{ statusText }}</text>
<!-- 正在刷新态律动微光三圆点(纯 CSS 几何圆点,零字符) -->
<view class="pulse-dots" v-if="status === 'refreshing'">
<view class="p-dot d1" :class="'dot-' + theme"></view>
<view class="p-dot d2" :class="'dot-' + theme"></view>
<view class="p-dot d3" :class="'dot-' + theme"></view>
</view>
</view>
</view>
<!-- 3. 原生物理阻尼滚动容器 -->
<scroll-view
class="yjyf-inner-scroll"
scroll-y
refresher-enabled
:refresher-threshold="threshold"
:refresher-triggered="refresherTriggered"
refresher-default-style="none"
refresher-background="transparent"
:lower-threshold="lowerThreshold"
@refresherpulling="onPulling"
@refresherrefresh="onRefresh"
@refresherrestore="onRestore"
@refresherabort="onRestore"
@scrolltolower="onScrollToLower"
@scroll="onScroll"
>
<view class="yjyf-scroll-body">
<slot></slot>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
import { getNavBarMetrics } from '@/utils/system.js';
const props = defineProps({
theme: {
type: String,
default: 'orange', // 'orange'(沉浸橙金渐变无缝融合) | 'light'(浅灰底悬浮白玉胶囊)
validator: (v) => ['orange', 'light'].includes(v)
},
navOffset: {
type: Number,
default: 0
},
refreshTask: {
type: Function,
default: null
},
threshold: {
type: Number,
default: 56
},
lowerThreshold: {
type: Number,
default: 80
}
});
const emit = defineEmits(['refresh', 'scrolltolower', 'scroll']);
const autoNavHeight = ref(64);
const refresherTriggered = ref(false);
const isPulling = ref(false);
const pullDistance = ref(0);
// 状态机:idle | pulling | ready | refreshing | done | closing
const status = ref('idle');
let isRefreshingLock = false;
let hasVibrated = false;
let releaseTimer = null;
let doneTimer = null;
let closeTimer = null;
function clearAllTimers() {
if (releaseTimer) { clearTimeout(releaseTimer); releaseTimer = null; }
if (doneTimer) { clearTimeout(doneTimer); doneTimer = null; }
if (closeTimer) { clearTimeout(closeTimer); closeTimer = null; }
}
function syncNavMetrics() {
const metrics = getNavBarMetrics();
if (metrics && metrics.totalNavHeight) {
autoNavHeight.value = metrics.totalNavHeight;
}
}
syncNavMetrics();
onMounted(() => {
syncNavMetrics();
});
onBeforeUnmount(() => {
clearAllTimers();
});
const actualNavOffset = computed(() => {
return props.navOffset > 0 ? props.navOffset : autoNavHeight.value;
});
const pullProgress = computed(() => {
if (status.value === 'refreshing' || status.value === 'done') return 1;
return Math.min(1, Math.max(0, pullDistance.value / props.threshold));
});
const backdropStyle = computed(() => {
if (props.theme === 'orange') {
const dynamicH = Math.max(140, Math.ceil(pullDistance.value + 48));
return {
height: dynamicH + 'px',
backgroundPosition: '0 -' + actualNavOffset.value + 'px'
};
}
return {
height: Math.max(100, Math.ceil(pullDistance.value + 32)) + 'px'
};
});
const stageStyle = computed(() => {
let h = 0;
if (status.value === 'refreshing' || status.value === 'done') {
h = props.threshold;
} else if (status.value === 'pulling' || status.value === 'ready') {
h = Math.max(0, Math.min(pullDistance.value, 150));
} else {
h = 0;
}
const visible = h > 4 && status.value !== 'idle' && status.value !== 'closing';
return {
height: h + 'px',
opacity: visible ? Math.min(1, Math.max(0, (h - 6) / 24)) : 0
};
});
const capsuleStyle = computed(() => {
if (status.value === 'refreshing' || status.value === 'done') {
return {
transform: 'scale(1)'
};
}
if (status.value === 'closing' || status.value === 'idle') {
return {
transform: 'scale(0.84)'
};
}
const p = pullProgress.value;
const scale = status.value === 'ready' ? 1.02 : (0.8 + 0.2 * p);
return {
transform: `scale(${scale.toFixed(3)})`
};
});
const arrowStyle = computed(() => {
if (status.value === 'ready') {
return { transform: 'rotate(180deg)' };
}
const deg = Math.round(pullProgress.value * 18);
return { transform: `rotate(${deg}deg)` };
});
const statusText = computed(() => {
switch (status.value) {
case 'ready':
return '释放立即刷新';
case 'refreshing':
return '正在刷新';
case 'done':
return '刷新成功';
default:
return '下拉刷新';
}
});
function triggerLightHaptic() {
if (hasVibrated) return;
hasVibrated = true;
// #ifdef MP-WEIXIN
try {
if (typeof uni.vibrateShort === 'function') {
uni.vibrateShort({ type: 'light', fail: () => {} });
}
} catch (e) {}
// #endif
}
function onPulling(e) {
if (isRefreshingLock) return;
if (releaseTimer) { clearTimeout(releaseTimer); releaseTimer = null; }
if (closeTimer) { clearTimeout(closeTimer); closeTimer = null; }
const detail = (e && e.detail) ? e.detail : {};
const rawDy = detail.dy !== undefined ? Number(detail.dy) : (detail.deltaY !== undefined ? Number(detail.deltaY) : 0);
const dy = Math.max(0, rawDy || 0);
isPulling.value = true;
pullDistance.value = dy;
if (dy >= props.threshold) {
if (status.value !== 'ready') {
status.value = 'ready';
triggerLightHaptic();
}
} else if (dy > 2) {
status.value = 'pulling';
if (dy < props.threshold - 8) {
hasVibrated = false;
}
} else {
status.value = 'idle';
hasVibrated = false;
}
}
function onTouchRelease() {
if (isRefreshingLock) return;
if (releaseTimer) clearTimeout(releaseTimer);
// 若松手后 45ms 内未进入 refreshing(即下拉未达阈值半途释放),主动平滑回弹归零
releaseTimer = setTimeout(() => {
if (!isRefreshingLock && status.value !== 'refreshing' && status.value !== 'done') {
isPulling.value = false;
pullDistance.value = 0;
status.value = 'closing';
hasVibrated = false;
closeTimer = setTimeout(() => {
if (!isRefreshingLock && !isPulling.value) {
status.value = 'idle';
}
}, 260);
}
}, 45);
}
async function onRefresh() {
if (isRefreshingLock) return;
clearAllTimers();
isRefreshingLock = true;
isPulling.value = false;
refresherTriggered.value = true;
pullDistance.value = props.threshold;
status.value = 'refreshing';
const startAt = Date.now();
try {
if (typeof props.refreshTask === 'function') {
await props.refreshTask();
} else {
await new Promise((resolve) => {
emit('refresh', resolve);
setTimeout(resolve, 500);
});
}
} catch (e) {
} finally {
const elapsed = Date.now() - startAt;
const minSpinMs = 380;
const remainSpin = elapsed < minSpinMs ? (minSpinMs - elapsed) : 0;
doneTimer = setTimeout(() => {
status.value = 'done';
doneTimer = setTimeout(() => {
refresherTriggered.value = false;
pullDistance.value = 0;
status.value = 'closing';
hasVibrated = false;
closeTimer = setTimeout(() => {
isRefreshingLock = false;
if (!isPulling.value) {
status.value = 'idle';
}
}, 280);
}, 240);
}, remainSpin);
}
}
function onRestore() {
clearAllTimers();
refresherTriggered.value = false;
isPulling.value = false;
pullDistance.value = 0;
isRefreshingLock = false;
hasVibrated = false;
status.value = 'idle';
}
function onScrollToLower(e) {
emit('scrolltolower', e);
}
function onScroll(e) {
emit('scroll', e);
}
defineExpose({
triggerRefresh: onRefresh
});
</script>
<style scoped>
/* #ifdef MP-WEIXIN */
:host {
flex: 1;
min-height: 0;
height: 0;
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* #endif */
.yjyf-refresh-wrap {
position: relative;
flex: 1;
min-height: 0;
height: 100%;
width: 100%;
overflow: hidden;
background-color: #F5F6F8;
display: flex;
flex-direction: column;
}
/* 1. 顶部无缝背景幕布层:与 YjyfNavBar 共享同一张 135deg 连续渐变 */
.refresh-backdrop {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 0;
pointer-events: none;
max-height: 75%;
}
.backdrop-orange {
background-color: #F0710D;
background-image: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
background-size: 100% 600rpx;
background-position: 0 0;
background-repeat: no-repeat;
}
.backdrop-light {
background-color: #F5F6F8;
}
/* 2. 下拉动效舞台层 */
.refresh-stage {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
pointer-events: none;
will-change: height, opacity;
}
.refresh-stage.is-animating {
transition: height 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}
/* 灵动悬浮胶囊指示器 */
.refresh-capsule {
display: inline-flex;
align-items: center;
justify-content: center;
height: 60rpx;
padding: 0 28rpx 0 22rpx;
border-radius: 30rpx;
box-sizing: border-box;
will-change: transform;
}
.refresh-capsule.is-animating {
transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}
/* 橙色渐变主题:半透明微光磨砂胶囊,与暖橙渐变浑然一体 */
.capsule-orange {
background: rgba(255, 255, 255, 0.18);
border: 1rpx solid rgba(255, 255, 255, 0.34);
box-shadow: 0 6rpx 20rpx rgba(185, 68, 0, 0.14);
}
.capsule-orange.is-ready,
.capsule-orange.st-refreshing,
.capsule-orange.st-done {
background: rgba(255, 255, 255, 0.24);
border-color: rgba(255, 255, 255, 0.48);
}
/* 浅灰主题:白玉微投影悬浮胶囊 */
.capsule-light {
background: #FFFFFF;
border: 1rpx solid rgba(240, 113, 13, 0.12);
box-shadow: 0 6rpx 22rpx rgba(31, 31, 31, 0.06);
}
.capsule-light.is-ready,
.capsule-light.st-refreshing {
border-color: rgba(240, 113, 13, 0.24);
box-shadow: 0 8rpx 24rpx rgba(240, 113, 13, 0.10);
}
.capsule-light.st-done {
border-color: rgba(47, 168, 79, 0.22);
}
/* 图标容积与动效 */
.icon-ring {
width: 34rpx;
height: 34rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12rpx;
flex-shrink: 0;
position: relative;
}
.rf-icon {
width: 34rpx;
height: 34rpx;
display: block;
}
.arrow-icon.is-smooth {
transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.spin-icon {
animation: yjyfRefreshSpin 0.72s linear infinite;
}
.done-icon {
animation: yjyfRefreshPop 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* 状态提示文字 */
.rf-text {
font-size: 24rpx;
font-weight: 500;
line-height: 1;
letter-spacing: 0.5rpx;
white-space: nowrap;
}
.txt-orange {
color: #FFFFFF;
}
.txt-light {
color: #444444;
}
.capsule-light.is-ready .txt-light,
.capsule-light.st-refreshing .txt-light {
color: #F0710D;
font-weight: 600;
}
.capsule-light.st-done .txt-light {
color: #2FA84F;
font-weight: 600;
}
/* 正在刷新微光律动点 */
.pulse-dots {
display: inline-flex;
align-items: center;
margin-left: 6rpx;
height: 24rpx;
}
.p-dot {
width: 5rpx;
height: 5rpx;
border-radius: 50%;
margin-left: 4rpx;
animation: yjyfDotWave 1.1s ease-in-out infinite;
}
.dot-orange {
background-color: rgba(255, 255, 255, 0.92);
}
.dot-light {
background-color: #F0710D;
}
.p-dot.d1 { animation-delay: 0s; }
.p-dot.d2 { animation-delay: 0.18s; }
.p-dot.d3 { animation-delay: 0.36s; }
/* 3. 原生滚动层与不透明内容画板 */
.yjyf-inner-scroll {
position: relative;
z-index: 2;
flex: 1;
height: 0;
width: 100%;
background: transparent;
}
.yjyf-scroll-body {
min-height: 100%;
width: 100%;
background-color: #F5F6F8;
box-sizing: border-box;
}
@keyframes yjyfRefreshSpin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes yjyfRefreshPop {
0% { transform: scale(0.55); opacity: 0.4; }
100% { transform: scale(1); opacity: 1; }
}
@keyframes yjyfDotWave {
0%, 80%, 100% { transform: translateY(0); opacity: 0.38; }
40% { transform: translateY(-4rpx); opacity: 1; }
}
</style>