Compare commits

..

42 Commits

Author SHA1 Message Date
kola-web 6fafba87bb 删除冗余弹窗 2 weeks ago
kola-web 497b53317b feat: 新增图片预览组件与笔记图片查看功能,优化多个页面样式与交互 3 weeks ago
kola-web b021f0949f 处理众测问题 4 weeks ago
kola-web d2347bceec style: 统一修改页面导航栏标题文案 1 month ago
kola-web 65c3ea976e refactor: 优化眼突度对比页面功能与样式 1 month ago
kola-web f2ad084a8f Improve diff baseline display and camera UX 1 month ago
kola-web fcf04cf202 bug fix 1 month ago
kola-web 5e454ce295 style: 统一代码格式和样式 1 month ago
kola-web 847838f3c5 fix(patient/noteAdd): 修复基准照选择逻辑并更新复选框样式 1 month ago
kola-web 6d53a8b081 feat(图片合并): 新增图片合并组件及功能优化 1 month ago
kola-web 6aca21f0bf feat: 新增照片对比功能及相关页面 1 month ago
kola-web f3af8dbb54 docs(接口文档): 更新突眼日记接口文档,完善接口规范和详细说明 1 month ago
kola-web b5f8e6ba78 突眼日记页面开发 2 months ago
kola-web 322c3c490e image stash 2 months ago
kola-web 383e1f4bba image stash 2 months ago
kola-web c15418f1aa image stash 2 months ago
kola-web d31fca2942 feat: 添加页面和按钮的行为追踪代码 2 months ago
kola-web 452e65a86b Merge branch 'dev' of http://39.106.86.127:3000/kola/xinda-miniprogram into dev 3 months ago
kola-web b2671cd939 fix: 修复推送ID处理逻辑并更新API配置 3 months ago
kola-web c3a47639d4 切换到开发环境 3 months ago
kola-web de550aa169 push id 适配 3 months ago
kola-web e949a70008 2.3.0 3 months ago
kola-web 0de235c1aa 选择医院bug处理 4 months ago
kola-web 6943ded348 2.2.0 修改完毕,上线版本 4 months ago
kola-web cbcf8c410b 2.2.0stash 4 months ago
kola-web b850a926c2 2.2.0 stash 4 months ago
kola-web fda038af27 2.2.2 stash 4 months ago
kola-web 003646127f 2.2.0 stash 4 months ago
kola-web 5e89a8dda5 2.2.0 开发stash 4 months ago
kola-web d38a412543 医保页面开发 4 months ago
kola-web eb0f042730 登录体验优化 5 months ago
kola-web 0824e8f811 激素量表上线 5 months ago
kola-web cb0edcb0af 激素 bugfix 5 months ago
kola-web 2bb9399e64 激素bug处理 6 months ago
kola-web 853c69aa7b 激素联调 6 months ago
kola-web 062a25c662 激素页面开发 6 months ago
kola-web 2110fa4a50 images 6 months ago
kola-web 04625c2753 忽略images文件夹的变化 6 months ago
kola-web a9e64f1ffe add git keep 6 months ago
kola-web f0ad8bde23 删除大量无用页面 6 months ago
kola-web e0354add61 激素 6 months ago
kola-web d2c122897d 增加版本更新提示 6 months ago
  1. 2
      .gitignore
  2. 240
      .trae/documents/proptosis_api_integration_plan.md
  3. 419
      .trae/rules/project_rules.md
  4. 4
      .vscode/settings.json
  5. 16
      .zed/settings.json
  6. 23
      README.md
  7. 6
      eslint.config.js
  8. 4
      project.config.json
  9. 149
      project.private.config.json
  10. 59
      src/app.json
  11. 51
      src/app.ts
  12. 43
      src/components/calendar/core.js
  13. 2
      src/components/calendar/helper.js
  14. 2
      src/components/calendar/index.d.ts
  15. 97
      src/components/calendar/index.js
  16. 2
      src/components/calendar/index.json
  17. 122
      src/components/calendar/plugins/holidays/holidays-map.js
  18. 2
      src/components/calendar/plugins/holidays/index.d.ts
  19. 86
      src/components/calendar/plugins/holidays/index.js
  20. 2
      src/components/calendar/plugins/index.d.ts
  21. 11
      src/components/calendar/plugins/index.js
  22. 116
      src/components/calendar/plugins/preset/base.js
  23. 30
      src/components/calendar/plugins/preset/get-calendar-data.js
  24. 2
      src/components/calendar/plugins/preset/index.d.ts
  25. 2
      src/components/calendar/plugins/preset/index.js
  26. 2
      src/components/calendar/plugins/selectable.d.ts
  27. 104
      src/components/calendar/plugins/selectable.js
  28. 662
      src/components/calendar/plugins/solarLunar/convertSolarLunar.js
  29. 2
      src/components/calendar/plugins/solarLunar/index.d.ts
  30. 29
      src/components/calendar/plugins/solarLunar/index.js
  31. 126
      src/components/calendar/plugins/time-range.js
  32. 2
      src/components/calendar/plugins/todo.d.ts
  33. 56
      src/components/calendar/plugins/todo.js
  34. 156
      src/components/calendar/plugins/week.js
  35. 47
      src/components/calendar/render.js
  36. 290
      src/components/calendar/utils/index.js
  37. 18
      src/components/calendar/utils/logger.js
  38. 17
      src/components/calendar/utils/wxData.js
  39. 148
      src/components/customPoster/README.md
  40. 88
      src/components/customPoster/index.js
  41. 1968
      src/components/customPoster/wxml2canvas/index.js
  42. 148
      src/components/customTable/README.md
  43. 203
      src/components/customTable/index.js
  44. 1966
      src/components/customTable/wxml2canvas/index.js
  45. 216
      src/components/ec-canvas/ec-canvas.js
  46. 2
      src/components/ec-canvas/ec-canvas.json
  47. 66
      src/components/ec-canvas/wx-canvas.js
  48. 149
      src/components/freeAudio/index.js
  49. 8
      src/components/image-merge/index.json
  50. 7
      src/components/image-merge/index.scss
  51. 200
      src/components/image-merge/index.ts
  52. 1
      src/components/image-merge/index.wxml
  53. 6
      src/components/loginNavbar/index.ts
  54. 6
      src/components/navbar/index.ts
  55. 7
      src/components/noteImagePreview/index.json
  56. 157
      src/components/noteImagePreview/index.scss
  57. 157
      src/components/noteImagePreview/index.ts
  58. 31
      src/components/noteImagePreview/index.wxml
  59. 6
      src/components/pageNavbar/index.ts
  60. 40
      src/components/patient-tab-bar/index.scss
  61. 16
      src/components/patient-tab-bar/index.ts
  62. 7
      src/components/patient-tab-bar/index.wxml
  63. 10
      src/components/pickerArea/index.scss
  64. 76
      src/components/pickerArea/index.ts
  65. 472
      src/components/popup/index.scss
  66. 3
      src/components/popup/index.ts
  67. 172
      src/components/popup/index.wxml
  68. 95
      src/components/referralFrom/index.scss
  69. 139
      src/components/referralFrom/index.ts
  70. 52
      src/components/referralFrom/index.wxml
  71. 209
      src/components/star/index.ts
  72. 8
      src/components/text-expandsion/index.scss
  73. 50
      src/components/timeOut/index.ts
  74. 143
      src/components/toast/index.scss
  75. 72
      src/components/toast/index.ts
  76. 65
      src/components/toast/index.wxml
  77. 87
      src/components/uploadFile/index.ts
  78. 28
      src/components/viewFile/index.js
  79. 2
      src/components/viewFile/index.json
  80. 7
      src/components/viewVideo/index.scss
  81. 228
      src/components/zd-navBar/navBar.js
  82. 2
      src/components/zd-navBar/navBar.scss
  83. 164
      src/components/zdUploadFile/index.js
  84. 12
      src/config.ts
  85. 4
      src/custom-tab-bar/index.scss
  86. 2
      src/doc/pages/doc1/index.scss
  87. 6
      src/doc/pages/doc1/index.ts
  88. 2
      src/doc/pages/doc2/index.scss
  89. 5184
      src/gift/compontnts/echart/echarts.js
  90. 6
      src/gift/pages/conformOrder/index.json
  91. 184
      src/gift/pages/conformOrder/index.scss
  92. 86
      src/gift/pages/conformOrder/index.ts
  93. 56
      src/gift/pages/conformOrder/index.wxml
  94. 4
      src/gift/pages/cutaneous/index.json
  95. 63
      src/gift/pages/cutaneous/index.scss
  96. 65
      src/gift/pages/cutaneous/index.ts
  97. 82
      src/gift/pages/cutaneous/index.wxml
  98. 4
      src/gift/pages/cutaneousDetail/index.json
  99. 11
      src/gift/pages/cutaneousDetail/index.scss
  100. 26
      src/gift/pages/cutaneousDetail/index.ts
  101. Some files were not shown because too many files have changed in this diff Show More

2
.gitignore vendored

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
node_modules
src/images/.svn
src/images/
.idea
.DS_Store
/src/images

240
.trae/documents/proptosis_api_integration_plan.md

@ -0,0 +1,240 @@ @@ -0,0 +1,240 @@
# 突眼日记接口联调计划
## 一、项目现状分析
### 1.1 已有页面结构
**医生端 (d\_ 前缀)**
- `d_noteList` - 突眼记录列表页(拍摄示例页)
- `d_noteDetail` - 突眼记录详情页
- `d_noteDiffData` - 凸眼度对比数据页(表格展示)
_患者端 (patient/pages/note_)\*
- `note` - 突眼日记首页
- `noteAdd` - 新增记录页
- `noteHistory` - 历史记录页
- `noteDiff` - 照片对比页
- `noteDiffEdit` - 对比编辑页
- `noteDemo` - 拍摄示例页
### 1.2 当前状态
- 所有页面都是静态数据,未接入接口
- 请求工具已封装在 `utils/request.ts`
- 使用 `wx.ajax` 进行接口调用(在 app.ts 中挂载)
---
## 二、需要的信息
在开始联调前,需要你提供以下信息:
### 2.1 环境信息
| 信息项 | 说明 | 是否必需 |
| -------------- | --------------------------- | -------- |
| 后端环境地址 | 开发/测试服务器地址 | 是 |
| 接口是否已部署 | 后端接口是否已上线可调用 | 是 |
| 登录态获取方式 | 如何获取 loginState/session | 是 |
### 2.2 接口测试信息
| 信息项 | 说明 | 是否必需 |
| ---------- | -------------------------- | -------- |
| 测试账号 | 医生账号和患者账号 | 是 |
| 测试患者ID | 用于医生端接口测试 | 是 |
| 已有数据 | 是否有已创建的突眼记录数据 | 否 |
### 2.3 图片上传相关
| 信息项 | 说明 | 是否必需 |
| ------------- | ----------------------------- | -------- |
| 图片上传方式 | 上传到腾讯云COS还是自家服务器 | 是 |
| 腾讯云IMS配置 | 是否已配置图片内容安全校验 | 否 |
---
## 三、接口联调清单
### 3.1 患者端接口 (10个)
| 序号 | 接口 | 用途 | 对应页面 | 优先级 |
| ---- | ------------------- | ---------------- | ----------------- | ------ |
| 1 | `baseline-status` | 获取基准照状态 | note | P0 |
| 2 | `record-list` | 获取记录列表 | note, noteHistory | P0 |
| 3 | `record-detail` | 获取记录详情 | noteHistory | P0 |
| 4 | `record-save` | 创建/更新记录 | noteAdd | P0 |
| 5 | `photo-upload` | 上传照片 | noteAdd | P0 |
| 6 | `record-delete` | 删除记录 | noteHistory | P1 |
| 7 | `compare-dates` | 获取对比可用日期 | noteDiff | P1 |
| 8 | `compare-photos` | 获取对比照片 | noteDiff | P1 |
| 9 | `get-compare-angle` | 获取对比角度列表 | noteDiffEdit | P1 |
| 10 | `get-session-id` | 获取唯一标识 | noteAdd | P2 |
### 3.2 医生端接口 (6个)
| 序号 | 接口 | 用途 | 对应页面 | 优先级 |
| ---- | ------------------------------------ | ---------------- | --------------- | ------ |
| 1 | `doctor/proptosis/latest` | 获取最近记录 | d_patientDetail | P0 |
| 2 | `doctor/proptosis/list` | 获取患者记录列表 | d_noteList | P0 |
| 3 | `doctor/proptosis/detail` | 获取记录详情 | d_noteDetail | P0 |
| 4 | `doctor/proptosis/export` | Excel导出 | d_noteDiffData | P1 |
| 5 | `doctor/proptosis/compare` | 获取对比数据 | d_noteDiffData | P1 |
| 6 | `doctor/proptosis/get-compare-angle` | 获取对比角度 | d_noteDiffData | P1 |
---
## 四、实施步骤
### Phase 1: 基础联调准备
1. 确认后端环境可用
2. 获取测试账号和患者ID
3. 验证登录态获取
### Phase 2: 患者端核心功能
1. 实现记录列表获取 (`record-list`)
2. 实现记录详情获取 (`record-detail`)
3. 实现记录创建/更新 (`record-save`)
4. 实现照片上传 (`photo-upload`)
### Phase 3: 患者端对比功能
1. 实现对比日期获取 (`compare-dates`)
2. 实现对比照片获取 (`compare-photos`)
3. 实现对比角度获取 (`get-compare-angle`)
### Phase 4: 医生端功能
1. 实现患者最近记录获取 (`doctor/proptosis/latest`)
2. 实现患者记录列表 (`doctor/proptosis/list`)
3. 实现记录详情 (`doctor/proptosis/detail`)
4. 实现对比数据获取 (`doctor/proptosis/compare`)
### Phase 5: 导出功能
1. 实现Excel导出 (`doctor/proptosis/export`)
---
## 五、数据结构映射
### 5.1 患者端 - 记录列表
```typescript
// 接口返回
interface RecordItem {
recordId: string
recordDate: string
isBaseline: number
photoCount: number
firstPhotoUrl: string
treatmentCount: number
leftEye: number
rightEye: number
interorbitalDistance: number
uploadCompleted: number
}
// 页面使用
interface DataListItem {
date: string // recordDate 格式化
left: string // leftEye
spacing: string // interorbitalDistance
right: string // rightEye
count: string // treatmentCount
isBaseline: boolean
photoCount: number
firstPhotoUrl: string
}
```
### 5.2 医生端 - 凸眼度对比表格
```typescript
// 接口返回 (compare 接口)
interface CompareItem {
recordId: string
recordDate: string
photoUrl: string
leftEye: number
rightEye: number
interorbitalDistance: number
treatmentCount: number
}
// 页面使用 (d_noteDiffData)
interface TableItem {
date: string // recordDate 格式化 2026.1.5
left: string // leftEye
spacing: string // interorbitalDistance
right: string // rightEye
count: string // treatmentCount
}
```
---
## 六、注意事项
### 6.1 业务规则
1. 同一天只能创建一条记录
2. 必须先上传照片再保存记录(photoIds 关联)
3. 基准照只能有一张
4. 图片需要经过腾讯云IMS安全校验
### 6.2 技术注意
1. 使用 `wx.ajax` 进行请求(已挂载在 app 上)
2. 医生端页面需要等待登录态 `app.waitLogin({ type: [2] })`
3. 患者端页面需要等待登录态 `app.waitLogin({ type: [1] })`
4. 图片URL需要拼接 `{{imageUrl}}` 前缀
### 6.3 角度映射
接口角度值与页面显示名称映射:
```typescript
const angleMap = {
front_open: '正面睁眼',
front_closed: '正面闭眼',
front_looking_up: '正面仰头',
side_left_90: '90°左侧',
side_right_90: '90°右侧',
side_left_45: '45°左侧',
side_right_45: '45°右侧',
eye_up_left: '左上',
eye_up: '向上',
eye_up_right: '右上',
eye_left: '向左',
eye_right: '向右',
eye_down_left: '左下',
eye_down: '向下',
eye_down_right: '右下',
}
```
---
## 七、下一步
请提供以下信息,我将开始实施联调:
1. **后端环境地址**(如:<https://m.xd.hbraas.com>
2. **测试账号**(医生和患者各一个)
3. **测试患者ID**(用于医生端接口测试)
4. **接口是否已部署**(确认后端已完成开发)
5. **图片上传方式**(腾讯云COS或自家服务器)

419
.trae/rules/project_rules.md

@ -0,0 +1,419 @@ @@ -0,0 +1,419 @@
# 项目规则 - 信达小程序 (Xinda Mini Program)
WeChat Mini Program for thyroid eye disease patient management. Dual-mode app serving both patients (患者端) and doctors (医生端).
## Project Type
- **Framework**: WeChat Mini Program v3.7.7
- **Language**: TypeScript (strict mode)
- **Styling**: SCSS/Sass via `useCompilerPlugins`
- **UI Library**: Vant Weapp (@vant/weapp)
- **Renderer**: Skyline enabled
- **App ID**: `wxf9ce8010f1ad24aa` (dev), `wx71ac9c27c3c3e3f4` (prod)
## Directory Structure
```
src/
├── pages/ # Doctor-side main pages (医生端)
├── patient/pages/ # Patient-side pages (subpackage)
├── gift/pages/ # DTP pharmacy pages (subpackage)
├── doc/pages/ # Privacy/terms documentation (subpackage)
├── components/ # Shared components
├── utils/ # Request, page/component wrappers, utilities
├── app.ts # App entry with global data
└── config.ts # Environment configs per appId
```
## Key Conventions
### Path Aliases
- `@/*``src/*` (configured in tsconfig.json and app.json `resolveAlias`)
- Use `@/utils/request` not relative paths
### User Types & Routing
Login types enforced in `app.ts`:
- `0`: Not logged in
- `1`: Patient (患者) → routes to `/patient/pages/*`
- `2`: Doctor (医生) → routes to `/pages/*`
Use `app.zdWaitLogin()` to guard pages that require login.
### Page/Component Wrappers
`app.ts` overrides global `Page` and `Component` with wrappers from `utils/page.ts` and `utils/component.ts`:
- Auto-sets `imageUrl` and `Timestamp` on page load
- Auto-handles navbar background on scroll
- Provides default share behavior
### Modal Colors (Required)
All `wx.showModal` must use:
```ts
wx.showModal({
confirmColor: '#8c75d0',
cancelColor: '#141515',
})
```
### App Instance (Required)
`getApp()` should be called at the top of the file, not inside methods:
```ts
// ✅ Correct
const app = getApp<IAppOption>()
Page({
onLoad() {
// Use app directly
console.log(app.globalData)
}
})
// ❌ Incorrect
Page({
onLoad() {
const app = getApp<IAppOption>()
console.log(app.globalData)
}
})
```
## WXML 开发规范
### 1. 不支持在 WXML 中直接调用方法
**错误示例:**
```xml
<!-- ❌ 错误:WXML 中不能直接调用方法 -->
<view>{{getUploadedCount()}}</view>
<view wx:if="{{hasPhotos()}}">内容</view>
```
**正确做法:**
```xml
<!-- ✅ 正确:使用数据绑定 -->
<view>{{uploadedCount}}</view>
<view wx:if="{{hasPhotos}}">内容</view>
```
```typescript
// 在 TS 中计算好数据
this.setData({
uploadedCount: photos.length,
hasPhotos: photos.length > 0
})
```
### 2. 列表渲染时使用 wx:key
```xml
<view wx:for="{{list}}" wx:key="id">{{item.name}}</view>
```
### 3. 条件渲染
```xml
<view wx:if="{{condition}}">显示</view>
<view wx:else>隐藏</view>
```
### 4. WXML 表达式限制
WXML 中的双大括号 `{{}}` 只能使用简单的表达式,**不支持**以下语法:
**❌ 不支持的语法:**
```xml
<!-- 方法调用 -->
<view>{{arr.indexOf(item) > -1}}</view>
<!-- 复杂表达式 -->
<view>{{obj.method().property}}</view>
<!-- 正则表达式 -->
<view>{{str.match(/regex/)}}</view>
<!-- new 操作符 -->
<view>{{new Date().getTime()}}</view>
```
**✅ 支持的语法:**
```xml
<!-- 简单属性访问 -->
<view>{{item.name}}</view>
<!-- 三元表达式 -->
<view class="{{item.isActive ? 'active' : ''}}">内容</view>
<!-- 简单比较 -->
<view wx:if="{{count > 0}}">有数据</view>
<!-- 逻辑运算 -->
<view wx:if="{{isLogin && isVip}}">VIP用户</view>
```
**解决方案:**
```typescript
// 在 TS 中预处理数据,将复杂计算转换为简单布尔值
this.setData({
// ❌ 不要在 WXML 中使用 indexOf
// isSelected: selectedDates.indexOf(item.recordId) > -1
// ✅ 在数据中直接提供 isSelected 字段
list: rawList.map(item => ({
...item,
isSelected: selectedDates.includes(item.recordId)
}))
})
```
## Available Commands
```bash
# Lint and auto-fix (only command available)
npm run lint:fix
# Install dependencies (pnpm preferred based on lockfile)
pnpm install
# Build: Use WeChat Developer Tools
# - Import project with src/ as root
# - project.config.json at repo root
```
## NPM Dependencies
**Critical**: After `npm install`, run **Tools → Build npm** in WeChat Developer Tools to generate `miniprogram_npm/`. This is required for Vant and other packages.
Key dependencies:
- `@vant/weapp`: UI components
- `miniprogram-licia`: Utility library (available as `licia`)
- `dayjs`: Date handling
- `mp-html`: Rich HTML rendering
## Images & Assets
**Images are stored in SVN, not git.**
- SVN URL: `svn://39.106.86.127:28386/projects/xd/proj_src/shop/frontend/web/xd/`
- Local path: `src/images/` (gitignored)
- Excluded from upload via `project.config.json` packOptions
- Only `/images/tabbar/*` is included in uploads
Image URL pattern:
```
{{imageUrl}}/path/to/image.png?t={{Timestamp}}
```
## TypeScript Configuration
- Strict mode enabled
- `noImplicitAny: false` (allows implicit any)
- Paths: `@/*` mapped to `src/*`
- Types: `miniprogram-api-typings` for WX API
Global types in `typings/index.d.ts`:
- `IAppOption`: Global app instance interface
- `pageType`: 0 | 1 | 2 for user types
- `wx.ajax`: Extended request method
## ESLint & Formatting
- Config: `@antfu/eslint-config` (flat config in `eslint.config.js`)
- Prettier: 2-space tabs, no semis, single quotes, trailing commas
- WXML files parsed as HTML, WXSS as CSS
- Globals defined: `wx`, `App`, `Page`, `Component`, `getCurrentPages`, etc.
## Environment Configuration
Selected by App ID in `src/config.ts`:
- `wxf9ce8010f1ad24aa`: Dev/Staging (hbraas.com)
- `wx71ac9c27c3c3e3f4`: Production (hbsaas.com)
App reads `wx.getAccountInfoSync().miniProgram.appId` on launch to select config.
## Testing & Development
- No unit test framework configured
- Manual testing via WeChat Developer Tools
- `project.private.config.json` has hot reload enabled (`compileHotReLoad: true`)
- Predefined test pages in `project.private.config.json` condition list
## Common Gotchas
1. **NPM packages**: Must run "Build npm" in WeChat tools after install
2. **Images**: Will 404 if SVN images not checked out to `src/images/`
3. **Subpackages**: Patient pages are in `patient/` subpackage, not main package
4. **Skyline**: Enabled in rendererOptions, some components may behave differently
5. **Login flow**: App automatically calls `startLogin()` on launch; pages must wait via `app.zdWaitLogin()`
## 自定义导航栏规范
### 统一使用 navbar 组件
所有需要自定义导航的页面统一使用 `/components/navbar/index`。`/components/zd-navBar/navBar` 是历史遗留组件,新页面**不要使用**。
**JSON 配置:**
```json
{
"navigationStyle": "custom",
"usingComponents": {
"navbar": "/components/navbar/index"
}
}
```
**WXML 用法:**
```xml
<navbar fixed title="页面标题" custom-style="background:{{background}}">
<van-icon name="arrow-left" slot="left" size="18px" color="#000" bind:tap="handleBack" />
</navbar>
<view class="page" style="padding-top:{{pageTop+20}}px;">
```
**TS 实现:**
```typescript
handleBack() {
wx.navigateBack()
}
```
### 关键参数
| 属性 | 说明 | 常用值 |
| -------------- | ------------ | --------------------------- |
| `fixed` | 固定导航栏 | `fixed` |
| `title` | 导航栏标题 | 字符串 |
| `custom-style` | 自定义样式 | `background:{{background}}` |
| `leftArrow` | 显示返回箭头 | Boolean |
| `slot="left"` | 左侧插槽 | van-icon 返回按钮 |
| `bind:tap` | 返回按钮点击 | `handleBack` |
### pageTop 变量
`pageTop``utils/page.ts` wrapper 自动注入,表示导航栏高度。页面内容区使用 `padding-top:{{pageTop+20}}px;` 避开导航栏。**不要手动计算 navBarHeight**。
## 返回拦截与弹窗规范
### 使用自定义弹窗替代系统弹窗
**禁止使用** `wx.showModal` 进行操作确认,统一使用项目内的 popup 组件:
```json
{
"usingComponents": {
"popup": "/components/popup/index"
}
}
```
```xml
<popup show="{{popupShow}}" type="{{popupType}}" params="{{popupParams}}" bind:ok="handlePopupOk" bind:cancel="handlePopupCancel" />
```
### 常用 popup 类型
| 类型 | 场景 | 标题 | 确认按钮 | 取消按钮 |
| --------- | -------------- | ------------------ | -------- | -------- |
| `popup15` | 删除确认 | "确认删除记录?" | 确认删除 | 取消 |
| `popup16` | 未保存数据退出 | "您的记录还未保存" | 保存记录 | 退出 |
| `popup17` | 裁剪未保存退出 | "您有裁剪的照片" | 退出 | 取消 |
### popup 数据定义
```typescript
data: {
popupShow: false,
popupType: 'popup16',
popupParams: {
close: false,
position: 'center',
} as any,
}
```
### 返回拦截模式
当页面有未保存数据时,使用自定义导航 + `bind:back` 拦截返回:
```typescript
handleBack() {
if (this.hasUnsavedData()) {
this.setData({ popupShow: true, popupType: 'popup16' })
} else {
wx.navigateBack()
}
}
handlePopupOk() {
this.setData({ popupShow: false })
this.handleSave()
}
handlePopupCancel() {
this.setData({ popupShow: false })
wx.navigateBack()
}
```
**注意**:`navigationStyle: "custom"` 后系统返回手势无法拦截,只有 navBar 的返回按钮可被拦截。如需拦截系统返回手势,需要额外使用 `wx.enableAlertBeforeUnload`
## wx.cropImage 规范
`wx.cropImage``src` 参数**只接受本地文件路径**,不支持网络 URL。裁剪网络图片时必须先用 `wx.getImageInfo` 下载到本地:
```typescript
handleCrop(e: any) {
const index = e.currentTarget.dataset.index
const photo = this.data.photos[index]
wx.showLoading({ title: '加载中...' })
wx.getImageInfo({
src: photo.photoUrl,
success: (imgRes) => {
wx.hideLoading()
wx.cropImage({
src: imgRes.path,
cropScale: '9:16',
success: (cropRes) => {
photos[index].croppedUrl = cropRes.tempFilePath
this.setData({ photos })
},
fail: (err) => {
if (err.errMsg?.includes('cancel')) return
wx.showToast({ title: '裁剪取消', icon: 'none' })
},
})
},
fail: () => {
wx.hideLoading()
wx.showToast({ title: '图片加载失败', icon: 'none' })
},
})
}
```
## 子包组件引用规范
主包页面(`src/pages/`)**不能引用**子包组件(`src/patient/components/`)。如果主包和子包都需要使用某个组件,需要将组件复制到 `src/components/` 目录下。
示例:`image-merge` 组件在 `patient/components/``components/` 各有一份,分别供子包和主包页面使用。

4
.vscode/settings.json vendored

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
{
"path-autocomplete.pathMappings": {
"@": "${folder}/src",
"/": "${folder}/src",
"/": "${folder}/src"
},
"emmet.preferences": {
"css.intUnit": "rpx",
@ -9,5 +9,5 @@ @@ -9,5 +9,5 @@
},
"css.customData": [
".vscode/css-data.json"
],
]
}

16
.zed/settings.json

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
"lsp": {
"emmet-language-server": {
"initialization_options": {
"preferences": {
"css.intUnit": "rpx",
"css.floatUnitr": "rpx",
},
},
},
},
}

23
README.md

