1
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
Component({
|
||||
properties: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
customerName: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
content: '',
|
||||
error: false,
|
||||
keyboardHeight: 0,
|
||||
canSave: false,
|
||||
},
|
||||
|
||||
observers: {
|
||||
visible(val: boolean) {
|
||||
if (val) {
|
||||
// 打开弹窗时重置
|
||||
this.setData({
|
||||
content: '',
|
||||
error: false,
|
||||
keyboardHeight: 0,
|
||||
canSave: false,
|
||||
})
|
||||
} else {
|
||||
// 关闭时重置键盘高度
|
||||
this.setData({ keyboardHeight: 0 })
|
||||
}
|
||||
},
|
||||
// 内容变化时重新计算 canSave
|
||||
content(val: string) {
|
||||
this.setData({
|
||||
canSave: val.trim().length > 0,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 文本输入 */
|
||||
onContentInput(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
|
||||
this.setData({ content: e.detail.value, error: false })
|
||||
},
|
||||
|
||||
/** 键盘弹出 */
|
||||
onTextareaFocus(e: WechatMiniprogram.InputEvent) {
|
||||
let height = (e as any).detail?.height ?? 0
|
||||
// 修复:首次激活时键盘高度可能为0,需要设置最小值确保弹窗移动
|
||||
if (height === 0) {
|
||||
height = 260 // 微信小程序默认键盘高度约 260px
|
||||
}
|
||||
this.setData({ keyboardHeight: height })
|
||||
},
|
||||
|
||||
/** 键盘收起 */
|
||||
onTextareaBlur() {
|
||||
this.setData({ keyboardHeight: 0 })
|
||||
},
|
||||
|
||||
/** 确认放弃 */
|
||||
onConfirm() {
|
||||
if (!this.data.canSave) {
|
||||
this.setData({ error: true })
|
||||
return
|
||||
}
|
||||
|
||||
this.triggerEvent('confirm', {
|
||||
reason: this.data.content.trim(),
|
||||
})
|
||||
},
|
||||
|
||||
/** 取消 */
|
||||
onCancel() {
|
||||
this.triggerEvent('cancel')
|
||||
},
|
||||
|
||||
/** 阻止冒泡 */
|
||||
noop() {},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,53 @@
|
||||
<view class="modal-overlay {{keyboardHeight > 0 ? 'modal-overlay--keyboard-open' : ''}}" wx:if="{{visible}}" catchtap="onCancel" catchtouchmove="noop">
|
||||
<view class="modal-container" catchtap="noop">
|
||||
<!-- 头部 -->
|
||||
<view class="modal-header">
|
||||
<view class="header-left">
|
||||
<text class="modal-emoji">⚠️</text>
|
||||
<text class="modal-title">放弃 <text class="modal-name">{{customerName}}</text></text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="onCancel" hover-class="modal-close--hover">
|
||||
<t-icon name="close" size="40rpx" color="#8b8b8b" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 描述 -->
|
||||
<view class="modal-desc-wrap">
|
||||
<text class="modal-desc">确定放弃该客户的维护任务?请填写原因:</text>
|
||||
</view>
|
||||
|
||||
<!-- 文本输入 -->
|
||||
<view class="textarea-section">
|
||||
<textarea
|
||||
class="abandon-textarea"
|
||||
placeholder="请输入放弃原因(必填)"
|
||||
value="{{content}}"
|
||||
bindinput="onContentInput"
|
||||
bindfocus="onTextareaFocus"
|
||||
bindblur="onTextareaBlur"
|
||||
maxlength="200"
|
||||
auto-height
|
||||
adjust-position="{{false}}"
|
||||
placeholder-class="textarea-placeholder"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 错误提示 -->
|
||||
<view class="error-wrap" wx:if="{{error}}">
|
||||
<text class="error-text">请输入放弃原因后再提交</text>
|
||||
</view>
|
||||
|
||||
<!-- 键盘弹出时的占位,防止内容被遮挡 -->
|
||||
<view wx:if="{{keyboardHeight > 0}}" style="height: {{keyboardHeight}}px;"></view>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<view class="modal-footer {{keyboardHeight > 0 ? 'modal-footer--float' : ''}}" style="{{keyboardHeight > 0 ? 'bottom: ' + keyboardHeight + 'px;' : ''}}">
|
||||
<view class="confirm-btn {{!canSave ? 'disabled' : ''}}" bindtap="onConfirm" hover-class="{{canSave ? 'confirm-btn--hover' : ''}}">
|
||||
<text class="confirm-text">确认放弃</text>
|
||||
</view>
|
||||
<view class="cancel-btn" bindtap="onCancel" hover-class="cancel-btn--hover">
|
||||
<text class="cancel-text">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,192 @@
|
||||
/* 放弃弹窗样式 */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
z-index: 1000;
|
||||
transition: align-items 0.3s ease;
|
||||
}
|
||||
|
||||
/* 键盘弹出时,弹窗移到顶部 */
|
||||
.modal-overlay--keyboard-open {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.modal-container {
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border-radius: 48rpx 48rpx 0 0;
|
||||
padding: 40rpx 40rpx 60rpx;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
transition: border-radius 0.3s ease;
|
||||
}
|
||||
|
||||
/* 键盘弹出时,改为全圆角 */
|
||||
.modal-overlay--keyboard-open .modal-container {
|
||||
border-radius: 0 0 48rpx 48rpx;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
/* 头部 */
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.modal-emoji {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
line-height: 44rpx;
|
||||
font-weight: 600;
|
||||
color: #242424;
|
||||
}
|
||||
|
||||
.modal-name {
|
||||
color: #e34d59;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.modal-close--hover {
|
||||
background: #f3f3f3;
|
||||
}
|
||||
|
||||
/* 描述 */
|
||||
.modal-desc-wrap {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.modal-desc {
|
||||
font-size: 26rpx;
|
||||
line-height: 36rpx;
|
||||
color: #8b8b8b;
|
||||
}
|
||||
|
||||
/* 文本输入 */
|
||||
.textarea-section {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.abandon-textarea {
|
||||
width: 100%;
|
||||
min-height: 240rpx;
|
||||
padding: 24rpx;
|
||||
background: #f3f3f3;
|
||||
border-radius: 24rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #242424;
|
||||
border: 2rpx solid #f3f3f3;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.abandon-textarea:focus {
|
||||
border-color: #0052d9;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.textarea-placeholder {
|
||||
color: #a6a6a6;
|
||||
}
|
||||
|
||||
/* 错误提示 */
|
||||
.error-wrap {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.error-text {
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #e34d59;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
/* 键盘弹出时固定在键盘上方 */
|
||||
.modal-footer--float {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 12rpx 40rpx 16rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 -2rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #e34d59, #f87171);
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(227, 77, 89, 0.3);
|
||||
}
|
||||
|
||||
.confirm-btn.disabled {
|
||||
background: #e7e7e7;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.confirm-text {
|
||||
font-size: 32rpx;
|
||||
line-height: 44rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn.disabled .confirm-text {
|
||||
color: #a6a6a6;
|
||||
}
|
||||
|
||||
.confirm-btn--hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cancel-text {
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #a6a6a6;
|
||||
}
|
||||
|
||||
.cancel-btn--hover .cancel-text {
|
||||
color: #5e5e5e;
|
||||
}
|
||||
@@ -50,8 +50,7 @@
|
||||
|
||||
/* SVG 图标 H5: 30px → 52rpx */
|
||||
.ai-icon-svg {
|
||||
width: 52rpx;
|
||||
height: 52rpx;
|
||||
height: 60rpx;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
Component({
|
||||
options: {
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
|
||||
/**
|
||||
* ai-inline-icon — 行首 AI 小图标组件
|
||||
*
|
||||
* ## 用法
|
||||
* 1. 在页面/组件的 .json 中注册:
|
||||
* "ai-inline-icon": "/components/ai-inline-icon/ai-inline-icon"
|
||||
*
|
||||
* 2. 在 WXML 中使用:
|
||||
* <!-- 固定配色 -->
|
||||
* <ai-inline-icon color="indigo" />
|
||||
*
|
||||
* <!-- 页面随机配色(推荐) -->
|
||||
* <ai-inline-icon color="{{aiColor}}" />
|
||||
*
|
||||
* ## color 可选值
|
||||
* red | orange | yellow | blue | indigo(默认)| purple
|
||||
*
|
||||
* ## 样式来源
|
||||
* 全局 app.wxss:.ai-inline-icon + .ai-color-*
|
||||
*
|
||||
* ## 页面随机配色初始化(复制到 Page.onLoad)
|
||||
* const AI_COLORS = ['red','orange','yellow','blue','indigo','purple']
|
||||
* const aiColor = AI_COLORS[Math.floor(Math.random() * AI_COLORS.length)]
|
||||
* this.setData({ aiColor })
|
||||
*/
|
||||
properties: {
|
||||
/** 颜色系列:red | orange | yellow | blue | indigo | purple */
|
||||
color: {
|
||||
type: String,
|
||||
value: 'indigo',
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
<view class="ai-inline-icon ai-color-{{color}}">
|
||||
<image src="/assets/icons/ai-robot-inline.svg" mode="aspectFit" />
|
||||
</view>
|
||||
@@ -0,0 +1,4 @@
|
||||
/* 引入全局 AI 样式 */
|
||||
@import "../../app.wxss";
|
||||
|
||||
/* 组件内样式继承全局定义 */
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
Component({
|
||||
options: {
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
|
||||
/**
|
||||
* ai-title-badge — 标题行 AI 徽章组件
|
||||
*
|
||||
* ## 用法
|
||||
* 1. 在页面/组件的 .json 中注册:
|
||||
* "ai-title-badge": "/components/ai-title-badge/ai-title-badge"
|
||||
*
|
||||
* 2. 在 WXML 中使用:
|
||||
* <!-- 固定配色,默认文字 -->
|
||||
* <ai-title-badge color="indigo" />
|
||||
*
|
||||
* <!-- 自定义文字 -->
|
||||
* <ai-title-badge color="blue" label="AI 建议" />
|
||||
*
|
||||
* <!-- 页面随机配色(推荐) -->
|
||||
* <ai-title-badge color="{{aiColor}}" />
|
||||
*
|
||||
* ## color 可选值
|
||||
* red | orange | yellow | blue | indigo(默认)| purple
|
||||
*
|
||||
* ## label 默认值
|
||||
* "AI智能洞察"
|
||||
*
|
||||
* ## 样式来源
|
||||
* 全局 app.wxss:.ai-title-badge + .ai-color-*
|
||||
*
|
||||
* ## 页面随机配色初始化(复制到 Page.onLoad)
|
||||
* const AI_COLORS = ['red','orange','yellow','blue','indigo','purple']
|
||||
* const aiColor = AI_COLORS[Math.floor(Math.random() * AI_COLORS.length)]
|
||||
* this.setData({ aiColor })
|
||||
*/
|
||||
properties: {
|
||||
/** 颜色系列:red | orange | yellow | blue | indigo | purple */
|
||||
color: {
|
||||
type: String,
|
||||
value: 'indigo',
|
||||
},
|
||||
/** 徽章文字,默认「AI智能洞察」 */
|
||||
label: {
|
||||
type: String,
|
||||
value: 'AI智能洞察',
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
<view class="ai-title-badge ai-color-{{color}}">
|
||||
<view class="ai-title-badge-icon">
|
||||
<image src="/assets/icons/ai-robot-badge.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<text>{{label}}</text>
|
||||
</view>
|
||||
@@ -0,0 +1,4 @@
|
||||
/* 引入全局 AI 样式 */
|
||||
@import "../../app.wxss";
|
||||
|
||||
/* 组件内样式继承全局定义 */
|
||||
@@ -1,6 +1,6 @@
|
||||
<!-- 筛选下拉组件 — 全屏宽度面板 + 遮罩层 -->
|
||||
<view class="filter-dropdown-wrap" wx:if="{{options && options.length > 0}}">
|
||||
<view class="filter-dropdown {{expanded ? 'filter-dropdown--active' : ''}}" bindtap="toggleDropdown">
|
||||
<view class="filter-dropdown {{expanded ? 'filter-dropdown--active' : ''}} {{selectedText ? 'filter-dropdown--selected' : ''}}" bindtap="toggleDropdown">
|
||||
<text class="filter-label">{{selectedText || label}}</text>
|
||||
<t-icon name="caret-down-small" size="32rpx" class="filter-arrow {{expanded ? 'filter-arrow--up' : ''}}" />
|
||||
</view>
|
||||
|
||||
@@ -6,15 +6,17 @@
|
||||
}
|
||||
|
||||
/* 触发按钮 */
|
||||
/* H5: px-3=12px→22rpx, py-2=8px→14rpx, bg-gray-50=#f9fafb, rounded-lg=8px→14rpx, border-gray-100=#f3f4f6 */
|
||||
/* 增加 padding 匹配 H5 按钮高度 37.33px */
|
||||
.filter-dropdown {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
background: #ffffff;
|
||||
border-radius: var(--radius-md);
|
||||
border: 2rpx solid var(--color-gray-1);
|
||||
padding: 16rpx 22rpx;
|
||||
background: #f9fafb;
|
||||
border-radius: 14rpx;
|
||||
border: 2rpx solid #f3f4f6;
|
||||
transition: border-color 0.2s, background-color 0.2s;
|
||||
}
|
||||
|
||||
@@ -23,17 +25,24 @@
|
||||
background: var(--color-primary-light);
|
||||
}
|
||||
|
||||
/* H5: text-sm=14px→24rpx, font-medium=500 for sort label */
|
||||
.filter-label {
|
||||
font-size: 24rpx;
|
||||
color: var(--color-gray-12);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 600;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.filter-dropdown--active .filter-label {
|
||||
color: var(--color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 已选中筛选项 — 粗字体标记当前选择 */
|
||||
.filter-dropdown--selected .filter-label {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 箭头旋转动画 */
|
||||
@@ -99,7 +108,7 @@
|
||||
|
||||
.dropdown-item--active {
|
||||
color: var(--color-primary, #0052d9);
|
||||
font-weight: 500;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dropdown-item + .dropdown-item {
|
||||
|
||||
@@ -16,13 +16,13 @@ Component({
|
||||
const s = val < 0 ? 0 : val > 10 ? 10 : val
|
||||
let emoji: string
|
||||
if (s > 8.5) {
|
||||
emoji = '💖'
|
||||
} else if (s > 7) {
|
||||
emoji = '🧡'
|
||||
} else if (s > 5) {
|
||||
emoji = '💛'
|
||||
emoji = '💖' // 粉红色 - 很好
|
||||
} else if (s >= 6) {
|
||||
emoji = '🧡' // 橙色 - 良好
|
||||
} else if (s >= 3.5) {
|
||||
emoji = '💛' // 黄色 - 一般
|
||||
} else {
|
||||
emoji = '💙'
|
||||
emoji = '💙' // 蓝色 - 待发展
|
||||
}
|
||||
this.setData({ heartEmoji: emoji })
|
||||
},
|
||||
|
||||
@@ -1,74 +1,231 @@
|
||||
Component({
|
||||
properties: {
|
||||
/** 控制弹窗显示/隐藏 */
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
/** 客户名(弹窗标题显示) */
|
||||
customerName: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
/** 初始评分 0-10 */
|
||||
initialScore: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
},
|
||||
/** 初始备注内容 */
|
||||
initialContent: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
|
||||
observers: {
|
||||
'visible, initialScore, initialContent'(visible: boolean) {
|
||||
if (visible) {
|
||||
const clamped = Math.max(0, Math.min(10, this.data.initialScore))
|
||||
this.setData({
|
||||
starValue: clamped / 2,
|
||||
content: this.data.initialContent,
|
||||
score: clamped,
|
||||
})
|
||||
}
|
||||
/** 是否显示展开/收起按钮 */
|
||||
showExpandBtn: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
/** 星星值 0-5(半星制) */
|
||||
starValue: 0,
|
||||
/** 内部评分 0-10 */
|
||||
score: 0,
|
||||
/** 备注内容 */
|
||||
ratingExpanded: false, // 默认收起
|
||||
serviceScore: 0, // 再次服务此客户 1-5
|
||||
returnScore: 0, // 再来店可能性 1-5
|
||||
content: '',
|
||||
keyboardHeight: 0, // 键盘高度 px
|
||||
canSave: false, // 是否可保存
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
created() {
|
||||
// 初始化私有缓存(不走 setData,避免触发渲染)
|
||||
;(this as any)._heartContainerRect = null
|
||||
;(this as any)._ballContainerRect = null
|
||||
},
|
||||
},
|
||||
|
||||
observers: {
|
||||
visible(val: boolean) {
|
||||
if (val) {
|
||||
// 打开弹窗时重置
|
||||
this.setData({
|
||||
ratingExpanded: !this.data.showExpandBtn, // 有展开按钮时默认收起,无按钮时默认展开
|
||||
serviceScore: 0,
|
||||
returnScore: 0,
|
||||
content: this.data.initialContent || '',
|
||||
keyboardHeight: 0,
|
||||
canSave: false,
|
||||
})
|
||||
// 多次重试获取容器位置信息,确保首次也能正确缓存
|
||||
this._retryGetContainerRects(0)
|
||||
} else {
|
||||
// 关闭时重置键盘高度
|
||||
this.setData({ keyboardHeight: 0 })
|
||||
}
|
||||
},
|
||||
// 任意评分或内容变化时重新计算 canSave
|
||||
'serviceScore, returnScore, content'(
|
||||
serviceScore: number,
|
||||
returnScore: number,
|
||||
content: string
|
||||
) {
|
||||
this.setData({
|
||||
canSave: serviceScore > 0 && returnScore > 0 && content.trim().length > 0,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 星星评分变化 */
|
||||
onRateChange(e: WechatMiniprogram.CustomEvent<{ value: number }>) {
|
||||
const starVal = e.detail.value
|
||||
this.setData({
|
||||
starValue: starVal,
|
||||
score: starVal * 2,
|
||||
/** 缓存容器位置信息 */
|
||||
_cacheContainerRects() {
|
||||
const query = this.createSelectorQuery()
|
||||
query.select('.rating-right-heart').boundingClientRect()
|
||||
query.select('.rating-right-ball').boundingClientRect()
|
||||
query.exec((res) => {
|
||||
if (res[0]) (this as any)._heartContainerRect = res[0] as WechatMiniprogram.BoundingClientRectCallbackResult
|
||||
if (res[1]) (this as any)._ballContainerRect = res[1] as WechatMiniprogram.BoundingClientRectCallbackResult
|
||||
})
|
||||
},
|
||||
|
||||
/** 文本内容变化 */
|
||||
onContentChange(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
|
||||
/** 重试获取容器位置,确保首次打开也能正确缓存 */
|
||||
_retryGetContainerRects(attempt: number) {
|
||||
const maxAttempts = 5
|
||||
const delay = 50 + attempt * 50 // 50ms, 100ms, 150ms, 200ms, 250ms
|
||||
|
||||
setTimeout(() => {
|
||||
this._cacheContainerRects()
|
||||
|
||||
// 检查是否成功缓存,如果没有且还有重试次数,继续重试
|
||||
const heartRect = (this as any)._heartContainerRect
|
||||
const ballRect = (this as any)._ballContainerRect
|
||||
|
||||
if ((!heartRect || !ballRect) && attempt < maxAttempts - 1) {
|
||||
this._retryGetContainerRects(attempt + 1)
|
||||
}
|
||||
}, delay)
|
||||
},
|
||||
|
||||
/** 切换展开/收起 */
|
||||
onToggleExpand() {
|
||||
const nextExpanded = !this.data.ratingExpanded
|
||||
this.setData({ ratingExpanded: nextExpanded })
|
||||
// 展开后重新获取位置
|
||||
if (nextExpanded) {
|
||||
setTimeout(() => {
|
||||
this._cacheContainerRects()
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
|
||||
/** 爱心点击 */
|
||||
onHeartTap(e: WechatMiniprogram.BaseEvent) {
|
||||
const score = e.currentTarget.dataset.score as number
|
||||
this.setData({ serviceScore: score })
|
||||
},
|
||||
|
||||
/** 爱心区域触摸开始 */
|
||||
onHeartTouchStart(e: WechatMiniprogram.TouchEvent) {
|
||||
this._updateHeartScore(e)
|
||||
},
|
||||
|
||||
/** 爱心区域触摸移动 */
|
||||
onHeartTouchMove(e: WechatMiniprogram.TouchEvent) {
|
||||
this._updateHeartScore(e)
|
||||
},
|
||||
|
||||
/** 更新爱心评分 */
|
||||
_updateHeartScore(e: WechatMiniprogram.TouchEvent) {
|
||||
const container = (this as any)._heartContainerRect as WechatMiniprogram.BoundingClientRectCallbackResult | null
|
||||
if (!container) return
|
||||
|
||||
const touch = e.touches[0]
|
||||
// 垂直方向超出不影响评分,仅用 X 轴计算
|
||||
let relativeX = touch.clientX - container.left
|
||||
|
||||
// 水平边界:最左=1分,最右=5分
|
||||
if (relativeX < 0) relativeX = 0
|
||||
if (relativeX > container.width) relativeX = container.width
|
||||
|
||||
// 计算分数 (1-5)
|
||||
const score = Math.ceil((relativeX / container.width) * 5)
|
||||
const finalScore = Math.max(1, Math.min(5, score))
|
||||
|
||||
if (finalScore !== this.data.serviceScore) {
|
||||
this.setData({ serviceScore: finalScore })
|
||||
}
|
||||
},
|
||||
|
||||
/** 台球点击 */
|
||||
onBallTap(e: WechatMiniprogram.BaseEvent) {
|
||||
const score = e.currentTarget.dataset.score as number
|
||||
this.setData({ returnScore: score })
|
||||
},
|
||||
|
||||
/** 台球区域触摸开始 */
|
||||
onBallTouchStart(e: WechatMiniprogram.TouchEvent) {
|
||||
this._updateBallScore(e)
|
||||
},
|
||||
|
||||
/** 台球区域触摸移动 */
|
||||
onBallTouchMove(e: WechatMiniprogram.TouchEvent) {
|
||||
this._updateBallScore(e)
|
||||
},
|
||||
|
||||
/** 更新台球评分 */
|
||||
_updateBallScore(e: WechatMiniprogram.TouchEvent) {
|
||||
const container = (this as any)._ballContainerRect as WechatMiniprogram.BoundingClientRectCallbackResult | null
|
||||
if (!container) return
|
||||
|
||||
const touch = e.touches[0]
|
||||
// 垂直方向超出不影响评分,仅用 X 轴计算
|
||||
let relativeX = touch.clientX - container.left
|
||||
|
||||
// 水平边界:最左=1分,最右=5分
|
||||
if (relativeX < 0) relativeX = 0
|
||||
if (relativeX > container.width) relativeX = container.width
|
||||
|
||||
// 计算分数 (1-5)
|
||||
const score = Math.ceil((relativeX / container.width) * 5)
|
||||
const finalScore = Math.max(1, Math.min(5, score))
|
||||
|
||||
if (finalScore !== this.data.returnScore) {
|
||||
this.setData({ returnScore: finalScore })
|
||||
}
|
||||
},
|
||||
|
||||
/** 文本输入 */
|
||||
onContentInput(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
|
||||
this.setData({ content: e.detail.value })
|
||||
},
|
||||
|
||||
/** 确认提交 */
|
||||
/** 键盘弹出 */
|
||||
onTextareaFocus(e: WechatMiniprogram.InputEvent) {
|
||||
let height = (e as any).detail?.height ?? 0
|
||||
// 修复:首次激活时键盘高度可能为0,需要设置最小值确保弹窗移动
|
||||
if (height === 0) {
|
||||
height = 260 // 微信小程序默认键盘高度约 260px
|
||||
}
|
||||
this.setData({ keyboardHeight: height })
|
||||
},
|
||||
|
||||
/** 键盘收起 */
|
||||
onTextareaBlur() {
|
||||
this.setData({ keyboardHeight: 0 })
|
||||
},
|
||||
|
||||
/** 确认保存 */
|
||||
onConfirm() {
|
||||
if (!this.data.content.trim()) return
|
||||
if (!this.data.canSave) return
|
||||
|
||||
// 计算综合评分:取两个评分的平均值,转换为10分制
|
||||
const avgScore = (this.data.serviceScore + this.data.returnScore) / 2
|
||||
const finalScore = avgScore * 2 // 转换为10分制
|
||||
|
||||
this.triggerEvent('confirm', {
|
||||
score: this.data.score,
|
||||
score: finalScore,
|
||||
content: this.data.content.trim(),
|
||||
serviceScore: this.data.serviceScore,
|
||||
returnScore: this.data.returnScore,
|
||||
})
|
||||
},
|
||||
|
||||
/** 取消关闭 */
|
||||
/** 取消 */
|
||||
onCancel() {
|
||||
this.triggerEvent('cancel')
|
||||
},
|
||||
|
||||
@@ -1,46 +1,83 @@
|
||||
<view class="modal-mask" wx:if="{{visible}}" catchtap="onCancel">
|
||||
<view class="modal-content" catchtap="noop">
|
||||
<view class="modal-overlay {{keyboardHeight > 0 ? 'modal-overlay--keyboard-open' : ''}}" wx:if="{{visible}}" catchtap="onCancel" catchtouchmove="noop">
|
||||
<view class="modal-container" catchtap="noop">
|
||||
<!-- 头部 -->
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">添加备注{{customerName ? ' - ' + customerName : ''}}</text>
|
||||
<view class="modal-close" bindtap="onCancel">
|
||||
<t-icon name="close" size="40rpx" color="#a6a6a6" />
|
||||
<view class="header-left">
|
||||
<text class="modal-title">添加备注</text>
|
||||
<view class="expand-btn" wx:if="{{showExpandBtn}}" bindtap="onToggleExpand" hover-class="expand-btn--hover">
|
||||
<text class="expand-text">{{ratingExpanded ? '收起评价 ▴' : '展开评价 ▾'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="onCancel" hover-class="modal-close--hover">
|
||||
<t-icon name="close" size="40rpx" color="#8b8b8b" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 评分区域 -->
|
||||
<view class="rating-section">
|
||||
<text class="rating-label">评分</text>
|
||||
<t-rate
|
||||
value="{{starValue}}"
|
||||
count="{{5}}"
|
||||
allow-half="{{true}}"
|
||||
size="48rpx"
|
||||
bind:change="onRateChange"
|
||||
/>
|
||||
<view class="rating-section" wx:if="{{ratingExpanded}}">
|
||||
<!-- 再次服务此客户 - 爱心 -->
|
||||
<view class="rating-group">
|
||||
<text class="rating-label">再次服务此客户</text>
|
||||
<view class="rating-right rating-right-heart" bindtouchstart="onHeartTouchStart" bindtouchmove="onHeartTouchMove">
|
||||
<view class="rating-row">
|
||||
<view class="rating-item" wx:for="{{[1,2,3,4,5]}}" wx:key="*this" bindtap="onHeartTap" data-score="{{item}}" hover-class="rating-item--hover">
|
||||
<image class="rating-icon" src="{{serviceScore >= item ? '/assets/icons/heart-filled.svg' : '/assets/icons/heart-empty.svg'}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="rating-hints">
|
||||
<text class="hint" style="text-align: left;">不想</text>
|
||||
<text class="hint"></text>
|
||||
<text class="hint">一般</text>
|
||||
<text class="hint"></text>
|
||||
<text class="hint">非常想</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 再来店可能性 - 台球 -->
|
||||
<view class="rating-group">
|
||||
<text class="rating-label">再来店可能性</text>
|
||||
<view class="rating-right rating-right-ball" bindtouchstart="onBallTouchStart" bindtouchmove="onBallTouchMove">
|
||||
<view class="rating-row">
|
||||
<view class="rating-item" wx:for="{{[1,2,3,4,5]}}" wx:key="*this" bindtap="onBallTap" data-score="{{item}}" hover-class="rating-item--hover">
|
||||
<image class="rating-icon" src="{{returnScore >= item ? '/assets/icons/ball-black.svg' : '/assets/icons/ball-gray.svg'}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="rating-hints">
|
||||
<text class="hint" style="text-align: left;">不可能</text>
|
||||
<text class="hint"></text>
|
||||
<text class="hint">不好说</text>
|
||||
<text class="hint"></text>
|
||||
<text class="hint">肯定能</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 文本输入 -->
|
||||
<view class="textarea-section">
|
||||
<t-textarea
|
||||
value="{{content}}"
|
||||
<textarea
|
||||
class="note-textarea"
|
||||
placeholder="请输入备注内容..."
|
||||
maxlength="{{500}}"
|
||||
autosize="{{true}}"
|
||||
bind:change="onContentChange"
|
||||
value="{{content}}"
|
||||
bindinput="onContentInput"
|
||||
bindfocus="onTextareaFocus"
|
||||
bindblur="onTextareaBlur"
|
||||
maxlength="500"
|
||||
auto-height
|
||||
adjust-position="{{false}}"
|
||||
placeholder-class="textarea-placeholder"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="modal-footer">
|
||||
<t-button theme="default" size="large" block bindtap="onCancel">取消</t-button>
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="large"
|
||||
block
|
||||
disabled="{{!content.trim()}}"
|
||||
bindtap="onConfirm"
|
||||
>确认</t-button>
|
||||
<!-- 键盘弹出时的占位,防止内容被遮挡 -->
|
||||
<view wx:if="{{keyboardHeight > 0}}" style="height: {{keyboardHeight}}px;"></view>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<view class="modal-footer {{keyboardHeight > 0 ? 'modal-footer--float' : ''}}" style="{{keyboardHeight > 0 ? 'bottom: ' + keyboardHeight + 'px;' : ''}}">
|
||||
<view class="save-btn {{!canSave ? 'disabled' : ''}}" bindtap="onConfirm" hover-class="{{canSave ? 'save-btn--hover' : ''}}">
|
||||
<text class="save-text">保存</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
.modal-mask {
|
||||
/* 备注弹窗样式 */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
z-index: 1000;
|
||||
transition: align-items 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
/* 键盘弹出时,弹窗移到顶部 */
|
||||
.modal-overlay--keyboard-open {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.modal-container {
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
background: #fff;
|
||||
border-radius: 48rpx 48rpx 0 0;
|
||||
padding: 40rpx 40rpx 60rpx;
|
||||
box-sizing: border-box;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
transition: border-radius 0.3s ease;
|
||||
}
|
||||
|
||||
/* 键盘弹出时,改为全圆角 */
|
||||
.modal-overlay--keyboard-open .modal-container {
|
||||
border-radius: 0 0 48rpx 48rpx;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
/* 头部 */
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -25,10 +41,34 @@
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: var(--font-lg, 36rpx);
|
||||
font-size: 32rpx;
|
||||
line-height: 44rpx;
|
||||
font-weight: 600;
|
||||
color: var(--color-gray-13, #242424);
|
||||
color: #242424;
|
||||
}
|
||||
|
||||
.expand-btn {
|
||||
padding: 6rpx 24rpx;
|
||||
background: #e8e8e8;
|
||||
border-radius: 999rpx;
|
||||
line-height: 16rpx;
|
||||
}
|
||||
|
||||
.expand-text {
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #5e5e5e;
|
||||
}
|
||||
|
||||
.expand-btn--hover {
|
||||
background: #eeeeee;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
@@ -38,31 +78,164 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background: var(--color-gray-1, #f3f3f3);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.modal-close--hover {
|
||||
background: #f3f3f3;
|
||||
}
|
||||
|
||||
/* 评分区域 */
|
||||
.rating-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.rating-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 32rpx;
|
||||
background: #f3f3f3;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.rating-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.rating-label {
|
||||
font-size: var(--font-sm, 28rpx);
|
||||
color: var(--color-gray-9, #5e5e5e);
|
||||
flex-shrink: 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
color: #242424;
|
||||
padding-top: 8rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.rating-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.rating-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.rating-item {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
/* 移除过渡动画 */
|
||||
}
|
||||
|
||||
.rating-item--hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.rating-icon {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
display: block;
|
||||
/* 移除过渡动画 */
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.rating-hints {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 20rpx;
|
||||
line-height: 28rpx;
|
||||
color: #a6a6a6;
|
||||
text-align: center;
|
||||
width: 80rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.textarea-section {
|
||||
margin-bottom: 40rpx;
|
||||
.hint:nth-child(2n) {
|
||||
width: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 文本输入 */
|
||||
.textarea-section {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.note-textarea {
|
||||
width: 100%;
|
||||
min-height: 240rpx;
|
||||
padding: 24rpx;
|
||||
background: #f3f3f3;
|
||||
border-radius: 24rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #242424;
|
||||
border: 2rpx solid #f3f3f3;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.note-textarea:focus {
|
||||
border-color: #0052d9;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.textarea-placeholder {
|
||||
color: #a6a6a6;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.modal-footer t-button {
|
||||
flex: 1;
|
||||
/* 键盘弹出时固定在键盘上方 */
|
||||
.modal-footer--float {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 12rpx 40rpx 16rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 -2rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
flex: 1;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #0052d9, #2979ff);
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 82, 217, 0.3);
|
||||
}
|
||||
|
||||
.save-btn.disabled {
|
||||
background: #e7e7e7;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.save-text {
|
||||
font-size: 32rpx;
|
||||
line-height: 44rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.save-btn.disabled .save-text {
|
||||
color: #a6a6a6;
|
||||
}
|
||||
|
||||
.save-btn--hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Component({
|
||||
properties: {
|
||||
/** 评分 0-10,内部转换为 0-5 星 */
|
||||
/** 评分 0-10,内部转换为 0-5 星,支持半星 */
|
||||
score: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
@@ -19,7 +19,7 @@ Component({
|
||||
|
||||
observers: {
|
||||
score(val: number) {
|
||||
// score(0-10) → star(0-5)
|
||||
// score(0-10) → star(0-5),支持半星(如 7.5 → 3.75星)
|
||||
const clamped = Math.max(0, Math.min(10, val))
|
||||
this.setData({ starValue: clamped / 2 })
|
||||
},
|
||||
|
||||
@@ -3,5 +3,7 @@
|
||||
count="{{5}}"
|
||||
allow-half
|
||||
size="{{size}}"
|
||||
color="#fbbf24"
|
||||
gap="{{4}}"
|
||||
disabled="{{readonly}}"
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* 星星评分组件样式 */
|
||||
:host {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user