From 5e0d53fc20e8192b429115adad43134b6622c0db Mon Sep 17 00:00:00 2001 From: duanshuwen Date: Sun, 3 Aug 2025 18:06:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FormCard/README.md | 461 ++++++++++++++++++ components/FormCard/demo.vue | 256 ++++++++++ components/FormCard/index.vue | 179 ++++++- components/FormCard/styles/index.scss | 138 +++++- components/ImageSwiper/README.md | 117 ++++- components/ImageSwiper/demo.vue | 76 +++ components/ImageSwiper/index.vue | 28 +- components/ImageSwiper/styles/index.scss | 3 +- components/Stepper/README.md | 72 +++ components/Stepper/images/icon_minus.png | Bin 1713 -> 0 bytes components/Stepper/images/icon_plus.png | Bin 1786 -> 0 bytes components/Stepper/index.vue | 25 +- components/Stepper/styles/index.scss | 17 +- components/SumCard/styles/index.scss | 9 +- pages/goods/components/GoodConfirm/README.md | 57 ++- pages/goods/components/GoodConfirm/demo.vue | 287 ++++++----- pages/goods/components/GoodConfirm/index.vue | 210 +++++--- .../components/GoodConfirm/styles/index.scss | 318 ++++++------ pages/goods/components/GoodInfo/index.vue | 11 - .../components/GoodInfo/styles/index.scss | 27 - pages/goods/index.vue | 25 +- pages/goods/styles/index.scss | 172 ++++--- 22 files changed, 1906 insertions(+), 582 deletions(-) create mode 100644 components/FormCard/README.md create mode 100644 components/FormCard/demo.vue create mode 100644 components/Stepper/README.md delete mode 100644 components/Stepper/images/icon_minus.png delete mode 100644 components/Stepper/images/icon_plus.png diff --git a/components/FormCard/README.md b/components/FormCard/README.md new file mode 100644 index 0000000..8e33ef9 --- /dev/null +++ b/components/FormCard/README.md @@ -0,0 +1,461 @@ +# FormCard 表单卡片组件 + +一个功能完整的表单卡片组件,支持姓名和手机号输入,具备数据验证和双向绑定功能。 + +## 功能特性 + +- 📝 **双向绑定**:支持 v-model 双向数据绑定 +- ✅ **数据验证**:内置手机号格式验证 +- 🎨 **自定义标题**:可配置游客标题文本 +- 🗑️ **删除功能**:支持删除操作,可配置显示/隐藏 +- 💫 **交互反馈**:输入框聚焦效果和错误状态提示 +- 📱 **响应式设计**:适配不同屏幕尺寸 +- 🎯 **事件支持**:完整的事件系统 +- ⚡ **性能优化**:使用计算属性优化渲染 + +## 基础用法 + +### 默认使用 + +```vue + + + +``` + +### 自定义标题 + +```vue + +``` + +### 隐藏删除图标 + +```vue + +``` + +### 多个表单卡片 + +```vue + + + +``` + +### 表单验证 + +```vue + + + +``` + +## API 文档 + +### Props + +| 参数 | 类型 | 默认值 | 说明 | +|------|------|--------|---------| +| title | String | "游客1" | 表单卡片标题 | +| form | Object | `{ name: '', phone: '' }` | 表单数据对象,包含 name 和 phone 字段 | +| form.name | String | "" | 姓名值 | +| form.phone | String | "" | 手机号值 | +| showDeleteIcon | Boolean | true | 是否显示删除图标 | + +### Events + +| 事件名 | 参数 | 说明 | +|--------|------|------| +| update:name | (value: string) | 姓名值更新时触发,自动去除首尾空格 | +| update:phone | (value: string) | 手机号值更新时触发,自动过滤非数字字符 | +| delete | - | 点击删除图标时触发 | + +### Methods (通过 ref 调用) + +| 方法名 | 参数 | 返回值 | 说明 | +|--------|------|--------|---------| +| validateName | - | void | 手动触发姓名验证 | +| validatePhone | - | void | 手动触发手机号验证 | +| getNameError | (name: string) | string | 获取姓名验证错误信息 | +| getPhoneError | (phone: string) | string | 获取手机号验证错误信息 | + +### 数据验证 + +组件内置完整的表单验证: +- **姓名验证**:不能为空,自动去除首尾空格 +- **手机号验证**:支持中国大陆手机号格式(1开头,第二位为3-9,总长度11位) +- **失焦验证**:只在输入框失去焦点时进行验证,避免输入干扰 +- **错误提示**:验证失败时显示错误信息,带有淡入动画效果 +- **视觉反馈**:输入框边框变红提示错误状态 +- **自动过滤**:手机号输入时自动过滤非数字字符 + +## 样式定制 + +### CSS 变量系统 + +组件使用 CSS 变量系统,支持主题定制: + +```scss +:root { + --form-primary-color: #00a6ff; // 主色调 + --form-error-color: #ff4d4f; // 错误色 + --form-text-color: #333; // 文本色 + --form-label-color: #86909c; // 标签色 + --form-border-color: #e5e8ef; // 边框色 + --form-input-border-color: #ddd; // 输入框边框色 + --form-bg-color: #fff; // 背景色 + --form-header-bg-color: rgba(25, 144, 255, 0.06); // 头部背景色 + --form-border-radius: 8px; // 圆角大小 + --form-transition: all 0.2s ease; // 过渡动画 +} +``` + +### 主要样式类 + +```scss +.form-wrapper { + // 表单容器,支持悬停效果和阴影 +} + +.form-header { + // 表单头部,包含标题和删除按钮 +} + +.form-title { + // 标题文本,支持文本溢出省略 +} + +.form-item { + // 表单项容器,支持分隔线 +} + +.form-input { + // 输入框,支持聚焦和错误状态 +} + +.form-error { + // 错误信息,带有淡入动画 +} +``` + +### 响应式设计 + +组件内置响应式支持,在小屏幕设备上自动调整: +- 320px 以下设备优化布局 +- 自动调整字体大小和间距 +- 保持良好的可用性 + +### 自定义主题 + +通过覆盖 CSS 变量来自定义主题: + +```scss +// 自定义主题色 +:root { + --form-primary-color: #your-primary-color; + --form-error-color: #your-error-color; + --form-border-radius: 12px; +} + +// 或者针对特定组件 +.your-custom-form { + --form-primary-color: #your-primary-color; + --form-header-bg-color: rgba(your-color, 0.1); +} +``` + +## 高级用法 + +### 表单验证集成 + +```vue + + + +``` + +### 动态表单管理 + +```vue + + + +``` + +## 注意事项 + +1. **数据传递**:使用 `:form` 对象传递数据,包含 `name` 和 `phone` 字段 +2. **双向绑定**:通过 `@update:name` 和 `@update:phone` 事件进行双向绑定 +3. **验证机制**:只在失去焦点时进行验证,避免输入干扰 +4. **手机号验证**:仅支持中国大陆手机号格式验证(1开头,第二位3-9,总长度11位) +5. **自动处理**:手机号自动过滤非数字字符,姓名自动去除首尾空格 +6. **删除功能**:删除事件需要父组件处理具体逻辑 +7. **方法调用**:通过 `ref` 可调用组件内部的验证方法 +8. **兼容性**:支持微信小程序、H5、App等平台 + +## 更新日志 + +### v1.3.0 (2024-12-19) +**性能与可维护性全面优化** +- 🚀 **性能优化**:提取常量定义,优化计算属性逻辑 +- 🛠️ **代码重构**:添加完整的 JSDoc 注释和类型定义 +- 🎨 **样式升级**:使用 CSS 变量系统,支持主题定制 +- ✨ **功能增强**:手机号自动过滤非数字字符,姓名自动去除空格 +- 🎭 **UI 改进**:新增悬停效果、错误信息动画和阴影效果 +- 📱 **响应式设计**:优化小屏幕设备适配 +- 🔧 **开发体验**:添加 defineExpose 暴露验证方法,便于测试 +- 📝 **文档完善**:更新演示和使用说明 + +### v1.2.3 (2024-12-19) +**优化验证行为** +- 🎨 优化验证行为,移除实时验证 +- ✨ 姓名和手机号只在失去焦点时进行验证 +- 🔧 移除不必要的 watch 监听器 +- 📝 更新文档和演示说明 +- ⚡ 提升组件性能和用户体验 + +### v1.2.2 (2024-12-19) +**新增姓名验证功能** +- ✨ 新增姓名非空验证功能 +- 👤 姓名为空时显示"请输入姓名"提示 +- 🔄 支持姓名实时验证,输入内容时错误信息自动隐藏 +- 🎯 完善表单验证体系,提升数据完整性 +- 💫 优化用户体验,提供友好的输入提示 + +### v1.2.1 (2024-12-19) +**优化手机号验证功能** +- 🐛 修复validatePhone方法中props引用错误的问题 +- ✨ 新增手机号实时验证功能 +- 🔄 输入正确手机号时错误信息自动隐藏 +- 📱 优化用户输入体验,提供即时反馈 +- 🎯 完善demo页面,增加功能说明 + +### v1.2.0 (2024-12-19) +**新增删除功能** +- ✨ 支持删除表单卡片 +- 🎯 可配置删除图标显示/隐藏 +- 🔄 完善事件系统,支持delete事件 +- 💫 优化用户交互体验 + +### v2.0.0 +- ✨ 重构组件,支持 props 传值和双向绑定 +- ✨ 新增 `title` 属性,支持自定义标题 +- ✨ 新增 `showDeleteIcon` 属性,控制删除图标显示 +- ✨ 新增完整的事件系统(update:name, update:phone, delete) +- 🎨 优化样式,新增错误状态和交互效果 +- 🔧 改进手机号验证逻辑 +- 📝 新增完整的文档和演示示例 + +### v1.0.0 +- 🎉 初始版本发布 +- ✨ 基础表单功能 +- ✨ 手机号验证 +- ✨ 基础样式 + +## 技术栈 + +- Vue 3 Composition API +- SCSS +- uni-app + +## 浏览器支持 + +- 微信小程序 +- H5 (Chrome, Firefox, Safari, Edge) +- App (iOS, Android) + +## 许可证 + +MIT License \ No newline at end of file diff --git a/components/FormCard/demo.vue b/components/FormCard/demo.vue new file mode 100644 index 0000000..379d758 --- /dev/null +++ b/components/FormCard/demo.vue @@ -0,0 +1,256 @@ + + + + + \ No newline at end of file diff --git a/components/FormCard/index.vue b/components/FormCard/index.vue index 816b2db..6d11d9f 100644 --- a/components/FormCard/index.vue +++ b/components/FormCard/index.vue @@ -1,44 +1,169 @@ \ No newline at end of file diff --git a/components/ImageSwiper/index.vue b/components/ImageSwiper/index.vue index 5464163..98ae825 100644 --- a/components/ImageSwiper/index.vue +++ b/components/ImageSwiper/index.vue @@ -2,7 +2,7 @@ - + [], }, + // 轮播图高度,支持数字(px)或字符串 + height: { + type: [Number, String], + default: 200, + }, + // 是否显示缩略图 + showThumbnails: { + type: Boolean, + default: true, + }, }); const active = ref(0); @@ -79,6 +89,20 @@ const borderRadiusStyle = computed(() => { }; }); +// 计算轮播图样式(包含高度和圆角) +const swiperStyle = computed(() => { + const radius = + typeof props.borderRadius === "number" + ? `${props.borderRadius}px` + : props.borderRadius; + const swiperHeight = + typeof props.height === "number" ? `${props.height}px` : props.height; + return { + borderRadius: radius, + height: swiperHeight, + }; +}); + // 默认图片数据 const defaultImages = [ { diff --git a/components/ImageSwiper/styles/index.scss b/components/ImageSwiper/styles/index.scss index a7d1329..e9a73f6 100644 --- a/components/ImageSwiper/styles/index.scss +++ b/components/ImageSwiper/styles/index.scss @@ -4,9 +4,8 @@ } .swiper-box { - height: 200px; overflow: hidden; - // 圆角通过内联样式动态设置 + // 高度和圆角通过内联样式动态设置 } .swiper-item image { diff --git a/components/Stepper/README.md b/components/Stepper/README.md new file mode 100644 index 0000000..2411ffc --- /dev/null +++ b/components/Stepper/README.md @@ -0,0 +1,72 @@ +# Stepper 数字步进器组件 + +一个简洁易用的数字步进器组件,支持增减操作和数值范围限制。 + +## 功能特性 + +- ✨ **双向数据绑定**:支持 v-model 语法糖 +- 🔢 **数值范围控制**:可设置最小值和最大值 +- 🎯 **响应式更新**:实时响应外部数值变化 +- 🎨 **简洁UI设计**:使用 uni-icons 图标,界面清爽 +- 📱 **移动端适配**:完美适配各种屏幕尺寸 + +## 使用方法 + +### 基础用法 + +```vue + + + +``` + +### 设置数值范围 + +```vue + +``` + +## API + +### Props + +| 参数 | 类型 | 默认值 | 说明 | +|------|------|--------|------| +| modelValue | Number | 1 | 当前数值,支持 v-model | +| min | Number | 1 | 最小值 | +| max | Number | 100 | 最大值 | + +### Events + +| 事件名 | 说明 | 回调参数 | +|--------|------|----------| +| update:modelValue | 数值变化时触发 | (value: number) | + +## 更新日志 + +### v1.1.0 (2024-12-19) +**修复响应性问题** +- 🐛 修复组件不响应外部 modelValue 变化的问题 +- 🔄 添加 watch 监听器,确保实时同步外部值变化 +- ✨ 提升组件响应性和数据同步准确性 +- 🎯 完善与父组件的双向数据绑定 + +### v1.0.0 +**初始版本** +- ✨ 基础数字步进器功能 +- 🔢 支持数值范围控制 +- 🎨 简洁的UI设计 +- 📱 移动端适配 \ No newline at end of file diff --git a/components/Stepper/images/icon_minus.png b/components/Stepper/images/icon_minus.png deleted file mode 100644 index ee2c481e9732f6b713ac560230118e69faab71cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1713 zcmaJ?do)ye9KXt|iCCNDk#3VzVqRe$W@4DZV5H&HG;1?s=3?UBJ7%to(JHJqMcGbv z$*$sLQI6>8wWg<2XRT^!Bd20}(I#yx3P*cK(f+aao^$W-aXz2V_woDu&drSo53(dU z5C8zM6a@1`_~>GI%}w!dKTuSJ5B3;ej76exSgK470bB(d3xNVy77vLanIbLu2E+z{ z`L4<+F(wvghqDvM5Xzg$jOrhI^MU!T_7?FTts3rkbfdK)AuF=6YTa<_b zP1UTO<_Lu>0iwZVh#V5|I7D29q*N+c45p_)pAta#rh3t-)IbWC!t>_(GyECeR2tKt z$(Z5tPqF0Vx92C=5=Q%~H;ti`SfbAGwOTbMc;& zOU9ES8xHqhhdr}}JIFAdwJyGxH9v&lj#uN>9;)&lz;Db70goG{z1LoJDX~+!_+sZN zIB9?z()|;h61m!zzzJKurrhVv(`0&K=D5|sq@$v;pKq0Q;q-n!JB)h*TbAiJC=rK# z7E&MK6JUQj<;(4zuB~*N?$hU85#e}W#p6f6r0a*%$uSSs@i!d~t$ewysjjY1;9`?h zAzHA%{Oz&M!InaZIe$EI(_vDTu_PzC_CBKT?d?q$pS)9BA*!xdF~Y{q^j>){weC_k zvU|3lE6qGJ=C*sqrN(2+rA7yt2OR0Xy+F+Z@bKQIMSxE}RDWf^FAQS4bzf5U&@*?_oj&Qoy+Bn#Pm7UD&8=lb9 zvhh(gGQ3TEw75>#&__esjE?qrnqa=VyB4>YSqsAR4_seV^Sr$Ux?*APRN!S7ZM@zu z&Z+2u^VTVD)BTri*RO_tr~mxzfr>yAbMYZ#NuhgN2eMRAwfUs|q3}u*b4TBK{ULUQ z9N5hvUsvWQVarN1BBf`^ud6Rf3%Crc7r#O42opvo5|Z=5qd`kTe%99Iooy)nT{=~@ zs^*!wwcE&Jw1)J$jK3?TsQ-Gr9EOKhxo9t+;F-q!*^{(mtM5x@O<~BBMPcn$>4~?3 z8lzjQ$2PuMDpe6jLLctA6C%&vyD%tb&+dp7JHMy27GaeOveTNHnpoBEs20ZuJ32a6 zo{RSpl(_s+pLKp@G#^-&owfOfzPWi~v1I6=^~8~4-}04o%kz5oCK diff --git a/components/Stepper/images/icon_plus.png b/components/Stepper/images/icon_plus.png deleted file mode 100644 index 87d4570d27804b1d71751bdc4d8b0f7adbc32f15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1786 zcmaJ?do)ye93QkxB6IALu(^gNP0ZZuG0d!?F=Li8@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