@ -11,12 +11,18 @@ svn://39.106.86.127:28386/projects/xd/proj_src/shop/frontend/web/xd @@ -11,12 +11,18 @@ svn://39.106.86.127:28386/projects/xd/proj_src/shop/frontend/web/xd
svn://39.106.86.127:28386/projects/xd/proj_src/branches/dev_v2.0/shop/frontend/web/xd/
## vscode
```
(/images/)(\S*(?=["|']))
{{imageUrl}}$2?t={{Timestamp}}
```
## neovim
```
(/images/)([^\"|']*)
{{imageUrl}}$2?t={{Timestamp}}
```
ui问题
@ -34,3 +40,20 @@ wx.showModal({ @@ -34,3 +40,20 @@ wx.showModal({
审核账号
18910233000 1111
正整数 3
正整数 2
正整数 4
正整数 2
正整数 3
已修改未上线内容
1. 医生端首页 统计数据改为实时更新
2. 就诊地图重新定位,在非北京地区重新定位会重新定位到北京,再次切换才会定位到当地
3. 患者端注册页导航栏增加返回上一页按钮
4. 量表安奈德修改为甲泼尼龙
5. 患者端聊天页点击任意区域都可关闭底部操作浮层
6. 患者顿啊登录页底部隐私政策区域展示异常修复

6
eslint.config.js

@ -4,6 +4,10 @@ export default antfu({ @@ -4,6 +4,10 @@ export default antfu({
env: {
es6: true,
},
ignores: [
'**/miniprogram_npm/**',
'src/miniprogram_npm/**',
],
parserOptions: { project: ['./tsconfig.json'] },
globals: {
wx: true,
@ -18,7 +22,7 @@ export default antfu({ @@ -18,7 +22,7 @@ export default antfu({
rules: {
'eslint-comments/no-unlimited-disable': 'off',
'ts/no-require-imports': 'off',
eqeqeq: 'off',
'eqeqeq': 'off',
},
formatters: {
css: 'prettier',

4
project.config.json

@ -71,5 +71,5 @@ @@ -71,5 +71,5 @@
}
]
},
"appid": "wx71ac9c27c3c3e3f4"
}
"appid": "wxf9ce8010f1ad24aa"
}

149
project.private.config.json

@ -23,37 +23,149 @@ @@ -23,37 +23,149 @@
"miniprogram": {
"list": [
{
"name": "药房",
"pathName": "gift/pages/dtpDurg/index",
"query": "id=10",
"name": "医生端-眼突度-对比",
"pathName": "pages/d_noteDiffData/index",
"query": "",
"scene": null,
"launchMode": "default"
},
{
"name": "医生端-日记列表",
"pathName": "pages/d_noteList/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "就诊地图",
"pathName": "patient/pages/doctor/index",
"name": "医生-突眼日记单条记录",
"pathName": "pages/d_noteDetail/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "patient/pages/liveDetail/index",
"pathName": "patient/pages/liveDetail/index",
"query": "id=33",
"name": "医生-患者详情",
"pathName": "pages/d_patientDetail/index",
"query": "id=319",
"launchMode": "default",
"scene": null
},
{
"name": "患者-个人信息",
"pathName": "patient/pages/personalInformation/index",
"query": "bottom=1",
"name": "突眼日记照片对比编辑",
"pathName": "patient/pages/noteDiffEdit/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "patient/pages/liveResult/index",
"pathName": "patient/pages/liveResult/index",
"query": "id=30&rewardScore=undefined",
"name": "眼突日记照片对比",
"pathName": "patient/pages/noteDiff/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "突眼日记-历史记录",
"pathName": "patient/pages/noteHistory/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "突眼日记拍照示例",
"pathName": "patient/pages/noteDemo/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "突眼日记添加",
"pathName": "patient/pages/noteAdd/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "突眼日记",
"pathName": "patient/pages/note/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "patient/pages/imageProcessing/index",
"pathName": "patient/pages/imageProcessing/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "患者-qol",
"pathName": "patient/pages/qol/index",
"query": "pushId=81",
"launchMode": "default",
"scene": null
},
{
"name": "医生-患者量表",
"pathName": "pages/d_qolDetail/index",
"query": "id=178",
"launchMode": "default",
"scene": null
},
{
"name": "医保-详情",
"pathName": "patient/pages/medicalDetail/index",
"query": "id=3",
"launchMode": "default",
"scene": null
},
{
"name": "患者-医保",
"pathName": "patient/pages/medical/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "医生-激素用药详情",
"pathName": "pages/d_patientHormones/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "激素量表-结果页",
"pathName": "patient/pages/hormonesResult/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "激素量表",
"pathName": "patient/pages/hormones/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "药房",
"pathName": "gift/pages/dtpDurg/index",
"query": "id=10",
"launchMode": "default",
"scene": null
},
{
"name": "就诊地图",
"pathName": "patient/pages/doctor/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "患者-个人信息",
"pathName": "patient/pages/personalInformation/index",
"query": "bottom=1",
"launchMode": "default",
"scene": null
},
@ -86,13 +198,6 @@ @@ -86,13 +198,6 @@
"scene": null
},
{
"name": "患者-qol",
"pathName": "patient/pages/qol/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "患者-录入个人信息",
"pathName": "patient/pages/enterInfo/index",
"query": "",
@ -215,4 +320,4 @@ @@ -215,4 +320,4 @@
}
},
"libVersion": "3.8.9"
}
}

59
src/app.json

@ -14,7 +14,14 @@ @@ -14,7 +14,14 @@
"pages/d_patientDetail/index",
"pages/d_userInfo/index",
"pages/d_invite/index",
"pages/d_patient/index"
"pages/d_patient/index",
"pages/d_patientHormones/index",
"pages/d_qolDetail/index",
"pages/d_noteDetail/index",
"pages/d_noteList/index",
"pages/d_noteDiffData/index",
"pages/d_noteDiff/index",
"pages/d_noteDiffEdit/index"
],
"subPackages": [
{
@ -26,13 +33,7 @@ @@ -26,13 +33,7 @@
"pages/vipLoginReject/index",
"pages/startReject/index",
"pages/startPending/index",
"pages/story/index",
"pages/publishStoryDetail/index",
"pages/storyEnter/index",
"pages/storyEnterResult/index",
"pages/storyList/index",
"pages/storyGuide/index",
"pages/storyDetail/index",
"pages/my/index",
"pages/mySave/index",
"pages/myLive/index",
@ -58,10 +59,6 @@ @@ -58,10 +59,6 @@
"pages/liveResult/index",
"pages/liveDetailVideo/index",
"pages/signIn/index",
"pages/adl/index",
"pages/adlShare/index",
"pages/adlTest/index",
"pages/adlResult/index",
"pages/smallPage/index",
"pages/hospital/index",
"pages/doctor/index",
@ -69,41 +66,29 @@ @@ -69,41 +66,29 @@
"pages/drugRecord/index",
"pages/comIns/index",
"pages/webview/index",
"pages/nrdl/index",
"pages/nrdlDetail/index",
"pages/infusionCenter/index",
"pages/nrdlTable/index",
"pages/interactivePatient/index",
"pages/referral/index",
"pages/qol/index",
"pages/qolAdd/index",
"pages/qolResult/index",
"pages/qolReport/index"
"pages/qolReport/index",
"pages/hormonesStart/index",
"pages/hormones/index",
"pages/hormonesResult/index",
"pages/medical/index",
"pages/medicalDetail/index",
"pages/note/index",
"pages/noteAdd/index",
"pages/noteDemo/index",
"pages/noteHistory/index",
"pages/noteDiff/index",
"pages/noteDiffEdit/index",
"pages/imageProcessing/index"
]
},
{
"root": "gift",
"pages": [
"pages/giftList/index",
"pages/conformOrder/index",
"pages/siteList/index",
"pages/siteEdit/index",
"pages/orderEnd/index",
"pages/orderDetail/index",
"pages/myGift/index",
"pages/priceDetail/index",
"pages/scoreRule/index",
"pages/dtpDurg/index",
"pages/vipCert/index",
"pages/vipReject/index",
"pages/vipPending/index",
"pages/vipStartPending/index",
"pages/myHealthRecord/index",
"pages/myHealthRecordChart/index",
"pages/cutaneous/index",
"pages/cutaneousDetail/index",
"pages/cutaneousVideo/index"
]
"pages": ["pages/dtpDurg/index"]
},
{
"root": "doc",

51
src/app.ts

@ -4,6 +4,7 @@ import component from '@/utils/component' @@ -4,6 +4,7 @@ import component from '@/utils/component'
import relativeTime from '@/utils/dayjs/relativeTime.js'
import page from '@/utils/page'
import { request } from '@/utils/request'
import config from './config'
import { parseScene } from './utils/util'
require('/utils/dayjs/day-zh-cn.js')
@ -13,18 +14,19 @@ dayjs.extend(relativeTime) @@ -13,18 +14,19 @@ dayjs.extend(relativeTime)
App<IAppOption>({
globalData: {
version: '2.0', // 在数据请求里面发送给后端的版本号[X-MP-Version]
// 测试号 wx2b0bb13edf717c1d
// dev
// appid:wxf9ce8010f1ad24aa
// url: 'https://m.xd.hbraas.com',
// upFileUrl: 'https://m.xd.hbraas.com/',
// imageUrl: 'https://m.xd.hbraas.com/xd/',
url: 'https://m.xd.hbraas.com',
upFileUrl: 'https://m.xd.hbraas.com/',
imageUrl: 'https://m.xd.hbraas.com/xd/',
// pro
// appid:wx71ac9c27c3c3e3f4
url: 'https://m.xd.hbsaas.com',
upFileUrl: 'https://m.xd.hbsaas.com/',
imageUrl: 'https://m.xd.hbsaas.com/api/xd/',
// url: 'https://m.xd.hbsaas.com',
// upFileUrl: 'https://m.xd.hbsaas.com/',
// imageUrl: 'https://m.xd.hbsaas.com/api/xd/',
loginState: '',
isLogin: 0,
@ -104,10 +106,13 @@ App<IAppOption>({ @@ -104,10 +106,13 @@ App<IAppOption>({
},
},
onLaunch() {
const appid = wx.getAccountInfoSync().miniProgram.appId
Object.assign(this.globalData, config[appid] || {})
Page = page as WechatMiniprogram.Page.Constructor
Component = component as WechatMiniprogram.Component.Constructor
wx.ajax = licia.curry(request)({ gUrl: this.globalData.url })
wx.ajax = licia.curry(request)({ gUrl: this.globalData.url, version: this.globalData.version })
this.startLogin()
@ -115,6 +120,8 @@ App<IAppOption>({ @@ -115,6 +120,8 @@ App<IAppOption>({
obeyMuteSwitch: false,
mixWithOther: false,
})
this.handleUpdateMiniprogram()
},
onShow(options) {
if (options.query.scene) {
@ -189,13 +196,13 @@ App<IAppOption>({ @@ -189,13 +196,13 @@ App<IAppOption>({
if (type.includes(0) && [0, 1, 2].includes(loginType)) {
return true
}
if ([0, 1].includes(loginType)) {
if (type.includes(0) || type.includes(1)) {
wx.reLaunch({
url: '/patient/pages/login/index',
})
return false
}
if (loginType === 2) {
if (type.includes(2)) {
wx.reLaunch({
url: '/pages/login/index',
})
@ -550,4 +557,30 @@ App<IAppOption>({ @@ -550,4 +557,30 @@ App<IAppOption>({
wx.removeTabBarBadge({ index: 2 })
})
},
handleUpdateMiniprogram() {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate((res) => {
// 请求完新版本信息的回调
// eslint-disable-next-line no-console
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
},
})
})
updateManager.onUpdateFailed(() => {
// 新版本下载失败
})
},
})

43
src/components/calendar/core.js

@ -10,7 +10,7 @@ function calculateEmptyGrids(year, month, config) { @@ -10,7 +10,7 @@ function calculateEmptyGrids(year, month, config) {
const nextMonthGrids = calculateNextMonthGrids(year, month, config)
return {
prevMonthGrids,
nextMonthGrids
nextMonthGrids,
}
}
@ -20,13 +20,14 @@ function calculateEmptyGrids(year, month, config) { @@ -20,13 +20,14 @@ function calculateEmptyGrids(year, month, config) {
* @param {number} month 月份
*/
function calculatePrevMonthGrids(year, month, config) {
let emptyGrids = []
const emptyGrids = []
const prevMonthDays = dateUtil.getDatesCountOfMonth(year, month - 1)
let firstDayOfWeek = dateUtil.firstDayOfWeek(year, month)
if (config.firstDayOfWeek === 'Mon') {
if (firstDayOfWeek === 0) {
firstDayOfWeek = 6
} else {
}
else {
firstDayOfWeek -= 1
}
}
@ -37,12 +38,13 @@ function calculatePrevMonthGrids(year, month, config) { @@ -37,12 +38,13 @@ function calculatePrevMonthGrids(year, month, config) {
for (let i = prevMonthDays; i > len; i--) {
if (onlyShowCurrentMonth) {
emptyGrids.push('')
} else {
}
else {
const week = dateUtil.getDayOfWeek(+year, +month, i)
emptyGrids.push({
...YMInfo,
date: i,
week
week,
})
}
}
@ -61,19 +63,24 @@ function calculateExtraEmptyDate(year, month, config) { @@ -61,19 +63,24 @@ function calculateExtraEmptyDate(year, month, config) {
let extDate = 0
if (+month === 2) {
extDate += 7
let firstDayofMonth = dateUtil.getDayOfWeek(year, month, 1)
const firstDayofMonth = dateUtil.getDayOfWeek(year, month, 1)
if (config.firstDayOfWeek === 'Mon') {
if (+firstDayofMonth === 1) extDate += 7
} else {
if (+firstDayofMonth === 0) extDate += 7
if (+firstDayofMonth === 1)
extDate += 7
}
else {
if (+firstDayofMonth === 0)
extDate += 7
}
} else {
let firstDayofMonth = dateUtil.getDayOfWeek(year, month, 1)
}
else {
const firstDayofMonth = dateUtil.getDayOfWeek(year, month, 1)
if (config.firstDayOfWeek === 'Mon') {
if (firstDayofMonth !== 0 && firstDayofMonth < 6) {
extDate += 7
}
} else {
}
else {
if (firstDayofMonth <= 5) {
extDate += 7
}
@ -87,13 +94,14 @@ function calculateExtraEmptyDate(year, month, config) { @@ -87,13 +94,14 @@ function calculateExtraEmptyDate(year, month, config) {
* @param {number} month 月份
*/
function calculateNextMonthGrids(year, month, config) {
let emptyGrids = []
const emptyGrids = []
const datesCount = dateUtil.getDatesCountOfMonth(year, month)
let lastDayWeek = dateUtil.getDayOfWeek(year, month, datesCount)
if (config.firstDayOfWeek === 'Mon') {
if (lastDayWeek === 0) {
lastDayWeek = 6
} else {
}
else {
lastDayWeek -= 1
}
}
@ -107,12 +115,13 @@ function calculateNextMonthGrids(year, month, config) { @@ -107,12 +115,13 @@ function calculateNextMonthGrids(year, month, config) {
const week = dateUtil.getDayOfWeek(+year, +month, i)
if (onlyShowCurrentMonth) {
emptyGrids.push('')
} else {
}
else {
emptyGrids.push({
id: i - 1,
...YMInfo,
date: i,
week: week || 7
week: week || 7,
})
}
}
@ -138,7 +147,7 @@ export function calcJumpData({ dateInfo, config, component }) { @@ -138,7 +147,7 @@ export function calcJumpData({ dateInfo, config, component }) {
curMonth: month,
curDate: date,
dates: calculateCurrentMonthDates(year, month),
...emptyGrids
...emptyGrids,
}
return calendar
}

2
src/components/calendar/helper.js

@ -7,6 +7,6 @@ export function calcTargetYMInfo() { @@ -7,6 +7,6 @@ export function calcTargetYMInfo() {
prev_month: dateUtil.getPrevMonthInfo,
next_month: dateUtil.getNextMonthInfo,
prev_year: dateUtil.getPrevYearInfo,
next_year: dateUtil.getNextYearInfo
next_year: dateUtil.getNextYearInfo,
}
}

2
src/components/calendar/index.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

97
src/components/calendar/index.js

@ -1,24 +1,24 @@ @@ -1,24 +1,24 @@
import plugins from './plugins/index'
import { calcJumpData } from './core'
import { renderCalendar } from './render'
import { calcTargetYMInfo } from './helper'
import { dateUtil, calendarGesture, logger } from './utils/index'
import plugins from './plugins/index'
import { renderCalendar } from './render'
import { calendarGesture, dateUtil, logger } from './utils/index'
Component({
options: {
styleIsolation: 'apply-shared',
multipleSlots: true // 在组件定义时的选项中启用多slot支持
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
},
properties: {
config: {
type: Object,
value: {}
}
value: {},
},
},
lifetimes: {
attached: function() {
attached() {
this.initComp()
}
},
},
methods: {
initComp() {
@ -30,7 +30,7 @@ Component({ @@ -30,7 +30,7 @@ Component({
const calendarConfig = this.properties.config || {}
if (calendarConfig.disableMode && !calendarConfig.disableMode.date) {
calendarConfig.disableMode.date = dateUtil.toTimeStr(
dateUtil.todayFMD()
dateUtil.todayFMD(),
)
}
return calendarConfig
@ -42,27 +42,29 @@ Component({ @@ -42,27 +42,29 @@ Component({
const dateInfo = defaultDate.split('-')
if (dateInfo.length < 3) {
return logger.warn('defaultDate配置格式应为: 2018-4-2 或 2018-04-02')
} else {
}
else {
date = {
year: +dateInfo[0],
month: +dateInfo[1],
date: +dateInfo[2]
date: +dateInfo[2],
}
}
}
const waitRenderData = calcJumpData({
dateInfo: date,
config
config,
})
const timestamp = dateUtil.todayTimestamp()
if (config.autoChoosedWhenJump) {
const target = waitRenderData.dates.filter(
item => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(date)
item => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(date),
)
if (target && target.length) {
if (!waitRenderData.selectedDates) {
waitRenderData.selectedDates = target
} else {
}
else {
waitRenderData.selectedDates.push(target[0])
}
}
@ -70,7 +72,7 @@ Component({ @@ -70,7 +72,7 @@ Component({
return {
...waitRenderData,
todayTimestamp: timestamp,
weeksCh: dateUtil.getWeekHeader(config.firstDayOfWeek)
weeksCh: dateUtil.getWeekHeader(config.firstDayOfWeek),
}
},
setConfig(config) {
@ -80,21 +82,23 @@ Component({ @@ -80,21 +82,23 @@ Component({
config.theme = config.theme || 'default'
this.setData(
{
config
config,
},
() => {
for (let plugin of plugins.installed) {
for (const plugin of plugins.installed) {
const [, p] = plugin
if (typeof p.install === 'function') {
p.install(this)
}
if (typeof p.methods === 'function') {
const methods = p.methods(this)
for (let fnName in methods) {
if (fnName.startsWith('__')) continue
for (const fnName in methods) {
if (fnName.startsWith('__'))
continue
const fn = methods[fnName]
if (typeof fn === 'function') {
if (!this.calendar) this.calendar = {}
if (!this.calendar)
this.calendar = {}
this.calendar[fnName] = fn
}
}
@ -102,25 +106,26 @@ Component({ @@ -102,25 +106,26 @@ Component({
}
const initData = this.initCalendar(config)
renderCalendar.call(this, initData, config)
}
},
)
},
tapDate(e) {
const { info } = e.currentTarget.dataset
const { date, disable } = info || {}
if (disable || !date) return
if (disable || !date)
return
const { calendar, config } = this.data
let calendarData = calendar
let calendarConfig = config
if (config.takeoverTap) {
return this.triggerEvent('takeoverTap', info)
}
for (let plugin of plugins.installed) {
for (const plugin of plugins.installed) {
const [, p] = plugin
if (typeof p.onTapDate === 'function') {
const {
calendarData: __calendarData,
calendarConfig: __calendarConfig
calendarConfig: __calendarConfig,
} = p.onTapDate(info, calendarData, calendarConfig)
calendarData = __calendarData
calendarConfig = __calendarConfig
@ -141,7 +146,7 @@ Component({ @@ -141,7 +146,7 @@ Component({
this.swipeLock = true
this.setData({
'gesture.startX': startX,
'gesture.startY': startY
'gesture.startY': startY,
})
},
/**
@ -151,7 +156,8 @@ Component({ @@ -151,7 +156,8 @@ Component({
calendarTouchmove(e) {
const { gesture } = this.data
const { preventSwipe } = this.properties.config
if (!this.swipeLock || preventSwipe) return
if (!this.swipeLock || preventSwipe)
return
if (calendarGesture.isLeft(gesture, e.touches[0])) {
this.handleSwipe('left')
this.swipeLock = false
@ -164,7 +170,7 @@ Component({ @@ -164,7 +170,7 @@ Component({
calendarTouchend(e) {
this.setData({
'calendar.leftSwipe': 0,
'calendar.rightSwipe': 0
'calendar.rightSwipe': 0,
})
},
handleSwipe(direction) {
@ -173,15 +179,15 @@ Component({ @@ -173,15 +179,15 @@ Component({
swipeKey = 'calendar.rightSwipe'
}
this.setData({
[swipeKey]: 1
[swipeKey]: 1,
})
const { calendar } = this.data
let calendarData = calendar
const calendarData = calendar
const { curYear, curMonth } = calendarData
const getMonthInfo = calcTargetYMInfo()[direction]
const target = getMonthInfo({
year: +curYear,
month: +curMonth
month: +curMonth,
})
target.direction = direction
this.renderCalendar(target)
@ -193,7 +199,7 @@ Component({ @@ -193,7 +199,7 @@ Component({
const getMonthInfo = calcTargetYMInfo()[type]
const target = getMonthInfo({
year: +curYear,
month: +curMonth
month: +curMonth,
})
target.direction = type
this.renderCalendar(target)
@ -201,7 +207,7 @@ Component({ @@ -201,7 +207,7 @@ Component({
renderCalendar(target) {
let { calendar: calendarData, config } = this.data
const { curYear, curMonth } = calendarData || {}
for (let plugin of plugins.installed) {
for (const plugin of plugins.installed) {
const [, p] = plugin
if (typeof p.onSwitchCalendar === 'function') {
calendarData = p.onSwitchCalendar(target, calendarData, this)
@ -215,44 +221,47 @@ Component({ @@ -215,44 +221,47 @@ Component({
this.triggerEvent(triggerEventName, {
current: {
year: +curYear,
month: +curMonth
month: +curMonth,
},
next: target
next: target,
})
this.triggerEvent('onSwipe', {
current: {
year: +curYear,
month: +curMonth
month: +curMonth,
},
next: target,
type: triggerEventName
type: triggerEventName,
})
})
},
doubleClickJumpToToday() {
const { multi, weekMode } = this.calendar.getCalendarConfig() || {}
if (multi || weekMode) return
if (multi || weekMode)
return
if (this.count === undefined) {
this.count = 1
} else {
}
else {
this.count += 1
}
if (this.lastClick) {
const difference = new Date().getTime() - this.lastClick
if (
difference < 500 &&
this.count >= 2 &&
typeof this.calendar.jump === 'function'
difference < 500
&& this.count >= 2
&& typeof this.calendar.jump === 'function'
) {
const today = dateUtil.todayFMD()
this.calendar.jump(today)
}
this.count = undefined
this.lastClick = undefined
} else {
}
else {
this.lastClick = new Date().getTime()
}
this.triggerEvent('jumpToToday')
}
}
},
},
})

2
src/components/calendar/index.json

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
{
"component": true
}
}

122
src/components/calendar/plugins/holidays/holidays-map.js

@ -14,38 +14,38 @@ export const festival = { @@ -14,38 +14,38 @@ export const festival = {
1: {
type: 'festival',
name: '春节',
label: '春节'
label: '春节',
},
8: {
type: 'festival',
name: '腊八节',
label: '腊八'
label: '腊八',
},
15: {
type: 'festival',
name: '元宵节',
label: '元宵'
}
label: '元宵',
},
},
7: {
7: {
type: 'festival',
name: '七夕节',
label: '七夕'
label: '七夕',
},
15: {
type: 'festival',
name: '中元节',
label: '中元节'
}
label: '中元节',
},
},
9: {
9: {
type: 'festival',
name: '重阳节',
label: '重阳节'
}
}
label: '重阳节',
},
},
},
// 阳历固定日期节日
solar: {
@ -53,160 +53,160 @@ export const festival = { @@ -53,160 +53,160 @@ export const festival = {
14: {
type: 'festival',
name: '情人节',
label: '情人节'
}
label: '情人节',
},
},
3: {
12: {
type: 'festival',
name: '植树节',
label: '植树节'
}
label: '植树节',
},
},
4: {
1: {
type: 'festival',
name: '愚人节',
label: '愚人节'
label: '愚人节',
},
5: {
type: 'festival',
name: '清明节',
label: '清明节'
}
label: '清明节',
},
},
5: {
1: {
type: 'festival',
name: '劳动节',
label: '劳动节'
}
label: '劳动节',
},
},
6: {
1: {
type: 'festival',
name: '儿童节',
label: '儿童节'
}
label: '儿童节',
},
},
7: {
1: {
type: 'festival',
name: '建党节',
label: '建党节'
}
label: '建党节',
},
},
8: {
1: {
type: 'festival',
name: '建军节',
label: '建军节'
}
label: '建军节',
},
},
9: {
10: {
type: 'festival',
name: '教师节',
label: '教师节'
}
label: '教师节',
},
},
10: {
1: {
type: 'festival',
name: '国庆节',
label: '国庆节'
}
label: '国庆节',
},
},
12: {
25: {
type: 'festival',
name: '圣诞节',
label: '圣诞节'
}
}
}
label: '圣诞节',
},
},
},
}
export const holidays = {
2020: {
1: {
1: {
'1': {
type: 'holiday',
name: '元旦',
label: '休'
label: '休',
},
19: {
'19': {
type: 'work',
name: '调班',
label: '班'
label: '班',
},
'24-30': {
type: 'holiday',
name: '春节',
label: '休'
}
label: '休',
},
},
2: {
1: {
type: 'work',
name: '调班',
label: '班'
}
label: '班',
},
},
4: {
'4-6': {
type: 'holiday',
name: '清明节',
label: '休'
label: '休',
},
26: {
'26': {
type: 'work',
name: '调班',
label: '班'
}
label: '班',
},
},
5: {
'1-5': {
type: 'holiday',
name: '劳动节',
label: '休'
label: '休',
},
9: {
'9': {
type: 'work',
name: '调班',
label: '班'
}
label: '班',
},
},
6: {
'25-27': {
type: 'holiday',
name: '端午节',
label: '休'
label: '休',
},
28: {
'28': {
type: 'work',
name: '调班',
label: '班'
}
label: '班',
},
},
9: {
27: {
type: 'work',
name: '调班',
label: '班'
}
label: '班',
},
},
10: {
'1-8': {
type: 'holiday',
name: '国庆节/中秋节',
label: '休'
label: '休',
},
10: {
'10': {
type: 'work',
name: '调班',
label: '班'
}
}
}
label: '班',
},
},
},
}

2
src/components/calendar/plugins/holidays/index.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

86
src/components/calendar/plugins/holidays/index.js

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
* @Last Modified time: 2020-10-16 17:34:13
*/
import { holidays, festival } from './holidays-map'
import { dateUtil, getCalendarData, logger } from '../../utils/index'
import { festival, holidays } from './holidays-map'
/**
* 当前是否在休假期内
@ -20,21 +20,21 @@ function inHolidays({ year, month }, { start, end, current }) { @@ -20,21 +20,21 @@ function inHolidays({ year, month }, { start, end, current }) {
const startTimestamp = getTimeStamp({
year,
month,
date: start
date: start,
})
const endTimestamp = getTimeStamp({
year,
month,
date: end
date: end,
})
const currentDateTimestamp = getTimeStamp({
year,
month,
date: current
date: current,
})
if (
currentDateTimestamp >= startTimestamp &&
currentDateTimestamp <= endTimestamp
currentDateTimestamp >= startTimestamp
&& currentDateTimestamp <= endTimestamp
) {
return true
}
@ -49,13 +49,15 @@ function addSpecialFestival(date, component) { @@ -49,13 +49,15 @@ function addSpecialFestival(date, component) {
const info = {
type: 'festival',
name: '除夕',
label: '除夕'
label: '除夕',
}
if (lMonth === 12) {
if (!festival.lunar['12']) festival.lunar['12'] = {}
if (!festival.lunar['12'])
festival.lunar['12'] = {}
if (convertlLunar2Solar(`${lYear}-12-30`) === -1) {
festival.lunar['12']['29'] = info
} else {
}
else {
festival.lunar['12']['30'] = info
}
}
@ -63,8 +65,8 @@ function addSpecialFestival(date, component) { @@ -63,8 +65,8 @@ function addSpecialFestival(date, component) {
/**
* 是否匹配到节日
* @param {object} [dateInfo={}]
* @param {object} [component={}]
* @param {object} [dateInfo]
* @param {object} [component]
* @returns {object|boolean} 匹配到的节日数据或者false
*/
function hasFestivalDate(dateInfo = {}, component = {}) {
@ -78,19 +80,22 @@ function hasFestivalDate(dateInfo = {}, component = {}) { @@ -78,19 +80,22 @@ function hasFestivalDate(dateInfo = {}, component = {}) {
if (!festivalDate) {
const festivalOfMonth = festival.lunar[lMonth] || {}
const festivalDateKey = Object.keys(festivalOfMonth).find(item =>
item.match(new RegExp(`\\b${lDay}\\b`))
item.match(new RegExp(`\\b${lDay}\\b`)),
)
if (!festivalDateKey) {
festivalDate = false
} else {
}
else {
const festivalInfo = festival.lunar[lMonth][festivalDateKey]
if (!festivalInfo) {
festivalDate = false
} else {
}
else {
const { condition } = festivalInfo
if (typeof condition === 'function') {
festivalDate = condition(lunarDateInfo)
} else {
}
else {
festivalDate = false
}
}
@ -106,23 +111,24 @@ export default () => { @@ -106,23 +111,24 @@ export default () => {
beforeRender(calendarData = {}, calendarConfig = {}, component) {
let { dates = [] } = calendarData
if (calendarConfig.showHolidays || calendarConfig.showFestival) {
dates = dates.map(d => {
dates = dates.map((d) => {
let item = { ...d }
const { year, month, date } = item
const holidaysOfMonth =
(holidays[year] && holidays[year][month]) || {}
const holidaysOfMonth
= (holidays[year] && holidays[year][month]) || {}
const holidayDate = holidaysOfMonth[date]
if (holidayDate) {
item = {
...item,
...holidayDate
...holidayDate,
}
} else {
}
else {
const holidayKeys = Object.keys(holidaysOfMonth).filter(item =>
item.includes('-')
item.includes('-'),
)
let target = ''
for (let v of holidayKeys) {
for (const v of holidayKeys) {
const [start, end] = v.split('-')
if (+d.date >= +start && +d.date <= +end) {
target = v
@ -133,28 +139,29 @@ export default () => { @@ -133,28 +139,29 @@ export default () => {
const isInHolidays = inHolidays(
{
year,
month
month,
},
{
start,
end,
current: date
}
current: date,
},
)
if (isInHolidays) {
item = {
...item,
...holidaysOfMonth[target]
...holidaysOfMonth[target],
}
} else if (calendarConfig.showFestival) {
const { convertSolarLunar, convertlLunar2Solar } =
component.calendar || {}
}
else if (calendarConfig.showFestival) {
const { convertSolarLunar, convertlLunar2Solar }
= component.calendar || {}
if (
typeof convertSolarLunar !== 'function' ||
typeof convertlLunar2Solar !== 'function'
typeof convertSolarLunar !== 'function'
|| typeof convertlLunar2Solar !== 'function'
) {
return logger.warn(
'农历节日显示需要引入农历插件(/component/v2/plugins/solarLunar)'
'农历节日显示需要引入农历插件(/component/v2/plugins/solarLunar)',
)
}
addSpecialFestival(item, component)
@ -162,7 +169,7 @@ export default () => { @@ -162,7 +169,7 @@ export default () => {
if (festivalDate) {
item = {
...item,
...festivalDate
...festivalDate,
}
}
}
@ -173,9 +180,9 @@ export default () => { @@ -173,9 +180,9 @@ export default () => {
return {
calendarData: {
...calendarData,
dates: dates
dates,
},
calendarConfig
calendarConfig,
}
},
methods(component) {
@ -186,16 +193,17 @@ export default () => { @@ -186,16 +193,17 @@ export default () => {
return this.methods(component).getHolidaysOfYear(curYear)
},
getHolidaysOfYear(year) {
if (!year) return logger.warn('getHolidaysOfCurrentYear() 入参错误')
if (!year)
return logger.warn('getHolidaysOfCurrentYear() 入参错误')
if (!holidays[year]) {
logger.warn('未匹配到当前年份节假日信息,请自行补充')
return {
err: 'not match'
err: 'not match',
}
}
return holidays[year]
}
},
}
}
},
}
}

2
src/components/calendar/plugins/index.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

11
src/components/calendar/plugins/index.js

@ -3,16 +3,17 @@ import preset from './preset/index' @@ -3,16 +3,17 @@ import preset from './preset/index'
export default {
installed: [...preset],
use(plugin) {
if (typeof plugin !== 'function') return
if (typeof plugin !== 'function')
return
const info = plugin() || {}
const { name } = info
if (
name &&
name !== 'methods' &&
!this.installed.some(p => p[0] === name)
name
&& name !== 'methods'
&& !this.installed.some(p => p[0] === name)
) {
this.installed.unshift([name, info])
}
return this
}
},
}

116
src/components/calendar/plugins/preset/base.js

@ -4,15 +4,15 @@ @@ -4,15 +4,15 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-11 13:28:52
* */
*/
import { calcJumpData } from '../../core'
import { renderCalendar } from '../../render'
import {
dateUtil,
getCalendarConfig,
getCalendarData,
setCalendarData,
getCalendarConfig
} from '../../utils/index'
export default () => {
@ -21,12 +21,12 @@ export default () => { @@ -21,12 +21,12 @@ export default () => {
beforeRender(calendarData = {}, calendarConfig) {
const calendar = calendarData
const { selectedDates = [], dates } = calendar
let _dates = [...dates]
const _dates = [...dates]
if (selectedDates.length) {
const selectedDatesStr = selectedDates.map(date =>
dateUtil.toTimeStr(date)
dateUtil.toTimeStr(date),
)
_dates.forEach(date => {
_dates.forEach((date) => {
const dateStr = dateUtil.toTimeStr(date)
if (selectedDatesStr.includes(dateStr)) {
date.choosed = true
@ -36,21 +36,21 @@ export default () => { @@ -36,21 +36,21 @@ export default () => {
return {
calendarData: {
...calendarData,
dates: _dates
dates: _dates,
},
calendarConfig
calendarConfig,
}
},
onTapDate(tapedDate, calendarData = {}, calendarConfig = {}) {
const calendar = {
...calendarData
...calendarData,
}
const dateIndex = dateUtil.findDateIndexInArray(
tapedDate,
calendarData.dates
calendarData.dates,
)
const { multi, inverse } = calendarConfig
let dates = [...calendar.dates]
const dates = [...calendar.dates]
const { selectedDates = [] } = calendar
if (!multi) {
let preSelectedDate = {}
@ -61,7 +61,7 @@ export default () => { @@ -61,7 +61,7 @@ export default () => {
if (!inverse && timeStr(preSelectedDate) === timeStr(tapedDate)) {
return calendar
}
let _tapedDate = { ...tapedDate, choosed: !tapedDate.choosed }
const _tapedDate = { ...tapedDate, choosed: !tapedDate.choosed }
dates[dateIndex] = _tapedDate
if (preSelectedDate.date) {
@ -73,32 +73,35 @@ export default () => { @@ -73,32 +73,35 @@ export default () => {
}
if (dates[dateIndex].choosed) {
calendar.selectedDates = [dates[dateIndex]]
} else {
}
else {
calendar.selectedDates = []
}
} else {
}
else {
dates[dateIndex] = {
...dates[dateIndex],
choosed: !dates[dateIndex].choosed
choosed: !dates[dateIndex].choosed,
}
if (!calendar.selectedDates) {
calendar.selectedDates = []
}
if (dates[dateIndex].choosed) {
calendar.selectedDates.push(dates[dateIndex])
} else {
}
else {
calendar.selectedDates = calendar.selectedDates.filter(
date =>
dateUtil.toTimeStr(date) !== dateUtil.toTimeStr(dates[dateIndex])
dateUtil.toTimeStr(date) !== dateUtil.toTimeStr(dates[dateIndex]),
)
}
}
return {
calendarData: {
...calendar,
dates
dates,
},
calendarConfig
calendarConfig,
}
},
onSwitchCalendar(date, calendarData = {}, component) {
@ -108,21 +111,21 @@ export default () => { @@ -108,21 +111,21 @@ export default () => {
}
const updatedRenderData = calcJumpData({
dateInfo: date,
config: calendarConfig
config: calendarConfig,
})
return {
...calendarData,
...updatedRenderData
...updatedRenderData,
}
},
methods(component) {
return {
jump: dateInfo => {
jump: (dateInfo) => {
if (Object.prototype.toString.call(dateInfo) !== '[object Object]')
return
const updatedRenderData = calcJumpData({
dateInfo,
component
component,
})
const existCalendarData = getCalendarData('calendar', component)
const config = getCalendarConfig(component)
@ -130,13 +133,14 @@ export default () => { @@ -130,13 +133,14 @@ export default () => {
const target = updatedRenderData.dates[dateInfo.date - 1]
if (!updatedRenderData.selectedDates) {
updatedRenderData.selectedDates = [target]
} else {
}
else {
updatedRenderData.selectedDates.push(target)
}
}
return renderCalendar.call(component, {
...existCalendarData,
...updatedRenderData
...updatedRenderData,
})
},
getCalendarConfig() {
@ -148,7 +152,7 @@ export default () => { @@ -148,7 +152,7 @@ export default () => {
reject('异常:未找到组件配置信息')
return
}
let conf = { ...component.config, ...config }
const conf = { ...component.config, ...config }
component.config = conf
setCalendarData({ config: conf }, component)
.then(resolve)
@ -164,66 +168,69 @@ export default () => { @@ -164,66 +168,69 @@ export default () => {
if (config.chooseAreaMode) {
chooseAreaData = {
chooseAreaTimestamp: [],
tempChooseAreaTimestamp: []
tempChooseAreaTimestamp: [],
}
}
if (!cancelDates.length) {
dates.forEach(item => {
dates.forEach((item) => {
item.choosed = false
})
updatedRenderData = {
dates,
selectedDates: []
selectedDates: [],
}
} else {
}
else {
const cancelDatesStr = cancelDates.map(date =>
dateUtil.toTimeStr(date)
dateUtil.toTimeStr(date),
)
const filterSelectedDates = selectedDates.filter(
date => !cancelDatesStr.includes(dateUtil.toTimeStr(date))
date => !cancelDatesStr.includes(dateUtil.toTimeStr(date)),
)
dates.forEach(date => {
dates.forEach((date) => {
if (cancelDatesStr.includes(dateUtil.toTimeStr(date))) {
date.choosed = false
}
})
updatedRenderData = {
dates,
selectedDates: filterSelectedDates
selectedDates: filterSelectedDates,
}
}
return renderCalendar.call(component, {
...existCalendarData,
...updatedRenderData,
...chooseAreaData
...chooseAreaData,
})
},
setSelectedDates: targetDates => {
setSelectedDates: (targetDates) => {
const existCalendarData = getCalendarData('calendar', component)
let { dates, selectedDates = [] } = existCalendarData || {}
const { dates, selectedDates = [] } = existCalendarData || {}
let __selectedDates = []
let __dates = dates
if (!targetDates) {
__dates = dates.map(item => {
__dates = dates.map((item) => {
const date = { ...item }
date.choosed = true
if (existCalendarData.showLabelAlways && date.showTodoLabel) {
date.showTodoLabel = true
} else {
}
else {
date.showTodoLabel = false
}
return date
})
__selectedDates = dates
} else if (targetDates && targetDates.length) {
}
else if (targetDates && targetDates.length) {
const allSelected = dateUtil.uniqueArrayByDate(
selectedDates.concat(targetDates)
selectedDates.concat(targetDates),
)
const allSelectedDateStr = allSelected.map(d =>
dateUtil.toTimeStr(d)
dateUtil.toTimeStr(d),
)
__dates = dates.map(item => {
__dates = dates.map((item) => {
const date = { ...item }
if (allSelectedDateStr.includes(dateUtil.toTimeStr(date))) {
date.choosed = true
@ -231,7 +238,8 @@ export default () => { @@ -231,7 +238,8 @@ export default () => {
}
if (existCalendarData.showLabelAlways && date.showTodoLabel) {
date.showTodoLabel = true
} else {
}
else {
date.showTodoLabel = false
}
return date
@ -240,38 +248,40 @@ export default () => { @@ -240,38 +248,40 @@ export default () => {
return renderCalendar.call(component, {
...existCalendarData,
dates: __dates,
selectedDates: __selectedDates
selectedDates: __selectedDates,
})
},
setDateStyle: toSetDates => {
if (!Array.isArray(toSetDates)) return Promise.reject()
setDateStyle: (toSetDates) => {
if (!Array.isArray(toSetDates))
return Promise.reject()
const existCalendarData = getCalendarData('calendar', component)
const { dates = [], specialStyleDates } = existCalendarData || {}
if (Array.isArray(specialStyleDates)) {
toSetDates = dateUtil.uniqueArrayByDate([
...specialStyleDates,
...toSetDates
...toSetDates,
])
}
const toSetDatesStr = toSetDates.map(item => dateUtil.toTimeStr(item))
const _dates = dates.map(item => {
const _dates = dates.map((item) => {
const idx = toSetDatesStr.indexOf(dateUtil.toTimeStr(item))
if (idx > -1) {
return {
...item,
class: toSetDates[idx].class
class: toSetDates[idx].class,
}
} else {
}
else {
return item
}
})
return renderCalendar.call(component, {
...existCalendarData,
dates: _dates,
specialStyleDates: toSetDates
specialStyleDates: toSetDates,
})
}
},
}
}
},
}
}

30
src/components/calendar/plugins/preset/get-calendar-data.js

@ -4,14 +4,14 @@ @@ -4,14 +4,14 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-11 13:42:37
* */
*/
import { getCalendarData, logger, getCalendarConfig } from '../../utils/index'
import { getCalendarConfig, getCalendarData, logger } from '../../utils/index'
function wrapDateWithLunar(dates = [], convertFn) {
const datesWithLunar = JSON.parse(JSON.stringify(dates)).map(date => ({
...date,
lunar: convertFn(date)
lunar: convertFn(date),
}))
return datesWithLunar
}
@ -25,21 +25,23 @@ export default () => { @@ -25,21 +25,23 @@ export default () => {
const { curYear, curMonth } = getCalendarData('calendar', component)
return {
year: curYear,
month: curMonth
month: curMonth,
}
},
getSelectedDates: (options = {}) => {
const dates =
getCalendarData('calendar.selectedDates', component) || []
const dates
= getCalendarData('calendar.selectedDates', component) || []
const config = getCalendarConfig(component) || {}
if (options.lunar && !config.showLunar) {
const injectedFns = component.calendar || {}
if (typeof injectedFns.convertSolarLunar === 'function') {
return wrapDateWithLunar(dates, injectedFns.convertSolarLunar)
} else {
}
else {
logger.warn('获取农历信息需引入农历插件')
}
} else {
}
else {
return dates
}
},
@ -50,20 +52,22 @@ export default () => { @@ -50,20 +52,22 @@ export default () => {
const injectedFns = component.calendar || {}
if (typeof injectedFns.convertSolarLunar === 'function') {
return wrapDateWithLunar(dates, injectedFns.convertSolarLunar)
} else {
}
else {
logger.warn('获取农历信息需引入农历插件')
}
} else {
}
else {
return dates
}
},
getCalendarAllData: () => {
return {
data: getCalendarData('calendar', component) || {},
config: getCalendarConfig(component) || {}
config: getCalendarConfig(component) || {},
}
}
},
}
}
},
}
}

2
src/components/calendar/plugins/preset/index.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

2
src/components/calendar/plugins/preset/index.js

@ -3,7 +3,7 @@ import getCalendarData from './get-calendar-data' @@ -3,7 +3,7 @@ import getCalendarData from './get-calendar-data'
const preset = [
['base', base()],
['get-calendar-data', getCalendarData()]
['get-calendar-data', getCalendarData()],
]
export default preset

2
src/components/calendar/plugins/selectable.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

104
src/components/calendar/plugins/selectable.js

@ -4,10 +4,10 @@ @@ -4,10 +4,10 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-08 21:25:00
* */
*/
import { getCalendarData, dateUtil, logger } from '../utils/index'
import { renderCalendar } from '../render'
import { dateUtil, getCalendarData, logger } from '../utils/index'
function convertEnableAreaToTimestamp(timearea = []) {
const start = timearea[0].split('-')
@ -24,7 +24,7 @@ function convertEnableAreaToTimestamp(timearea = []) { @@ -24,7 +24,7 @@ function convertEnableAreaToTimestamp(timearea = []) {
start,
end,
startTimestamp,
endTimestamp
endTimestamp,
}
}
@ -33,39 +33,46 @@ function isValiditeOfDateArea(dateArea) { @@ -33,39 +33,46 @@ function isValiditeOfDateArea(dateArea) {
start,
end,
startTimestamp,
endTimestamp
endTimestamp,
} = convertEnableAreaToTimestamp(dateArea)
if (!start || !end) return
if (!start || !end)
return
const datesCountOfStart = dateUtil.getDatesCountOfMonth(start[0], start[1])
const datesCountOfEnd = dateUtil.getDatesCountOfMonth(end[0], end[1])
if (start[2] > datesCountOfStart || start[2] < 1) {
logger.warn('enableArea() 开始日期错误,指定日期不在指定月份天数范围内')
return false
} else if (start[1] > 12 || start[1] < 1) {
}
else if (start[1] > 12 || start[1] < 1) {
logger.warn('enableArea() 开始日期错误,月份超出1-12月份')
return false
} else if (end[2] > datesCountOfEnd || end[2] < 1) {
}
else if (end[2] > datesCountOfEnd || end[2] < 1) {
logger.warn('enableArea() 截止日期错误,指定日期不在指定月份天数范围内')
return false
} else if (end[1] > 12 || end[1] < 1) {
}
else if (end[1] > 12 || end[1] < 1) {
logger.warn('enableArea() 截止日期错误,月份超出1-12月份')
return false
} else if (startTimestamp > endTimestamp) {
}
else if (startTimestamp > endTimestamp) {
logger.warn('enableArea()参数最小日期大于了最大日期')
return false
} else {
}
else {
return true
}
}
function handleDisableMode(calendarConfig) {
const { disableMode } = calendarConfig
if (!disableMode) return {}
const disableBound =
dateUtil.getTimeStamp(disableMode.date) || dateUtil.todayTimestamp()
if (!disableMode)
return {}
const disableBound
= dateUtil.getTimeStamp(disableMode.date) || dateUtil.todayTimestamp()
return {
disableBound,
disableType: disableMode.type
disableType: disableMode.type,
}
}
@ -73,11 +80,12 @@ function disabledByConfig(dateInfo, currentDate, calendarConfig) { @@ -73,11 +80,12 @@ function disabledByConfig(dateInfo, currentDate, calendarConfig) {
const date = { ...dateInfo }
const { disableType, disableBound } = handleDisableMode(calendarConfig)
if (
(disableType === 'before' && disableBound && currentDate < disableBound) ||
(disableType === 'after' && disableBound && currentDate > disableBound)
(disableType === 'before' && disableBound && currentDate < disableBound)
|| (disableType === 'after' && disableBound && currentDate > disableBound)
) {
date.disable = true
} else {
}
else {
date.disable = false
}
return date
@ -92,34 +100,38 @@ export default () => { @@ -92,34 +100,38 @@ export default () => {
enableArea,
enableDates,
disableDates,
renderCausedBy
renderCausedBy,
} = calendarData
const _dates = [...dates].map(date => {
let item = { ...date }
const _dates = [...dates].map((date) => {
const item = { ...date }
const timeStr = dateUtil.toTimeStr(date)
const timestamp = +dateUtil.getTimeStamp(item)
if (renderCausedBy === 'enableDates') {
if (enableDates && enableDates.length) {
if (enableDates.includes(timeStr)) {
item.disable = false
} else {
}
else {
item.disable = true
}
return item
}
} else if (renderCausedBy === 'enableArea') {
}
else if (renderCausedBy === 'enableArea') {
if (enableArea && enableArea.length) {
const [startTimestamp, endTimestamp] = enableArea || []
const ifOutofArea =
+startTimestamp > timestamp || timestamp > +endTimestamp
const ifOutofArea
= +startTimestamp > timestamp || timestamp > +endTimestamp
item.disable = ifOutofArea
return item
}
} else if (renderCausedBy === 'disableDates') {
}
else if (renderCausedBy === 'disableDates') {
if (disableDates && disableDates.length) {
if (disableDates && disableDates.includes(timeStr)) {
item.disable = true
} else {
}
else {
item.disable = false
}
return item
@ -131,9 +143,9 @@ export default () => { @@ -131,9 +143,9 @@ export default () => {
return {
calendarData: {
...calendarData,
dates: _dates
dates: _dates,
},
calendarConfig
calendarConfig,
}
},
methods(component) {
@ -145,26 +157,28 @@ export default () => { @@ -145,26 +157,28 @@ export default () => {
const existCalendarData = getCalendarData('calendar', component)
const {
startTimestamp,
endTimestamp
endTimestamp,
} = convertEnableAreaToTimestamp(dateArea)
return renderCalendar.call(component, {
...existCalendarData,
renderCausedBy: 'enableArea',
enableArea: [startTimestamp, endTimestamp]
enableArea: [startTimestamp, endTimestamp],
})
}
} else {
}
else {
return Promise.inject(
'enableArea()参数需为时间范围数组,形如:["2018-8-4" , "2018-8-24"]'
'enableArea()参数需为时间范围数组,形如:["2018-8-4" , "2018-8-24"]',
)
}
},
enableDates: (toSet = []) => {
if (!toSet.length) return
if (!toSet.length)
return
const existCalendarData = getCalendarData('calendar', component)
const { enableDates = [] } = existCalendarData || {}
let toSetDates = toSet.map(item => {
let toSetDates = toSet.map((item) => {
if (typeof item === 'string') {
return dateUtil.transformDateRow2Dict(item)
}
@ -173,25 +187,25 @@ export default () => { @@ -173,25 +187,25 @@ export default () => {
if (enableDates.length) {
toSetDates = dateUtil.uniqueArrayByDate([
...toSetDates,
...enableDates.map(d => dateUtil.transformDateRow2Dict(d))
...enableDates.map(d => dateUtil.transformDateRow2Dict(d)),
])
}
return renderCalendar.call(component, {
...existCalendarData,
renderCausedBy: 'enableDates',
enableDates: toSetDates.map(date => {
enableDates: toSetDates.map((date) => {
if (typeof date !== 'string') {
return dateUtil.toTimeStr(date)
}
return date
})
}),
})
},
disableDates: toSet => {
disableDates: (toSet) => {
const existCalendarData = getCalendarData('calendar', component)
const { disableDates = [], dates = [] } = existCalendarData || {}
let toSetDates = toSet.map(item => {
let date = { ...item }
let toSetDates = toSet.map((item) => {
const date = { ...item }
if (typeof date === 'string') {
return dateUtil.transformDateRow2Dict(item)
}
@ -200,22 +214,22 @@ export default () => { @@ -200,22 +214,22 @@ export default () => {
if (disableDates && disableDates.length) {
toSetDates = dateUtil.uniqueArrayByDate([
...toSetDates,
...disableDates.map(d => dateUtil.transformDateRow2Dict(d))
...disableDates.map(d => dateUtil.transformDateRow2Dict(d)),
])
}
return renderCalendar.call(component, {
...existCalendarData,
renderCausedBy: 'disableDates',
dates,
disableDates: toSetDates.map(date => {
disableDates: toSetDates.map((date) => {
if (typeof date !== 'string') {
return dateUtil.toTimeStr(date)
}
return date
})
}),
})
}
},
}
}
},
}
}

662
src/components/calendar/plugins/solarLunar/convertSolarLunar.js

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
*/
/* 公历年月日转农历数据 返回json */
// calendar.solar2lunar(1987,11,01);
/** 农历年月日转公历年月日 **/
/** 农历年月日转公历年月日 */
// calendar.lunar2solar(1987,9,10);
// 调用以上方法后返回类似如下object(json)具体以上就不需要解释了吧!
// c开头的是公历各属性值 l开头的自然就是农历咯 gz开头的就是天干地支纪年的数据啦~
@ -39,208 +39,208 @@ const calendar = { @@ -39,208 +39,208 @@ const calendar = {
* @return Hex
*/
lunarInfo: [
0x04bd8,
0x04ae0,
0x0a570,
0x054d5,
0x0d260,
0x0d950,
0x04BD8,
0x04AE0,
0x0A570,
0x054D5,
0x0D260,
0x0D950,
0x16554,
0x056a0,
0x09ad0,
0x055d2, // 1900-1909
0x04ae0,
0x0a5b6,
0x0a4d0,
0x0d250,
0x1d255,
0x0b540,
0x0d6a0,
0x0ada2,
0x095b0,
0x056A0,
0x09AD0,
0x055D2, // 1900-1909
0x04AE0,
0x0A5B6,
0x0A4D0,
0x0D250,
0x1D255,
0x0B540,
0x0D6A0,
0x0ADA2,
0x095B0,
0x14977, // 1910-1919
0x04970,
0x0a4b0,
0x0b4b5,
0x06a50,
0x06d40,
0x1ab54,
0x02b60,
0x0A4B0,
0x0B4B5,
0x06A50,
0x06D40,
0x1AB54,
0x02B60,
0x09570,
0x052f2,
0x052F2,
0x04970, // 1920-1929
0x06566,
0x0d4a0,
0x0ea50,
0x06e95,
0x05ad0,
0x02b60,
0x186e3,
0x092e0,
0x1c8d7,
0x0c950, // 1930-1939
0x0d4a0,
0x1d8a6,
0x0b550,
0x056a0,
0x1a5b4,
0x025d0,
0x092d0,
0x0d2b2,
0x0a950,
0x0b557, // 1940-1949
0x06ca0,
0x0b550,
0x0D4A0,
0x0EA50,
0x06E95,
0x05AD0,
0x02B60,
0x186E3,
0x092E0,
0x1C8D7,
0x0C950, // 1930-1939
0x0D4A0,
0x1D8A6,
0x0B550,
0x056A0,
0x1A5B4,
0x025D0,
0x092D0,
0x0D2B2,
0x0A950,
0x0B557, // 1940-1949
0x06CA0,
0x0B550,
0x15355,
0x04da0,
0x0a5b0,
0x04DA0,
0x0A5B0,
0x14573,
0x052b0,
0x0a9a8,
0x0e950,
0x06aa0, // 1950-1959
0x0aea6,
0x0ab50,
0x04b60,
0x0aae4,
0x0a570,
0x052B0,
0x0A9A8,
0x0E950,
0x06AA0, // 1950-1959
0x0AEA6,
0x0AB50,
0x04B60,
0x0AAE4,
0x0A570,
0x05260,
0x0f263,
0x0d950,
0x05b57,
0x056a0, // 1960-1969
0x096d0,
0x04dd5,
0x04ad0,
0x0a4d0,
0x0d4d4,
0x0d250,
0x0d558,
0x0b540,
0x0b6a0,
0x195a6, // 1970-1979
0x095b0,
0x049b0,
0x0a974,
0x0a4b0,
0x0b27a,
0x06a50,
0x06d40,
0x0af46,
0x0ab60,
0x0F263,
0x0D950,
0x05B57,
0x056A0, // 1960-1969
0x096D0,
0x04DD5,
0x04AD0,
0x0A4D0,
0x0D4D4,
0x0D250,
0x0D558,
0x0B540,
0x0B6A0,
0x195A6, // 1970-1979
0x095B0,
0x049B0,
0x0A974,
0x0A4B0,
0x0B27A,
0x06A50,
0x06D40,
0x0AF46,
0x0AB60,
0x09570, // 1980-1989
0x04af5,
0x04AF5,
0x04970,
0x064b0,
0x074a3,
0x0ea50,
0x06b58,
0x055c0,
0x0ab60,
0x096d5,
0x092e0, // 1990-1999
0x0c960,
0x0d954,
0x0d4a0,
0x0da50,
0x064B0,
0x074A3,
0x0EA50,
0x06B58,
0x055C0,
0x0AB60,
0x096D5,
0x092E0, // 1990-1999
0x0C960,
0x0D954,
0x0D4A0,
0x0DA50,
0x07552,
0x056a0,
0x0abb7,
0x025d0,
0x092d0,
0x0cab5, // 2000-2009
0x0a950,
0x0b4a0,
0x0baa4,
0x0ad50,
0x055d9,
0x04ba0,
0x0a5b0,
0x056A0,
0x0ABB7,
0x025D0,
0x092D0,
0x0CAB5, // 2000-2009
0x0A950,
0x0B4A0,
0x0BAA4,
0x0AD50,
0x055D9,
0x04BA0,
0x0A5B0,
0x15176,
0x052b0,
0x0a930, // 2010-2019
0x052B0,
0x0A930, // 2010-2019
0x07954,
0x06aa0,
0x0ad50,
0x05b52,
0x04b60,
0x0a6e6,
0x0a4e0,
0x0d260,
0x0ea65,
0x0d530, // 2020-2029
0x05aa0,
0x076a3,
0x096d0,
0x04afb,
0x04ad0,
0x0a4d0,
0x1d0b6,
0x0d250,
0x0d520,
0x0dd45, // 2030-2039
0x0b5a0,
0x056d0,
0x055b2,
0x049b0,
0x0a577,
0x0a4b0,
0x0aa50,
0x1b255,
0x06d20,
0x0ada0, // 2040-2049
/** Add By JJonline@JJonline.Cn **/
0x14b63,
0x06AA0,
0x0AD50,
0x05B52,
0x04B60,
0x0A6E6,
0x0A4E0,
0x0D260,
0x0EA65,
0x0D530, // 2020-2029
0x05AA0,
0x076A3,
0x096D0,
0x04AFB,
0x04AD0,
0x0A4D0,
0x1D0B6,
0x0D250,
0x0D520,
0x0DD45, // 2030-2039
0x0B5A0,
0x056D0,
0x055B2,
0x049B0,
0x0A577,
0x0A4B0,
0x0AA50,
0x1B255,
0x06D20,
0x0ADA0, // 2040-2049
/** Add By JJonline@JJonline.Cn */
0x14B63,
0x09370,
0x049f8,
0x049F8,
0x04970,
0x064b0,
0x168a6,
0x0ea50,
0x06b20,
0x1a6c4,
0x0aae0, // 2050-2059
0x0a2e0,
0x0d2e3,
0x0c960,
0x0d557,
0x0d4a0,
0x0da50,
0x05d55,
0x056a0,
0x0a6d0,
0x055d4, // 2060-2069
0x052d0,
0x0a9b8,
0x0a950,
0x0b4a0,
0x0b6a6,
0x0ad50,
0x055a0,
0x0aba4,
0x0a5b0,
0x052b0, // 2070-2079
0x0b273,
0x064B0,
0x168A6,
0x0EA50,
0x06B20,
0x1A6C4,
0x0AAE0, // 2050-2059
0x0A2E0,
0x0D2E3,
0x0C960,
0x0D557,
0x0D4A0,
0x0DA50,
0x05D55,
0x056A0,
0x0A6D0,
0x055D4, // 2060-2069
0x052D0,
0x0A9B8,
0x0A950,
0x0B4A0,
0x0B6A6,
0x0AD50,
0x055A0,
0x0ABA4,
0x0A5B0,
0x052B0, // 2070-2079
0x0B273,
0x06930,
0x07337,
0x06aa0,
0x0ad50,
0x14b55,
0x04b60,
0x0a570,
0x054e4,
0x0d160, // 2080-2089
0x0e968,
0x0d520,
0x0daa0,
0x16aa6,
0x056d0,
0x04ae0,
0x0a9d4,
0x0a2d0,
0x0d150,
0x0f252, // 2090-2099
0x0d520
0x06AA0,
0x0AD50,
0x14B55,
0x04B60,
0x0A570,
0x054E4,
0x0D160, // 2080-2089
0x0E968,
0x0D520,
0x0DAA0,
0x16AA6,
0x056D0,
0x04AE0,
0x0A9D4,
0x0A2D0,
0x0D150,
0x0F252, // 2090-2099
0x0D520,
], // 2100
/**
@ -257,15 +257,15 @@ const calendar = { @@ -257,15 +257,15 @@ const calendar = {
*/
Gan: [
'\u7532',
'\u4e59',
'\u4e19',
'\u4e01',
'\u620a',
'\u5df1',
'\u5e9a',
'\u8f9b',
'\u58ec',
'\u7678'
'\u4E59',
'\u4E19',
'\u4E01',
'\u620A',
'\u5DF1',
'\u5E9A',
'\u8F9B',
'\u58EC',
'\u7678',
],
/**
@ -275,18 +275,18 @@ const calendar = { @@ -275,18 +275,18 @@ const calendar = {
* @return Cn string
*/
Zhi: [
'\u5b50',
'\u4e11',
'\u5bc5',
'\u536f',
'\u8fb0',
'\u5df3',
'\u5B50',
'\u4E11',
'\u5BC5',
'\u536F',
'\u8FB0',
'\u5DF3',
'\u5348',
'\u672a',
'\u672A',
'\u7533',
'\u9149',
'\u620c',
'\u4ea5'
'\u620C',
'\u4EA5',
],
/**
@ -296,18 +296,18 @@ const calendar = { @@ -296,18 +296,18 @@ const calendar = {
* @return Cn string
*/
Animals: [
'\u9f20',
'\u725b',
'\u864e',
'\u9F20',
'\u725B',
'\u864E',
'\u5154',
'\u9f99',
'\u86c7',
'\u9a6c',
'\u7f8a',
'\u9F99',
'\u86C7',
'\u9A6C',
'\u7F8A',
'\u7334',
'\u9e21',
'\u72d7',
'\u732a'
'\u9E21',
'\u72D7',
'\u732A',
],
/**
@ -317,30 +317,30 @@ const calendar = { @@ -317,30 +317,30 @@ const calendar = {
* @return Cn string
*/
solarTerm: [
'\u5c0f\u5bd2',
'\u5927\u5bd2',
'\u7acb\u6625',
'\u96e8\u6c34',
'\u60ca\u86f0',
'\u5C0F\u5BD2',
'\u5927\u5BD2',
'\u7ACB\u6625',
'\u96E8\u6C34',
'\u60CA\u86F0',
'\u6625\u5206',
'\u6e05\u660e',
'\u8c37\u96e8',
'\u7acb\u590f',
'\u5c0f\u6ee1',
'\u8292\u79cd',
'\u590f\u81f3',
'\u5c0f\u6691',
'\u6E05\u660E',
'\u8C37\u96E8',
'\u7ACB\u590F',
'\u5C0F\u6EE1',
'\u8292\u79CD',
'\u590F\u81F3',
'\u5C0F\u6691',
'\u5927\u6691',
'\u7acb\u79cb',
'\u7ACB\u79CB',
'\u5904\u6691',
'\u767d\u9732',
'\u79cb\u5206',
'\u5bd2\u9732',
'\u971c\u964d',
'\u7acb\u51ac',
'\u5c0f\u96ea',
'\u5927\u96ea',
'\u51ac\u81f3'
'\u767D\u9732',
'\u79CB\u5206',
'\u5BD2\u9732',
'\u971C\u964D',
'\u7ACB\u51AC',
'\u5C0F\u96EA',
'\u5927\u96EA',
'\u51AC\u81F3',
],
/**
@ -549,7 +549,7 @@ const calendar = { @@ -549,7 +549,7 @@ const calendar = {
'665f67f0e37f1489801eb072297c35',
'7ec967f0e37f14998082b0787b06bd',
'7f07e7f0e47f531b0723b0b6fb0721',
'7f0e27f1487f531b0b0bb0b6fb0722'
'7f0e27f1487f531b0b0bb0b6fb0722',
],
/**
@ -559,17 +559,17 @@ const calendar = { @@ -559,17 +559,17 @@ const calendar = {
* @return Cn string
*/
nStr1: [
'\u65e5',
'\u4e00',
'\u4e8c',
'\u4e09',
'\u56db',
'\u4e94',
'\u516d',
'\u4e03',
'\u516b',
'\u4e5d',
'\u5341'
'\u65E5',
'\u4E00',
'\u4E8C',
'\u4E09',
'\u56DB',
'\u4E94',
'\u516D',
'\u4E03',
'\u516B',
'\u4E5D',
'\u5341',
],
/**
@ -578,7 +578,7 @@ const calendar = { @@ -578,7 +578,7 @@ const calendar = {
* @trans ['初','十','廿','卅']
* @return Cn string
*/
nStr2: ['\u521d', '\u5341', '\u5eff', '\u5345'],
nStr2: ['\u521D', '\u5341', '\u5EFF', '\u5345'],
/**
* 月份转农历称呼速查表
@ -587,18 +587,18 @@ const calendar = { @@ -587,18 +587,18 @@ const calendar = {
* @return Cn string
*/
nStr3: [
'\u6b63',
'\u4e8c',
'\u4e09',
'\u56db',
'\u4e94',
'\u516d',
'\u4e03',
'\u516b',
'\u4e5d',
'\u6B63',
'\u4E8C',
'\u4E09',
'\u56DB',
'\u4E94',
'\u516D',
'\u4E03',
'\u516B',
'\u4E5D',
'\u5341',
'\u51ac',
'\u814a'
'\u51AC',
'\u814A',
],
/**
@ -607,7 +607,7 @@ const calendar = { @@ -607,7 +607,7 @@ const calendar = {
* @return Number
* @eg:var count = calendar.lYearDays(1987) ;//count=387
*/
lYearDays: function(y) {
lYearDays(y) {
let i
let sum = 348
for (i = 0x8000; i > 0x8; i >>= 1) {
@ -622,9 +622,9 @@ const calendar = { @@ -622,9 +622,9 @@ const calendar = {
* @return Number (0-12)
* @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6
*/
leapMonth: function(y) {
leapMonth(y) {
// 闰字编码 \u95f0
return calendar.lunarInfo[y - 1900] & 0xf
return calendar.lunarInfo[y - 1900] & 0xF
},
/**
@ -633,7 +633,7 @@ const calendar = { @@ -633,7 +633,7 @@ const calendar = {
* @return Number (02930)
* @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29
*/
leapDays: function(y) {
leapDays(y) {
if (calendar.leapMonth(y)) {
return calendar.lunarInfo[y - 1900] & 0x10000 ? 30 : 29
}
@ -646,8 +646,9 @@ const calendar = { @@ -646,8 +646,9 @@ const calendar = {
* @return Number (-12930)
* @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29
*/
monthDays: function(y, m) {
if (m > 12 || m < 1) return -1 // 月份参数从1至12,参数错误返回-1
monthDays(y, m) {
if (m > 12 || m < 1)
return -1 // 月份参数从1至12,参数错误返回-1
return calendar.lunarInfo[y - 1900] & (0x10000 >> m) ? 30 : 29
},
@ -657,13 +658,15 @@ const calendar = { @@ -657,13 +658,15 @@ const calendar = {
* @return Number (-128293031)
* @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30
*/
solarDays: function(y, m) {
if (m > 12 || m < 1) return -1 // 若参数错误 返回-1
solarDays(y, m) {
if (m > 12 || m < 1)
return -1 // 若参数错误 返回-1
const ms = m - 1
if (+ms === 1) {
// 2月份的闰平规律测算后确认返回28或29
return (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0 ? 29 : 28
} else {
}
else {
return calendar.solarMonth[ms]
}
},
@ -673,11 +676,13 @@ const calendar = { @@ -673,11 +676,13 @@ const calendar = {
* @param lYear 农历年的年份数
* @return Cn string
*/
toGanZhiYear: function(lYear) {
toGanZhiYear(lYear) {
let ganKey = (lYear - 3) % 10
let zhiKey = (lYear - 3) % 12
if (+ganKey === 0) ganKey = 10 // 如果余数为0则为最后一个天干
if (+zhiKey === 0) zhiKey = 12 // 如果余数为0则为最后一个地支
if (+ganKey === 0)
ganKey = 10 // 如果余数为0则为最后一个天干
if (+zhiKey === 0)
zhiKey = 12 // 如果余数为0则为最后一个地支
return calendar.Gan[ganKey - 1] + calendar.Zhi[zhiKey - 1]
},
@ -687,11 +692,11 @@ const calendar = { @@ -687,11 +692,11 @@ const calendar = {
* @param cDay [description]
* @return Cn string
*/
toAstro: function(cMonth, cDay) {
const s =
'\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf'
toAstro(cMonth, cDay) {
const s
= '\u9B54\u7FAF\u6C34\u74F6\u53CC\u9C7C\u767D\u7F8A\u91D1\u725B\u53CC\u5B50\u5DE8\u87F9\u72EE\u5B50\u5904\u5973\u5929\u79E4\u5929\u874E\u5C04\u624B\u9B54\u7FAF'
const arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]
return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + '\u5ea7' // 座
return `${s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2)}\u5EA7` // 座
},
/**
@ -699,7 +704,7 @@ const calendar = { @@ -699,7 +704,7 @@ const calendar = {
* @param offset 相对甲子的偏移量
* @return Cn string
*/
toGanZhi: function(offset) {
toGanZhi(offset) {
return calendar.Gan[offset % 10] + calendar.Zhi[offset % 12]
},
@ -709,17 +714,19 @@ const calendar = { @@ -709,17 +714,19 @@ const calendar = {
* @return day Number
* @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春
*/
getTerm: function(y, n) {
if (y < 1900 || y > 2100) return -1
if (n < 1 || n > 24) return -1
getTerm(y, n) {
if (y < 1900 || y > 2100)
return -1
if (n < 1 || n > 24)
return -1
const _table = calendar.sTermInfo[y - 1900]
const _info = [
parseInt('0x' + _table.substr(0, 5)).toString(),
parseInt('0x' + _table.substr(5, 5)).toString(),
parseInt('0x' + _table.substr(10, 5)).toString(),
parseInt('0x' + _table.substr(15, 5)).toString(),
parseInt('0x' + _table.substr(20, 5)).toString(),
parseInt('0x' + _table.substr(25, 5)).toString()
Number.parseInt(`0x${_table.substr(0, 5)}`).toString(),
Number.parseInt(`0x${_table.substr(5, 5)}`).toString(),
Number.parseInt(`0x${_table.substr(10, 5)}`).toString(),
Number.parseInt(`0x${_table.substr(15, 5)}`).toString(),
Number.parseInt(`0x${_table.substr(20, 5)}`).toString(),
Number.parseInt(`0x${_table.substr(25, 5)}`).toString(),
]
const _calday = [
_info[0].substr(0, 1),
@ -750,9 +757,9 @@ const calendar = { @@ -750,9 +757,9 @@ const calendar = {
_info[5].substr(0, 1),
_info[5].substr(1, 2),
_info[5].substr(3, 1),
_info[5].substr(4, 2)
_info[5].substr(4, 2),
]
return parseInt(_calday[n - 1])
return Number.parseInt(_calday[n - 1])
},
/**
@ -761,9 +768,10 @@ const calendar = { @@ -761,9 +768,10 @@ const calendar = {
* @return Cn string
* @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月'
*/
toChinaMonth: function(m) {
toChinaMonth(m) {
// 月 => \u6708
if (m > 12 || m < 1) return -1 // 若参数错误 返回-1
if (m > 12 || m < 1)
return -1 // 若参数错误 返回-1
let s = calendar.nStr3[m - 1]
s += '\u6708' // 加上月字
return s
@ -775,18 +783,18 @@ const calendar = { @@ -775,18 +783,18 @@ const calendar = {
* @return Cn string
* @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一'
*/
toChinaDay: function(d) {
toChinaDay(d) {
// 日 => \u65e5
let s
switch (d) {
case 10:
s = '\u521d\u5341'
s = '\u521D\u5341'
break
case 20:
s = '\u4e8c\u5341'
s = '\u4E8C\u5341'
break
case 30:
s = '\u4e09\u5341'
s = '\u4E09\u5341'
break
default:
s = calendar.nStr2[Math.floor(d / 10)]
@ -801,7 +809,7 @@ const calendar = { @@ -801,7 +809,7 @@ const calendar = {
* @return Cn string
* @eg:var animal = calendar.getAnimal(1987) ;//animal='兔'
*/
getAnimal: function(y) {
getAnimal(y) {
return calendar.Animals[(y - 4) % 12]
},
@ -813,7 +821,7 @@ const calendar = { @@ -813,7 +821,7 @@ const calendar = {
* @return JSON object
* @eg:console.log(calendar.solar2lunar(1987,11,01));
*/
solar2lunar: function(y, m, d) {
solar2lunar(y, m, d) {
// 参数区间1900.1.31~2100.12.31
// 年份限定、上限
if (y < 1900 || y > 2100) {
@ -827,8 +835,9 @@ const calendar = { @@ -827,8 +835,9 @@ const calendar = {
let objDate
if (!y) {
objDate = new Date()
} else {
objDate = new Date(y, parseInt(m) - 1, d)
}
else {
objDate = new Date(y, Number.parseInt(m) - 1, d)
}
let i
let leap = 0
@ -837,10 +846,10 @@ const calendar = { @@ -837,10 +846,10 @@ const calendar = {
y = objDate.getFullYear()
m = objDate.getMonth() + 1
d = objDate.getDate()
let offset =
(Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) -
Date.UTC(1900, 0, 31)) /
86400000
let offset
= (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate())
- Date.UTC(1900, 0, 31))
/ 86400000
for (i = 1900; i < 2101 && offset > 0; i++) {
temp = calendar.lYearDays(i)
offset -= temp
@ -854,9 +863,9 @@ const calendar = { @@ -854,9 +863,9 @@ const calendar = {
const isTodayObj = new Date()
let isToday = false
if (
isTodayObj.getFullYear() === +y &&
isTodayObj.getMonth() + 1 === +m &&
isTodayObj.getDate() === +d
isTodayObj.getFullYear() === +y
&& isTodayObj.getMonth() + 1 === +m
&& isTodayObj.getDate() === +d
) {
isToday = true
}
@ -879,18 +888,21 @@ const calendar = { @@ -879,18 +888,21 @@ const calendar = {
--i
isLeap = true
temp = calendar.leapDays(year) // 计算农历闰月天数
} else {
}
else {
temp = calendar.monthDays(year, i) // 计算农历普通月天数
}
// 解除闰月
if (isLeap === true && i === leap + 1) isLeap = false
if (isLeap === true && i === leap + 1)
isLeap = false
offset -= temp
}
// 闰月导致数组下标重叠取反
if (offset === 0 && leap > 0 && i === leap + 1) {
if (isLeap) {
isLeap = false
} else {
}
else {
isLeap = true
--i
}
@ -940,7 +952,7 @@ const calendar = { @@ -940,7 +952,7 @@ const calendar = {
lMonth: month,
lDay: day,
Animal: calendar.getAnimal(year),
IMonthCn: (isLeap ? '\u95f0' : '') + calendar.toChinaMonth(month),
IMonthCn: (isLeap ? '\u95F0' : '') + calendar.toChinaMonth(month),
IDayCn: calendar.toChinaDay(day),
cYear: y,
cMonth: m,
@ -948,13 +960,13 @@ const calendar = { @@ -948,13 +960,13 @@ const calendar = {
gzYear: gzY,
gzMonth: gzM,
gzDay: gzD,
isToday: isToday,
isLeap: isLeap,
nWeek: nWeek,
ncWeek: '\u661f\u671f' + cWeek,
isTerm: isTerm,
Term: Term,
astro: astro
isToday,
isLeap,
nWeek,
ncWeek: `\u661F\u671F${cWeek}`,
isTerm,
Term,
astro,
}
},
@ -967,18 +979,20 @@ const calendar = { @@ -967,18 +979,20 @@ const calendar = {
* @return JSON object
* @eg:console.log(calendar.lunar2solar(1987,9,10));
*/
lunar2solar: function(y, m, d, isLeapMonth) {
lunar2solar(y, m, d, isLeapMonth) {
// 参数区间1900.1.31~2100.12.1
isLeapMonth = !!isLeapMonth
// let leapOffset = 0;
const leapMonth = calendar.leapMonth(y)
// let leapDay = calendar.leapDays(y);
if (isLeapMonth && leapMonth !== m) return -1 // 传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同
if (isLeapMonth && leapMonth !== m)
return -1 // 传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同
if (
(+y === 2100 && +m === 12 && +d > 1) ||
(+y === 1900 && +m === 1 && +d < 31)
)
return -1 // 超出了最大极限值
(+y === 2100 && +m === 12 && +d > 1)
|| (+y === 1900 && +m === 1 && +d < 31)
) {
return -1
} // 超出了最大极限值
const day = calendar.monthDays(y, m)
let _day = day
// bugFix 2016-9-25
@ -986,7 +1000,8 @@ const calendar = { @@ -986,7 +1000,8 @@ const calendar = {
if (isLeapMonth) {
_day = calendar.leapDays(y, m)
}
if (y < 1900 || y > 2100 || d > _day) return -1 // 参数合法性效验
if (y < 1900 || y > 2100 || d > _day)
return -1 // 参数合法性效验
// 计算农历的时间差
let offset = 0
@ -1007,7 +1022,8 @@ const calendar = { @@ -1007,7 +1022,8 @@ const calendar = {
offset += calendar.monthDays(y, i)
}
// 转换闰月农历 需补充该年闰月的前一个月的时差
if (isLeapMonth) offset += day
if (isLeapMonth)
offset += day
// 1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点)
const stmap = Date.UTC(1900, 1, 30, 0, 0, 0)
const calObj = new Date((offset + d - 31) * 86400000 + stmap)
@ -1016,7 +1032,7 @@ const calendar = { @@ -1016,7 +1032,7 @@ const calendar = {
const cD = calObj.getUTCDate()
return calendar.solar2lunar(cY, cM, cD)
}
},
}
const {

2
src/components/calendar/plugins/solarLunar/index.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

29
src/components/calendar/plugins/solarLunar/index.js

@ -2,7 +2,8 @@ import { dateUtil } from '../../utils/index' @@ -2,7 +2,8 @@ import { dateUtil } from '../../utils/index'
import convertSolarLunar from './convertSolarLunar'
function getDateRow2Dict(dateInfo) {
if (!dateInfo) return dateInfo
if (!dateInfo)
return dateInfo
if (typeof dateInfo === 'string' && dateInfo.includes('-')) {
dateInfo = dateUtil.transformDateRow2Dict(dateInfo)
}
@ -15,45 +16,47 @@ export default () => { @@ -15,45 +16,47 @@ export default () => {
beforeRender(calendarData = {}, calendarConfig = {}) {
let { dates = [], selectedDates = [] } = calendarData
if (calendarConfig.showLunar) {
dates = dates.map(dataInfo => {
dates = dates.map((dataInfo) => {
const { year, month, date } = dataInfo
return {
...dataInfo,
lunar: convertSolarLunar.solar2lunar(year, month, date)
lunar: convertSolarLunar.solar2lunar(year, month, date),
}
})
selectedDates = selectedDates.map(dataInfo => {
selectedDates = selectedDates.map((dataInfo) => {
const { year, month, date } = dataInfo
return {
...dataInfo,
lunar: convertSolarLunar.solar2lunar(year, month, date)
lunar: convertSolarLunar.solar2lunar(year, month, date),
}
})
}
return {
calendarData: {
...calendarData,
dates: dates,
selectedDates: selectedDates
dates,
selectedDates,
},
calendarConfig
calendarConfig,
}
},
methods() {
return {
convertSolarLunar: dateInfo => {
convertSolarLunar: (dateInfo) => {
dateInfo = getDateRow2Dict(dateInfo)
if (!dateInfo) return dateInfo
if (!dateInfo)
return dateInfo
const { year, month, date } = dateInfo
return convertSolarLunar.solar2lunar(year, month, date)
},
convertlLunar2Solar: (dateInfo, isLeapMonth) => {
dateInfo = getDateRow2Dict(dateInfo)
if (!dateInfo) return dateInfo
if (!dateInfo)
return dateInfo
const { year, month, date } = dateInfo
return convertSolarLunar.lunar2solar(year, month, date, isLeapMonth)
}
},
}
}
},
}
}

126
src/components/calendar/plugins/time-range.js

@ -4,32 +4,32 @@ @@ -4,32 +4,32 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-11 13:56:32
* */
*/
import { renderCalendar } from '../render'
import {
logger,
dateUtil,
getCalendarConfig,
getCalendarData
getCalendarData,
logger,
} from '../utils/index'
function pusheNextMonthDateArea(
dateInfo = {},
startTimestamp,
endTimestamp,
selectedDates = []
selectedDates = [],
) {
let tempOfSelectedDate = [...selectedDates]
const tempOfSelectedDate = [...selectedDates]
const dates = dateUtil.calcDates(dateInfo.year, dateInfo.month)
let datesLen = dates.length
const datesLen = dates.length
for (let i = 0; i < datesLen; i++) {
const date = dates[i]
const timeStamp = dateUtil.getTimeStamp(date)
if (timeStamp <= endTimestamp && timeStamp >= startTimestamp) {
tempOfSelectedDate.push({
...date,
choosed: true
choosed: true,
})
}
if (i === datesLen - 1 && timeStamp < endTimestamp) {
@ -37,7 +37,7 @@ function pusheNextMonthDateArea( @@ -37,7 +37,7 @@ function pusheNextMonthDateArea(
dateUtil.getNextMonthInfo(date),
startTimestamp,
endTimestamp,
tempOfSelectedDate
tempOfSelectedDate,
)
}
}
@ -47,22 +47,22 @@ function pushPrevMonthDateArea( @@ -47,22 +47,22 @@ function pushPrevMonthDateArea(
dateInfo = {},
startTimestamp,
endTimestamp,
selectedDates = []
selectedDates = [],
) {
let tempOfSelectedDate = [...selectedDates]
const tempOfSelectedDate = [...selectedDates]
const dates = dateUtil.sortDatesByTime(
dateUtil.calcDates(dateInfo.year, dateInfo.month),
'desc'
'desc',
)
let datesLen = dates.length
let firstDate = dateUtil.getTimeStamp(dates[0])
const datesLen = dates.length
const firstDate = dateUtil.getTimeStamp(dates[0])
for (let i = 0; i < datesLen; i++) {
const date = dates[i]
const timeStamp = dateUtil.getTimeStamp(date)
if (timeStamp >= startTimestamp && timeStamp <= endTimestamp) {
tempOfSelectedDate.push({
...date,
choosed: true
choosed: true,
})
}
if (i === datesLen - 1 && firstDate > startTimestamp) {
@ -70,7 +70,7 @@ function pushPrevMonthDateArea( @@ -70,7 +70,7 @@ function pushPrevMonthDateArea(
dateUtil.getPrevMonthInfo(date),
startTimestamp,
endTimestamp,
tempOfSelectedDate
tempOfSelectedDate,
)
}
}
@ -88,7 +88,7 @@ function calcDateWhenNotInOneMonth(info) { @@ -88,7 +88,7 @@ function calcDateWhenNotInOneMonth(info) {
dateUtil.getPrevMonthInfo(firstDate),
startTimestamp,
endTimestamp,
selectedDate
selectedDate,
)
}
if (dateUtil.getTimeStamp(lastDate) < endTimestamp) {
@ -96,7 +96,7 @@ function calcDateWhenNotInOneMonth(info) { @@ -96,7 +96,7 @@ function calcDateWhenNotInOneMonth(info) {
dateUtil.getNextMonthInfo(lastDate),
startTimestamp,
endTimestamp,
selectedDate
selectedDate,
)
}
return [...selectedDate]
@ -104,7 +104,7 @@ function calcDateWhenNotInOneMonth(info) { @@ -104,7 +104,7 @@ function calcDateWhenNotInOneMonth(info) {
/**
* 指定日期区域转时间戳
* @param {array} timearea 时间区域
* @param {Array} timearea 时间区域
*/
export function convertTimeRangeToTimestamp(timearea = []) {
const start = timearea[0].split('-')
@ -121,40 +121,46 @@ export function convertTimeRangeToTimestamp(timearea = []) { @@ -121,40 +121,46 @@ export function convertTimeRangeToTimestamp(timearea = []) {
start,
end,
startTimestamp,
endTimestamp
endTimestamp,
}
}
/**
* 校验时间区域是否合法
* @param {array} dateArea 时间区域
* @param {Array} dateArea 时间区域
*/
function validateTimeRange(dateArea) {
const {
start,
end,
startTimestamp,
endTimestamp
endTimestamp,
} = convertTimeRangeToTimestamp(dateArea)
if (!start || !end) return
if (!start || !end)
return
const startMonthDays = dateUtil.getDatesCountOfMonth(start[0], start[1])
const endMonthDays = dateUtil.getDatesCountOfMonth(end[0], end[1])
if (start[2] > startMonthDays || start[2] < 1) {
logger.warn('enableArea() 开始日期错误,指定日期不在当前月份天数范围内')
return false
} else if (start[1] > 12 || start[1] < 1) {
}
else if (start[1] > 12 || start[1] < 1) {
logger.warn('enableArea() 开始日期错误,月份超出1-12月份')
return false
} else if (end[2] > endMonthDays || end[2] < 1) {
}
else if (end[2] > endMonthDays || end[2] < 1) {
logger.warn('enableArea() 截止日期错误,指定日期不在当前月份天数范围内')
return false
} else if (end[1] > 12 || end[1] < 1) {
}
else if (end[1] > 12 || end[1] < 1) {
logger.warn('enableArea() 截止日期错误,月份超出1-12月份')
return false
} else if (startTimestamp > endTimestamp) {
}
else if (startTimestamp > endTimestamp) {
logger.warn('enableArea()参数最小日期大于了最大日期')
return false
} else {
}
else {
return true
}
}
@ -166,26 +172,27 @@ export default () => { @@ -166,26 +172,27 @@ export default () => {
const {
chooseAreaTimestamp = [],
dates = [],
selectedDates = []
selectedDates = [],
} = calendarData
let __dates = dates
let __selectedDates = selectedDates
const [startDateTimestamp, endDateTimestamp] = chooseAreaTimestamp
if (chooseAreaTimestamp.length === 2) {
__selectedDates = []
__dates = dates.map(d => {
__dates = dates.map((d) => {
const date = { ...d }
const dateTimeStamp = dateUtil.getTimeStamp(date)
if (
dateTimeStamp >= startDateTimestamp &&
endDateTimestamp >= dateTimeStamp
dateTimeStamp >= startDateTimestamp
&& endDateTimestamp >= dateTimeStamp
) {
date.choosed = true
__selectedDates.push(date)
} else {
}
else {
date.choosed = false
__selectedDates = __selectedDates.filter(
item => dateUtil.getTimeStamp(item) !== dateTimeStamp
item => dateUtil.getTimeStamp(item) !== dateTimeStamp,
)
}
return date
@ -198,7 +205,7 @@ export default () => { @@ -198,7 +205,7 @@ export default () => {
lastDate: __dates[__dates.length - 1],
startTimestamp: startDateTimestamp,
endTimestamp: endDateTimestamp,
selectedDate: __selectedDates
selectedDate: __selectedDates,
})
}
}
@ -207,44 +214,47 @@ export default () => { @@ -207,44 +214,47 @@ export default () => {
...calendarData,
dates: __dates,
selectedDates: dateUtil.sortDatesByTime(
dateUtil.uniqueArrayByDate(__selectedDates)
)
dateUtil.uniqueArrayByDate(__selectedDates),
),
},
calendarConfig
calendarConfig,
}
},
onTapDate(tapedDate, calendarData = {}, calendarConfig = {}) {
if (!calendarConfig.chooseAreaMode) {
return {
calendarData,
calendarConfig
calendarConfig,
}
}
let {
tempChooseAreaTimestamp = [],
chooseAreaTimestamp: existChooseAreaTimestamp = [],
selectedDates = [],
dates = []
dates = [],
} = calendarData
const timestamp = dateUtil.getTimeStamp(tapedDate)
let __dates = [...dates]
const __dates = [...dates]
let __selectedDates = [...selectedDates]
if (
tempChooseAreaTimestamp.length === 2 ||
existChooseAreaTimestamp.length === 2
tempChooseAreaTimestamp.length === 2
|| existChooseAreaTimestamp.length === 2
) {
tempChooseAreaTimestamp = [tapedDate]
__selectedDates = []
__dates.forEach(d => (d.choosed = false))
} else if (tempChooseAreaTimestamp.length === 1) {
}
else if (tempChooseAreaTimestamp.length === 1) {
const preChoosedDate = tempChooseAreaTimestamp[0]
const preTimestamp = dateUtil.getTimeStamp(preChoosedDate)
if (preTimestamp <= timestamp) {
tempChooseAreaTimestamp.push(tapedDate)
} else if (preTimestamp > timestamp) {
}
else if (preTimestamp > timestamp) {
tempChooseAreaTimestamp.unshift(tapedDate)
}
} else {
}
else {
tempChooseAreaTimestamp = [tapedDate]
}
let chooseAreaTimestamp = []
@ -260,46 +270,48 @@ export default () => { @@ -260,46 +270,48 @@ export default () => {
chooseAreaTimestamp,
tempChooseAreaTimestamp,
dates: __dates,
selectedDates: __selectedDates
selectedDates: __selectedDates,
},
calendarConfig: {
...calendarConfig,
multi: true
}
multi: true,
},
}
},
methods(component) {
return {
/**
* 设置连续日期选择区域
* @param {array} dateArea 区域开始结束日期数组
* @param {Array} dateArea 区域开始结束日期数组
*/
chooseDateArea: (dateArea = []) => {
if (dateArea.length === 1) {
dateArea = dateArea.concat(dateArea)
}
if (dateArea.length !== 2) return
if (dateArea.length !== 2)
return
const isRight = validateTimeRange(dateArea)
if (!isRight) return
if (!isRight)
return
const config = getCalendarConfig(component) || {}
const { startTimestamp, endTimestamp } = convertTimeRangeToTimestamp(
dateArea
dateArea,
)
const existCalendarData = getCalendarData('calendar', component)
return renderCalendar.call(
component,
{
...existCalendarData,
chooseAreaTimestamp: [startTimestamp, endTimestamp]
chooseAreaTimestamp: [startTimestamp, endTimestamp],
},
{
...config,
multi: true,
chooseAreaMode: true
}
chooseAreaMode: true,
},
)
}
},
}
}
},
}
}

2
src/components/calendar/plugins/todo.d.ts vendored

@ -1 +1 @@ @@ -1 +1 @@
export {};
export {}

56
src/components/calendar/plugins/todo.js

@ -4,22 +4,24 @@ @@ -4,22 +4,24 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-11 14:23:02
* */
*/
import { getCalendarData, dateUtil } from '../utils/index'
import { renderCalendar } from '../render'
import { dateUtil, getCalendarData } from '../utils/index'
function updateDatePropertyOfTodoLabel(todos, dates, showLabelAlways) {
const datesInfo = [...dates]
for (let todo of todos) {
let targetIdx = datesInfo.findIndex(
item => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(todo)
for (const todo of todos) {
const targetIdx = datesInfo.findIndex(
item => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(todo),
)
let target = datesInfo[targetIdx]
if (!target) continue
const target = datesInfo[targetIdx]
if (!target)
continue
if (showLabelAlways) {
target.showTodoLabel = true
} else {
}
else {
target.showTodoLabel = !target.choosed
}
if (target.showTodoLabel) {
@ -38,14 +40,14 @@ export default () => { @@ -38,14 +40,14 @@ export default () => {
const dateWithTodoInfo = updateDatePropertyOfTodoLabel(
todos,
dates,
showLabelAlways
showLabelAlways,
)
return {
calendarData: {
...calendarData,
dates: dateWithTodoInfo
dates: dateWithTodoInfo,
},
calendarConfig
calendarConfig,
}
},
methods(component) {
@ -60,17 +62,17 @@ export default () => { @@ -60,17 +62,17 @@ export default () => {
dotColor = '',
pos = 'bottom',
showLabelAlways,
dates: todoDates = []
dates: todoDates = [],
} = options
const { todos = [] } = calendar
const tranformStr2NumOfTodo = todoDates.map(date =>
dateUtil.tranformStr2NumOfDate(date)
dateUtil.tranformStr2NumOfDate(date),
)
const calendarData = {
dates: calendar.dates,
todos: dateUtil.uniqueArrayByDate(
todos.concat(tranformStr2NumOfTodo)
)
todos.concat(tranformStr2NumOfTodo),
),
}
if (!circle) {
calendarData.todoLabelPos = pos
@ -81,55 +83,55 @@ export default () => { @@ -81,55 +83,55 @@ export default () => {
const existCalendarData = getCalendarData('calendar', component)
return renderCalendar.call(component, {
...existCalendarData,
...calendarData
...calendarData,
})
},
deleteTodos(todos = []) {
if (!(todos instanceof Array) || !todos.length)
if (!(Array.isArray(todos)) || !todos.length)
return Promise.reject('deleteTodos()应为入参为非空数组')
const existCalendarData = getCalendarData('calendar', component)
const allTodos = existCalendarData.todos || []
const toDeleteTodos = todos.map(item => dateUtil.toTimeStr(item))
const remainTodos = allTodos.filter(
item => !toDeleteTodos.includes(dateUtil.toTimeStr(item))
item => !toDeleteTodos.includes(dateUtil.toTimeStr(item)),
)
const { dates, curYear, curMonth } = existCalendarData
const _dates = [...dates]
const currentMonthTodos = dateUtil.filterDatesByYM(
{
year: curYear,
month: curMonth
month: curMonth,
},
remainTodos
remainTodos,
)
_dates.forEach(item => {
_dates.forEach((item) => {
item.showTodoLabel = false
})
currentMonthTodos.forEach(item => {
currentMonthTodos.forEach((item) => {
_dates[item.date - 1].showTodoLabel = !_dates[item.date - 1].choosed
})
return renderCalendar.call(component, {
...existCalendarData,
dates: _dates,
todos: remainTodos
todos: remainTodos,
})
},
clearTodos() {
const existCalendarData = getCalendarData('calendar', component)
const _dates = [...existCalendarData.dates]
_dates.forEach(item => {
_dates.forEach((item) => {
item.showTodoLabel = false
})
return renderCalendar.call(component, {
...existCalendarData,
dates: _dates,
todos: []
todos: [],
})
},
getTodos() {
return getCalendarData('calendar.todos', component) || []
}
},
}
}
},
}
}

156
src/components/calendar/plugins/week.js

@ -4,16 +4,16 @@ @@ -4,16 +4,16 @@
* @Date: 2020-10-08 21:22:09*
* @Last Modified by: drfu
* @Last Modified time: 2020-10-12 14:39:45
* */
*/
import { calcJumpData } from '../core'
import { renderCalendar } from '../render'
import {
dateUtil,
getCalendarConfig,
getCalendarData,
logger,
dateUtil
} from '../utils/index'
import { calcJumpData } from '../core'
/**
* 当月第一周所有日期
@ -21,7 +21,7 @@ import { calcJumpData } from '../core' @@ -21,7 +21,7 @@ import { calcJumpData } from '../core'
function firstWeekInMonth(
target = {},
calendarDates = [],
calendarConfig = {}
calendarConfig = {},
) {
const { firstDayOfWeek } = calendarConfig
const firstDayOfWeekIsMon = firstDayOfWeek === 'Mon'
@ -54,10 +54,11 @@ function lastWeekInMonth(target = {}, calendarDates = [], calendarConfig = {}) { @@ -54,10 +54,11 @@ function lastWeekInMonth(target = {}, calendarDates = [], calendarConfig = {}) {
* 判断目标日期是否在某些指定日历内
*/
function dateIsInDatesRange(target, dates) {
if (!target || !dates || !dates.length) return false
if (!target || !dates || !dates.length)
return false
const targetDateStr = dateUtil.toTimeStr(target)
let rst = false
for (let date of dates) {
for (const date of dates) {
const dateStr = dateUtil.toTimeStr(date)
if (dateStr === targetDateStr) {
rst = true
@ -73,17 +74,17 @@ function getDatesWhenTargetInFirstWeek(target, firstWeekDates) { @@ -73,17 +74,17 @@ function getDatesWhenTargetInFirstWeek(target, firstWeekDates) {
const prevMonthInfo = dateUtil.getPrevMonthInfo({ year, month })
let lastMonthDatesCount = dateUtil.getDatesCountOfMonth(
prevMonthInfo.year,
prevMonthInfo.month
prevMonthInfo.month,
)
let dates = firstWeekDates
let firstWeekCount = firstWeekDates.length
const dates = firstWeekDates
const firstWeekCount = firstWeekDates.length
for (let i = 0; i < 7 - firstWeekCount; i++) {
const week = dateUtil.getDayOfWeek(+year, +month, lastMonthDatesCount)
dates.unshift({
year: prevMonthInfo.year,
month: prevMonthInfo.month,
date: lastMonthDatesCount,
week
week,
})
lastMonthDatesCount -= 1
}
@ -93,15 +94,15 @@ function getDatesWhenTargetInFirstWeek(target, firstWeekDates) { @@ -93,15 +94,15 @@ function getDatesWhenTargetInFirstWeek(target, firstWeekDates) {
function getDatesWhenTargetInLastWeek(target, lastWeekDates) {
const { year, month } = target
const prevMonthInfo = dateUtil.getNextMonthInfo({ year, month })
let dates = lastWeekDates
let lastWeekCount = lastWeekDates.length
const dates = lastWeekDates
const lastWeekCount = lastWeekDates.length
for (let i = 0; i < 7 - lastWeekCount; i++) {
const week = dateUtil.getDayOfWeek(+year, +month, i + 1)
dates.push({
year: prevMonthInfo.year,
month: prevMonthInfo.month,
date: i + 1,
week
week,
})
}
return dates
@ -115,23 +116,27 @@ function getDates(target, calendarDates = [], calendarConfig = {}) { @@ -115,23 +116,27 @@ function getDates(target, calendarDates = [], calendarConfig = {}) {
if (firstDayOfWeekIsMon) {
const startIdx = date - (targetDay || 7)
return calendarDates.splice(startIdx, 7)
} else {
}
else {
const startIdx = date - targetDay - 1
return calendarDates.splice(startIdx, 7)
}
}
function getTargetWeekDates(target, calendarConfig) {
if (!target) return
if (!target)
return
const { year, month } = target
const calendarDates = dateUtil.calcDates(year, month)
const firstWeekDates = firstWeekInMonth(target, calendarDates, calendarConfig)
const lastWeekDates = lastWeekInMonth(target, calendarDates, calendarConfig)
if (dateIsInDatesRange(target, firstWeekDates)) {
return getDatesWhenTargetInFirstWeek(target, firstWeekDates)
} else if (dateIsInDatesRange(target, lastWeekDates)) {
}
else if (dateIsInDatesRange(target, lastWeekDates)) {
return getDatesWhenTargetInLastWeek(target, lastWeekDates)
} else {
}
else {
return getDates(target, calendarDates, calendarConfig)
}
}
@ -157,42 +162,44 @@ function calculateFirstDateOfCurrentWeek(calendarData = {}) { @@ -157,42 +162,44 @@ function calculateFirstDateOfCurrentWeek(calendarData = {}) {
function calculateNextWeekDates(calendarData = {}) {
let { curYear, curMonth } = calendarData
let calendarDates = []
let lastDateInThisWeek = calculateLastDateOfCurrentWeek(calendarData)
const lastDateInThisWeek = calculateLastDateOfCurrentWeek(calendarData)
const { year: LYear, month: LMonth } = lastDateInThisWeek
if (curYear !== LYear || curMonth !== LMonth) {
calendarDates = dateUtil.calcDates(LYear, LMonth)
curYear = LYear
curMonth = LMonth
} else {
}
else {
calendarDates = dateUtil.calcDates(curYear, curMonth)
}
const lastDateInThisMonth = dateUtil.getDatesCountOfMonth(curYear, curMonth)
const count = lastDateInThisMonth - lastDateInThisWeek.date
const lastDateIdx = calendarDates.findIndex(
date => dateUtil.toTimeStr(date) === dateUtil.toTimeStr(lastDateInThisWeek)
date => dateUtil.toTimeStr(date) === dateUtil.toTimeStr(lastDateInThisWeek),
)
const startIdx = lastDateIdx + 1
if (count >= 7) {
return {
dates: calendarDates.splice(startIdx, 7),
year: curYear,
month: curMonth
month: curMonth,
}
} else {
}
else {
const nextMonth = dateUtil.getNextMonthInfo({
year: curYear,
month: curMonth
month: curMonth,
})
const { year, month } = nextMonth || {}
const calendarDatesOfNextMonth = dateUtil.calcDates(year, month)
const remainDatesOfThisMonth = calendarDates.splice(startIdx)
const patchDatesOfNextMonth = calendarDatesOfNextMonth.splice(
0,
7 - remainDatesOfThisMonth.length
7 - remainDatesOfThisMonth.length,
)
return {
dates: [...remainDatesOfThisMonth, ...patchDatesOfNextMonth],
...nextMonth
...nextMonth,
}
}
}
@ -202,43 +209,45 @@ function calculateNextWeekDates(calendarData = {}) { @@ -202,43 +209,45 @@ function calculateNextWeekDates(calendarData = {}) {
*/
function calculatePrevWeekDates(calendarData = {}) {
let { curYear, curMonth } = calendarData
let firstDateInThisWeek = calculateFirstDateOfCurrentWeek(calendarData)
const firstDateInThisWeek = calculateFirstDateOfCurrentWeek(calendarData)
let calendarDates = []
const { year: FYear, month: FMonth } = firstDateInThisWeek
if (curYear !== FYear || curMonth !== FMonth) {
calendarDates = dateUtil.calcDates(FYear, FMonth)
curYear = FYear
curMonth = FMonth
} else {
}
else {
calendarDates = dateUtil.calcDates(curYear, curMonth)
}
const firstDateIdx = calendarDates.findIndex(
date => dateUtil.toTimeStr(date) === dateUtil.toTimeStr(firstDateInThisWeek)
date => dateUtil.toTimeStr(date) === dateUtil.toTimeStr(firstDateInThisWeek),
)
if (firstDateIdx - 7 >= 0) {
const startIdx = firstDateIdx - 7
return {
dates: calendarDates.splice(startIdx, 7),
year: curYear,
month: curMonth
month: curMonth,
}
} else {
}
else {
const prevMonth = dateUtil.getPrevMonthInfo({
year: curYear,
month: curMonth
month: curMonth,
})
const { year, month } = prevMonth || {}
const calendarDatesOfPrevMonth = dateUtil.calcDates(year, month)
const remainDatesOfThisMonth = calendarDates.splice(
0,
firstDateInThisWeek.date - 1
firstDateInThisWeek.date - 1,
)
const patchDatesOfPrevMonth = calendarDatesOfPrevMonth.splice(
-(7 - remainDatesOfThisMonth.length)
-(7 - remainDatesOfThisMonth.length),
)
return {
dates: [...patchDatesOfPrevMonth, ...remainDatesOfThisMonth],
...prevMonth
...prevMonth,
}
}
}
@ -250,30 +259,30 @@ export default () => { @@ -250,30 +259,30 @@ export default () => {
const { initializedWeekMode, selectedDates } = calendarData
if (calendarConfig.weekMode && !initializedWeekMode) {
const { defaultDate } = calendarConfig
const target =
(selectedDates && selectedDates[0]) ||
(defaultDate && dateUtil.transformDateRow2Dict(defaultDate)) ||
dateUtil.todayFMD()
const target
= (selectedDates && selectedDates[0])
|| (defaultDate && dateUtil.transformDateRow2Dict(defaultDate))
|| dateUtil.todayFMD()
const waitRenderData = this.methods(
component
component,
).__calcDatesWhenSwitchView('week', target)
const { data, config } = waitRenderData || {}
const setSelectDates = this.methods(
component
component,
).__selectTargetDateWhenJump(target, data.dates, config)
return {
calendarData: {
...data,
...setSelectDates,
weeksCh: dateUtil.getWeekHeader(calendarConfig.firstDayOfWeek),
initializedWeekMode: true
initializedWeekMode: true,
},
calendarConfig
calendarConfig,
}
}
return {
calendarData,
calendarConfig
calendarConfig,
}
},
onSwitchCalendar(target = {}, calendarData = {}, component) {
@ -284,7 +293,8 @@ export default () => { @@ -284,7 +293,8 @@ export default () => {
if (calendarConfig.weekMode) {
if (direction === 'left') {
waitRenderData = calculateNextWeekDates(calendarData)
} else {
}
else {
waitRenderData = calculatePrevWeekDates(calendarData)
}
const { dates, year, month } = waitRenderData
@ -292,7 +302,7 @@ export default () => { @@ -292,7 +302,7 @@ export default () => {
...calendarData,
dates,
curYear: year || curYear,
curMonth: month || curMonth
curMonth: month || curMonth,
}
}
return calendarData
@ -304,8 +314,8 @@ export default () => { @@ -304,8 +314,8 @@ export default () => {
const weekDates = dates.map((date, idx) => {
const tmp = { ...date }
tmp.id = idx
const isTarget =
dateUtil.toTimeStr(target) === dateUtil.toTimeStr(tmp)
const isTarget
= dateUtil.toTimeStr(target) === dateUtil.toTimeStr(tmp)
if (isTarget && !target.choosed && config.autoChoosedWhenJump) {
tmp.choosed = true
selectedDate = tmp
@ -314,7 +324,7 @@ export default () => { @@ -314,7 +324,7 @@ export default () => {
})
return {
dates: weekDates,
selectedDates: [selectedDate]
selectedDates: [selectedDate],
}
},
__calcDatesForWeekMode(target, config = {}, calendarData = {}) {
@ -328,31 +338,31 @@ export default () => { @@ -328,31 +338,31 @@ export default () => {
nextMonthGrids: null,
dates: weekDates,
curYear: year,
curMonth: month
curMonth: month,
},
config: {
...config,
weekMode: true
}
weekMode: true,
},
}
},
__calcDatesForMonthMode(target, config = {}, calendarData = {}) {
const { year, month } = target || {}
const waitRenderData = calcJumpData({
dateInfo: target,
config
config,
})
return {
data: {
...calendarData,
...waitRenderData,
curYear: year,
curMonth: month
curMonth: month,
},
config: {
...config,
weekMode: false
}
weekMode: false,
},
}
},
/**
@ -369,18 +379,20 @@ export default () => { @@ -369,18 +379,20 @@ export default () => {
selectedDates = [],
dates = [],
curYear,
curMonth
curMonth,
} = existCalendarData
const currentMonthSelected = selectedDates.filter(
item => curYear === +item.year || curMonth === +item.month
item => curYear === +item.year || curMonth === +item.month,
)
let jumpTarget = {}
if (target) {
jumpTarget = target
} else {
}
else {
if (currentMonthSelected.length) {
jumpTarget = currentMonthSelected.pop()
} else {
}
else {
jumpTarget = dates[0]
}
}
@ -388,45 +400,47 @@ export default () => { @@ -388,45 +400,47 @@ export default () => {
return this.methods(component).__calcDatesForWeekMode(
jumpTarget,
calendarConfig,
existCalendarData
existCalendarData,
)
} else {
}
else {
return this.methods(component).__calcDatesForMonthMode(
jumpTarget,
calendarConfig,
existCalendarData
existCalendarData,
)
}
},
weekModeJump: dateInfo => {
weekModeJump: (dateInfo) => {
const target = dateInfo || dateUtil.todayFMD()
const existCalendarData = getCalendarData('calendar', component) || {}
const waitRenderData = this.methods(
component
component,
).__calcDatesWhenSwitchView('week', target)
const { data, config } = waitRenderData || {}
const setSelectDates = this.methods(
component
component,
).__selectTargetDateWhenJump(target, data.dates, config)
return renderCalendar.call(
component,
{
...existCalendarData,
...data,
...setSelectDates
...setSelectDates,
},
config
config,
)
},
switchView: (view, target) => {
const waitRenderData = this.methods(
component
component,
).__calcDatesWhenSwitchView(view, target)
const { data, config } = waitRenderData || {}
if (!data) return logger.warn('当前状态不能切换为周视图')
if (!data)
return logger.warn('当前状态不能切换为周视图')
return renderCalendar.call(component, data, config)
}
},
}
}
},
}
}

47
src/components/calendar/render.js

@ -1,29 +1,30 @@ @@ -1,29 +1,30 @@
import plugins from "./plugins/index";
import { getCalendarConfig } from "./utils/index";
import plugins from './plugins/index'
import { getCalendarConfig } from './utils/index'
/**
* 渲染日历
*/
export function renderCalendar(calendarData, calendarConfig) {
return new Promise((resolve) => {
const Component = this;
const Component = this
if (Component.firstRender === void 0) {
Component.firstRender = true;
} else {
Component.firstRender = false;
Component.firstRender = true
}
else {
Component.firstRender = false
}
const exitData = Component.data.calendar || {};
for (let plugin of plugins.installed) {
const [, p] = plugin;
if (typeof p.beforeRender === "function") {
const { calendarData: newData, calendarConfig: newConfig } =
p.beforeRender(
const exitData = Component.data.calendar || {}
for (const plugin of plugins.installed) {
const [, p] = plugin
if (typeof p.beforeRender === 'function') {
const { calendarData: newData, calendarConfig: newConfig }
= p.beforeRender(
{ ...exitData, ...calendarData },
calendarConfig || getCalendarConfig(Component),
Component
);
calendarData = newData;
calendarConfig = newConfig;
Component,
)
calendarData = newData
calendarConfig = newConfig
}
}
@ -37,13 +38,13 @@ export function renderCalendar(calendarData, calendarConfig) { @@ -37,13 +38,13 @@ export function renderCalendar(calendarData, calendarConfig) {
calendar: calendarData,
config: calendarConfig,
firstRender: Component.firstRender,
};
resolve(rst);
}
resolve(rst)
if (Component.firstRender) {
Component.triggerEvent("afterCalendarRender", rst);
Component.firstRender = false;
Component.triggerEvent('afterCalendarRender', rst)
Component.firstRender = false
}
}
);
});
},
)
})
}

290
src/components/calendar/utils/index.js

@ -1,16 +1,17 @@ @@ -1,16 +1,17 @@
import Logger from "./logger";
import WxData from "./wxData";
import Logger from './logger'
import WxData from './wxData'
let systemInfo;
let systemInfo
export function getSystemInfo() {
if (systemInfo) return systemInfo;
systemInfo = wx.getSystemInfoSync();
return systemInfo;
if (systemInfo)
return systemInfo
systemInfo = wx.getSystemInfoSync()
return systemInfo
}
export function isIos() {
const sys = getSystemInfo();
return /iphone|ios/i.test(sys.platform);
const sys = getSystemInfo()
return /iphone|ios/i.test(sys.platform)
}
class Gesture {
@ -20,69 +21,77 @@ class Gesture { @@ -20,69 +21,77 @@ class Gesture {
* @returns {boolean} 布尔值
*/
isLeft(gesture = {}, touche = {}) {
const { startX, startY } = gesture;
const deltaX = touche.clientX - startX;
const deltaY = touche.clientY - startY;
const { startX, startY } = gesture
const deltaX = touche.clientX - startX
const deltaY = touche.clientY - startY
if (deltaX < -60 && deltaY < 20 && deltaY > -20) {
return true;
} else {
return false;
return true
}
else {
return false
}
}
}
/**
* 右滑
* @param {object} e 事件对象
* @returns {boolean} 布尔值
*/
isRight(gesture = {}, touche = {}) {
const { startX, startY } = gesture;
const deltaX = touche.clientX - startX;
const deltaY = touche.clientY - startY;
const { startX, startY } = gesture
const deltaX = touche.clientX - startX
const deltaY = touche.clientY - startY
if (deltaX > 60 && deltaY < 20 && deltaY > -20) {
return true;
} else {
return false;
return true
}
else {
return false
}
}
}
class DateUtil {
newDate(year, month, date) {
let cur = `${+year}-${+month}-${+date}`;
let cur = `${+year}-${+month}-${+date}`
if (isIos()) {
cur = `${+year}/${+month}/${+date}`;
cur = `${+year}/${+month}/${+date}`
}
return new Date(cur);
}
return new Date(cur)
}
/**
* 计算指定日期时间戳
* @param {object} date
*/
getTimeStamp(dateInfo) {
if (typeof dateInfo === "string") {
dateInfo = this.transformDateRow2Dict(dateInfo);
if (typeof dateInfo === 'string') {
dateInfo = this.transformDateRow2Dict(dateInfo)
}
if (Object.prototype.toString.call(dateInfo) !== "[object Object]") return;
const dateUtil = new DateUtil();
return dateUtil.newDate(dateInfo.year, dateInfo.month, dateInfo.date).getTime();
}
if (Object.prototype.toString.call(dateInfo) !== '[object Object]')
return
const dateUtil = new DateUtil()
return dateUtil.newDate(dateInfo.year, dateInfo.month, dateInfo.date).getTime()
}
/**
* 计算指定月份共多少天
* @param {number} year 年份
* @param {number} month 月份
*/
getDatesCountOfMonth(year, month) {
return new Date(Date.UTC(year, month, 0)).getUTCDate();
}
return new Date(Date.UTC(year, month, 0)).getUTCDate()
}
/**
* 计算指定月份第一天星期几
* @param {number} year 年份
* @param {number} month 月份
*/
firstDayOfWeek(year, month) {
return new Date(Date.UTC(year, month - 1, 1)).getUTCDay();
}
return new Date(Date.UTC(year, month - 1, 1)).getUTCDay()
}
/**
* 计算指定日期星期几
* @param {number} year 年份
@ -90,60 +99,68 @@ class DateUtil { @@ -90,60 +99,68 @@ class DateUtil {
* @param {number} date 日期
*/
getDayOfWeek(year, month, date) {
return new Date(Date.UTC(year, month - 1, date)).getUTCDay();
}
return new Date(Date.UTC(year, month - 1, date)).getUTCDay()
}
todayFMD() {
const _date = new Date();
const year = _date.getFullYear();
const month = _date.getMonth() + 1;
const date = _date.getDate();
const _date = new Date()
const year = _date.getFullYear()
const month = _date.getMonth() + 1
const date = _date.getDate()
return {
year: +year,
month: +month,
date: +date,
};
}
}
}
todayTimestamp() {
const { year, month, date } = this.todayFMD();
const timestamp = this.newDate(year, month, date).getTime();
return timestamp;
}
const { year, month, date } = this.todayFMD()
const timestamp = this.newDate(year, month, date).getTime()
return timestamp
}
toTimeStr(dateInfo = {}) {
return `${+dateInfo.year}-${+dateInfo.month}-${+dateInfo.date}`;
}
return `${+dateInfo.year}-${+dateInfo.month}-${+dateInfo.date}`
}
transformDateRow2Dict(dateStr) {
if (typeof dateStr === "string" && dateStr.includes("-")) {
const [year, month, date] = dateStr.split("-");
if (typeof dateStr === 'string' && dateStr.includes('-')) {
const [year, month, date] = dateStr.split('-')
return this.tranformStr2NumOfDate({
year,
month,
date,
});
})
}
return {};
}
return {}
}
tranformStr2NumOfDate(date = {}) {
const target = { ...date };
const target = { ...date }
// 可能传入字符串
target.year = +target.year;
target.month = +target.month;
target.date = +target.date;
return target;
}
target.year = +target.year
target.month = +target.month
target.date = +target.date
return target
}
sortDatesByTime(dates = [], sortType) {
return dates.sort((a, b) => {
const at = this.getTimeStamp(a);
const bt = this.getTimeStamp(b);
if (at < bt && sortType !== "desc") {
return -1;
} else {
return 1;
const at = this.getTimeStamp(a)
const bt = this.getTimeStamp(b)
if (at < bt && sortType !== 'desc') {
return -1
}
else {
return 1
}
});
}
})
}
getPrevMonthInfo(date = {}) {
const prevMonthInfo =
Number(date.month) > 1
const prevMonthInfo
= Number(date.month) > 1
? {
year: +date.year,
month: Number(date.month) - 1,
@ -151,12 +168,13 @@ class DateUtil { @@ -151,12 +168,13 @@ class DateUtil {
: {
year: Number(date.year) - 1,
month: 12,
};
return prevMonthInfo;
}
}
return prevMonthInfo
}
getNextMonthInfo(date = {}) {
const nextMonthInfo =
Number(date.month) < 12
const nextMonthInfo
= Number(date.month) < 12
? {
year: +date.year,
month: Number(date.month) + 1,
@ -164,30 +182,34 @@ class DateUtil { @@ -164,30 +182,34 @@ class DateUtil {
: {
year: Number(date.year) + 1,
month: 1,
};
return nextMonthInfo;
}
}
return nextMonthInfo
}
getPrevYearInfo(date = {}) {
return {
year: Number(date.year) - 1,
month: +date.month,
};
}
}
}
getNextYearInfo(date = {}) {
return {
year: Number(date.year) + 1,
month: +date.month,
};
}
}
}
findDateIndexInArray(target, dates) {
return dates.findIndex((item) => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(target));
}
return dates.findIndex(item => dateUtil.toTimeStr(item) === dateUtil.toTimeStr(target))
}
calcDates(year, month) {
const datesCount = this.getDatesCountOfMonth(year, month);
const dates = [];
const today = dateUtil.todayFMD();
const datesCount = this.getDatesCountOfMonth(year, month)
const dates = []
const today = dateUtil.todayFMD()
for (let i = 1; i <= datesCount; i++) {
const week = dateUtil.getDayOfWeek(+year, +month, i);
const week = dateUtil.getDayOfWeek(+year, +month, i)
const date = {
year: +year,
id: i - 1,
@ -195,45 +217,48 @@ class DateUtil { @@ -195,45 +217,48 @@ class DateUtil {
date: i,
week,
isToday: +today.year === +year && +today.month === +month && i === +today.date,
};
dates.push(date);
}
dates.push(date)
}
return dates;
}
return dates
}
/**
* 日期数组根据日期去重
* @param {array} array 数组
* @param {Array} array 数组
*/
uniqueArrayByDate(array = []) {
let uniqueObject = {};
let uniqueArray = [];
const uniqueObject = {}
const uniqueArray = []
array.forEach((item) => {
uniqueObject[dateUtil.toTimeStr(item)] = item;
});
for (let i in uniqueObject) {
uniqueArray.push(uniqueObject[i]);
uniqueObject[dateUtil.toTimeStr(item)] = item
})
for (const i in uniqueObject) {
uniqueArray.push(uniqueObject[i])
}
return uniqueArray;
}
return uniqueArray
}
/**
* 筛选指定年月日期
* @param {object} target 指定年月
* @param {array} dates 待筛选日期
* @param {Array} dates 待筛选日期
*/
filterDatesByYM(target, dates) {
if (target) {
const { year, month } = target;
const _dates = dates.filter((item) => +item.year === +year && +item.month === +month);
return _dates;
const { year, month } = target
const _dates = dates.filter(item => +item.year === +year && +item.month === +month)
return _dates
}
return dates;
}
return dates
}
getWeekHeader(firstDayOfWeek) {
let weeksCh = ["日", "一", "二", "三", "四", "五", "六"];
if (firstDayOfWeek === "Mon") {
weeksCh = ["一", "二", "三", "四", "五", "六", "日"];
let weeksCh = ['日', '一', '二', '三', '四', '五', '六']
if (firstDayOfWeek === 'Mon') {
weeksCh = ['一', '二', '三', '四', '五', '六', '日']
}
return weeksCh;
return weeksCh
}
}
@ -241,35 +266,38 @@ class DateUtil { @@ -241,35 +266,38 @@ class DateUtil {
* 获取当前页面实例
*/
export function getCurrentPage() {
const pages = getCurrentPages() || [];
const last = pages.length - 1;
return pages[last] || {};
const pages = getCurrentPages() || []
const last = pages.length - 1
return pages[last] || {}
}
export function getComponentById(componentId) {
const logger = new Logger();
let page = getCurrentPage() || {};
if (page.selectComponent && typeof page.selectComponent === "function") {
const logger = new Logger()
const page = getCurrentPage() || {}
if (page.selectComponent && typeof page.selectComponent === 'function') {
if (componentId) {
return page.selectComponent(componentId);
} else {
logger.warn("请传入组件ID");
return page.selectComponent(componentId)
}
else {
logger.warn('请传入组件ID')
}
} else {
logger.warn("该基础库暂不支持多个小程序日历组件");
}
else {
logger.warn('该基础库暂不支持多个小程序日历组件')
}
}
export const logger = new Logger();
export const calendarGesture = new Gesture();
export const dateUtil = new DateUtil();
export const getCalendarData = (key, component) => new WxData(component).getData(key);
export const setCalendarData = (data, component) => new WxData(component).setData(data);
export const getCalendarConfig = (component) => getCalendarData("config", component);
export const setCalendarConfig = (config, component) =>
setCalendarData(
export const logger = new Logger()
export const calendarGesture = new Gesture()
export const dateUtil = new DateUtil()
export const getCalendarData = (key, component) => new WxData(component).getData(key)
export const setCalendarData = (data, component) => new WxData(component).setData(data)
export const getCalendarConfig = component => getCalendarData('config', component)
export function setCalendarConfig(config, component) {
return setCalendarData(
{
config,
},
component,
);
)
}

18
src/components/calendar/utils/logger.js

@ -1,23 +1,25 @@ @@ -1,23 +1,25 @@
export default class Logger {
info(msg) {
console.log(
'%cInfo: %c' + msg,
`%cInfo: %c${msg}`,
'color:#FF0080;font-weight:bold',
'color: #FF509B'
'color: #FF509B',
)
}
}
warn(msg) {
console.log(
'%cWarn: %c' + msg,
`%cWarn: %c${msg}`,
'color:#FF6600;font-weight:bold',
'color: #FF9933'
'color: #FF9933',
)
}
}
tips(msg) {
console.log(
'%cTips: %c' + msg,
`%cTips: %c${msg}`,
'color:#00B200;font-weight:bold',
'color: #00CC33'
'color: #00CC33',
)
}
}

17
src/components/calendar/utils/wxData.js

@ -1,23 +1,28 @@ @@ -1,23 +1,28 @@
class WxData {
constructor(component) {
this.Component = component
}
}
getData(key) {
const data = this.Component.data
if (!key) return data
if (!key)
return data
if (key.includes('.')) {
let keys = key.split('.')
const keys = key.split('.')
const tmp = keys.reduce((prev, next) => {
return prev[next]
}, data)
return tmp
} else {
}
else {
return this.Component.data[key]
}
}
}
setData(data) {
return new Promise((resolve, reject) => {
if (!data) return reject('no data to set')
if (!data)
return reject('no data to set')
if (typeof data === 'object') {
this.Component.setData(data, () => {
resolve(data)

148
src/components/customPoster/README.md

@ -28,28 +28,28 @@ const data = { @@ -28,28 +28,28 @@ const data = {
},
elements: [
{
id: 'circle-name',
desc: '圈名称',
type: 1,
text: '治疗讨论',
font: '宋体',
'id': 'circle-name',
'desc': '圈名称',
'type': 1,
'text': '治疗讨论',
'font': '宋体',
'font-size': '42',
color: '#FFFFFF',
'color': '#FFFFFF',
'single-line': true,
halign: 'center',
top: '106',
'halign': 'center',
'top': '106',
},
{
id: 'master-name',
desc: '专家名称',
type: 1,
text: '健康小贴士',
font: '宋体',
'id': 'master-name',
'desc': '专家名称',
'type': 1,
'text': '健康小贴士',
'font': '宋体',
'font-size': '38',
color: '#FFFFFF',
'color': '#FFFFFF',
'single-line': true,
halign: 'center',
top: '237',
'halign': 'center',
'top': '237',
},
{
id: 'master-avatar',
@ -64,72 +64,72 @@ const data = { @@ -64,72 +64,72 @@ const data = {
top: '328',
},
{
id: 'note-content',
desc: '动态内容',
type: 1,
text: '11月5日上海组织进口博览会CIIE大会,邀请大家来我们的展馆现场交流。',
font: '宋体',
'id': 'note-content',
'desc': '动态内容',
'type': 1,
'text': '11月5日上海组织进口博览会CIIE大会,邀请大家来我们的展馆现场交流。',
'font': '宋体',
'font-size': '45',
color: '#18191A',
width: '630',
height: '348',
left: '60',
top: '495',
'color': '#18191A',
'width': '630',
'height': '348',
'left': '60',
'top': '495',
},
{
id: 'note-title',
desc: '长文标题',
type: 1,
text: '',
font: '宋体',
'id': 'note-title',
'desc': '长文标题',
'type': 1,
'text': '',
'font': '宋体',
'font-size': '42',
color: '#18191A',
width: '659',
height: '116',
left: '46',
top: '495',
'color': '#18191A',
'width': '659',
'height': '116',
'left': '46',
'top': '495',
'font-weight': 'bold',
},
{
id: 'note-summary',
desc: '长文摘要 ',
type: 1,
text: '',
font: '宋体',
'id': 'note-summary',
'desc': '长文摘要 ',
'type': 1,
'text': '',
'font': '宋体',
'font-size': '42',
color: '#18191A',
width: '672',
height: '232',
left: '39',
top: '646',
'color': '#18191A',
'width': '672',
'height': '232',
'left': '39',
'top': '646',
},
{
id: 'note-more',
desc: '还有',
type: 1,
text: '还有3条精彩附件>',
font: '宋体',
'id': 'note-more',
'desc': '还有',
'type': 1,
'text': '还有3条精彩附件>',
'font': '宋体',
'font-size': '31',
color: '#666666',
'color': '#666666',
'single-line': true,
width: '292',
height: '46',
left: '60',
top: '1024',
'width': '292',
'height': '46',
'left': '60',
'top': '1024',
},
{
id: 'scanText',
desc: '扫描二维码查看详情',
type: 1,
text: '扫描二维码查看详情',
font: '宋体',
'id': 'scanText',
'desc': '扫描二维码查看详情',
'type': 1,
'text': '扫描二维码查看详情',
'font': '宋体',
'font-size': '31',
color: '#666666',
'color': '#666666',
'single-line': true,
width: '279',
height: '43',
left: '60',
top: '1087',
'width': '279',
'height': '43',
'left': '60',
'top': '1087',
},
{
id: 'note-qrcode',
@ -143,16 +143,16 @@ const data = { @@ -143,16 +143,16 @@ const data = {
top: '1012',
},
{
id: 'brand',
desc: 'brand×华秉科技',
type: 1,
text: '做企业数字化转型的亲密伙伴×华秉科技',
font: '宋体',
'id': 'brand',
'desc': 'brand×华秉科技',
'type': 1,
'text': '做企业数字化转型的亲密伙伴×华秉科技',
'font': '宋体',
'font-size': '24',
color: '#B2B3B4',
'color': '#B2B3B4',
'single-line': true,
halign: 'center',
top: '1192',
'halign': 'center',
'top': '1192',
},
],
},

88
src/components/customPoster/index.js

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import Wxml2Canvas from "./wxml2canvas/index.js"; // 根据具体路径修改,node_modules会被忽略
import Wxml2Canvas from './wxml2canvas/index.js' // 根据具体路径修改,node_modules会被忽略
Component({
properties: {
@ -6,24 +6,24 @@ Component({ @@ -6,24 +6,24 @@ Component({
type: Object,
observer(newVal, _olVal) {
if (Object.keys(newVal).length > 0) {
this.paramsFormat(newVal);
this.paramsFormat(newVal)
this.setData({
width: newVal.body.width,
height: newVal.body.height,
bgImg: newVal.body.bgImg,
elementsMp: newVal.elements,
});
this.drawImage();
})
this.drawImage()
}
},
},
},
data: {
imgUrl: "",
width: "",
height: "",
imgheight: "",
bgImg: "",
imgUrl: '',
width: '',
height: '',
imgheight: '',
bgImg: '',
elementsMp: [],
},
lifetimes: {
@ -34,68 +34,70 @@ Component({ @@ -34,68 +34,70 @@ Component({
params.elements.forEach((item) => {
if (item.type === 0) {
// 图片居中
if (item.halign === "center") {
item.left = (params.body.width - item.width) / 2;
if (item.halign === 'center') {
item.left = (params.body.width - item.width) / 2
}
} else {
item.text = item.text.replace(/[\r\n]/g, "");
}
else {
item.text = item.text.replace(/[\r\n]/g, '')
// 文字居中(使文字标签宽度等于画布宽度,文字加上居中的className)
if (item.halign === "center") {
item.width = item.width || params.body.width;
item.left = (params.body.width - item.width) / 2;
if (item.halign === 'center') {
item.width = item.width || params.body.width
item.left = (params.body.width - item.width) / 2
}
if (item.halign === 'right') {
item.width = params.body.width
}
if (item.halign === "right") {
item.width = params.body.width;
if (item.id === 'shareText' && item.text.length > 30) {
item.text = `${item.text.slice(0, 30)}...`
}
if (item.id === "shareText" && item.text.length > 30) {
item.text = item.text.slice(0, 30) + "...";
if (item.id === 'note-title' && item.text.length > 28) {
item.text = `${item.text.slice(0, 28)}...`
}
if (item.id === "note-title" && item.text.length > 28) {
item.text = item.text.slice(0, 28) + "...";
if (item.id === 'note-content' && item.text.length > 90) {
item.text = `${item.text.slice(0, 90)}...`
}
if (item.id === "note-content" && item.text.length > 90) {
item.text = item.text.slice(0, 90) + "...";
const len = params.elements.some(x => x.id === 'note-title' && x.text.length)
if (len && item.id === 'note-summary' && item.text.length > 62) {
item.text = `${item.text.slice(0, 62)}...`
}
let len = params.elements.some((x) => x.id === "note-title" && x.text.length);
if (len && item.id === "note-summary" && item.text.length > 62) {
item.text = item.text.slice(0, 62) + "...";
} else if (item.id === "note-summary" && item.text.length > 76) {
item.text = item.text.slice(0, 76) + "...";
else if (item.id === 'note-summary' && item.text.length > 76) {
item.text = `${item.text.slice(0, 76)}...`
}
}
});
})
},
drawImage() {
let self = this;
const self = this
this.drawImage1 = new Wxml2Canvas({
obj: self,
width: this.data.width, // 宽, 以iphone6为基准,传具体数值,其它机型自动适配
height: this.data.height, // 高
element: "canvas1",
background: "transparent",
element: 'canvas1',
background: 'transparent',
progress(percent) {},
finish(url) {
self.setData({
imgUrl: url,
});
self.triggerEvent("finish", url);
})
self.triggerEvent('finish', url)
},
error(res) {},
});
})
let data = {
const data = {
list: [
{
type: "wxml",
class: "#canvas-bill-body-mp .draw_canvas",
limit: "#canvas-bill-body-mp",
type: 'wxml',
class: '#canvas-bill-body-mp .draw_canvas',
limit: '#canvas-bill-body-mp',
x: 0,
y: 0,
},
],
};
}
this.drawImage1.draw(data);
this.drawImage1.draw(data)
},
},
});
})

1968
src/components/customPoster/wxml2canvas/index.js

File diff suppressed because it is too large Load Diff

148
src/components/customTable/README.md

@ -28,28 +28,28 @@ const data = { @@ -28,28 +28,28 @@ const data = {
},
elements: [
{
id: 'circle-name',
desc: '圈名称',
type: 1,
text: '治疗讨论',
font: '宋体',
'id': 'circle-name',
'desc': '圈名称',
'type': 1,
'text': '治疗讨论',
'font': '宋体',
'font-size': '42',
color: '#FFFFFF',
'color': '#FFFFFF',
'single-line': true,
halign: 'center',
top: '106',
'halign': 'center',
'top': '106',
},
{
id: 'master-name',
desc: '专家名称',
type: 1,
text: '健康小贴士',
font: '宋体',
'id': 'master-name',
'desc': '专家名称',
'type': 1,
'text': '健康小贴士',
'font': '宋体',
'font-size': '38',
color: '#FFFFFF',
'color': '#FFFFFF',
'single-line': true,
halign: 'center',
top: '237',
'halign': 'center',
'top': '237',
},
{
id: 'master-avatar',
@ -64,72 +64,72 @@ const data = { @@ -64,72 +64,72 @@ const data = {
top: '328',
},
{
id: 'note-content',
desc: '动态内容',
type: 1,
text: '11月5日上海组织进口博览会CIIE大会,邀请大家来我们的展馆现场交流。',
font: '宋体',
'id': 'note-content',
'desc': '动态内容',
'type': 1,
'text': '11月5日上海组织进口博览会CIIE大会,邀请大家来我们的展馆现场交流。',
'font': '宋体',
'font-size': '45',
color: '#18191A',
width: '630',
height: '348',
left: '60',
top: '495',
'color': '#18191A',
'width': '630',
'height': '348',
'left': '60',
'top': '495',
},
{
id: 'note-title',
desc: '长文标题',
type: 1,
text: '',
font: '宋体',
'id': 'note-title',
'desc': '长文标题',
'type': 1,
'text': '',
'font': '宋体',
'font-size': '42',
color: '#18191A',
width: '659',
height: '116',
left: '46',
top: '495',
'color': '#18191A',
'width': '659',
'height': '116',
'left': '46',
'top': '495',
'font-weight': 'bold',
},
{
id: 'note-summary',
desc: '长文摘要 ',
type: 1,
text: '',
font: '宋体',
'id': 'note-summary',
'desc': '长文摘要 ',
'type': 1,
'text': '',
'font': '宋体',
'font-size': '42',
color: '#18191A',
width: '672',
height: '232',
left: '39',
top: '646',
'color': '#18191A',
'width': '672',
'height': '232',
'left': '39',
'top': '646',
},
{
id: 'note-more',
desc: '还有',
type: 1,
text: '还有3条精彩附件>',
font: '宋体',
'id': 'note-more',
'desc': '还有',
'type': 1,
'text': '还有3条精彩附件>',
'font': '宋体',
'font-size': '31',
color: '#666666',
'color': '#666666',
'single-line': true,
width: '292',
height: '46',
left: '60',
top: '1024',
'width': '292',
'height': '46',
'left': '60',
'top': '1024',
},
{
id: 'scanText',
desc: '扫描二维码查看详情',
type: 1,
text: '扫描二维码查看详情',
font: '宋体',
'id': 'scanText',
'desc': '扫描二维码查看详情',
'type': 1,
'text': '扫描二维码查看详情',
'font': '宋体',
'font-size': '31',
color: '#666666',
'color': '#666666',
'single-line': true,
width: '279',
height: '43',
left: '60',
top: '1087',
'width': '279',
'height': '43',
'left': '60',
'top': '1087',
},
{
id: 'note-qrcode',
@ -143,16 +143,16 @@ const data = { @@ -143,16 +143,16 @@ const data = {
top: '1012',
},
{
id: 'brand',
desc: 'brand×华秉科技',
type: 1,
text: '做企业数字化转型的亲密伙伴×华秉科技',
font: '宋体',
'id': 'brand',
'desc': 'brand×华秉科技',
'type': 1,
'text': '做企业数字化转型的亲密伙伴×华秉科技',
'font': '宋体',
'font-size': '24',
color: '#B2B3B4',
'color': '#B2B3B4',
'single-line': true,
halign: 'center',
top: '1192',
'halign': 'center',
'top': '1192',
},
],
},

203
src/components/customTable/index.js

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
const app = getApp();
import Wxml2Canvas from "./wxml2canvas/index.js"; // 根据具体路径修改,node_modules会被忽略
import Wxml2Canvas from './wxml2canvas/index.js'
const app = getApp() // 根据具体路径修改,node_modules会被忽略
Component({
properties: {
@ -7,193 +8,193 @@ Component({ @@ -7,193 +8,193 @@ Component({
type: Object,
observer(newVal, _olVal) {
if (Object.keys(newVal).length > 0) {
this.drawImage1();
this.drawImage1()
}
},
},
},
data: {
imageUrl: app.globalData.imageUrl,
imgUrl: "",
width: "626",
height: "980",
imgheight: "",
bgImg: "",
imgUrl: '',
width: '626',
height: '980',
imgheight: '',
bgImg: '',
elementsMp: [],
tableData: [
{
title: "说话",
key: "TalkingScore",
title: '说话',
key: 'TalkingScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "间或有点含糊或有鼻音",
id: '2',
title: '间或有点含糊或有鼻音',
},
{
id: "3",
title: "经常含糊不清或者有鼻音,但是别人还能听懂",
id: '3',
title: '经常含糊不清或者有鼻音,但是别人还能听懂',
},
{
id: "4",
title: "别人听不太懂",
id: '4',
title: '别人听不太懂',
},
],
},
{
title: "咀嚼",
key: "ChewScore",
title: '咀嚼',
key: 'ChewScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "咀嚼固体食物会感到疲劳",
id: '2',
title: '咀嚼固体食物会感到疲劳',
},
{
id: "3",
title: "咀嚼松软食物会感到疲劳",
id: '3',
title: '咀嚼松软食物会感到疲劳',
},
{
id: "4",
title: "使用喂食管进食,如鼻胃管胃肠管等",
id: '4',
title: '使用喂食管进食,如鼻胃管胃肠管等',
},
],
},
{
title: "吞咽",
key: "SwallowScore",
title: '吞咽',
key: 'SwallowScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "偶尔会噎到",
id: '2',
title: '偶尔会噎到',
},
{
id: "3",
title: "经常会噎到,因而需要改变饮食习惯",
id: '3',
title: '经常会噎到,因而需要改变饮食习惯',
},
{
id: "4",
title: "使用喂食管进食,如鼻胃管胃肠管等",
id: '4',
title: '使用喂食管进食,如鼻胃管胃肠管等',
},
],
},
{
title: "呼吸",
key: "BreathScore",
title: '呼吸',
key: 'BreathScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "劳累后感到气促或呼吸不畅",
id: '2',
title: '劳累后感到气促或呼吸不畅',
},
{
id: "3",
title: "静止时感到气促或呼吸不畅",
id: '3',
title: '静止时感到气促或呼吸不畅',
},
{
id: "4",
title: "依赖呼吸机",
id: '4',
title: '依赖呼吸机',
},
],
},
{
title: "刷牙梳头能力受损",
key: "BrushTeethAndCombHairScore",
title: '刷牙梳头能力受损',
key: 'BrushTeethAndCombHairScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "需要多费些力气但是不需要停下来",
id: '2',
title: '需要多费些力气但是不需要停下来',
},
{
id: "3",
title: "需要停下来休息才能完成",
id: '3',
title: '需要停下来休息才能完成',
},
{
id: "4",
title: "无法自己完成",
id: '4',
title: '无法自己完成',
},
],
},
{
title: "从椅子上起身能力受损",
key: "GetUpFromChairScore",
title: '从椅子上起身能力受损',
key: 'GetUpFromChairScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "轻度受损,有时需要用手帮忙",
id: '2',
title: '轻度受损,有时需要用手帮忙',
},
{
id: "3",
title: "中度受损,总是需要用手帮忙",
id: '3',
title: '中度受损,总是需要用手帮忙',
},
{
id: "4",
title: "严重受损,需要他人帮助",
id: '4',
title: '严重受损,需要他人帮助',
},
],
},
{
title: "复视/重影",
key: "DoubleVisionScore",
title: '复视/重影',
key: 'DoubleVisionScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "有,但不是每天",
id: '2',
title: '有,但不是每天',
},
{
id: "3",
title: "每天,但不是持续一整天",
id: '3',
title: '每天,但不是持续一整天',
},
{
id: "4",
title: "持续有",
id: '4',
title: '持续有',
},
],
},
{
title: "眼睑下垂",
key: "DroopyEyelidsScore",
title: '眼睑下垂',
key: 'DroopyEyelidsScore',
list: [
{
id: "1",
title: "正常",
id: '1',
title: '正常',
},
{
id: "2",
title: "有,但不是每天",
id: '2',
title: '有,但不是每天',
},
{
id: "3",
title: "每天,但不是持续一整天",
id: '3',
title: '每天,但不是持续一整天',
},
{
id: "4",
title: "持续有",
id: '4',
title: '持续有',
},
],
},
@ -204,37 +205,37 @@ Component({ @@ -204,37 +205,37 @@ Component({
},
methods: {
drawImage1() {
let self = this;
const self = this
// destZoom: 10,
this.drawImage1 = new Wxml2Canvas({
obj: self,
width: this.data.width, // 宽, 以iphone6为基准,传具体数值,其它机型自动适配
height: this.data.height, // 高
element: "canvas1",
background: "#ffffff",
element: 'canvas1',
background: '#ffffff',
progress(_percent) {},
finish(url) {
self.setData({
imgUrl: url,
});
self.triggerEvent("finish", url);
})
self.triggerEvent('finish', url)
},
error(_res) {},
});
})
let data = {
const data = {
list: [
{
type: "wxml",
class: "#canvas-bill-body-mp .draw_canvas",
limit: "#canvas-bill-body-mp",
type: 'wxml',
class: '#canvas-bill-body-mp .draw_canvas',
limit: '#canvas-bill-body-mp',
x: 0,
y: 0,
},
],
};
}
this.drawImage1.draw(data);
this.drawImage1.draw(data)
},
},
});
})

1966
src/components/customTable/wxml2canvas/index.js

File diff suppressed because it is too large Load Diff

216
src/components/ec-canvas/ec-canvas.js

@ -1,31 +1,32 @@ @@ -1,31 +1,32 @@
import WxCanvas from './wx-canvas';
import WxCanvas from './wx-canvas'
let ctx;
let echarts;
let ctx
let echarts
function compareVersion(v1, v2) {
v1 = v1.split('.');
v2 = v2.split('.');
const len = Math.max(v1.length, v2.length);
v1 = v1.split('.')
v2 = v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0');
v1.push('0')
}
while (v2.length < len) {
v2.push('0');
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i]);
const num2 = parseInt(v2[i]);
const num1 = Number.parseInt(v1[i])
const num2 = Number.parseInt(v2[i])
if (num1 > num2) {
return 1;
} else if (num1 < num2) {
return -1;
return 1
}
else if (num1 < num2) {
return -1
}
}
return 0;
return 0
}
Component({
@ -49,223 +50,230 @@ Component({ @@ -49,223 +50,230 @@ Component({
isUseNewCanvas: false,
},
ready: async function () {
echarts = await require.async('../../gift/compontnts/echart/echarts.js');
async ready() {
echarts = await require.async('../../gift/compontnts/echart/echarts.js')
// Disable prograssive because drawImage doesn't support DOM as parameter
// See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
echarts.registerPreprocessor((option) => {
if (option && option.series) {
if (option.series.length > 0) {
option.series.forEach((series) => {
series.progressive = 0;
});
} else if (typeof option.series === 'object') {
option.series.progressive = 0;
series.progressive = 0
})
}
else if (typeof option.series === 'object') {
option.series.progressive = 0
}
}
});
})
if (!this.data.ec) {
console.warn(
'组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" ' +
'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>',
);
return;
'组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>',
)
return
}
if (!this.data.ec.lazyLoad) {
this.init();
this.init()
}
},
methods: {
init: async function (callback) {
echarts = await require.async('../../gift/compontnts/echart/echarts.js');
const version = wx.getSystemInfoSync().SDKVersion;
async init(callback) {
echarts = await require.async('../../gift/compontnts/echart/echarts.js')
const version = wx.getSystemInfoSync().SDKVersion
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
const forceUseOldCanvas = this.data.forceUseOldCanvas;
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
this.setData({ isUseNewCanvas });
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0
const forceUseOldCanvas = this.data.forceUseOldCanvas
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas
this.setData({ isUseNewCanvas })
if (forceUseOldCanvas && canUseNewCanvas) {
console.warn('开发者强制使用旧canvas,建议关闭');
console.warn('开发者强制使用旧canvas,建议关闭')
}
if (isUseNewCanvas) {
// console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
// 2.9.0 可以使用 <canvas type="2d"></canvas>
this.initByNewWay(callback);
} else {
const isValid = compareVersion(version, '1.9.91') >= 0;
this.initByNewWay(callback)
}
else {
const isValid = compareVersion(version, '1.9.91') >= 0
if (!isValid) {
console.error(
'微信基础库版本过低,需大于等于 1.9.91。' +
'参见:https://github.com/ecomfe/echarts-for-weixin' +
'#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82',
);
return;
} else {
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
this.initByOldWay(callback);
'微信基础库版本过低,需大于等于 1.9.91。'
+ '参见:https://github.com/ecomfe/echarts-for-weixin'
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82',
)
}
else {
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能')
this.initByOldWay(callback)
}
}
},
initByOldWay(callback) {
// 1.9.91 <= version < 2.9.0:原来的方式初始化
ctx = wx.createCanvasContext(this.data.canvasId, this);
const canvas = new WxCanvas(ctx, this.data.canvasId, false);
ctx = wx.createCanvasContext(this.data.canvasId, this)
const canvas = new WxCanvas(ctx, this.data.canvasId, false)
echarts.setCanvasCreator(() => {
return canvas;
});
return canvas
})
// const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
const canvasDpr = 1;
var query = wx.createSelectorQuery().in(this);
const canvasDpr = 1
const query = wx.createSelectorQuery().in(this)
query
.select('.ec-canvas')
.boundingClientRect((res) => {
if (typeof callback === 'function') {
this.chart = callback(canvas, res.width, res.height, canvasDpr);
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
} else {
this.chart = callback(canvas, res.width, res.height, canvasDpr)
}
else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr)
}
else {
this.triggerEvent('init', {
canvas: canvas,
canvas,
width: res.width,
height: res.height,
canvasDpr: canvasDpr, // 增加了dpr,可方便外面echarts.init
});
canvasDpr, // 增加了dpr,可方便外面echarts.init
})
}
})
.exec();
.exec()
},
initByNewWay(callback) {
// version >= 2.9.0:使用新的方式初始化
const query = wx.createSelectorQuery().in(this);
const query = wx.createSelectorQuery().in(this)
query
.select('.ec-canvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvasNode = res[0].node;
this.canvasNode = canvasNode;
const canvasNode = res[0].node
this.canvasNode = canvasNode
const canvasDpr = wx.getSystemInfoSync().pixelRatio;
const canvasWidth = res[0].width;
const canvasHeight = res[0].height;
const canvasDpr = wx.getSystemInfoSync().pixelRatio
const canvasWidth = res[0].width
const canvasHeight = res[0].height
const ctx = canvasNode.getContext('2d');
const ctx = canvasNode.getContext('2d')
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode);
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
echarts.setCanvasCreator(() => {
return canvas;
});
return canvas
})
if (typeof callback === 'function') {
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr);
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr);
} else {
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
}
else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
}
else {
this.triggerEvent('init', {
canvas: canvas,
canvas,
width: canvasWidth,
height: canvasHeight,
dpr: canvasDpr,
});
})
}
});
})
},
canvasToTempFilePath(opt) {
if (this.data.isUseNewCanvas) {
// 新版
const query = wx.createSelectorQuery().in(this);
const query = wx.createSelectorQuery().in(this)
query
.select('.ec-canvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvasNode = res[0].node;
opt.canvas = canvasNode;
wx.canvasToTempFilePath(opt);
});
} else {
const canvasNode = res[0].node
opt.canvas = canvasNode
wx.canvasToTempFilePath(opt)
})
}
else {
// 旧的
if (!opt.canvasId) {
opt.canvasId = this.data.canvasId;
opt.canvasId = this.data.canvasId
}
ctx.draw(true, () => {
wx.canvasToTempFilePath(opt, this);
});
wx.canvasToTempFilePath(opt, this)
})
}
},
touchStart(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
const touch = e.touches[0]
const handler = this.chart.getZr().handler
handler.dispatch('mousedown', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
})
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
handler.processGesture(wrapTouch(e), 'start');
})
handler.processGesture(wrapTouch(e), 'start')
}
},
touchMove(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
const touch = e.touches[0]
const handler = this.chart.getZr().handler
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
handler.processGesture(wrapTouch(e), 'change');
})
handler.processGesture(wrapTouch(e), 'change')
}
},
touchEnd(e) {
if (this.chart) {
const touch = e.changedTouches ? e.changedTouches[0] : {};
var handler = this.chart.getZr().handler;
const touch = e.changedTouches ? e.changedTouches[0] : {}
const handler = this.chart.getZr().handler
handler.dispatch('mouseup', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
})
handler.dispatch('click', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
handler.processGesture(wrapTouch(e), 'end');
})
handler.processGesture(wrapTouch(e), 'end')
}
},
},
});
})
function wrapTouch(event) {
for (let i = 0; i < event.touches.length; ++i) {
const touch = event.touches[i];
touch.offsetX = touch.x;
touch.offsetY = touch.y;
const touch = event.touches[i]
touch.offsetX = touch.x
touch.offsetY = touch.y
}
return event;
return event
}

2
src/components/ec-canvas/ec-canvas.json

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
{
"component": true,
"usingComponents": {}
}
}

66
src/components/ec-canvas/wx-canvas.js

@ -1,24 +1,24 @@ @@ -1,24 +1,24 @@
export default class WxCanvas {
constructor(ctx, canvasId, isNew, canvasNode) {
this.ctx = ctx;
this.canvasId = canvasId;
this.chart = null;
this.ctx = ctx
this.canvasId = canvasId
this.chart = null
this.isNew = isNew
if (isNew) {
this.canvasNode = canvasNode;
this.canvasNode = canvasNode
}
else {
this._initStyle(ctx);
this._initStyle(ctx)
}
// this._initCanvas(zrender, ctx);
this._initEvent();
this._initEvent()
}
getContext(contextType) {
if (contextType === '2d') {
return this.ctx;
return this.ctx
}
}
@ -30,7 +30,7 @@ export default class WxCanvas { @@ -30,7 +30,7 @@ export default class WxCanvas {
// }
setChart(chart) {
this.chart = chart;
this.chart = chart
}
addEventListener() {
@ -47,55 +47,58 @@ export default class WxCanvas { @@ -47,55 +47,58 @@ export default class WxCanvas {
_initCanvas(zrender, ctx) {
zrender.util.getContext = function () {
return ctx;
};
return ctx
}
zrender.util.$override('measureText', function (text, font) {
ctx.font = font || '12px sans-serif';
return ctx.measureText(text);
});
zrender.util.$override('measureText', (text, font) => {
ctx.font = font || '12px sans-serif'
return ctx.measureText(text)
})
}
_initStyle(ctx) {
ctx.createRadialGradient = () => {
return ctx.createCircularGradient(arguments);
};
return ctx.createCircularGradient(arguments)
}
}
_initEvent() {
this.event = {};
this.event = {}
const eventNames = [{
wxName: 'touchStart',
ecName: 'mousedown'
ecName: 'mousedown',
}, {
wxName: 'touchMove',
ecName: 'mousemove'
ecName: 'mousemove',
}, {
wxName: 'touchEnd',
ecName: 'mouseup'
ecName: 'mouseup',
}, {
wxName: 'touchEnd',
ecName: 'click'
}];
eventNames.forEach(name => {
this.event[name.wxName] = e => {
const touch = e.touches[0];
ecName: 'click',
}]
eventNames.forEach((name) => {
this.event[name.wxName] = (e) => {
const touch = e.touches[0]
this.chart.getZr().handler.dispatch(name.ecName, {
zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
zrY: name.wxName === 'tap' ? touch.clientY : touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
};
});
stopPropagation: () => {},
})
}
})
}
set width(w) {
if (this.canvasNode) this.canvasNode.width = w
if (this.canvasNode)
this.canvasNode.width = w
}
set height(h) {
if (this.canvasNode) this.canvasNode.height = h
if (this.canvasNode)
this.canvasNode.height = h
}
get width() {
@ -103,6 +106,7 @@ export default class WxCanvas { @@ -103,6 +106,7 @@ export default class WxCanvas {
return this.canvasNode.width
return 0
}
get height() {
if (this.canvasNode)
return this.canvasNode.height

149
src/components/freeAudio/index.js

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
const app = getApp();
import dayjs from "dayjs";
const app = getApp()
Component({
behaviors: [],
properties: {
@ -7,19 +6,19 @@ Component({ @@ -7,19 +6,19 @@ Component({
type: Object,
observer(val) {
if (this.audioContext) {
const { play } = this.data;
const { play } = this.data
if (play) {
this.audioContext.pause();
this.audioContext.pause()
this.setData({
play: false,
progress: 0,
time: "00",
});
time: '00',
})
}
this.audioContext.destroy();
this.audioContext.destroy()
}
if (val) {
this.audioAddEventListener(val);
this.audioAddEventListener(val)
}
},
},
@ -27,8 +26,8 @@ Component({ @@ -27,8 +26,8 @@ Component({
data: {
Timestamp: app.globalData.Timestamp,
progress: 0,
time: "00",
duration: "00",
time: '00',
duration: '00',
play: false,
loading: true,
@ -41,136 +40,138 @@ Component({ @@ -41,136 +40,138 @@ Component({
moved() {},
detached() {
if (this.audioContext) {
const { play } = this.data;
const { play } = this.data
if (play) {
this.audioContext.pause();
this.audioContext.pause()
}
this.audioContext.destroy();
this.audioContext.destroy()
}
this.audioAddEventListener = null;
this.audioAddEventListener = null
this.setData({
play: false,
progress: 0,
time: "00",
});
time: '00',
})
},
},
pageLifetimes: {
// 组件所在页面的生命周期函数
show: function () {},
hide: function () {
const { play } = this.data;
show() {},
hide() {
const { play } = this.data
if (play) {
this.audioContext.pause();
this.audioContext.pause()
}
},
resize: function () {},
resize() {},
},
methods: {
togglePlay() {
const { play, loading } = this.data;
const { play, loading } = this.data
if (loading) {
wx.showToast({
title: "音频加载中",
icon: "none",
});
return;
title: '音频加载中',
icon: 'none',
})
return
}
if (play) {
this.audioContext.pause();
} else {
this.audioContext.play();
this.audioContext.pause()
}
else {
this.audioContext.play()
}
},
formatTime(time) {
let m = parseInt(time / 60);
let s = parseInt(time % 60);
return this.towNum(m) + ":" + this.towNum(s);
const m = Number.parseInt(time / 60)
const s = Number.parseInt(time % 60)
return `${this.towNum(m)}:${this.towNum(s)}`
},
towNum(num) {
if (num >= 10) {
return num;
} else {
return "0" + num;
return num
}
else {
return `0${num}`
}
},
audioAddEventListener(val) {
const that = this;
const that = this
this.setData({
duration: this.formatTime(val.size),
});
that.audioContext = wx.createInnerAudioContext();
that.audioContext.src = val.url;
})
that.audioContext = wx.createInnerAudioContext()
that.audioContext.src = val.url
that.setData({
loading: false,
});
})
that.audioContext.onError(({ errCode, ...reset }) => {
console.log("reset: ", reset);
console.log("errCode: ", errCode);
console.log('reset: ', reset)
console.log('errCode: ', errCode)
if (errCode === 10004 || errCode == 10001 || errCode == -1) {
that.audioContext.destroy();
that.audioContext.destroy()
that.setData({
loading: true,
});
})
setTimeout(() => {
that.audioAddEventListener(val);
}, 300);
that.audioAddEventListener(val)
}, 300)
}
});
})
that.audioContext.onPlay(() => {
that.setData({
play: true,
});
});
})
})
that.audioContext.onPause(() => {
console.log(1111111);
console.log(1111111)
that.setData({
play: false,
});
});
})
})
that.audioContext.onEnded(() => {
that.audioContext.seek(0);
that.audioContext.seek(0)
that.setData({
play: false,
progress: 0,
time: "00",
});
});
time: '00',
})
})
that.audioContext.onTimeUpdate(() => {
const duration = that.audioContext.duration || 0;
const currentTime = that.audioContext.currentTime || 0;
const progress = (currentTime / duration) * 100;
const duration = that.audioContext.duration || 0
const currentTime = that.audioContext.currentTime || 0
const progress = (currentTime / duration) * 100
if (duration == Infinity) {
return;
return
}
that.setData({
play: true,
duration: that.formatTime(duration),
time: that.formatTime(currentTime),
});
})
if (that.data.progressimg) {
this.setData({
progress: progress,
});
progress,
})
}
});
})
},
handleAuthChangeimg() {
console.log(11111);
console.log(11111)
this.setData({
progressimg: false,
});
})
},
handleAuthChange(e) {
console.log(22222222222);
let { duration } = this.data;
const secods = this.audioContext.duration || duration.split(":")[0] * 60 + duration.split(":")[1] * 1;
const progress = e.detail.value;
let seek = ((secods / 100) * progress).toFixed(3) * 1;
this.audioContext.seek(seek);
console.log(22222222222)
const { duration } = this.data
const secods = this.audioContext.duration || duration.split(':')[0] * 60 + duration.split(':')[1] * 1
const progress = e.detail.value
const seek = ((secods / 100) * progress).toFixed(3) * 1
this.audioContext.seek(seek)
this.setData({
progressimg: true,
});
})
},
},
});
})

8
src/components/image-merge/index.json

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"van-button": "@vant/weapp/button/index",
"van-icon": "@vant/weapp/icon/index",
"van-toast": "@vant/weapp/toast/index"
}
}

7
src/components/image-merge/index.scss

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
.merge-canvas {
position: fixed;
left: -9999px;
top: -9999px;
width: 1px;
height: 1px;
}

200
src/components/image-merge/index.ts

@ -0,0 +1,200 @@ @@ -0,0 +1,200 @@
interface ImageItem {
src: string
time?: string
}
Component({
properties: {
id: {
type: String,
value: 'default',
},
},
data: {
imageList: [] as ImageItem[],
mergedImage: '',
isLoading: false,
},
methods: {
mergeImages(imageList: ImageItem[]) {
if (this.data.isLoading) {
return
}
if (!imageList || imageList.length < 2) {
wx.showToast({ title: '至少需要2张图片才能拼接', icon: 'none' })
return
}
wx.showLoading({ title: '拼接中...', mask: true })
this.setData({ isLoading: true, imageList })
this.validateImages(imageList)
.then(() => this.drawImagesOnCanvas())
.then((mergedImage) => {
wx.hideLoading()
this.setData({
mergedImage,
isLoading: false,
})
this.triggerEvent('save', { tempFilePath: mergedImage })
wx.previewImage({
urls: [mergedImage],
current: mergedImage,
showmenu: true,
})
})
.catch((error) => {
wx.hideLoading()
console.error('拼接失败:', error)
this.setData({ isLoading: false })
wx.showToast({ title: error.message || '拼接失败,请重试', icon: 'none' })
this.triggerEvent('error', { reason: error.message })
})
},
validateImages(imageList: ImageItem[]): Promise<void> {
return Promise.all(
imageList.map(
(item, index) =>
new Promise<void>((resolve, reject) => {
wx.getImageInfo({
src: item.src,
success: () => resolve(),
fail: () => reject(new Error(`${index + 1}张图片加载失败`)),
})
}),
),
)
},
formatTime(date: Date): string {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
},
drawImagesOnCanvas(): Promise<string> {
return new Promise((resolve, reject) => {
const { imageList, id } = this.data
const query = this.createSelectorQuery()
query
.in(this)
.select(`#mergeCanvas-${id}`)
.fields({ node: true, size: true })
.exec((res) => {
if (!res[0]) {
reject(new Error('Canvas not found'))
return
}
const canvas = res[0].node
const ctx = canvas.getContext('2d')
Promise.all(imageList.map(item => this.getImageInfo(item.src)))
.then((imageInfos) => {
const targetWidth = 750
const pixelRatio = wx.getWindowInfo().pixelRatio
const canvasWidth = Math.floor((targetWidth * pixelRatio) / 2)
const fontScale = pixelRatio / 2
let totalHeight = 0
const scaledHeights: number[] = []
imageInfos.forEach((info) => {
const scale = canvasWidth / info.width
const scaledHeight = Math.floor(info.height * scale)
scaledHeights.push(scaledHeight)
totalHeight += scaledHeight
})
canvas.width = canvasWidth
canvas.height = totalHeight
let currentY = 0
let loadedCount = 0
// 预计算每张图片的 Y 偏移,确保顺序正确
const yPositions: number[] = []
scaledHeights.forEach((h, i) => {
yPositions.push(currentY)
currentY += h
})
loadedCount = 0
currentY = 0
imageInfos.forEach((info, index) => {
const img = canvas.createImage()
img.src = info.path
img.onload = () => {
ctx.drawImage(img, 0, yPositions[index], canvasWidth, scaledHeights[index])
const timeText = imageList[index].time || this.formatTime(new Date())
const padding = 20 * fontScale
const fontSize = Math.round(28 * fontScale)
const textY = yPositions[index] + 40 * fontScale
ctx.font = `bold ${fontSize}px sans-serif`
ctx.textBaseline = 'middle'
const textMetrics = ctx.measureText(timeText)
const bgPaddingH = 16 * fontScale
const bgPaddingV = 10 * fontScale
const bgH = fontSize + bgPaddingV * 2
const bgX = padding - bgPaddingH
const bgY = textY - bgH / 2
const bgW = textMetrics.width + bgPaddingH * 2
ctx.fillStyle = 'rgba(0, 0, 0, 0.45)'
ctx.fillRect(bgX, bgY, bgW, bgH)
ctx.fillStyle = '#ffffff'
ctx.textAlign = 'left'
ctx.fillText(timeText, padding, textY)
if (index === imageInfos.length - 1) {
const lastImageBottom = yPositions[index] + scaledHeights[index]
ctx.fillStyle = 'rgba(255, 255, 255, 0.8)'
ctx.font = `${Math.round(24 * fontScale)}px sans-serif`
ctx.textAlign = 'right'
ctx.fillText('由-TED关爱小助手-小程序生成', canvasWidth - 20 * fontScale, lastImageBottom - 20 * fontScale)
}
loadedCount++
if (loadedCount === imageInfos.length) {
wx.canvasToTempFilePath({
canvas,
success: (result) => {
resolve(result.tempFilePath)
},
fail: reject,
})
}
}
img.onerror = () => {
reject(new Error(`Failed to load image: ${info.path}`))
}
})
})
.catch(reject)
})
})
},
getImageInfo(src: string): Promise<WechatMiniprogram.GetImageInfoSuccessCallbackResult> {
return new Promise((resolve, reject) => {
wx.getImageInfo({
src,
success: resolve,
fail: reject,
})
})
},
},
})

1
src/components/image-merge/index.wxml

@ -0,0 +1 @@ @@ -0,0 +1 @@
<canvas type="2d" id="mergeCanvas-{{id}}" class="merge-canvas"></canvas>

6
src/components/loginNavbar/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>();
const app = getApp<IAppOption>()
Component({
properties: {
@ -17,7 +17,7 @@ Component({ @@ -17,7 +17,7 @@ Component({
},
methods: {
handleBack() {
this.triggerEvent("back");
this.triggerEvent('back')
},
},
});
})

6
src/components/navbar/index.ts

@ -32,7 +32,7 @@ Component({ @@ -32,7 +32,7 @@ Component({
*/
data: {
imageUrl: app.globalData.imageUrl,
Timestamp:app.globalData.Timestamp
Timestamp: app.globalData.Timestamp,
},
/**
@ -40,8 +40,8 @@ Component({ @@ -40,8 +40,8 @@ Component({
*/
methods: {
onClickLeft() {
if(this.data.back)
this.triggerEvent('clickLeft', {}, {})
if (this.data.back)
this.triggerEvent('clickLeft', {}, {})
},
onClickRight() {
this.triggerEvent('clickRight', {}, {})

7
src/components/noteImagePreview/index.json

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"van-icon": "@vant/weapp/icon/index",
"navbar": "/components/navbar/index"
}
}

157
src/components/noteImagePreview/index.scss

@ -0,0 +1,157 @@ @@ -0,0 +1,157 @@
.preview-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #000;
z-index: 1000;
display: flex;
flex-direction: column;
opacity: 0;
visibility: hidden;
transition:
opacity 0.3s,
visibility 0.3s;
&.show {
opacity: 1;
visibility: visible;
}
}
// 图片展示区域
.image-wrapper {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
.order {
position: absolute;
left: 50%;
transform: translate(-50%, 0 );
padding: 18rpx 32rpx;
font-size: 40rpx;
font-weight: bold;
text-align: center;
color: #211d2e;
border-radius: 94rpx;
display: inline-flex;
align-items: baseline;
background-color: #fff;
z-index: 10;
white-space: nowrap;
.num {
margin-left: 20rpx;
}
.m-num {
font-size: 28rpx;
}
}
.preview-image {
display: block;
width: 100%;
height: 100%;
}
// 左右切换按钮
.nav-btn {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
&:active:not(.disabled) {
background: rgba(0, 0, 0, 0.6);
}
&.disabled {
opacity: 0.3;
}
&.nav-prev {
left: 24rpx;
}
&.nav-next {
right: 24rpx;
}
}
}
// 页码指示器
.indicator {
position: absolute;
left: 0;
right: 0;
text-align: center;
color: #fff;
font-size: 28rpx;
z-index: 10;
bottom: calc(168rpx + env(safe-area-inset-bottom));
.current {
font-weight: 600;
}
.separator {
margin: 0 8rpx;
opacity: 0.6;
}
.total {
opacity: 0.6;
}
}
// 底部操作栏
.action-bar {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 40rpx;
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
background: #fff;
display: flex;
gap: 32rpx;
.btn {
flex: 1;
height: 88rpx;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
&-delete {
border: 1px solid #b982ff;
color: #b982ff;
background: #fff;
}
&-retake {
background: linear-gradient(0deg, #e98ff8 0%, #b073ff 100%);
color: #fff;
}
&:active {
opacity: 0.8;
}
}
}

157
src/components/noteImagePreview/index.ts

@ -0,0 +1,157 @@ @@ -0,0 +1,157 @@
Component({
properties: {
visible: {
type: Boolean,
value: false,
observer(newVal) {
this.setData({ visible: newVal })
},
},
src: {
type: String,
value: '',
},
images: {
type: Array,
value: [],
},
currentIndex: {
type: Number,
value: 0,
},
photoLabels: {
type: Array,
value: [] as { name: string; index: number; total: number }[],
},
showActions: {
type: Boolean,
value: true,
},
},
data: {
visible: false,
src: '',
images: [] as string[],
currentIndex: 0,
navHeight: wx.getSystemInfoSync().statusBarHeight + 44,
startX: 0,
startY: 0,
},
observers: {
'currentIndex, images': function (currentIndex: number, images: string[]) {
if (images && images.length > 0 && images[currentIndex]) {
this.setData({
src: images[currentIndex],
})
}
},
},
methods: {
// 返回/关闭
handleBack() {
this.triggerEvent('close')
},
// 更多操作
handleMore() {
this.triggerEvent('more')
},
// 预览/查看
handlePreview(src) {
if (src) {
this.setData({
visible: true,
src,
})
}
},
handleHidePreview() {
this.setData({
visible: false,
src: '',
})
},
// 上一张
handlePrev() {
const { currentIndex, images } = this.data
if (currentIndex > 0) {
const newIndex = currentIndex - 1
this.setData({
currentIndex: newIndex,
})
this.triggerEvent('change', { index: newIndex })
}
},
// 下一张
handleNext() {
const { currentIndex, images } = this.data
if (currentIndex < images.length - 1) {
const newIndex = currentIndex + 1
this.setData({
currentIndex: newIndex,
})
this.triggerEvent('change', { index: newIndex })
}
},
// 滑动手势 - 开始
handleTouchStart(e: any) {
this.setData({
startX: e.touches[0].clientX,
startY: e.touches[0].clientY,
})
},
// 滑动手势 - 结束
handleTouchEnd(e: any) {
const { startX, startY, currentIndex, images } = this.data
const endX = e.changedTouches[0].clientX
const endY = e.changedTouches[0].clientY
const diffX = endX - startX
const diffY = endY - startY
// 水平滑动距离大于50且大于垂直滑动距离时才触发切换
if (Math.abs(diffX) > 50 && Math.abs(diffX) > Math.abs(diffY)) {
if (diffX > 0) {
// 右滑 - 上一张
if (currentIndex > 0) {
this.handlePrev()
}
} else {
// 左滑 - 下一张
if (currentIndex < images.length - 1) {
this.handleNext()
}
}
}
},
// 删除
handleDelete() {
wx.showModal({
title: '提示',
content: '确定要删除这张照片吗?',
confirmColor: '#8c75d0',
cancelColor: '#141515',
success: (res) => {
if (res.confirm) {
this.handleHidePreview()
this.triggerEvent('delete')
}
},
})
},
// 重拍
handleRetake() {
this.handleHidePreview()
this.triggerEvent('retake')
},
},
})

31
src/components/noteImagePreview/index.wxml

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
<view class="preview-container {{visible ? 'show' : ''}}">
<navbar fixed title="" custom-style="background:transparent" bind:click-left="handleBack">
<van-icon name="arrow-left" slot="left" size="18px" color="#fff" bind:tap="handleBack" />
</navbar>
<view class="image-wrapper" style="padding-top:{{navHeight}}px;" bindtouchstart="handleTouchStart" bindtouchend="handleTouchEnd">
<view class="order" wx:if="{{photoLabels[currentIndex]}}" style="top:{{navHeight * 0.5}}px;">
{{photoLabels[currentIndex].name}}
<!-- <view class="num">{{photoLabels[currentIndex].index}}</view> -->
<!-- <view class="m-num">/{{photoLabels[currentIndex].total}}</view> -->
</view>
<view class="nav-btn nav-prev {{currentIndex <= 0 ? 'disabled' : ''}}" wx:if="{{images.length > 1}}" bindtap="handlePrev">
<van-icon name="arrow-left" size="20px" color="{{currentIndex <= 0 ? '#666' : '#fff'}}" />
</view>
<image class="preview-image" src="{{src}}" mode="aspectFit" />
<view class="nav-btn nav-next {{currentIndex >= images.length - 1 ? 'disabled' : ''}}" wx:if="{{images.length > 1}}" bindtap="handleNext">
<van-icon name="arrow" size="20px" color="{{currentIndex >= images.length - 1 ? '#666' : '#fff'}}" />
</view>
</view>
<view class="indicator" wx:if="{{images.length > 1}}">
<text class="current">{{currentIndex + 1}}</text>
<text class="separator">/</text>
<text class="total">{{images.length}}</text>
</view>
<view class="action-bar" wx:if="{{showActions}}">
<view class="btn btn-delete" bindtap="handleDelete">删除</view>
<view class="btn btn-retake" bindtap="handleRetake">重拍</view>
</view>
</view>

6
src/components/pageNavbar/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>();
const app = getApp<IAppOption>()
Component({
properties: {
@ -17,7 +17,7 @@ Component({ @@ -17,7 +17,7 @@ Component({
},
methods: {
handleBack() {
wx.navigateBack();
wx.navigateBack()
},
},
});
})

40
src/components/patient-tab-bar/index.scss

@ -1,6 +1,46 @@ @@ -1,6 +1,46 @@
/* custom-tab-bar/index.wxss */
.tab-custom-item {
position: relative;
flex: 1;
z-index: 1;
.circle {
display: block;
margin: 0 auto;
margin-top: -53rpx;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
border: 3px solid #fff;
background: linear-gradient(0deg, #e98ff8 0%, #b073ff 100%);
display: flex;
align-items: center;
justify-content: center;
.icon {
width: 60rpx;
height: 60rpx;
}
}
.name {
font-size: 26rpx;
color: rgba(105, 104, 110, 1);
text-align: center;
&.active {
color: rgba(33, 29, 46, 1);
}
}
.tip-card {
position: absolute;
top: -30rpx;
left: 50%;
width: 390rpx;
height: 230rpx;
transform: translate(-50%, -100%);
}
}
.tab-item {
flex: 1;
.icon {
width: 48rpx;
height: 48rpx;

16
src/components/patient-tab-bar/index.ts

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
import { getCurrentPageUrl } from '@/utils/util'
const app = getApp()
Component({
@ -21,6 +22,11 @@ Component({ @@ -21,6 +22,11 @@ Component({
iconActive: 'tab-active2',
},
{
pagePath: '/patient/pages/note/index',
text: '突眼日记',
custom: true,
},
{
pagePath: '/patient/pages/live/index',
text: '大咖说',
icon: 'tab5',
@ -48,7 +54,7 @@ Component({ @@ -48,7 +54,7 @@ Component({
})
const pagePath = getCurrentPageUrl()
const active = this.data.list.findIndex((item) => item.pagePath === pagePath)
const active = this.data.list.findIndex(item => item.pagePath === pagePath)
this.setData({
active,
})
@ -72,8 +78,14 @@ Component({ @@ -72,8 +78,14 @@ Component({
handleNav(e) {
const { index } = e.currentTarget.dataset
const { list } = this.data
const pagePath = list[index].pagePath
const { pagePath, custom } = list[index]
app.globalData.BeginnerCardId = ''
if (custom) {
wx.navigateTo({
url: pagePath,
})
return
}
wx.reLaunch({
url: pagePath,
})

7
src/components/patient-tab-bar/index.wxml

@ -1,6 +1,13 @@ @@ -1,6 +1,13 @@
<van-tabbar active="{{ active }}" active-color="#CF5375" bind:change="onChange" inactive-color="#CCCCCC">
<block wx:for="{{list}}" wx:key="*this">
<view class="tab-custom-item" wx:if="{{item.custom}}" bind:tap="handleNav" data-index="{{index}}">
<view class="circle">
<image class="icon" src="{{imageUrl}}icon142.png?t={{Timestamp}}"></image>
</view>
<view class="name">突眼日记</view>
</view>
<van-tabbar-item
wx:else
class="tab-item"
bind:tap="handleNav"
data-index="{{index}}"

10
src/components/pickerArea/index.scss

@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
padding: 18rpx 30rpx;
box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(0, 0, 0, 0.11);
border-radius: 12rpx 12rpx 12rpx 12rpx;
border: 2rpx solid #B982FF;
border: 2rpx solid #b982ff;
display: flex;
align-items: center;
justify-content: space-between;
@ -69,7 +69,7 @@ @@ -69,7 +69,7 @@
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient( 197deg, #FFBCF9 0%, #B982FF 100%);
background: linear-gradient(197deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 12rpx 12rpx 12rpx 12rpx;
}
}
@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
background: #f7f8f9;
&.active {
color: #fff;
background-color: #B982FF;
background-color: #b982ff;
}
}
}
@ -118,9 +118,9 @@ @@ -118,9 +118,9 @@
height: 36rpx;
}
&.active {
color: #B982FF;
color: #b982ff;
.word {
color: #B982FF;
color: #b982ff;
}
}
}

76
src/components/pickerArea/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>();
const app = getApp<IAppOption>()
Component({
properties: {
@ -22,10 +22,14 @@ Component({ @@ -22,10 +22,14 @@ Component({
type: String,
value: '',
},
required: {
type: Boolean,
value: false,
},
},
observers: {
show(newVal: boolean) {
this.triggerEvent('show', newVal);
this.triggerEvent('show', newVal)
},
},
data: {
@ -217,6 +221,7 @@ Component({ @@ -217,6 +221,7 @@ Component({
handleShow() {
this.setData({
show: true,
active: 0,
ProvinceName: this.data.pname || '',
ProvinceId: this.data.pid || '',
CityName: this.data.cname || '',
@ -224,8 +229,8 @@ Component({ @@ -224,8 +229,8 @@ Component({
scrollIntoView0: this.data.pid || '',
scrollIntoView1: this.data.cid || '',
});
this.getArea();
})
this.getArea()
},
getArea() {
wx.ajax({
@ -235,78 +240,95 @@ Component({ @@ -235,78 +240,95 @@ Component({
}).then((res) => {
this.setData({
area: res,
});
this.getRangeList();
});
})
this.getRangeList()
})
},
handleItem(e: any) {
const { code, name } = e.currentTarget.dataset;
const { code, name } = e.currentTarget.dataset
this.setData({
ProvinceId: code,
ProvinceName: name,
CityId: '',
CityName: '',
});
this.getRangeList();
})
this.getRangeList()
},
handleChangeCity(e: any) {
const { code, name } = e.currentTarget.dataset;
const { code, name } = e.currentTarget.dataset
this.setData({
CityId: code,
CityName: name,
});
})
},
handleShare() {
if (this.data.required) {
if (!this.data.ProvinceId) {
wx.showToast({
icon: 'none',
title: '请选择省份',
})
return
}
if (!this.data.CityId) {
wx.showToast({
icon: 'none',
title: '请选择城市',
})
return
}
}
this.setData({
show: false,
});
})
this.triggerEvent('ok', {
ProvinceName: this.data.ProvinceName,
ProvinceId: this.data.ProvinceId,
CityName: this.data.CityName,
CityId: this.data.CityId,
});
})
},
handleSelect(e) {
const { id } = e.currentTarget.dataset;
const { id } = e.currentTarget.dataset
this.setData({
word: id,
scrollIntoView0: id,
});
})
},
getRangeList() {
const { area, ProvinceId } = this.data;
if (!ProvinceId) return;
const range = area.filter((item: any) => item.value == ProvinceId)[0].children;
const { area, ProvinceId } = this.data
if (!ProvinceId)
return
const range = area.filter((item: any) => item.value == ProvinceId)[0].children
this.setData({
range,
active: 1,
scrollIntoView0: '',
scrollIntoView1: `id${this.data.CityId}`,
});
})
},
handleProvince() {
this.setData({
active: 0,
scrollIntoView0: this.data.word || `id${this.data.ProvinceId}`,
scrollIntoView1: '',
});
})
},
handleCity() {
const { ProvinceId } = this.data;
const { ProvinceId } = this.data
if (!ProvinceId) {
wx.showToast({
title: '请先选择省份',
icon: 'none',
});
return;
})
return
}
this.getRangeList();
this.getRangeList()
},
handleClose() {
this.setData({
show: false,
});
})
},
},
});
})

472
src/components/popup/index.scss

@ -155,19 +155,19 @@ @@ -155,19 +155,19 @@
}
.contaienr {
margin-top: -80rpx;
padding: 96rpx 0 0;
padding: 122rpx 0 0;
width: 540rpx;
border-radius: 24rpx;
box-sizing: border-box;
background: linear-gradient(353deg, #ffffff 0%, #f5eeff 100%);
box-shadow: inset 0rpx -1rpx 0rpx 0rpx #e5e6eb;
.content {
font-size: 28rpx;
font-size: 36rpx;
color: #adacb2;
text-align: center;
}
.footer {
margin-top: 40rpx;
margin-top: 66rpx;
border-top: 1px solid #e5e6eb;
display: flex;
.sure,
@ -231,12 +231,476 @@ @@ -231,12 +231,476 @@
height: 88rpx;
line-height: 88rpx;
font-size: 32rpx;
color: #FFFFFF;
color: #ffffff;
background: linear-gradient(197deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx 100rpx 100rpx 100rpx;
}
}
.popup10,
.popup11 {
padding: 48rpx 50rpx 48rpx;
width: 650rpx;
box-sizing: border-box;
background-color: #fff;
border-radius: 24rpx;
.title {
margin-top: 24rpx;
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
line-height: 56rpx;
text-align: center;
}
.content {
margin-top: 24rpx;
text-align: center;
.link {
font-size: 32rpx;
color: #b982ff;
}
}
.footer {
margin-top: 40rpx;
display: flex;
gap: 30rpx;
.sure,
.cancel {
flex: 1;
padding: 20rpx;
text-align: center;
font-size: 36rpx;
border-radius: 100rpx;
}
.cancel {
padding: 18rpx 0;
color: #b982ff;
border: 1px solid #b982ff;
}
.sure {
padding: 0;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
}
.popup12 {
.popup-container {
padding: 0 40rpx 40rpx;
width: 630rpx;
height: 860rpx;
box-sizing: border-box;
.container {
padding: 236rpx 0 0;
.c-header {
display: flex;
align-items: center;
justify-content: center;
.avatar {
width: 76rpx;
height: 76rpx;
border-radius: 50%;
}
.name {
margin-left: 20rpx;
font-size: 32rpx;
color: #211d2e;
font-weight: bold;
line-height: 44rpx;
}
}
.code {
margin: 60rpx auto 0;
display: block;
width: 260rpx;
height: 260rpx;
border-radius: 24rpx;
}
.tip {
margin-top: 60rpx;
text-align: center;
font-size: 32rpx;
color: #211d2e;
line-height: 44rpx;
}
}
}
}
.popup13 {
.popup-container {
padding: 48rpx 32rpx 32rpx;
width: 670rpx;
height: 1124rpx;
background: linear-gradient(180deg, #f1e6ff 0%, #ffffff 12.03%, #ffffff 100%);
border-radius: 32rpx 32rpx 32rpx 32rpx;
border: 2rpx solid #ffffff;
box-sizing: border-box;
.title {
font-size: 44rpx;
color: #b982ff;
text-align: center;
font-weight: bold;
}
.scroll {
margin-top: 32rpx;
padding: 32rpx 32rpx 32rpx 0;
background: #f6f8f9;
border-radius: 32rpx 32rpx 32rpx 32rpx;
height: 824rpx;
overflow-y: auto;
box-sizing: border-box;
.s-title {
font-size: 36rpx;
line-height: 60rpx;
font-weight: bold;
margin-left: 32rpx;
color: #332c49;
border-radius: 0 32rpx 32rpx 0;
display: inline-block;
margin-top: 28rpx;
position: relative;
&::after {
position: absolute;
left: 0;
bottom: 6rpx;
content: '';
width: 100%;
height: 16rpx;
background: linear-gradient(90deg, #b982ff 0%, rgba(185, 130, 255, 0) 100%);
opacity: 0.4;
}
&:first-of-type {
margin-top: 0;
}
}
.content {
margin-top: 32rpx;
padding: 0 32rpx;
font-size: 32rpx;
color: #69686e;
line-height: 48rpx;
.high {
color: #b982ff;
font-weight: bold;
}
}
.s-name {
margin-top: 32rpx;
padding: 0 32rpx;
font-size: 32rpx;
color: #211d2e;
line-height: 48rpx;
display: flex;
align-items: center;
gap: 8rpx;
&::before {
content: '';
width: 8rpx;
height: 30rpx;
background: #b982ff;
border-radius: 2rpx 2rpx 2rpx 2rpx;
}
}
.row {
padding: 0 32rpx;
.col {
margin-top: 24rpx;
display: flex;
gap: 12rpx;
.order {
margin-top: 10rpx;
flex-shrink: 0;
width: 36rpx;
height: 36rpx;
text-align: center;
line-height: 36rpx;
font-size: 28rpx;
color: #ffffff;
border-radius: 50%;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
}
.c-content {
font-size: 32rpx;
color: #69686e;
line-height: 48rpx;
.high {
color: #b982ff;
font-weight: bold;
}
}
}
}
}
.btn {
margin-top: 32rpx;
width: 606rpx;
height: 88rpx;
font-size: 36rpx;
color: #ffffff;
line-height: 88rpx;
text-align: center;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx 100rpx 100rpx 100rpx;
}
}
}
.popup14 {
.badge {
position: relative;
z-index: 1;
display: block;
width: 198rpx;
height: 198rpx;
margin: 0 auto -110rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
box-sizing: border-box;
padding: 130rpx 58rpx 56rpx;
border-radius: 32rpx;
background: linear-gradient(180deg, #f1e6ff 0%, #ffffff 29.75%, #ffffff 100%);
.title {
font-size: 36rpx;
color: #211d2e;
font-weight: bold;
}
.content {
margin-top: 28rpx;
font-size: 36rpx;
color: #69686e;
line-height: 48rpx;
text-align: center;
}
.btn {
margin-top: 56rpx;
height: 88rpx;
line-height: 88rpx;
text-align: center;
font-size: 36rpx;
color: #ffffff;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx;
}
}
}
.popup15 {
.badge {
position: relative;
z-index: 1;
display: block;
width: 144rpx;
height: 144rpx;
margin: 0 auto -72rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
box-sizing: border-box;
padding: 118rpx 48rpx 16rpx;
border-radius: 32rpx;
background: #fff;
.title {
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
text-align: center;
}
.content {
margin-top: 20rpx;
font-size: 32rpx;
color: #69686e;
line-height: 48rpx;
text-align: center;
.date {
color: #b982ff;
}
}
.btn {
margin-top: 44rpx;
height: 88rpx;
line-height: 88rpx;
text-align: center;
font-size: 36rpx;
color: #ffffff;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx;
}
.cancel {
padding: 32rpx;
font-size: 32rpx;
color: #b982ff;
text-align: center;
}
}
}
.popup16 {
.badge {
position: relative;
z-index: 1;
display: block;
width: 144rpx;
height: 144rpx;
margin: 0 auto -72rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
box-sizing: border-box;
padding: 118rpx 48rpx 44rpx;
border-radius: 32rpx;
background: #fff;
.title {
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
text-align: center;
}
.p-footer {
margin-top: 52rpx;
display: flex;
gap: 30rpx;
.sure,
.cancel {
flex: 1;
font-size: 36rpx;
border-radius: 100rpx;
height: 88rpx;
box-sizing: border-box;
}
.cancel {
color: #b982ff;
border: 1px solid #b982ff;
display: flex;
align-items: center;
justify-content: center;
}
.sure {
padding: 0;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
.popup17 {
.badge {
position: relative;
z-index: 1;
display: block;
width: 144rpx;
height: 144rpx;
margin: 0 auto -72rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
box-sizing: border-box;
padding: 118rpx 48rpx 44rpx;
border-radius: 32rpx;
background: #fff;
.title {
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
text-align: center;
}
.p-footer {
margin-top: 52rpx;
display: flex;
gap: 30rpx;
.sure,
.cancel {
flex: 1;
font-size: 36rpx;
border-radius: 100rpx;
height: 88rpx;
box-sizing: border-box;
}
.cancel {
color: #b982ff;
border: 1px solid #b982ff;
display: flex;
align-items: center;
justify-content: center;
}
.sure {
padding: 0;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
.popup18 {
.badge {
position: relative;
z-index: 1;
display: block;
width: 144rpx;
height: 144rpx;
margin: 0 auto -72rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
box-sizing: border-box;
padding: 118rpx 48rpx 44rpx;
border-radius: 32rpx;
background: #fff;
.title {
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
text-align: center;
}
.p-footer {
margin-top: 52rpx;
display: flex;
gap: 30rpx;
.sure,
.cancel {
flex: 1;
font-size: 36rpx;
border-radius: 100rpx;
height: 88rpx;
box-sizing: border-box;
}
.cancel {
color: #b982ff;
border: 1px solid #b982ff;
display: flex;
align-items: center;
justify-content: center;
}
.sure {
padding: 0;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
.close {
margin: 48rpx auto 0;
display: block;

3
src/components/popup/index.ts

@ -36,6 +36,9 @@ Component({ @@ -36,6 +36,9 @@ Component({
handleCancel() {
this.triggerEvent('cancel')
},
handlePhone(e) {
this.triggerEvent('phone', e.detail)
},
routerTo(e: any) {
const { url } = e.currentTarget.dataset
wx.navigateTo({

172
src/components/popup/index.wxml

@ -81,6 +81,178 @@ @@ -81,6 +81,178 @@
</view>
<view class="btn" bind:tap="handleOk">知道了</view>
</view>
<view class="popup10" wx:if="{{type==='popup10'}}">
<view class="title">我已阅读并同意</view>
<view class="content">
<text class="link" bind:tap="routerTo" data-url="/doc/pages/doc2/index?active=1">《用户协议》</text>
<text class="link" bind:tap="routerTo" data-url="/doc/pages/doc2/index">《隐私政策》</text>
<view></view>
<text class="link" bind:tap="routerTo" data-url="/doc/pages/doc2/index?active=2">《个人信息共享知情同意书》</text>
</view>
<view class="footer">
<view class="cancel" bind:tap="handleCancel">取消</view>
<button class="sure" open-type="getPhoneNumber" bindgetphonenumber="handlePhone">确定</button>
</view>
</view>
<view class="popup11" wx:if="{{type==='popup11'}}">
<view class="title">我已阅读并同意</view>
<view class="content">
<text class="link" bind:tap="routerTo" data-url="/doc/pages/doc1/index">《隐私协议保护政策》</text>
</view>
<view class="footer">
<view class="cancel" bind:tap="handleCancel">取消</view>
<view wx:if="{{params.customPhone}}" class="sure" bind:tap="handleOk">确定</view>
<button wx:else class="sure" open-type="getPhoneNumber" bindgetphonenumber="handlePhone">确定</button>
</view>
</view>
<view class="popup12" wx:if="{{type==='popup12'}}">
<view
class="popup-container"
style="background: url('{{imageUrl}}bg29.png?t={{Timestamp}}') no-repeat top center/100%"
>
<view class="container">
<view class="c-header">
<image class="avatar" src="{{params.ConsultQwAvatar}}"></image>
<view class="name">{{params.ConsultQwName}}</view>
</view>
<image class="code" mode="aspectFill" src="{{params.ConsultQwImg}}" show-menu-by-longpress></image>
<view class="tip">
长按识别二维码
<view></view>
添加客服人员
</view>
</view>
</view>
</view>
<view class="popup13" wx:if="{{type==='popup13'}}">
<view class="popup-container">
<view class="title">了解双通道/临采/院内用药</view>
<view class="scroll">
<view class="s-title">什么是“双通道”?</view>
<view class="content">
“双通道”是指除了医院,患者还能去
<text class="high">指定药店</text>
买药,而且
<text class="high">报销比例和医院一样。</text>
</view>
<view class="s-name">“双通道”报销需要注意以下两点</view>
<view class="row">
<view class="col">
<view class="order">1</view>
<view class="c-content">
外配处方通常存在
<text class="high">有效期</text>
,我们要在有效期内去药店购药;
</view>
</view>
<view class="col">
<view class="order">2</view>
<view class="c-content">
药店必须是纳入“双通道”管理的
<text class="high">定点药店</text>
,才能享受同等报销待遇。
</view>
</view>
</view>
<view class="s-title">什么是“临采”?</view>
<view class="content">
“临采”全称是临时采购,适用场景主要是:医院暂时缺货、有突发的治疗需求、或者有特种病例需要紧急用药的情况。
</view>
<view class="content">
整个流程有
<text class="high">明确的时间限制</text>
,是短期解决“缺药”问题的办法,
<text class="high">不适合长期</text>
常规用药。
</view>
<view class="s-title">什么是“院内用药”?</view>
<view class="content">
院内用药就是“在医院看诊-拿药-直接报销”的一站式全流程,也是最传统、最省心的方式,全程
<text class="high">自动报销</text>
</view>
<view class="s-name">“院内用药”报销需满足两个条件</view>
<view class="row">
<view class="col">
<view class="order">1</view>
<view class="c-content">
医院必须是
<text class="high">医保定点机构</text>
</view>
</view>
<view class="col">
<view class="order">2</view>
<view class="c-content">
医生开具的处方要符合药品说明书适应症和医保限定支付范围(即:
<text class="high">中重度甲状腺眼病</text>
)。
</view>
</view>
</view>
</view>
<view class="btn" bind:tap="handleOk">了解更多详情</view>
</view>
</view>
<view class="popup14" wx:if="{{type==='popup14'}}">
<image class="badge" src="{{imageUrl}}icon131.png?t={{Timestamp}}"></image>
<view class="popup-container">
<view class="title">访问直播活动页需切换至患者端</view>
<view class="content">请问是否继续</view>
<view class="btn" bind:tap="handleOk">继续</view>
</view>
</view>
<view class="popup15" wx:if="{{type==='popup15'}}">
<image class="badge" src="{{imageUrl}}icon155.png?t={{Timestamp}}"></image>
<view class="popup-container">
<view class="title">确认删除记录?</view>
<view class="content">
删除
<text class="date">{{params.recordDate}}</text>
记录
<view>此操作不可逆,相关照片将永久删除</view>
</view>
<view class="btn" bind:tap="handleOk">确认删除</view>
<view class="cancel" bind:tap="handleCancel">取消</view>
</view>
</view>
<view class="popup16" wx:if="{{type==='popup16'}}">
<image class="badge" src="{{imageUrl}}icon156.png?t={{Timestamp}}"></image>
<view class="popup-container">
<view class="title">您的记录还未保存</view>
<view class="p-footer">
<view class="cancel" bind:tap="handleCancel">退出</view>
<view class="sure" bind:tap="handleOk">保存记录</view>
</view>
</view>
</view>
<view class="popup17" wx:if="{{type==='popup17'}}">
<image class="badge" src="{{imageUrl}}icon156.png?t={{Timestamp}}"></image>
<view class="popup-container">
<view class="title">
您有裁剪的照片
<view></view>
现在退出会被清空
</view>
<view class="p-footer">
<view class="cancel" bind:tap="handleCancel">取消</view>
<view class="sure" bind:tap="handleOk">继续退出</view>
</view>
</view>
</view>
<view class="popup18" wx:if="{{type==='popup18'}}">
<image class="badge" src="{{imageUrl}}icon156.png?t={{Timestamp}}"></image>
<view class="popup-container">
<view class="title">
是否替换已有基准照
</view>
<view class="p-footer">
<view class="cancel" bind:tap="handleCancel">取消</view>
<view class="sure" bind:tap="handleOk">确认替换</view>
</view>
</view>
</view>
<image
wx:if="{{params.close}}"

95
src/components/referralFrom/index.scss

@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
.from {
padding: 48rpx 40rpx;
width: 650rpx;
box-sizing: border-box;
background: linear-gradient(349deg, #ffffff 0%, #e2f1f4 100%);
border-radius: 24rpx 24rpx 24rpx 24rpx;
border: 2rpx solid #ffffff;
.title {
font-size: 32rpx;
color: #283031;
font-weight: bold;
}
.date {
margin-top: 24rpx;
padding: 14rpx 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
background-color: #f2f4f5;
border-radius: 16rpx;
.conetent {
font-size: 32rpx;
color: #283031;
}
.tril {
width: 0;
height: 0;
border-style: solid;
border-width: 10rpx 10rpx 0 10rpx;
border-color: #aeb3b4 transparent transparent transparent;
}
}
.select-title {
margin-top: 48rpx;
font-size: 32rpx;
color: #283031;
font-weight: bold;
.sub {
font-weight: normal;
}
}
.list {
margin-top: 26rpx;
max-height: 55vh;
overflow-y: auto;
&::-webkit-scrollbar{
display: none;
}
.item {
margin-bottom: 16rpx;
padding: 14rpx 32rpx;
font-size: 32rpx;
color: #283031;
line-height: 48rpx;
background-color: #f2f4f5;
border: 1px solid #f2f4f5;
border-radius: 16rpx;
&.active {
border-color: #67baca;
background-color: #e7f5f8;
color: #67baca;
}
}
}
.footer {
margin-top: 32rpx;
display: flex;
justify-content: space-between;
align-items: center;
gap: 26rpx;
text-align: center;
.cancel {
flex: 1;
height: 80rpx;
font-size: 36rpx;
color: #67BACA;
line-height: 80rpx;
background: #ffffff;
border-radius: 98rpx 98rpx 98rpx 98rpx;
border: 2rpx solid #67baca;
}
.submit {
flex: 1;
height: 80rpx;
font-size: 36rpx;
color: #FFFFFF;
line-height: 80rpx;
background: #67baca;
border-radius: 98rpx 98rpx 98rpx 98rpx;
border: 2rpx solid #67baca;
}
}
}

139
src/components/referralFrom/index.ts

@ -1,139 +0,0 @@ @@ -1,139 +0,0 @@
import dayjs from 'dayjs'
const _app = getApp<IAppOption>()
// pages/story/a.ts
Component({
/**
*
*/
properties: {
show: {
type: Boolean,
value: false,
},
params: {
type: Object,
value: undefined,
},
},
observers: {
show() {
if (this.data.params) {
this.setData({
...this.data.params,
})
this.handleDateChange()
} else {
this.setData({
visitDateName: '',
visitDate: '',
hormone: 2,
traditionalInhibitor: 2,
gammaGlobulin: 2,
plasmaExchange: 2,
bCellInhibitor: 2,
fcRnAntagonists: 2,
c5ComplementInhibitor: 2,
chineseMedicine: 2,
other: 2,
recordId: '',
})
}
},
},
data: {
currentDate: dayjs().format('YYYY-MM-DD'),
visitDateName: '',
visitDate: '',
hormone: 2,
traditionalInhibitor: 2,
gammaGlobulin: 2,
plasmaExchange: 2,
bCellInhibitor: 2,
fcRnAntagonists: 2,
c5ComplementInhibitor: 2,
chineseMedicine: 2,
other: 2,
recordId: '',
},
methods: {
handleDateChange() {
this.setData({
visitDateName: dayjs(this.data.visitDate).format('YYYY年MM月DD日'),
})
},
handleSelect(e) {
const { name } = e.currentTarget.dataset
const value = this.data[name]
this.setData({
[name]: value === 2 ? 1 : 2,
})
},
submit() {
const { visitDate, recordId } = this.data
const params = {
visitDate,
recordId,
}
if(!visitDate){
wx.showToast({
title: '请选择复诊日期',
icon: 'none',
})
return
}
const selectKeys = [
'hormone',
'traditionalInhibitor',
'gammaGlobulin',
'plasmaExchange',
'bCellInhibitor',
'fcRnAntagonists',
'c5ComplementInhibitor',
'chineseMedicine',
'other',
]
selectKeys.forEach((item) => {
params[item] = this.data[item]
})
const onlySelect = selectKeys.some((item) => {
return this.data[item] === 1
})
if (!onlySelect) {
wx.showToast({
title: '请至少选择一种复诊后的方案',
icon: 'none',
})
return
}
wx.ajax({
method: 'POST',
url: '?r=xd/re-visit/save-record',
data: params,
}).then(() => {
if (recordId) {
wx.showToast({
icon: 'none',
title: '编辑成功',
})
} else {
wx.showToast({
icon: 'none',
title: '添加成功',
})
}
this.handleCancel()
this.triggerEvent('refresh', params)
})
},
handleCancel() {
this.setData({
show: false,
})
},
},
})

52
src/components/referralFrom/index.wxml

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
<van-popup custom-style="background: transparent;" round z-index="{{100000}}" show="{{ show }}">
<view class="from">
<view class="title">您上一次复诊时间?</view>
<picker mode="date" model:value="{{visitDate}}" end="{{currentDate}}" bind:change="handleDateChange">
<view class="date">
<view class="content">{{visitDateName||'请选择'}}</view>
<view class="tril"></view>
</view>
</picker>
<view class="select-title">
您复诊后的方案是?
<text class="sub">(多选)</text>
</view>
<view class="list">
<view bind:tap="handleSelect" data-name="hormone" class="item {{hormone===1 && 'active'}}">1.激素</view>
<view
bind:tap="handleSelect"
data-name="traditionalInhibitor"
class="item {{traditionalInhibitor===1 && 'active'}}"
>
2.传统免疫抑制剂(如他克莫司、吗 替麦考酚酯等)
</view>
<view bind:tap="handleSelect" data-name="gammaGlobulin" class="item {{gammaGlobulin===1 && 'active'}}">
3.静脉输注丙种球蛋白
</view>
<view bind:tap="handleSelect" data-name="plasmaExchange" class="item {{plasmaExchange===1 && 'active'}}">
4.血浆置换
</view>
<view bind:tap="handleSelect" data-name="bCellInhibitor" class="item {{bCellInhibitor===1 && 'active'}}">
5.B细胞抑制剂(如:利妥昔单抗、泰 它西普、伊奈利珠单抗)
</view>
<view bind:tap="handleSelect" data-name="fcRnAntagonists" class="item {{fcRnAntagonists===1 && 'active'}}">
6.FcRn拮抗剂(如:艾加莫德)
</view>
<view
bind:tap="handleSelect"
data-name="c5ComplementInhibitor"
class="item {{c5ComplementInhibitor===1 && 'active'}}"
>
7.C5补体抑制剂(如:依库珠单抗)
</view>
<view bind:tap="handleSelect" data-name="chineseMedicine" class="item {{chineseMedicine===1 && 'active'}}">
8.中药或中成药
</view>
<view bind:tap="handleSelect" data-name="other" class="item {{other===1 && 'active'}}">9.其他</view>
</view>
<view class="footer">
<view class="cancel" bind:tap="handleCancel">取消</view>
<view class="submit" bind:tap="submit">确定</view>
</view>
</view>
</van-popup>

209
src/components/star/index.ts

@ -1,70 +1,70 @@ @@ -1,70 +1,70 @@
const app = getApp();
const app = getApp()
/**
* >=min && <=max
* @param min
* @param max
*/
function getRandom(min, max) {
return min + Math.floor(Math.random() * (max - min + 1));
return min + Math.floor(Math.random() * (max - min + 1))
}
Component({
options: {},
lifetimes: {
attached() {
const query = wx.createSelectorQuery().in(this);
const query = wx.createSelectorQuery().in(this)
query
.select("#thumsCanvas")
.select('#thumsCanvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node;
const context = canvas.getContext("2d");
const canvas = res[0].node
const context = canvas.getContext('2d')
this.setData({
context: context,
});
context,
})
const dpr = wx.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr;
this.data.width = res[0].width * dpr;
this.data.height = res[0].height * dpr;
const dpr = wx.getSystemInfoSync().pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
this.data.width = res[0].width * dpr
this.data.height = res[0].height * dpr
// context.fillStyle = "rgba(255, 255, 255, 0)";
const images = [
"za-images/star/icon1.png",
"za-images/star/icon2.png",
"za-images/star/icon3.png",
"za-images/star/icon4.png",
"za-images/star/icon5.png",
"za-images/star/icon6.png",
"za-images/star/icon7.png",
"za-images/star/icon8.png",
];
const promiseAll = [] as Array<Promise<any>>;
'za-images/star/icon1.png',
'za-images/star/icon2.png',
'za-images/star/icon3.png',
'za-images/star/icon4.png',
'za-images/star/icon5.png',
'za-images/star/icon6.png',
'za-images/star/icon7.png',
'za-images/star/icon8.png',
]
const promiseAll = [] as Array<Promise<any>>
images.forEach((src) => {
const p = new Promise(function (resolve) {
const img = canvas.createImage();
img.onerror = img.onload = resolve.bind(null, img);
img.src = app.globalData.imageUrl + src;
});
promiseAll.push(p);
});
const p = new Promise((resolve) => {
const img = canvas.createImage()
img.onerror = img.onload = resolve.bind(null, img)
img.src = app.globalData.imageUrl + src
})
promiseAll.push(p)
})
Promise.all(promiseAll).then((imgsList) => {
const imgsLists = imgsList.filter((d) => {
if (d && d.width > 0) return true;
return false;
});
if (d && d.width > 0)
return true
return false
})
this.setData({
imgsList: imgsLists,
});
})
if (this.data.imgsList.length == 0) {
// logger.error("imgsList load all error");
wx.showToast({
icon: "none",
title: "imgsList load all error",
});
return;
icon: 'none',
title: 'imgsList load all error',
})
}
});
});
})
})
},
},
properties: {},
@ -79,98 +79,105 @@ Component({ @@ -79,98 +79,105 @@ Component({
},
methods: {
handleTap() {
this.start();
this.start()
},
createRender() {
if (this.data.imgsList.length == 0) return null;
const basicScale = [0.6, 0.9, 1.2][getRandom(0, 2)];
if (this.data.imgsList.length == 0)
return null
const basicScale = [0.6, 0.9, 1.2][getRandom(0, 2)]
const getScale = (diffTime) => {
if (diffTime < this.data.scaleTime) {
return +(diffTime / this.data.scaleTime).toFixed(2) * basicScale;
} else {
return basicScale;
return +(diffTime / this.data.scaleTime).toFixed(2) * basicScale
}
};
const context = this.data.context;
else {
return basicScale
}
}
const context = this.data.context
// 随机读取一个图片来渲染
const image: any = this.data.imgsList[getRandom(0, this.data.imgsList.length - 1)];
const offset = 20;
const basicX = this.data.width / 2 + getRandom(-offset, offset);
const angle = getRandom(2, 10);
let ratio = getRandom(10, 30) * (getRandom(0, 1) ? 1 : -1);
const image: any = this.data.imgsList[getRandom(0, this.data.imgsList.length - 1)]
const offset = 20
const basicX = this.data.width / 2 + getRandom(-offset, offset)
const angle = getRandom(2, 10)
const ratio = getRandom(10, 30) * (getRandom(0, 1) ? 1 : -1)
const getTranslateX = (diffTime) => {
if (diffTime < this.data.scaleTime) {
// 放大期间,不进行摇摆位移
return basicX;
} else {
return basicX + ratio * Math.sin(angle * (diffTime - this.data.scaleTime));
return basicX
}
else {
return basicX + ratio * Math.sin(angle * (diffTime - this.data.scaleTime))
}
};
}
const getTranslateY = (diffTime) => {
return image.height / 2 + (this.data.height - image.height / 2) * (1 - diffTime);
};
return image.height / 2 + (this.data.height - image.height / 2) * (1 - diffTime)
}
const fadeOutStage = getRandom(14, 18) / 100;
const fadeOutStage = getRandom(14, 18) / 100
const getAlpha = (diffTime) => {
let left = 1 - +diffTime;
const left = 1 - +diffTime
if (left > fadeOutStage) {
return 1;
} else {
return 1 - +((fadeOutStage - left) / fadeOutStage).toFixed(2);
return 1
}
};
else {
return 1 - +((fadeOutStage - left) / fadeOutStage).toFixed(2)
}
}
return (diffTime) => {
// 差值满了,即结束了 0 ---》 1
if (diffTime >= 1) return true;
context.save();
const scale = getScale(diffTime);
if (diffTime >= 1)
return true
context.save()
const scale = getScale(diffTime)
// const rotate = getRotate();
const translateX = getTranslateX(diffTime);
const translateY = getTranslateY(diffTime);
context.translate(translateX, translateY);
context.scale(scale, scale);
const translateX = getTranslateX(diffTime)
const translateY = getTranslateY(diffTime)
context.translate(translateX, translateY)
context.scale(scale, scale)
// context.rotate(rotate * Math.PI / 180);
context.globalAlpha = getAlpha(diffTime);
context.drawImage(image, -image.width / 2, -image.height / 2, image.width, image.height);
context.restore();
};
context.globalAlpha = getAlpha(diffTime)
context.drawImage(image, -image.width / 2, -image.height / 2, image.width, image.height)
context.restore()
}
},
scan() {
this.data.context.clearRect(0, 0, this.data.width, this.data.height);
this.data.context.fillStyle = "rgba(255, 255, 255, 0)";
this.data.context.fillRect(0, 0, 200, 400);
let index = 0;
let length = this.data.renderList.length;
this.data.context.clearRect(0, 0, this.data.width, this.data.height)
this.data.context.fillStyle = 'rgba(255, 255, 255, 0)'
this.data.context.fillRect(0, 0, 200, 400)
let index = 0
let length = this.data.renderList.length
if (length > 0) {
this.requestFrame(this.scan.bind(this));
this.requestFrame(this.scan.bind(this))
this.setData({
scanning: true,
});
} else {
})
}
else {
this.setData({
scanning: false,
});
})
}
while (index < length) {
const child = this.data.renderList[index];
const child = this.data.renderList[index]
if (!child || !child.render || child.render.call(null, (Date.now() - child.timestamp) / child.duration)) {
// 结束了,删除该动画
this.setData({
renderList: [...this.data.renderList].filter((_item, fIndex) => fIndex != index),
});
length--;
} else {
})
length--
}
else {
// continue
index++;
index++
}
}
},
start() {
const render = this.createRender();
const duration = getRandom(1500, 3000);
const render = this.createRender()
const duration = getRandom(1500, 3000)
this.setData({
renderList: [
...this.data.renderList,
@ -180,25 +187,25 @@ Component({ @@ -180,25 +187,25 @@ Component({
timestamp: Date.now(),
},
],
});
})
if (!this.data.scanning) {
this.setData({
scanning: true,
});
})
this.requestFrame(this.scan.bind(this));
this.requestFrame(this.scan.bind(this))
// this.scan.bind(this)();
}
return this;
return this
},
requestFrame(cb) {
return (
this.data.context.requestAnimationFrame ||
(function (callback) {
setTimeout(callback, 1000 / 60);
this.data.context.requestAnimationFrame
|| (function (callback) {
setTimeout(callback, 1000 / 60)
})(cb)
);
)
},
},
});
})

8
src/components/text-expandsion/index.scss

@ -10,13 +10,13 @@ @@ -10,13 +10,13 @@
max-height: 9em;
text-align: justify;
&::before {
content: "";
content: '';
float: right;
height: 100%;
margin-bottom: -40rpx;
}
&::after {
content: "";
content: '';
width: 100vw;
height: 100vh;
position: absolute;
@ -32,11 +32,11 @@ @@ -32,11 +32,11 @@
clear: both;
line-height: 42rpx;
&::before {
content: "...";
content: '...';
margin-right: 8rpx;
}
&::after {
content: "";
content: '';
display: inline-block;
margin-bottom: 2rpx;
margin-left: 4rpx;

50
src/components/timeOut/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>();
const app = getApp<IAppOption>()
// pages/story/a.ts
Component({
@ -8,7 +8,7 @@ Component({ @@ -8,7 +8,7 @@ Component({
properties: {
detailId: {
type: String,
value: "0",
value: '0',
},
asideOut: {
type: Boolean,
@ -16,7 +16,7 @@ Component({ @@ -16,7 +16,7 @@ Component({
},
asideType: {
type: String,
value: "",
value: '',
},
timeToast: {
type: Boolean,
@ -24,33 +24,34 @@ Component({ @@ -24,33 +24,34 @@ Component({
},
timeToastType: {
type: String,
value: "",
value: '',
},
timeToastParams: {
type: Object,
value() {
return {};
return {}
},
},
},
observers: {
asideOut: function (asideOut) {
asideOut(asideOut) {
if (asideOut) {
setTimeout(() => {
this.countDown();
}, 1000);
this.countDown()
}, 1000)
}
},
},
lifetimes: {
attached() {
let systemInfo = wx.getSystemInfoSync();
const systemInfo = wx.getSystemInfoSync()
this.setData({
sliderTop: systemInfo.screenHeight - 250,
});
})
},
detached() {
if (this.timer) clearInterval(this.timer);
if (this.timer)
clearInterval(this.timer)
},
},
data: {
@ -66,25 +67,26 @@ Component({ @@ -66,25 +67,26 @@ Component({
methods: {
timer: null as any,
countDown() {
const that = this;
if (that.timer) return;
let circle = 100;
const that = this
if (that.timer)
return
let circle = 100
that.timer = setInterval(() => {
circle--;
circle--
that.setData({
circleVal: circle,
centerVal: Math.floor(circle / 10),
});
})
if (circle <= 0) {
clearInterval(that.timer);
this.handleAsideOut();
clearInterval(that.timer)
this.handleAsideOut()
}
}, 100);
}, 100)
},
handleAsideOut() {
wx.ajax({
method: "POST",
url: "?r=xd/score/send-score",
method: 'POST',
url: '?r=xd/score/send-score',
data: {
Type: this.data.asideType,
Id: this.data.detailId,
@ -93,9 +95,9 @@ Component({ @@ -93,9 +95,9 @@ Component({
if (!Array.isArray(res)) {
this.setData({
rewardScore: res.rewardScore,
});
})
}
});
})
},
},
});
})

143
src/components/toast/index.scss

@ -4,6 +4,14 @@ @@ -4,6 +4,14 @@
justify-content: center;
}
.popup-close {
margin: 40rpx auto;
display: block;
font-size: 80rpx;
color: #fff;
text-align: center;
}
.popup {
position: relative;
z-index: 9999999999;
@ -2620,7 +2628,7 @@ @@ -2620,7 +2628,7 @@
width: 364rpx;
height: 84rpx;
font-size: 36rpx;
color: #FFFFFF;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
@ -2631,3 +2639,136 @@ @@ -2631,3 +2639,136 @@
}
}
}
.popup-medical-guide {
margin-bottom: -120rpx;
.popup-container {
.container {
padding: 424rpx 0 0;
width: 750rpx;
height: 800rpx;
box-sizing: border-box;
.tip {
font-size: 40rpx;
color: #b982ff;
text-align: center;
}
.btn {
margin: 42rpx auto 0;
width: 526rpx;
height: 88rpx;
font-size: 40rpx;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx;
}
}
}
}
.popup-question-toast {
.popup-container {
padding: 48rpx 0 68rpx;
background: linear-gradient(180deg, #f1e6ff 0%, #ffffff 12.03%, #ffffff 100%);
border-radius: 32rpx 32rpx 32rpx 32rpx;
border: 2rpx solid #ffffff;
width: 670rpx;
box-sizing: border-box;
.title {
font-size: 44rpx;
color: #b982ff;
line-height: 48rpx;
text-align: center;
font-weight: bold;
}
.scroll {
margin-top: 32rpx;
padding: 0 50rpx;
font-size: 36rpx;
color: #211d2e;
line-height: 60rpx;
height: 716rpx;
overflow-y: auto;
}
}
}
.popup-enter-info {
.badge {
position: relative;
z-index: 1;
display: block;
width: 200rpx;
height: 224rpx;
margin: 0 auto -140rpx;
text-align: center;
}
.popup-container {
width: 670rpx;
position: relative;
box-sizing: border-box;
padding: 148rpx 24rpx 56rpx;
border-radius: 32rpx;
background: linear-gradient(180deg, #f1e6ff 0%, #ffffff 29.75%, #ffffff 100%);
text-align: center;
.p-close {
position: absolute;
right: 22rpx;
top: 22rpx;
font-size: 38rpx;
color: #adacb2;
}
.title {
font-size: 40rpx;
color: #211d2e;
font-weight: bold;
}
.content {
margin-top: 28rpx;
font-size: 32rpx;
color: #adacb2;
line-height: 48rpx;
.high {
color: #b982ff;
}
}
.btn {
margin: 32rpx 30rpx 0;
height: 88rpx;
line-height: 88rpx;
text-align: center;
font-size: 36rpx;
color: #ffffff;
background: linear-gradient(344deg, #ffbcf9 0%, #b982ff 100%);
border-radius: 100rpx;
}
}
}
.popup-qw {
.popup-container {
width: 630rpx;
height: 802rpx;
overflow: hidden;
.code {
margin: 342rpx auto 0;
display: block;
width: 264rpx;
height: 264rpx;
}
}
}
.popup-note-guide {
.popup-container {
.guide {
margin: 0 auto 62rpx;
display: block;
width: 660rpx;
height: 673rpx;
}
}
}

72
src/components/toast/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp();
const app = getApp()
Component({
properties: {
show: {
@ -9,7 +9,7 @@ Component({ @@ -9,7 +9,7 @@ Component({
params: {
type: Object,
value() {
return {};
return {}
},
},
},
@ -19,37 +19,37 @@ Component({ @@ -19,37 +19,37 @@ Component({
app.zdGetTheme().then((res) => {
this.setData({
theme: res,
});
});
})
})
if (this.data.params.timeOut) {
let time = this.data.params.timeOut;
let time = this.data.params.timeOut
const timerFunc = () => {
if (time <= 0) {
this.setData({
timeOut: '',
});
clearInterval(this.timer);
return;
})
clearInterval(this.timer)
return
}
this.setData({
timeOut: `${time}s`,
});
--time;
};
timerFunc();
this.timer = setInterval(timerFunc, 1000);
})
--time
}
timerFunc()
this.timer = setInterval(timerFunc, 1000)
}
if (['storyLead', 'storyStar', 'storyShare'].includes(this.data.type)) {
this.getSettingInfo();
this.getSettingInfo()
}
}
this.setData({
zdUserInfo: app.globalData.zdUserInfo,
});
})
},
type(val) {
if (val === 'healthCare') {
this.getOpenPatientList();
this.getOpenPatientList()
}
},
},
@ -66,42 +66,42 @@ Component({ @@ -66,42 +66,42 @@ Component({
this.setData({
imageUrl: app.globalData.imageUrl,
Timestamp: app.globalData.Timestamp,
});
})
},
},
methods: {
timer: null as any,
handleOk() {
if (this.data.timeOut) {
return;
return
}
this.triggerEvent('ok', { protocol: this.data.protocol });
this.triggerEvent('ok', { protocol: this.data.protocol })
},
handleCancel(e = { currentTarget: { dataset: { key: '' } } }) {
const { key } = e.currentTarget.dataset;
const { key } = e.currentTarget.dataset
if (this.timer) {
clearInterval(this.timer);
clearInterval(this.timer)
this.setData({
timeOut: '',
});
})
}
this.triggerEvent('cancel', { key });
this.triggerEvent('cancel', { key })
},
handleTaskCancel() {
this.triggerEvent('taskCancel');
this.triggerEvent('taskCancel')
},
handleJump() {
this.triggerEvent('jump');
this.triggerEvent('jump')
},
handleDel() {
this.triggerEvent('del');
this.triggerEvent('del')
},
routerTo(e) {
const { path } = e.currentTarget.dataset;
const { path } = e.currentTarget.dataset
wx.navigateTo({
url: path,
});
this.handleCancel();
})
this.handleCancel()
},
getSettingInfo() {
wx.ajax({
@ -111,8 +111,8 @@ Component({ @@ -111,8 +111,8 @@ Component({
}).then((res) => {
this.setData({
settingsInfo: res,
});
});
})
})
},
getOpenPatientList() {
wx.ajax({
@ -122,18 +122,18 @@ Component({ @@ -122,18 +122,18 @@ Component({
}).then((res) => {
this.setData({
openPatientList: res,
});
});
})
})
},
handleProtocolChange() {
this.setData({
protocol: !this.data.protocol,
});
})
},
handleAdlQuestion() {
wx.navigateTo({
url: '/pages/repositoryDetail/index?id=9',
});
})
},
},
});
})

65
src/components/toast/index.wxml

@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
round
z-index="{{100000}}"
show="{{ show }}"
position="{{params.position || 'center'}}"
safe-area-inset-bottom="{{false}}"
>
<view class="popup-class" wx:if="{{type=='videoComplate'}}">
<image class="bg" src="{{imageUrl}}za-images/popup-class-bg.png?t={{Timestamp}}"></image>
@ -790,4 +792,67 @@ @@ -790,4 +792,67 @@
</view>
</view>
</view>
<view class="popup-medical-guide" wx:if="{{type == 'medical-guide'}}">
<view class="popup-container">
<view class="container" style="background: url('{{imageUrl}}bg43.png?t={{Timestamp}}') no-repeat top center/100%">
<view class="tip">医保政策轻松查询</view>
<view class="btn" bind:tap="handleOk">立即查询</view>
</view>
</view>
</view>
<view class="popup-question-toast" wx:if="{{type == 'question-toast'}}">
<view class="popup-container">
<view class="title">{{params.title}}</view>
<view class="scroll" wx:if="{{params.type==1}}">
GO-QOL生活质量量表,是《中国甲状腺相关眼病诊断和治疗指南(2022年)》中提及的唯一可居家自测的甲状腺眼病评估量表,反映了疾病对患者生活质量的影响。得分越低影响越大,让患者主观感受清晰可见。
</view>
<view class="scroll" wx:elif="{{params.type==2}}">
《中国甲状腺相关眼病诊断和治疗指南(2022年)》指出,剂量越高短期效果可能越好,但不良反应也会更大,并且同一疗程需严格控制累积剂量。
且风险与用药剂量和用药时间相关。
<view></view>
规范记录每次用药时间、剂量与不适反应,可帮助及时发现风险线索,便于医生综合评估疗效与安全性并调整方案;这是用药安全管理的关键一步。
</view>
</view>
</view>
<view class="popup-enter-info" wx:if="{{type==='guideEnterInfo'}}">
<image class="badge" src="{{imageUrl}}icon133.png?t={{Timestamp}}"></image>
<view class="popup-container">
<van-icon class="p-close" name="cross" bind:tap="handleCancel" />
<view class="title">完善个人信息</view>
<view class="content">
完善个人信息,可获得
<text class="high">【医生】</text>
更多关注
</view>
<view class="btn" bind:tap="handleOk">确认</view>
</view>
</view>
<view class="popup-enter-info" wx:if="{{type==='guideEnterInfoJump'}}">
<image class="badge" src="{{imageUrl}}icon133.png?t={{Timestamp}}"></image>
<view class="popup-container">
<van-icon class="p-close" name="cross" bind:tap="handleCancel" />
<view class="title">完善个人信息</view>
<view class="content">
完善个人信息,可获得
<text class="high">【医生】</text>
更多关注
</view>
<view class="btn" bind:tap="handleOk">确认</view>
</view>
</view>
<view class="popup-qw" wx:if="{{type==='guideQw'}}">
<view
class="popup-container"
style="background: url('{{imageUrl}}bg49.png?t={{Timestamp}}') no-repeat top center/100%"
>
<image class="code" src="{{params.ConsultQwImg}}" show-menu-by-longpress></image>
</view>
</view>
<view class="popup-note-guide" wx:if="{{type==='noteGuide'}}">
<view class="popup-container" bind:tap="handleCancel">
<image class="guide" src="{{imageUrl}}bg59.png?t={{Timestamp}}"></image>
</view>
</view>
<van-icon wx:if="{{params.close}}" class="popup-close" bind:tap="handleCancel" name="close" />
</van-popup>

87
src/components/uploadFile/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>();
const app = getApp<IAppOption>()
// pages/story/a.ts
Component({
@ -32,17 +32,17 @@ Component({ @@ -32,17 +32,17 @@ Component({
*/
methods: {
GetExtensionFileName(pathfilename) {
const reg = /(\\+)/g;
const pString = pathfilename.replace(reg, '#'); //用正则表达式来将\或\\替换成#
const arr = pString.split('#'); // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png
const lastString = arr[arr.length - 1]; //取最后一个字符
const arr2 = lastString.split('.'); // 再以"."作为分隔符
return arr2[arr2.length - 1]; //将后缀名返回出来
const reg = /(\\+)/g
const pString = pathfilename.replace(reg, '#') // 用正则表达式来将\或\\替换成#
const arr = pString.split('#') // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png
const lastString = arr[arr.length - 1] // 取最后一个字符
const arr2 = lastString.split('.') // 再以"."作为分隔符
return arr2[arr2.length - 1] // 将后缀名返回出来
},
handleAfterRead(e) {
this.uploadFile(e.detail.file).then((res) => {
this.triggerEvent('file', res as object);
});
this.triggerEvent('file', res as object)
})
},
handleChooseAvatar(e) {
this.uploadFile({
@ -50,8 +50,8 @@ Component({ @@ -50,8 +50,8 @@ Component({
tempFilePath: e.detail.avatarUrl,
size: 0,
}).then((res) => {
this.triggerEvent('file', res as object);
});
this.triggerEvent('file', res as object)
})
},
handleChooseFile() {
wx.chooseMessageFile({
@ -63,41 +63,44 @@ Component({ @@ -63,41 +63,44 @@ Component({
fileType: res.tempFiles[0].type,
tempFilePath: res.tempFiles[0].path,
}).then((res) => {
this.triggerEvent('file', res as object);
});
this.triggerEvent('file', res as object)
})
},
fail() {
wx.showToast({
icon: 'none',
title: '取消选择',
});
})
},
});
})
},
uploadFile(item) {
wx.showLoading({
title: '正在上传',
});
})
return new Promise((resolve, reject) => {
let url = `${app.globalData.upFileUrl}?r=file-service/upload-`;
let url = `${app.globalData.upFileUrl}?r=file-service/upload-`
if (item.fileType === 'image') {
url += 'img';
} else if (item.fileType === 'video' || item.type === 'video') {
url += 'video';
item.tempFilePath = item.url;
} else if (item.fileType === 'audio') {
url += 'audio';
} else {
url += 'doc';
url += 'img'
}
else if (item.fileType === 'video' || item.type === 'video') {
url += 'video'
item.tempFilePath = item.url
}
else if (item.fileType === 'audio') {
url += 'audio'
}
else {
url += 'doc'
}
wx.uploadFile({
filePath: item.tempFilePath,
name: 'file',
url,
success: (res) => {
wx.hideLoading();
const data = JSON.parse(res.data);
const suffix = this.GetExtensionFileName(data.data.Url);
wx.hideLoading()
const data = JSON.parse(res.data)
const suffix = this.GetExtensionFileName(data.data.Url)
const expandJson = {
fileId: '',
name: item.name || `病历相关文件.${suffix}`,
@ -109,24 +112,26 @@ Component({ @@ -109,24 +112,26 @@ Component({
duration: 0,
videoUrl: '',
hash: '',
};
}
if (item.fileType === 'image') {
expandJson.imgUrl = data.data.Url;
} else if (item.fileType === 'video' || item.type === 'video') {
expandJson.imgUrl = data.data.SnapshotUrl;
} else if (item.fileType === 'audio') {
expandJson.duration = Number.parseInt(String(item.duration / 1000));
expandJson.imgUrl = data.data.Url
}
else if (item.fileType === 'video' || item.type === 'video') {
expandJson.imgUrl = data.data.SnapshotUrl
}
else if (item.fileType === 'audio') {
expandJson.duration = Number.parseInt(String(item.duration / 1000))
}
resolve(expandJson);
resolve(expandJson)
},
fail() {
wx.hideLoading();
reject(new Error('上传失败'));
wx.hideLoading()
reject(new Error('上传失败'))
},
});
});
})
})
},
},
});
})
export {};
export {}

28
src/components/viewFile/index.js

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// components/viewFile/index.js
const app = getApp();
const app = getApp()
Component({
/**
* 组件的属性列表
@ -25,7 +25,7 @@ Component({ @@ -25,7 +25,7 @@ Component({
* 组件的初始数据
*/
data: {
Timestamp: app.globalData.Timestamp,
Timestamp: app.globalData.Timestamp,
imageUrl: app.globalData.imageUrl,
},
@ -34,28 +34,28 @@ Component({ @@ -34,28 +34,28 @@ Component({
*/
methods: {
deleteFile(e) {
const { index, item } = e.currentTarget.dataset;
this.triggerEvent("deleteFile", {
const { index, item } = e.currentTarget.dataset
this.triggerEvent('deleteFile', {
index,
item,
});
})
},
viewFile(e) {
const { index } = e.currentTarget.dataset;
const { fileList } = this.properties;
let sources = [];
const { index } = e.currentTarget.dataset
const { fileList } = this.properties
const sources = []
fileList.map((e) => {
const obj = {
url: e.fileUrl,
type: e.type, // image video
poster: e.imgUrl,
};
sources.push(obj);
});
}
sources.push(obj)
})
wx.previewMedia({
current: index,
sources: sources,
});
sources,
})
},
},
});
})

2
src/components/viewFile/index.json

@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
"usingComponents": {
"van-icon": "@vant/weapp/icon/index"
}
}
}

7
src/components/viewVideo/index.scss

@ -27,9 +27,10 @@ @@ -27,9 +27,10 @@
align-items: center;
flex-direction: row-reverse;
background: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 0%, #000000 100%);
>view,>image{
margin-right: 32rpx;
};
> view,
> image {
margin-right: 32rpx;
}
transition: all 0.8s;
.time {
font-size: 24rpx;

228
src/components/zd-navBar/navBar.js

@ -1,35 +1,35 @@ @@ -1,35 +1,35 @@
const app = getApp();
const app = getApp()
Component({
options: {
multipleSlots: true,
addGlobalClass: true,
},
properties: {
slotLeft:{
type:Boolean,
value:false,
slotLeft: {
type: Boolean,
value: false,
},
extClass: {
type: String,
value: "",
value: '',
},
background: {
type: String,
value: "transparent",
observer: "_showChange",
value: 'transparent',
observer: '_showChange',
},
backgroundColorTop: {
type: String,
value: "transparent",
observer: "_showChangeBackgroundColorTop",
value: 'transparent',
observer: '_showChangeBackgroundColorTop',
},
color: {
type: String,
value: "#000000",
value: '#000000',
},
title: {
type: String,
value: "",
value: '',
},
back: {
type: Boolean,
@ -41,7 +41,7 @@ Component({ @@ -41,7 +41,7 @@ Component({
},
iconTheme: {
type: String,
value: "nuohe",
value: 'nuohe',
},
/* animated: {
type: Boolean,
@ -61,11 +61,11 @@ Component({ @@ -61,11 +61,11 @@ Component({
value: false,
},
},
created: function () {
this.getSystemInfo();
created() {
this.getSystemInfo()
},
attached: function () {
this.setStyle(); //设置样式
attached() {
this.setStyle() // 设置样式
},
data: {
imageUrl: app.globalData.imageUrl,
@ -73,50 +73,52 @@ Component({ @@ -73,50 +73,52 @@ Component({
isHome: false,
},
pageLifetimes: {
show: function () {
show() {
if (getApp().globalSystemInfo.ios) {
this.getSystemInfo();
this.setStyle(); //设置样式1
this.getSystemInfo()
this.setStyle() // 设置样式1
}
let pages = getCurrentPages();
const pages = getCurrentPages()
this.setData({
isHome: !pages[pages.length - 2],
});
})
},
hide: function () {},
hide() {},
},
methods: {
setStyle: function (life) {
const { statusBarHeight, navBarHeight, capsulePosition, navBarExtendHeight, ios, windowWidth } =
getApp().globalSystemInfo;
const { back, home, title } = this.data;
let rightDistance = windowWidth - capsulePosition.right; //胶囊按钮右侧到屏幕右侧的边距
let leftWidth = windowWidth - capsulePosition.left; //胶囊按钮左侧到屏幕右侧的边距
setStyle(life) {
const { statusBarHeight, navBarHeight, capsulePosition, navBarExtendHeight, ios, windowWidth }
= getApp().globalSystemInfo
const { back, home, title } = this.data
const rightDistance = windowWidth - capsulePosition.right // 胶囊按钮右侧到屏幕右侧的边距
const leftWidth = windowWidth - capsulePosition.left // 胶囊按钮左侧到屏幕右侧的边距
this.setData({
leftWidth: leftWidth,
});
leftWidth,
})
let navigationbarinnerStyle = [
const navigationbarinnerStyle = [
`color: ${this.data.color}`,
`background: ${this.data.background}`,
`height:${navBarHeight + navBarExtendHeight}px`,
`padding-top:${statusBarHeight}px`,
`padding-right:${leftWidth}px`,
`padding-bottom:${navBarExtendHeight}px`,
].join(";");
let navBarLeft = [];
].join(';')
let navBarLeft = []
if ((back && !home) || (!back && home)) {
navBarLeft = [`width:${capsulePosition.width}px`, `height:${capsulePosition.height}px`].join(";");
} else if ((back && home) || title) {
navBarLeft = [`width:${capsulePosition.width}px`, `height:${capsulePosition.height}px`].join(';')
}
else if ((back && home) || title) {
navBarLeft = [
`width:${capsulePosition.width}px`,
`height:${capsulePosition.height}px`,
`margin-left:${rightDistance}px`,
].join(";");
} else {
navBarLeft = [`width:auto`, `margin-left:0px`].join(";");
].join(';')
}
else {
navBarLeft = [`width:auto`, `margin-left:0px`].join(';')
}
if (life === "created") {
if (life === 'created') {
this.data = {
navigationbarinnerStyle,
navBarLeft,
@ -124,8 +126,9 @@ Component({ @@ -124,8 +126,9 @@ Component({
capsulePosition,
navBarExtendHeight,
ios,
};
} else {
}
}
else {
this.setData({
navigationbarinnerStyle,
navBarLeft,
@ -133,118 +136,125 @@ Component({ @@ -133,118 +136,125 @@ Component({
capsulePosition,
navBarExtendHeight,
ios,
});
})
}
},
_showChange: function (value) {
this.setStyle();
_showChange(value) {
this.setStyle()
},
// 返回事件
back: function () {
let pages = getCurrentPages();
back() {
const pages = getCurrentPages()
if (app.globalData.backPage) {
wx.reLaunch({
url: app.globalData.backPage,
});
app.globalData.backPage = null;
return;
})
app.globalData.backPage = null
return
}
if (!pages[pages.length - 2] && !app.globalData.anyWhere) {
wx.reLaunch({
url: "/pages/index/index",
});
return;
url: '/pages/index/index',
})
return
}
this.triggerEvent("back", { delta: this.data.delta });
this.triggerEvent('back', { delta: this.data.delta })
},
home: function () {
home() {
wx.reLaunch({
url: "/pages/start/index",
});
url: '/pages/start/index',
})
},
search: function () {
this.triggerEvent("search", {});
search() {
this.triggerEvent('search', {})
},
getSystemInfo() {
var app = getApp();
const app = getApp()
if (app.globalSystemInfo && !app.globalSystemInfo.ios) {
return app.globalSystemInfo;
} else {
let systemInfo = wx.getSystemInfoSync();
let ios = !!(systemInfo.system.toLowerCase().search("ios") + 1);
let rect;
return app.globalSystemInfo
}
else {
const systemInfo = wx.getSystemInfoSync()
const ios = !!(systemInfo.system.toLowerCase().search('ios') + 1)
let rect
try {
rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null;
rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null
if (rect === null) {
throw "getMenuButtonBoundingClientRect error";
throw 'getMenuButtonBoundingClientRect error'
}
//取值为0的情况 有可能width不为0 top为0的情况
// 取值为0的情况 有可能width不为0 top为0的情况
if (!rect.width || !rect.top || !rect.left || !rect.height) {
throw "getMenuButtonBoundingClientRect error";
throw 'getMenuButtonBoundingClientRect error'
}
} catch (error) {
let gap = ""; //胶囊按钮上下间距 使导航内容居中
let width = 96; //胶囊的宽度
if (systemInfo.platform === "android") {
gap = 8;
width = 96;
} else if (systemInfo.platform === "devtools") {
}
catch (error) {
let gap = '' // 胶囊按钮上下间距 使导航内容居中
let width = 96 // 胶囊的宽度
if (systemInfo.platform === 'android') {
gap = 8
width = 96
}
else if (systemInfo.platform === 'devtools') {
if (ios) {
gap = 5.5; //开发工具中ios手机
} else {
gap = 7.5; //开发工具中android和其它手机
gap = 5.5 // 开发工具中ios手机
}
} else {
gap = 4;
width = 88;
else {
gap = 7.5 // 开发工具中android和其它手机
}
}
else {
gap = 4
width = 88
}
if (!systemInfo.statusBarHeight) {
//开启wifi的情况下修复statusBarHeight值获取不到
systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
// 开启wifi的情况下修复statusBarHeight值获取不到
systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20
}
rect = {
//获取不到胶囊信息就自定义重置一个
// 获取不到胶囊信息就自定义重置一个
bottom: systemInfo.statusBarHeight + gap + 32,
height: 32,
left: systemInfo.windowWidth - width - 10,
right: systemInfo.windowWidth - 10,
top: systemInfo.statusBarHeight + gap,
width: width,
};
console.log("error", error);
console.log("rect", rect);
width,
}
console.log('error', error)
console.log('rect', rect)
}
let navBarHeight = "";
let navBarHeight = ''
if (!systemInfo.statusBarHeight) {
systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20
navBarHeight = (function () {
let gap = rect.top - systemInfo.statusBarHeight;
return 2 * gap + rect.height;
})();
const gap = rect.top - systemInfo.statusBarHeight
return 2 * gap + rect.height
})()
systemInfo.statusBarHeight = 0;
systemInfo.navBarExtendHeight = 0; //下方扩展4像素高度 防止下方边距太小
} else {
systemInfo.statusBarHeight = 0
systemInfo.navBarExtendHeight = 0 // 下方扩展4像素高度 防止下方边距太小
}
else {
navBarHeight = (function () {
let gap = rect.top - systemInfo.statusBarHeight;
return systemInfo.statusBarHeight + 2 * gap + rect.height;
})();
const gap = rect.top - systemInfo.statusBarHeight
return systemInfo.statusBarHeight + 2 * gap + rect.height
})()
if (ios) {
systemInfo.navBarExtendHeight = 4; //下方扩展4像素高度 防止下方边距太小
} else {
systemInfo.navBarExtendHeight = 0;
systemInfo.navBarExtendHeight = 4 // 下方扩展4像素高度 防止下方边距太小
}
else {
systemInfo.navBarExtendHeight = 0
}
}
systemInfo.navBarHeight = navBarHeight; //导航栏高度不包括statusBarHeight
systemInfo.capsulePosition = rect; //右上角胶囊按钮信息bottom: 58 height: 32 left: 317 right: 404 top: 26 width: 87 目前发现在大多机型都是固定值 为防止不一样所以会使用动态值来计算nav元素大小
systemInfo.ios = ios; //是否ios
systemInfo.navBarHeight = navBarHeight // 导航栏高度不包括statusBarHeight
systemInfo.capsulePosition = rect // 右上角胶囊按钮信息bottom: 58 height: 32 left: 317 right: 404 top: 26 width: 87 目前发现在大多机型都是固定值 为防止不一样所以会使用动态值来计算nav元素大小
systemInfo.ios = ios // 是否ios
app.globalSystemInfo = systemInfo; //将信息保存到全局变量中,后边再用就不用重新异步获取了
app.globalSystemInfo = systemInfo // 将信息保存到全局变量中,后边再用就不用重新异步获取了
//console.log('systemInfo', systemInfo);
return systemInfo;
// console.log('systemInfo', systemInfo);
return systemInfo
}
},
},
});
})

2
src/components/zd-navBar/navBar.scss

@ -75,7 +75,7 @@ page { @@ -75,7 +75,7 @@ page {
}
.lxy-nav-bar__buttons::after {
position: absolute;
content: "";
content: '';
width: 1rpx;
height: 18.4px;
background: rgba(204, 204, 204, 0.6);

164
src/components/zdUploadFile/index.js

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// components/uploadFile/index.js
const app = getApp();
const app = getApp()
Component({
/**
* 组件的属性列表
@ -17,17 +17,17 @@ Component({ @@ -17,17 +17,17 @@ Component({
},
accept: {
type: String,
value: "media",
value: 'media',
},
fileTypes: {
// 上传类型
type: Array,
value: ["image", "video"],
value: ['image', 'video'],
},
// 拍照和相机
sourceType: {
type: Array,
value: ["album", "camera"],
value: ['album', 'camera'],
},
// 是否可以删除
canDelete: {
@ -67,62 +67,64 @@ Component({ @@ -67,62 +67,64 @@ Component({
*/
methods: {
viewFile(e) {
const { index } = e.currentTarget.dataset;
const { fileList } = this.properties;
let sources = [];
const { index } = e.currentTarget.dataset
const { fileList } = this.properties
const sources = []
fileList.map((e) => {
const obj = {
url: e.fileUrl,
type: e.type, // image video
poster: e.imgUrl,
};
sources.push(obj);
});
}
sources.push(obj)
})
wx.previewMedia({
current: index,
sources: sources,
});
sources,
})
},
deleteFile(e) {
const { index, item } = e.currentTarget.dataset;
this.triggerEvent("deleteFile", {
const { index, item } = e.currentTarget.dataset
this.triggerEvent('deleteFile', {
index,
item,
});
})
},
downFile(e) {
const { item } = e.currentTarget.dataset;
const { item } = e.currentTarget.dataset
wx.showToast({
title: "正在下载,请稍后...",
icon: "none",
});
title: '正在下载,请稍后...',
icon: 'none',
})
wx.downloadFile({
url: item.fileUrl,
success(res) {
if (item.type === "image") {
if (item.type === 'image') {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
wx.showToast({
title: "下载成功",
});
title: '下载成功',
})
},
});
} else if (item.type === "video") {
})
}
else if (item.type === 'video') {
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
wx.showToast({
title: "下载成功",
});
title: '下载成功',
})
},
});
} else {
})
}
else {
wx.showToast({
title: "附件请到pc端下载!",
icon: "none",
});
title: '附件请到pc端下载!',
icon: 'none',
})
// wx.saveFile({
// tempFilePath: res.tempFilePath,
// success: () => {
@ -136,96 +138,96 @@ Component({ @@ -136,96 +138,96 @@ Component({
// })
}
},
});
})
},
uploadFile(item) {
return new Promise((resolve, resject) => {
let url = `${app.globalData.upFileUrl}?r=file-service/upload-`;
if (item.fileType === "image") {
url += "img";
let url = `${app.globalData.upFileUrl}?r=file-service/upload-`
if (item.fileType === 'image') {
url += 'img'
}
if (item.fileType === "video") {
url += "video";
if (item.fileType === 'video') {
url += 'video'
}
let that = this;
const that = this
wx.uploadFile({
filePath: item.tempFilePath,
name: "file",
url: url,
name: 'file',
url,
success(res) {
let data = JSON.parse(res.data);
let expandJson = {
fileId: "",
const data = JSON.parse(res.data)
const expandJson = {
fileId: '',
name: data.data.Url,
size: (item.size / 1024).toFixed(2),
fileUrl: data.data.Url,
suffix: that.GetExtensionFileName(data.data.Url),
type: item.fileType,
};
if (item.fileType === "image") {
expandJson.imgUrl = data.data.Url;
}
if (item.fileType === "video") {
expandJson.imgUrl = data.data.SnapshotUrl;
if (item.fileType === 'image') {
expandJson.imgUrl = data.data.Url
}
if (item.fileType === 'video') {
expandJson.imgUrl = data.data.SnapshotUrl
}
resolve(expandJson);
resolve(expandJson)
},
fail() {
resject();
resject()
},
});
});
})
})
},
GetExtensionFileName(pathfilename) {
var reg = /(\\+)/g;
var pString = pathfilename.replace(reg, "#"); //用正则表达式来将\或\\替换成#
var arr = pString.split("#"); // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png
var lastString = arr[arr.length - 1]; //取最后一个字符
var arr2 = lastString.split("."); // 再以"."作为分隔符
return arr2[arr2.length - 1]; //将后缀名返回出来
const reg = /(\\+)/g
const pString = pathfilename.replace(reg, '#') // 用正则表达式来将\或\\替换成#
const arr = pString.split('#') // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png
const lastString = arr[arr.length - 1] // 取最后一个字符
const arr2 = lastString.split('.') // 再以"."作为分隔符
return arr2[arr2.length - 1] // 将后缀名返回出来
},
upFile(data) {
wx.showLoading({
title: "正在上传",
});
let apiArr = [];
title: '正在上传',
})
const apiArr = []
data.map((e) => {
apiArr.push(this.uploadFile(e));
});
apiArr.push(this.uploadFile(e))
})
Promise.all(apiArr)
.then((res) => {
wx.hideLoading({
success: () => {
this.triggerEvent("setData", res);
this.triggerEvent('setData', res)
},
});
})
})
.catch(() => {
wx.showToast({
title: "上传失败",
icon: "error",
});
});
title: '上传失败',
icon: 'error',
})
})
},
selectFile() {
let { fileList, maxNum, sourceType, fileTypes, count = 0 } = this.properties;
var that = this;
let { fileList, maxNum, sourceType, fileTypes, count = 0 } = this.properties
const that = this
if (maxNum >= 0 && count == 0) {
count = maxNum - fileList.length;
count = maxNum - fileList.length
}
this.triggerEvent("choose");
this.triggerEvent('choose')
wx.chooseMedia({
mediaType: fileTypes,
count: count,
sourceType: sourceType,
sizeType: ["original"],
count,
sourceType,
sizeType: ['original'],
success(res) {
res.tempFiles.map((e) => {
e.fileType = e.fileType || res.type;
});
that.upFile(res.tempFiles);
e.fileType = e.fileType || res.type
})
that.upFile(res.tempFiles)
},
});
})
},
},
});
})

12
src/config.ts

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
export default {
wxf9ce8010f1ad24aa: {
url: 'https://m.xd.hbraas.com',
upFileUrl: 'https://m.xd.hbraas.com/',
imageUrl: 'https://m.xd.hbraas.com/xd/',
},
wx71ac9c27c3c3e3f4: {
url: 'https://m.xd.hbsaas.com',
upFileUrl: 'https://m.xd.hbsaas.com/',
imageUrl: 'https://m.xd.hbsaas.com/api/xd/',
},
}

4
src/custom-tab-bar/index.scss

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
.name {
margin-top: 8rpx;
font-size: 22rpx;
color: #69686E;
color: #69686e;
line-height: 21rpx;
}
&.active {
@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
}
}
.name {
color: #211D2E;
color: #211d2e;
}
}
}

2
src/doc/pages/doc1/index.scss

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
.page{
.page {
padding: 0 40rpx;
}

6
src/doc/pages/doc1/index.ts

File diff suppressed because one or more lines are too long

2
src/doc/pages/doc2/index.scss

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
.mp-html{
.mp-html {
padding: 20rpx 40rpx;
}

5184
src/gift/compontnts/echart/echarts.js

File diff suppressed because one or more lines are too long

6
src/gift/pages/conformOrder/index.json

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
{
"navigationBarTitleText": "确认订单",
"usingComponents": {
"van-icon": "@vant/weapp/icon/index"
}
}

184
src/gift/pages/conformOrder/index.scss

@ -1,184 +0,0 @@ @@ -1,184 +0,0 @@
.page {
padding: 34rpx 40rpx;
.site {
padding: 40rpx 32rpx;
background: #ffffff;
box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
border-radius: 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
.wrap {
.title {
.label {
width: 72rpx;
height: 36rpx;
border: 1rpx solid #e04775;
font-size: 24rpx;
color: #e04775;
text-align: center;
border-radius: 10rpx;
box-sizing: border-box;
}
.name {
margin-top: -42rpx;
text-indent: 80rpx;
font-size: 36rpx;
line-height: 46rpx;
color: #3f3f3f;
font-weight: bold;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
&.no-indent {
margin-top: 0;
text-indent: 0;
}
}
}
.content {
margin-top: 0;
margin-top: 12rpx;
font-size: 28rpx;
color: #b6b7ba;
}
}
.more {
flex-shrink: 0;
}
}
.shop {
margin-top: 16px;
padding: 40rpx 32rpx;
background: #ffffff;
box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
border-radius: 24rpx;
.shop-header {
padding-bottom: 10px;
display: flex;
.shop-img {
flex-shrink: 0;
width: 204rpx;
height: 204rpx;
border-radius: 24rpx;
}
.wrap {
padding-top: 8rpx;
flex: 1;
padding-left: 24rpx;
.name {
font-size: 32rpx;
font-weight: bold;
color: #3f3f3f;
line-height: 44rpx;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.specification {
margin-top: 8rpx;
font-size: 28rpx;
color: #b6b7ba;
}
.price {
margin-top: 14rpx;
display: flex;
align-items: center;
justify-content: space-between;
.num {
font-size: 32rpx;
color: #3f3f3f;
}
.sub {
font-size: 22rpx;
}
.val {
font-size: 28rpx;
color: #b6b7ba;
}
}
}
}
.row {
margin-top: 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
.label {
font-size: 32rpx;
color: #3f3f3f;
}
.content {
font-size: 32rpx;
color: #3f3f3f;
&.yellow {
color: #e04775;
}
.sub {
font-size: 22rpx;
}
}
}
}
.remark {
margin-top: 16px;
padding: 40rpx 32rpx;
background: #ffffff;
box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
border-radius: 24rpx;
.title {
font-size: 32rpx;
color: #3f3f3f;
font-weight: bold;
}
.textarea {
margin-top: 10rpx;
padding: 24rpx 32rpx;
background-color: #fafafa;
min-height: 196rpx;
border-radius: 16rpx;
box-sizing: border-box;
}
}
.footer {
padding: 24rpx 48rpx 48rpx;
position: fixed;
bottom: 0;
left: 0;
width: 100vw;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
height: 168rpx;
background: #ffffff;
box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.26);
.price {
font-size: 28rpx;
color: #b6b7ba;
.num {
font-size: 40rpx;
color: #e04775;
}
.sub {
font-size: 24rpx;
}
}
.submit {
width: 260rpx;
height: 96rpx;
background: #e04775;
border-radius: 48rpx;
text-align: center;
line-height: 96rpx;
color: #fff;
font-weight: bold;
}
}
}

86
src/gift/pages/conformOrder/index.ts

@ -1,86 +0,0 @@ @@ -1,86 +0,0 @@
const app = getApp<IAppOption>();
Page({
data: {
id: "",
detail: {},
select: false,
addressDetail: {} as any,
remark: "",
},
onLoad(options) {
this.setData({
id: options.id,
});
},
onShow() {
app.waitLogin().then(() => {
this.getDetail();
if (!this.data.select) {
this.getDefaultAddress();
} else {
this.setData({
select: false,
});
}
});
},
getDefaultAddress() {
wx.ajax({
method: "GET",
url: "?r=zd/patient-address/get-default-address",
data: {},
}).then((res) => {
this.setData({
addressDetail: res,
});
});
},
getDetail() {
wx.ajax({
method: "GET",
url: "?r=zd/gift-order/get-order-detail",
data: {
orderId: this.data.id,
},
}).then((res) => {
this.setData({
detail: res,
});
});
},
handleSite() {
if (this.data.addressDetail) {
wx.navigateTo({
url: "/gift/pages/siteList/index",
});
} else {
wx.navigateTo({
url: "/gift/pages/siteEdit/index",
});
}
},
handleSubmit() {
if (!this.data.addressDetail?.addressId) {
wx.showToast({
icon: "none",
title: "请选择地址",
});
return;
}
wx.ajax({
method: "POST",
url: "?r=zd/gift-order/confirm-order",
data: {
orderId: this.data.id,
addressId: this.data.addressDetail.addressId,
remark: this.data.remark,
},
loading: true,
}).then(() => {
wx.reLaunch({
url: `/gift/pages/orderEnd/index?id=${this.data.id}`,
});
});
},
});

56
src/gift/pages/conformOrder/index.wxml

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
<view class="page">
<view class="site" bind:tap="handleSite">
<view class="wrap">
<block wx:if="{{addressDetail}}">
<view class="title">
<view class="label" wx:if="{{addressDetail.isDefault==1}}">默认</view>
<view class="name {{addressDetail.isDefault!=1 && 'no-indent'}}">
{{addressDetail.provinceName}}{{addressDetail.cityName}}{{addressDetail.countyName}}{{addressDetail.address}}
</view>
</view>
<view class="content">{{addressDetail.receiveUserName}} {{addressDetail.receiveTelephone}}</view>
</block>
<view class="title" wx:else>请添加收货地址</view>
</view>
<van-icon class="more" name="arrow" />
</view>
<view class="shop">
<view class="shop-header">
<image class="shop-img" src="{{detail.giftBigImg}}"></image>
<view class="wrap">
<view class="name">{{detail.giftName}}</view>
<view class="specification" wx:if="{{detail.specName}}">规格:{{detail.specName}}</view>
<view class="price">
<view class="num">{{detail.giftScore}}<text class="sub">能量</text></view>
<view class="val">x{{detail.orderCount}}</view>
</view>
</view>
</view>
<view class="row">
<view class="label">礼品总价</view>
<view class="content yellow">{{detail.orderScore}}<text class="sub">能量</text></view>
</view>
<view class="row" >
<view class="label">配送方式</view>
<view class="content" style="font-weight:normal">快递配送</view>
</view>
<view class="row" >
<view class="label">商家电话</view>
<view class="content" style="font-weight:normal">{{detail.serviceTel}}</view>
</view>
</view>
<view class="remark">
<view class="title">留言</view>
<textarea class="textarea" model:value="{{remark}}" placeholder="请输入留言" auto-height></textarea>
</view>
<view class="footer">
<view class="price">
共{{detail.orderCount}}件
<view>
合计消耗
<text class="num">{{detail.orderScore}}<text class="sub">能量</text></text>
</view>
</view>
<view class="submit" bind:tap="handleSubmit">提交订单</view>
</view>
</view>

4
src/gift/pages/cutaneous/index.json

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
{
"navigationBarTitleText": "皮下剂型",
"usingComponents": {}
}

63
src/gift/pages/cutaneous/index.scss

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
page {
background-color: #f7f6f7;
}
.page {
.page1 {
height: 869rpx;
}
.page2 {
position: relative;
height: 630rpx;
.mg-video {
position: absolute;
top: 290rpx;
right: 60rpx;
width: 600rpx;
height: 288rpx;
}
}
.page3 {
position: relative;
height: 782rpx;
.cidp-mask {
position: absolute;
top: 174rpx;
right: 30rpx;
z-index: 1;
width: 74rpx;
height: 304rpx;
}
.cidp-list {
position: absolute;
top: 184rpx;
right: 30rpx;
width: 632rpx;
height: 288rpx;
overflow-x: auto;
overflow-y: hidden;
display: flex;
gap: 16rpx;
.cidp-item {
flex-shrink: 0;
width: 216rpx;
height: 288rpx;
}
}
}
.page4 {
height: 302rpx;
}
.page5 {
height: 306rpx;
}
.page6 {
display: block;
width: 100%;
height: 574rpx;
}
}
#video {
width: 0;
height: 0;
}

65
src/gift/pages/cutaneous/index.ts

@ -1,65 +0,0 @@ @@ -1,65 +0,0 @@
const _app = getApp<IAppOption>()
Page({
data: {
mg: [
{
url: 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/video/20241129469_MG%E4%B8%93%E5%8C%BA%E8%A7%86%E9%A2%9101.mp4',
},
],
cidp: [
{
url: 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/video/20241129233_CIDP%E4%B8%93%E5%8C%BA%E8%A7%86%E9%A2%9101.mp4',
},
{
url: 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/video/20241129667_CIDP%E4%B8%93%E5%8C%BA%E8%A7%86%E9%A2%9103.mp4',
},
{
url: 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/video/20241129630_CIDP%E8%A7%86%E9%A2%91%E4%B8%93%E5%8C%BA02.mp4',
},
{
url: 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/video/20241129281_CIDP%E4%B8%93%E5%8C%BA%E8%A7%86%E9%A2%9104.mp4',
},
],
},
videoContext: null as WechatMiniprogram.VideoContext | null,
onLoad() {
this.videoContext = wx.createVideoContext('video')
},
onUnload() {
if (this.videoContext) {
this.videoContext.stop()
}
},
handleVideo(e: any) {
const { key, index } = e.currentTarget.dataset
const url = this.data[key][index].url
if (this.videoContext) {
this.setData({
videoUrl: url,
})
this.videoContext.play()
this.videoContext.requestFullScreen({
direction: 0,
})
}
},
handleFullScreen(e) {
if (!e.detail.fullScreen && this.videoContext) {
this.videoContext.stop()
}
},
handleDetail(e: any) {
const { id } = e.currentTarget.dataset
wx.navigateTo({
url: `/gift/pages/cutaneousDetail/index?id=${id}`,
})
},
handleVideoDetail() {
wx.navigateTo({
url: `/gift/pages/cutaneousVideo/index`,
})
},
})
export {}

82
src/gift/pages/cutaneous/index.wxml

@ -1,82 +0,0 @@ @@ -1,82 +0,0 @@
<view class="page">
<view
class="page1"
style="background: url({{imageUrl}}za-images//cutaneous/home1.png?t={{Timestamp}}) no-repeat top center/100%;"
></view>
<view
class="page2"
style="background: url({{imageUrl}}za-images//cutaneous/home2.png?t={{Timestamp}}) no-repeat top center/100%;"
bind:tap="handleDetail"
data-id="2"
>
<image
class="mg-video"
src="{{imageUrl}}za-images//cutaneous/video1-1.png?t={{Timestamp}}"
data-key="mg"
data-index="0"
catch:tap="handleVideo"
></image>
</view>
<view
class="page3"
style="background: url({{imageUrl}}za-images//cutaneous/home3.png?t={{Timestamp}}) no-repeat top center/100%;"
bind:tap="handleDetail"
data-id="3"
>
<image class="cidp-mask" src="{{imageUrl}}za-images//cutaneous/cidp-mask.png?t={{Timestamp}}"></image>
<view class="cidp-list">
<image
class="cidp-item"
src="{{imageUrl}}za-images//cutaneous/video2-1.png?t={{Timestamp}}"
data-key="cidp"
data-index="0"
catch:tap="handleVideo"
></image>
<image
class="cidp-item"
src="{{imageUrl}}za-images//cutaneous/video2-2.png?t={{Timestamp}}"
data-key="cidp"
data-index="1"
catch:tap="handleVideo"
></image>
<image
class="cidp-item"
src="{{imageUrl}}za-images//cutaneous/video2-3.png?t={{Timestamp}}"
data-key="cidp"
data-index="2"
catch:tap="handleVideo"
></image>
<image
class="cidp-item"
src="{{imageUrl}}za-images//cutaneous/video2-4.png?t={{Timestamp}}"
data-key="cidp"
data-index="3"
catch:tap="handleVideo"
></image>
</view>
</view>
<view
class="page4"
style="background: url({{imageUrl}}za-images//cutaneous/home4.png?t={{Timestamp}}) no-repeat top center/100%;"
bind:tap="handleDetail"
data-id="4"
></view>
<view
class="page5"
style="background: url({{imageUrl}}za-images//cutaneous/home5.png?t={{Timestamp}}) no-repeat top center/100%;"
bind:tap="handleDetail"
data-id="5"
></view>
<image class="page6" bind:tap="handleVideoDetail" src="{{imageUrl}}za-images//cutaneous/home6.png?t={{Timestamp}}"></image>
</view>
<video
id="video"
src="{{videoUrl}}"
loop
show-play-btn
play-btn-position="center"
enable-play-gesture
bindfullscreenchange="handleFullScreen"
></video>

4
src/gift/pages/cutaneousDetail/index.json

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
{
"navigationBarTitleText": "皮下剂型",
"usingComponents": {}
}

11
src/gift/pages/cutaneousDetail/index.scss

@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
.page {
.card {
width: 100%;
display: block;
}
}
#video {
width: 0;
height: 0;
}

26
src/gift/pages/cutaneousDetail/index.ts

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
const _app = getApp<IAppOption>()
Page({
data: {
list: {
2: ['2-1', '2-2', '2-3', '2-4'],
3: ['3-1', '3-2', '3-3', '3-4', '3-5'],
4: ['4-1', '4-2'],
5: ['5-1', '5-2', '5-3', '5-4', '5-5'],
},
curentList: [] as any,
},
onLoad(e) {
if (e.id) {
this.setData({
curentList: this.data.list[e.id],
})
} else {
this.setData({
curentList: this.data.list[2],
})
}
},
})
export {}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save