diff --git a/.image/Java监控.jpg b/.image/Java监控.jpg deleted file mode 100644 index 6ad522a..0000000 Binary files a/.image/Java监控.jpg and /dev/null differ diff --git a/.image/MySQL.jpg b/.image/MySQL.jpg deleted file mode 100644 index 64a1940..0000000 Binary files a/.image/MySQL.jpg and /dev/null differ diff --git a/.image/OA请假-列表.jpg b/.image/OA请假-列表.jpg deleted file mode 100644 index 787bb73..0000000 Binary files a/.image/OA请假-列表.jpg and /dev/null differ diff --git a/.image/OA请假-发起.jpg b/.image/OA请假-发起.jpg deleted file mode 100644 index 1a7342d..0000000 Binary files a/.image/OA请假-发起.jpg and /dev/null differ diff --git a/.image/OA请假-详情.jpg b/.image/OA请假-详情.jpg deleted file mode 100644 index a83e7c1..0000000 Binary files a/.image/OA请假-详情.jpg and /dev/null differ diff --git a/.image/Redis.jpg b/.image/Redis.jpg deleted file mode 100644 index 9569352..0000000 Binary files a/.image/Redis.jpg and /dev/null differ diff --git a/.image/admin-uniapp/01.png b/.image/admin-uniapp/01.png deleted file mode 100644 index 0f65d99..0000000 Binary files a/.image/admin-uniapp/01.png and /dev/null differ diff --git a/.image/admin-uniapp/02.png b/.image/admin-uniapp/02.png deleted file mode 100644 index 05ec781..0000000 Binary files a/.image/admin-uniapp/02.png and /dev/null differ diff --git a/.image/admin-uniapp/03.png b/.image/admin-uniapp/03.png deleted file mode 100644 index f400c68..0000000 Binary files a/.image/admin-uniapp/03.png and /dev/null differ diff --git a/.image/admin-uniapp/04.png b/.image/admin-uniapp/04.png deleted file mode 100644 index d5d5ea0..0000000 Binary files a/.image/admin-uniapp/04.png and /dev/null differ diff --git a/.image/admin-uniapp/05.png b/.image/admin-uniapp/05.png deleted file mode 100644 index 1de6d8a..0000000 Binary files a/.image/admin-uniapp/05.png and /dev/null differ diff --git a/.image/admin-uniapp/06.png b/.image/admin-uniapp/06.png deleted file mode 100644 index 400ae90..0000000 Binary files a/.image/admin-uniapp/06.png and /dev/null differ diff --git a/.image/admin-uniapp/07.png b/.image/admin-uniapp/07.png deleted file mode 100644 index 2ed8c0f..0000000 Binary files a/.image/admin-uniapp/07.png and /dev/null differ diff --git a/.image/admin-uniapp/08.png b/.image/admin-uniapp/08.png deleted file mode 100644 index 090e64a..0000000 Binary files a/.image/admin-uniapp/08.png and /dev/null differ diff --git a/.image/admin-uniapp/09.png b/.image/admin-uniapp/09.png deleted file mode 100644 index f2032c8..0000000 Binary files a/.image/admin-uniapp/09.png and /dev/null differ diff --git a/.image/common/mall-feature.png b/.image/common/mall-feature.png deleted file mode 100644 index cca05c0..0000000 Binary files a/.image/common/mall-feature.png and /dev/null differ diff --git a/.image/common/mall-preview.png b/.image/common/mall-preview.png deleted file mode 100644 index f939214..0000000 Binary files a/.image/common/mall-preview.png and /dev/null differ diff --git a/.image/common/project-vs.png b/.image/common/project-vs.png deleted file mode 100644 index 561e092..0000000 Binary files a/.image/common/project-vs.png and /dev/null differ diff --git a/.image/common/ruoyi-vue-pro-architecture.png b/.image/common/ruoyi-vue-pro-architecture.png deleted file mode 100644 index 7bd7d59..0000000 Binary files a/.image/common/ruoyi-vue-pro-architecture.png and /dev/null differ diff --git a/.image/common/ruoyi-vue-pro-biz.png b/.image/common/ruoyi-vue-pro-biz.png deleted file mode 100644 index 24a385a..0000000 Binary files a/.image/common/ruoyi-vue-pro-biz.png and /dev/null differ diff --git a/.image/common/yudao-cloud-architecture.png b/.image/common/yudao-cloud-architecture.png deleted file mode 100644 index 59416d8..0000000 Binary files a/.image/common/yudao-cloud-architecture.png and /dev/null differ diff --git a/.image/common/yudao-roadmap.png b/.image/common/yudao-roadmap.png deleted file mode 100644 index f4becc9..0000000 Binary files a/.image/common/yudao-roadmap.png and /dev/null differ diff --git a/.image/个人中心.jpg b/.image/个人中心.jpg deleted file mode 100644 index ce57f6e..0000000 Binary files a/.image/个人中心.jpg and /dev/null differ diff --git a/.image/代码生成.jpg b/.image/代码生成.jpg deleted file mode 100644 index 751603e..0000000 Binary files a/.image/代码生成.jpg and /dev/null differ diff --git a/.image/令牌管理.jpg b/.image/令牌管理.jpg deleted file mode 100644 index 04abf4d..0000000 Binary files a/.image/令牌管理.jpg and /dev/null differ diff --git a/.image/任务列表-审批.jpg b/.image/任务列表-审批.jpg deleted file mode 100644 index cba312a..0000000 Binary files a/.image/任务列表-审批.jpg and /dev/null differ diff --git a/.image/任务列表-已办.jpg b/.image/任务列表-已办.jpg deleted file mode 100644 index 7a8d0fb..0000000 Binary files a/.image/任务列表-已办.jpg and /dev/null differ diff --git a/.image/任务列表-待办.jpg b/.image/任务列表-待办.jpg deleted file mode 100644 index a90323f..0000000 Binary files a/.image/任务列表-待办.jpg and /dev/null differ diff --git a/.image/任务日志.jpg b/.image/任务日志.jpg deleted file mode 100644 index 599e50a..0000000 Binary files a/.image/任务日志.jpg and /dev/null differ diff --git a/.image/商户信息.jpg b/.image/商户信息.jpg deleted file mode 100644 index 483eace..0000000 Binary files a/.image/商户信息.jpg and /dev/null differ diff --git a/.image/在线用户.jpg b/.image/在线用户.jpg deleted file mode 100644 index b183009..0000000 Binary files a/.image/在线用户.jpg and /dev/null differ diff --git a/.image/大屏设计器-列表.jpg b/.image/大屏设计器-列表.jpg deleted file mode 100644 index 9a45c3b..0000000 Binary files a/.image/大屏设计器-列表.jpg and /dev/null differ diff --git a/.image/大屏设计器-编辑.jpg b/.image/大屏设计器-编辑.jpg deleted file mode 100644 index 63298a0..0000000 Binary files a/.image/大屏设计器-编辑.jpg and /dev/null differ diff --git a/.image/大屏设计器-预览.jpg b/.image/大屏设计器-预览.jpg deleted file mode 100644 index 501d9ea..0000000 Binary files a/.image/大屏设计器-预览.jpg and /dev/null differ diff --git a/.image/字典数据.jpg b/.image/字典数据.jpg deleted file mode 100644 index 8298c89..0000000 Binary files a/.image/字典数据.jpg and /dev/null differ diff --git a/.image/字典类型.jpg b/.image/字典类型.jpg deleted file mode 100644 index 6613392..0000000 Binary files a/.image/字典类型.jpg and /dev/null differ diff --git a/.image/定时任务.jpg b/.image/定时任务.jpg deleted file mode 100644 index d5bbd85..0000000 Binary files a/.image/定时任务.jpg and /dev/null differ diff --git a/.image/岗位管理.jpg b/.image/岗位管理.jpg deleted file mode 100644 index 42b64d2..0000000 Binary files a/.image/岗位管理.jpg and /dev/null differ diff --git a/.image/应用信息-列表.jpg b/.image/应用信息-列表.jpg deleted file mode 100644 index da419a2..0000000 Binary files a/.image/应用信息-列表.jpg and /dev/null differ diff --git a/.image/应用信息-编辑.jpg b/.image/应用信息-编辑.jpg deleted file mode 100644 index 913cfbc..0000000 Binary files a/.image/应用信息-编辑.jpg and /dev/null differ diff --git a/.image/应用管理.jpg b/.image/应用管理.jpg deleted file mode 100644 index 6e7789f..0000000 Binary files a/.image/应用管理.jpg and /dev/null differ diff --git a/.image/我的流程-列表.jpg b/.image/我的流程-列表.jpg deleted file mode 100644 index 223d17a..0000000 Binary files a/.image/我的流程-列表.jpg and /dev/null differ diff --git a/.image/我的流程-发起.jpg b/.image/我的流程-发起.jpg deleted file mode 100644 index 7a83306..0000000 Binary files a/.image/我的流程-发起.jpg and /dev/null differ diff --git a/.image/我的流程-详情.jpg b/.image/我的流程-详情.jpg deleted file mode 100644 index 6a01541..0000000 Binary files a/.image/我的流程-详情.jpg and /dev/null differ diff --git a/.image/报表设计器-图形报表.jpg b/.image/报表设计器-图形报表.jpg deleted file mode 100644 index 681b318..0000000 Binary files a/.image/报表设计器-图形报表.jpg and /dev/null differ diff --git a/.image/报表设计器-打印设计.jpg b/.image/报表设计器-打印设计.jpg deleted file mode 100644 index bb86da6..0000000 Binary files a/.image/报表设计器-打印设计.jpg and /dev/null differ diff --git a/.image/报表设计器-数据报表.jpg b/.image/报表设计器-数据报表.jpg deleted file mode 100644 index 9ca5b9b..0000000 Binary files a/.image/报表设计器-数据报表.jpg and /dev/null differ diff --git a/.image/操作日志.jpg b/.image/操作日志.jpg deleted file mode 100644 index 4a0611a..0000000 Binary files a/.image/操作日志.jpg and /dev/null differ diff --git a/.image/支付订单.jpg b/.image/支付订单.jpg deleted file mode 100644 index 0a56dd7..0000000 Binary files a/.image/支付订单.jpg and /dev/null differ diff --git a/.image/敏感词.jpg b/.image/敏感词.jpg deleted file mode 100644 index 92a5397..0000000 Binary files a/.image/敏感词.jpg and /dev/null differ diff --git a/.image/数据库文档.jpg b/.image/数据库文档.jpg deleted file mode 100644 index a4339d9..0000000 Binary files a/.image/数据库文档.jpg and /dev/null differ diff --git a/.image/文件管理.jpg b/.image/文件管理.jpg deleted file mode 100644 index 054b19f..0000000 Binary files a/.image/文件管理.jpg and /dev/null differ diff --git a/.image/文件管理2.jpg b/.image/文件管理2.jpg deleted file mode 100644 index b12e5c3..0000000 Binary files a/.image/文件管理2.jpg and /dev/null differ diff --git a/.image/文件配置.jpg b/.image/文件配置.jpg deleted file mode 100644 index e618049..0000000 Binary files a/.image/文件配置.jpg and /dev/null differ diff --git a/.image/日志中心.jpg b/.image/日志中心.jpg deleted file mode 100644 index 27c1c6c..0000000 Binary files a/.image/日志中心.jpg and /dev/null differ diff --git a/.image/流程模型-列表.jpg b/.image/流程模型-列表.jpg deleted file mode 100644 index ffdc584..0000000 Binary files a/.image/流程模型-列表.jpg and /dev/null differ diff --git a/.image/流程模型-定义.jpg b/.image/流程模型-定义.jpg deleted file mode 100644 index 18b316c..0000000 Binary files a/.image/流程模型-定义.jpg and /dev/null differ diff --git a/.image/流程模型-设计.jpg b/.image/流程模型-设计.jpg deleted file mode 100644 index 9614969..0000000 Binary files a/.image/流程模型-设计.jpg and /dev/null differ diff --git a/.image/流程表单.jpg b/.image/流程表单.jpg deleted file mode 100644 index 60669c1..0000000 Binary files a/.image/流程表单.jpg and /dev/null differ diff --git a/.image/生成效果.jpg b/.image/生成效果.jpg deleted file mode 100644 index 98ff2cc..0000000 Binary files a/.image/生成效果.jpg and /dev/null differ diff --git a/.image/用户分组.jpg b/.image/用户分组.jpg deleted file mode 100644 index 39af1cd..0000000 Binary files a/.image/用户分组.jpg and /dev/null differ diff --git a/.image/用户管理.jpg b/.image/用户管理.jpg deleted file mode 100644 index 844604a..0000000 Binary files a/.image/用户管理.jpg and /dev/null differ diff --git a/.image/登录.jpg b/.image/登录.jpg deleted file mode 100644 index b782b98..0000000 Binary files a/.image/登录.jpg and /dev/null differ diff --git a/.image/登录日志.jpg b/.image/登录日志.jpg deleted file mode 100644 index 25662d9..0000000 Binary files a/.image/登录日志.jpg and /dev/null differ diff --git a/.image/短信日志.jpg b/.image/短信日志.jpg deleted file mode 100644 index ada8e56..0000000 Binary files a/.image/短信日志.jpg and /dev/null differ diff --git a/.image/短信模板.jpg b/.image/短信模板.jpg deleted file mode 100644 index 09381cc..0000000 Binary files a/.image/短信模板.jpg and /dev/null differ diff --git a/.image/短信渠道.jpg b/.image/短信渠道.jpg deleted file mode 100644 index df3a5c3..0000000 Binary files a/.image/短信渠道.jpg and /dev/null differ diff --git a/.image/租户套餐.png b/.image/租户套餐.png deleted file mode 100644 index 9663167..0000000 Binary files a/.image/租户套餐.png and /dev/null differ diff --git a/.image/租户管理.jpg b/.image/租户管理.jpg deleted file mode 100644 index 647416a..0000000 Binary files a/.image/租户管理.jpg and /dev/null differ diff --git a/.image/系统接口.jpg b/.image/系统接口.jpg deleted file mode 100644 index 6d39d42..0000000 Binary files a/.image/系统接口.jpg and /dev/null differ diff --git a/.image/菜单管理.jpg b/.image/菜单管理.jpg deleted file mode 100644 index ad3b797..0000000 Binary files a/.image/菜单管理.jpg and /dev/null differ diff --git a/.image/表单构建.jpg b/.image/表单构建.jpg deleted file mode 100644 index 81f0374..0000000 Binary files a/.image/表单构建.jpg and /dev/null differ diff --git a/.image/角色管理.jpg b/.image/角色管理.jpg deleted file mode 100644 index eed776e..0000000 Binary files a/.image/角色管理.jpg and /dev/null differ diff --git a/.image/访问日志.jpg b/.image/访问日志.jpg deleted file mode 100644 index ef301aa..0000000 Binary files a/.image/访问日志.jpg and /dev/null differ diff --git a/.image/退款订单.jpg b/.image/退款订单.jpg deleted file mode 100644 index 2c6c6c9..0000000 Binary files a/.image/退款订单.jpg and /dev/null differ diff --git a/.image/通知公告.jpg b/.image/通知公告.jpg deleted file mode 100644 index 97bb42f..0000000 Binary files a/.image/通知公告.jpg and /dev/null differ diff --git a/.image/部门管理.jpg b/.image/部门管理.jpg deleted file mode 100644 index 6eab233..0000000 Binary files a/.image/部门管理.jpg and /dev/null differ diff --git a/.image/配置管理.jpg b/.image/配置管理.jpg deleted file mode 100644 index 0abaec9..0000000 Binary files a/.image/配置管理.jpg and /dev/null differ diff --git a/.image/链路追踪.jpg b/.image/链路追踪.jpg deleted file mode 100644 index 12f7aa8..0000000 Binary files a/.image/链路追踪.jpg and /dev/null differ diff --git a/.image/错误日志.jpg b/.image/错误日志.jpg deleted file mode 100644 index eb615ea..0000000 Binary files a/.image/错误日志.jpg and /dev/null differ diff --git a/.image/错误码管理.jpg b/.image/错误码管理.jpg deleted file mode 100644 index ea91dde..0000000 Binary files a/.image/错误码管理.jpg and /dev/null differ diff --git a/.image/首页.jpg b/.image/首页.jpg deleted file mode 100644 index 10a7fde..0000000 Binary files a/.image/首页.jpg and /dev/null differ diff --git a/__MACOSX/wxcomponents/._.DS_Store b/__MACOSX/wxcomponents/._.DS_Store new file mode 100644 index 0000000..a5b28df Binary files /dev/null and b/__MACOSX/wxcomponents/._.DS_Store differ diff --git a/api/enterprise/index.js b/api/enterprise/index.js new file mode 100644 index 0000000..c06e5a2 --- /dev/null +++ b/api/enterprise/index.js @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +/** + * 创建企业 + * @param {Object} data + */ +export function createEnterPrise(data) { + return request({ + url: `/system/enterprise/create`, + method: 'POST', + data + }) +} + +/** + * 获取企业列表 + * @param {Object} params + */ +export function getEnterPriseList(params) { + return request({ + url: `/system/enterprise/page`, + method: 'GET', + params + }) +} \ No newline at end of file diff --git a/api/enterprise/prove.js b/api/enterprise/prove.js new file mode 100644 index 0000000..b45a5df --- /dev/null +++ b/api/enterprise/prove.js @@ -0,0 +1,38 @@ +import request from '@/utils/request' + +/** + * 新增资质 + * @param {Object} data + */ +export function createProve(data) { + return request({ + url: `/system/enterprise-qualification/create`, + method: 'POST', + data + }) +} + + +/** + * 更新资质 + * @param {Object} data + */ +export function updateProve(data) { + return request({ + url: `/system/enterprise-qualification/update`, + method: 'PUT', + data + }) +} + +/** + * 获取资质列表 + * @param {Object} data + */ +export function getProveList(data) { + return request({ + url: `/system/enterprise-qualification/page`, + method: 'GET', + data + }) +} \ No newline at end of file diff --git a/api/system/file.js b/api/system/file.js new file mode 100644 index 0000000..764f1d2 --- /dev/null +++ b/api/system/file.js @@ -0,0 +1,10 @@ +import upload from '@/utils/upload' + +export function uploadFile(data) { + return upload({ + url: '/admin-api/infra/file/upload', + method: 'POST', + name: data.name, + filePath: data.filePath + }) +} \ No newline at end of file diff --git a/components/cs-page/index.vue b/components/cs-page/index.vue index 2057a80..f586816 100644 --- a/components/cs-page/index.vue +++ b/components/cs-page/index.vue @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ export default { grid-template-rows: auto 1fr auto; height: 100vh; width: 100vw; - display: grid; .view { position: relative; .inner { position: absolute; + overflow: hidden; inset: 0; } } diff --git a/main.js b/main.js index 7bc492e..1b4254f 100644 --- a/main.js +++ b/main.js @@ -4,6 +4,8 @@ import store from './store' // store import plugins from './plugins' // plugins import './permission' // permission import * as dict from '@/utils/dict.js' +import * as util from '@/utils/ruoyi.js' + // 引入uView import uView from '@/uni_modules/uview-ui' // import mpShare from '@/uni_modules/uview-ui/libs/mixin/mpShare.js' @@ -16,6 +18,7 @@ Vue.config.productionTip = false // 挂载vuex Vue.prototype.$store = store Vue.prototype.$dict = dict +Vue.prototype.$util = util App.mpType = 'app' diff --git a/pages.json b/pages.json index a48608b..ac6b6bb 100644 --- a/pages.json +++ b/pages.json @@ -14,7 +14,11 @@ { "path": "pages/enterprise", "style": { - "navigationBarTitleText": "企业" + "navigationBarTitleText": "企业", + "usingComponents": { + "van-dropdown-menu": "/wxcomponents/vant/dropdown-menu/index", + "van-dropdown-item": "/wxcomponents/vant/dropdown-item/index" + } } }, { @@ -51,6 +55,8 @@ "path": "owner/invite" }, { "path": "enterprise/edit" + }, { + "path": "common/waiting" }] }], "tabBar": { diff --git a/pages/enterprise.vue b/pages/enterprise.vue index a04cfd3..d7989dd 100644 --- a/pages/enterprise.vue +++ b/pages/enterprise.vue @@ -1,13 +1,35 @@ - + diff --git a/pages/index.vue b/pages/index.vue index 5d47022..4eaac4b 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,37 +1,11 @@ - + diff --git a/pages/login.vue b/pages/login.vue index 44072c8..2f4b70b 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -21,45 +21,68 @@ export default { } }, onLoad(res) { - this.invateId = res.invateId + if (res.invateId) { + this.invateId = res.invateId + } this.init() }, methods: { init() { uni.login({ success: res => { + const data = { + type: 34, + code: res.code, + state: 'default', + userType: this.getUserType() + } // 系统登录 - this.$store - .dispatch('Login', { - type: 34, - code: res.code, - state: 'default' - }) - .then(() => { - this.loginSuccess() - }) + this.$store.dispatch('Login', data).then(() => { + this.loginSuccess() + }) } }) }, + getUserType() { + // 企业邀请 + if (this.invateId) return 2 + // if (this.type == 'internal') return 3 + // return 1 + return 3 + }, loginSuccess() { this.$store.dispatch('GetInfo').then(res => { - const { data } = res - const { user } = data - if (this.invateId) { - uni.navigateTo({ - url: `/sub/enterprise/edit?invateId=${this.invateId}` - }) - return - } - if (user.audit) { - uni.switchTab({ - url: '/pages/index' - }) - return - } + this.handlerNavigateTo(res.data.user) + }) + }, + handlerNavigateTo(user) { + // 邀请企业 + if (this.invateId) { + uni.navigateTo({ + url: `/sub/enterprise/edit?invateId=${this.invateId}` + }) + return + } + + // 审核中 + if (user.audit == 1) { uni.navigateTo({ - url: '/sub/owner/edit' + url: '/sub/common/waiting' }) + return + } + + // 审核通过 + if (user.audit == 2) { + uni.switchTab({ + url: '/pages/index' + }) + return + } + + // 局内用户首次登录 + uni.navigateTo({ + url: '/sub/owner/edit' }) } } diff --git a/static/images/invateImage.png b/static/images/invateImage.png new file mode 100644 index 0000000..1718ef8 Binary files /dev/null and b/static/images/invateImage.png differ diff --git a/sub/common/waiting.vue b/sub/common/waiting.vue new file mode 100644 index 0000000..df4b6f2 --- /dev/null +++ b/sub/common/waiting.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/sub/enterprise/edit.vue b/sub/enterprise/edit.vue new file mode 100644 index 0000000..672b411 --- /dev/null +++ b/sub/enterprise/edit.vue @@ -0,0 +1,431 @@ + + + + + diff --git a/sub/owner/invite.vue b/sub/owner/invite.vue new file mode 100644 index 0000000..86189cb --- /dev/null +++ b/sub/owner/invite.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/uni_modules/s-components/s-header/index.vue b/uni_modules/s-components/s-header/index.vue index 564fccf..c9c1fba 100644 --- a/uni_modules/s-components/s-header/index.vue +++ b/uni_modules/s-components/s-header/index.vue @@ -47,6 +47,8 @@ export default { .container { background-color: #fff; box-shadow: 0 1px 2px 1px $cs-shadow-color; + z-index: 1; + margin-bottom: 2px; .fit-content { height: 6vh; } @@ -54,6 +56,8 @@ export default { padding: 10px; .title { color: #000; + font-size: 18px; + font-weight: bold; } .icon-box { padding: 5px; @@ -62,4 +66,4 @@ export default { } } } - + \ No newline at end of file diff --git a/uni_modules/s-components/s-tabber/index.vue b/uni_modules/s-components/s-tabber/index.vue index b7ecdc1..de5d4f4 100644 --- a/uni_modules/s-components/s-tabber/index.vue +++ b/uni_modules/s-components/s-tabber/index.vue @@ -1,96 +1,113 @@ diff --git a/uni_modules/uni-calendar/changelog.md b/uni_modules/uni-calendar/changelog.md new file mode 100644 index 0000000..30ca0df --- /dev/null +++ b/uni_modules/uni-calendar/changelog.md @@ -0,0 +1,30 @@ +## 1.4.12(2024-09-21) +- 修复 calendar在选择日期范围后重新选择日期需要点两次的Bug +## 1.4.11(2024-01-10) +- 修复 回到今天时,月份显示不一致问题 +## 1.4.10(2023-04-10) +- 修复 某些情况 monthSwitch 未触发的Bug +## 1.4.9(2023-02-02) +- 修复 某些情况切换月份错误的Bug +## 1.4.8(2023-01-30) +- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/161964) +## 1.4.7(2022-09-16) +- 优化 支持使用 uni-scss 控制主题色 +## 1.4.6(2022-09-08) +- 修复 表头年月切换,导致改变当前日期为选择月1号,且未触发change事件的Bug +## 1.4.5(2022-02-25) +- 修复 条件编译 nvue 不支持的 css 样式的Bug +## 1.4.4(2022-02-25) +- 修复 条件编译 nvue 不支持的 css 样式的Bug +## 1.4.3(2021-09-22) +- 修复 startDate、 endDate 属性失效的Bug +## 1.4.2(2021-08-24) +- 新增 支持国际化 +## 1.4.1(2021-08-05) +- 修复 弹出层被 tabbar 遮盖的Bug +## 1.4.0(2021-07-30) +- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) +## 1.3.16(2021-05-12) +- 新增 组件示例地址 +## 1.3.15(2021-02-04) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-calendar/components/uni-calendar/calendar.js b/uni_modules/uni-calendar/components/uni-calendar/calendar.js new file mode 100644 index 0000000..55eed81 --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/calendar.js @@ -0,0 +1,544 @@ +/** +* @1900-2100区间内的公历、农历互转 +* @charset UTF-8 +* @github https://github.com/jjonline/calendar.js +* @Author Jea杨(JJonline@JJonline.Cn) +* @Time 2014-7-21 +* @Time 2016-8-13 Fixed 2033hex、Attribution Annals +* @Time 2016-9-25 Fixed lunar LeapMonth Param Bug +* @Time 2017-7-24 Fixed use getTerm Func Param Error.use solar year,NOT lunar year +* @Version 1.0.3 +* @公历转农历:calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0] +* @农历转公历:calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0] +*/ +/* eslint-disable */ +var calendar = { + + /** + * 农历1900-2100的润大小信息表 + * @Array Of Property + * @return Hex + */ + lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909 + 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919 + 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 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, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 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, 0x09570, // 1980-1989 + 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999 + 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009 + 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 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, 0x09370, 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, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080-2089 + 0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090-2099 + 0x0d520], // 2100 + + /** + * 公历每个月份的天数普通表 + * @Array Of Property + * @return Number + */ + solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + + /** + * 天干地支之天干速查表 + * @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"] + * @return Cn string + */ + Gan: ['\u7532', '\u4e59', '\u4e19', '\u4e01', '\u620a', '\u5df1', '\u5e9a', '\u8f9b', '\u58ec', '\u7678'], + + /** + * 天干地支之地支速查表 + * @Array Of Property + * @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"] + * @return Cn string + */ + Zhi: ['\u5b50', '\u4e11', '\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348', '\u672a', '\u7533', '\u9149', '\u620c', '\u4ea5'], + + /** + * 天干地支之地支速查表<=>生肖 + * @Array Of Property + * @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"] + * @return Cn string + */ + Animals: ['\u9f20', '\u725b', '\u864e', '\u5154', '\u9f99', '\u86c7', '\u9a6c', '\u7f8a', '\u7334', '\u9e21', '\u72d7', '\u732a'], + + /** + * 24节气速查表 + * @Array Of Property + * @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"] + * @return Cn string + */ + solarTerm: ['\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', '\u5927\u6691', '\u7acb\u79cb', '\u5904\u6691', '\u767d\u9732', '\u79cb\u5206', '\u5bd2\u9732', '\u971c\u964d', '\u7acb\u51ac', '\u5c0f\u96ea', '\u5927\u96ea', '\u51ac\u81f3'], + + /** + * 1900-2100各年的24节气日期速查表 + * @Array Of Property + * @return 0x string For splice + */ + sTermInfo: ['9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', + '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', + 'b027097bd097c36b0b6fc9274c91aa', '9778397bd19801ec9210c965cc920e', '97b6b97bd19801ec95f8c965cc920f', + '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd197c36c9210c9274c91aa', + '97b6b97bd19801ec95f8c965cc920e', '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', + '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec95f8c965cc920e', '97bcf97c3598082c95f8e1cfcc920f', + '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', + '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c359801ec95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd097bd07f595b0b6fc920fb0722', + '9778397bd097c36b0b6fc9210c8dc2', '9778397bd19801ec9210c9274c920e', '97b6b97bd19801ec95f8c965cc920f', + '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', + '97b6b97bd19801ec95f8c965cc920f', '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', + '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bd07f1487f595b0b0bc920fb0722', + '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f531b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf7f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '9778397bd097c36b0b6fc9210c91aa', '97b6b97bd197c36c9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', + '97b6b7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', + '9778397bd097c36b0b70c9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b7f0e47f531b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '9778397bd097c36b0b6fc9210c91aa', '97b6b7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '977837f0e37f149b0723b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c35b0b6fc9210c8dc2', + '977837f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc9210c8dc2', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '977837f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', + '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '977837f0e37f14998082b0723b06bd', '7f07e7f0e37f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f595b0b0bb0b6fb0722', '7f0e37f0e37f14898082b0723b02d5', + '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f531b0b0bb0b6fb0722', + '7f0e37f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e37f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', + '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f149b0723b0787b0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0723b06bd', + '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', '7f0e37f0e366aa89801eb072297c35', + '7ec967f0e37f14998082b0723b06bd', '7f07e7f0e37f14998083b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14898082b0723b02d5', '7f07e7f0e37f14998082b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66aa89801e9808297c35', '665f67f0e37f14898082b0723b02d5', + '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66a449801e9808297c35', + '665f67f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e36665b66a449801e9808297c35', '665f67f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e26665b66a449801e9808297c35', '665f67f0e37f1489801eb072297c35', + '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722'], + + /** + * 数字转中文速查表 + * @Array Of Property + * @trans ['日','一','二','三','四','五','六','七','八','九','十'] + * @return Cn string + */ + nStr1: ['\u65e5', '\u4e00', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'], + + /** + * 日期转农历称呼速查表 + * @Array Of Property + * @trans ['初','十','廿','卅'] + * @return Cn string + */ + nStr2: ['\u521d', '\u5341', '\u5eff', '\u5345'], + + /** + * 月份转农历称呼速查表 + * @Array Of Property + * @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊'] + * @return Cn string + */ + nStr3: ['\u6b63', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341', '\u51ac', '\u814a'], + + /** + * 返回农历y年一整年的总天数 + * @param lunar Year + * @return Number + * @eg:var count = calendar.lYearDays(1987) ;//count=387 + */ + lYearDays: function (y) { + var i; var sum = 348 + for (i = 0x8000; i > 0x8; i >>= 1) { sum += (this.lunarInfo[y - 1900] & i) ? 1 : 0 } + return (sum + this.leapDays(y)) + }, + + /** + * 返回农历y年闰月是哪个月;若y年没有闰月 则返回0 + * @param lunar Year + * @return Number (0-12) + * @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 + */ + leapMonth: function (y) { // 闰字编码 \u95f0 + return (this.lunarInfo[y - 1900] & 0xf) + }, + + /** + * 返回农历y年闰月的天数 若该年没有闰月则返回0 + * @param lunar Year + * @return Number (0、29、30) + * @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29 + */ + leapDays: function (y) { + if (this.leapMonth(y)) { + return ((this.lunarInfo[y - 1900] & 0x10000) ? 30 : 29) + } + return (0) + }, + + /** + * 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法 + * @param lunar Year + * @return Number (-1、29、30) + * @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29 + */ + monthDays: function (y, m) { + if (m > 12 || m < 1) { return -1 }// 月份参数从1至12,参数错误返回-1 + return ((this.lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29) + }, + + /** + * 返回公历(!)y年m月的天数 + * @param solar Year + * @return Number (-1、28、29、30、31) + * @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30 + */ + solarDays: function (y, m) { + if (m > 12 || m < 1) { return -1 } // 若参数错误 返回-1 + var ms = m - 1 + if (ms == 1) { // 2月份的闰平规律测算后确认返回28或29 + return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28) + } else { + return (this.solarMonth[ms]) + } + }, + + /** + * 农历年份转换为干支纪年 + * @param lYear 农历年的年份数 + * @return Cn string + */ + toGanZhiYear: function (lYear) { + var ganKey = (lYear - 3) % 10 + var zhiKey = (lYear - 3) % 12 + if (ganKey == 0) ganKey = 10// 如果余数为0则为最后一个天干 + if (zhiKey == 0) zhiKey = 12// 如果余数为0则为最后一个地支 + return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1] + }, + + /** + * 公历月、日判断所属星座 + * @param cMonth [description] + * @param cDay [description] + * @return Cn string + */ + toAstro: function (cMonth, cDay) { + var 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' + var 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'// 座 + }, + + /** + * 传入offset偏移量返回干支 + * @param offset 相对甲子的偏移量 + * @return Cn string + */ + toGanZhi: function (offset) { + return this.Gan[offset % 10] + this.Zhi[offset % 12] + }, + + /** + * 传入公历(!)y年获得该年第n个节气的公历日期 + * @param y公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起 + * @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 } + var _table = this.sTermInfo[y - 1900] + var _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() + ] + var _calday = [ + _info[0].substr(0, 1), + _info[0].substr(1, 2), + _info[0].substr(3, 1), + _info[0].substr(4, 2), + + _info[1].substr(0, 1), + _info[1].substr(1, 2), + _info[1].substr(3, 1), + _info[1].substr(4, 2), + + _info[2].substr(0, 1), + _info[2].substr(1, 2), + _info[2].substr(3, 1), + _info[2].substr(4, 2), + + _info[3].substr(0, 1), + _info[3].substr(1, 2), + _info[3].substr(3, 1), + _info[3].substr(4, 2), + + _info[4].substr(0, 1), + _info[4].substr(1, 2), + _info[4].substr(3, 1), + _info[4].substr(4, 2), + + _info[5].substr(0, 1), + _info[5].substr(1, 2), + _info[5].substr(3, 1), + _info[5].substr(4, 2) + ] + return parseInt(_calday[n - 1]) + }, + + /** + * 传入农历数字月份返回汉语通俗表示法 + * @param lunar month + * @return Cn string + * @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月' + */ + toChinaMonth: function (m) { // 月 => \u6708 + if (m > 12 || m < 1) { return -1 } // 若参数错误 返回-1 + var s = this.nStr3[m - 1] + s += '\u6708'// 加上月字 + return s + }, + + /** + * 传入农历日期数字返回汉字表示法 + * @param lunar day + * @return Cn string + * @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一' + */ + toChinaDay: function (d) { // 日 => \u65e5 + var s + switch (d) { + case 10: + s = '\u521d\u5341'; break + case 20: + s = '\u4e8c\u5341'; break + case 30: + s = '\u4e09\u5341'; break + default : + s = this.nStr2[Math.floor(d / 10)] + s += this.nStr1[d % 10] + } + return (s) + }, + + /** + * 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春” + * @param y year + * @return Cn string + * @eg:var animal = calendar.getAnimal(1987) ;//animal='兔' + */ + getAnimal: function (y) { + return this.Animals[(y - 4) % 12] + }, + + /** + * 传入阳历年月日获得详细的公历、农历object信息 <=>JSON + * @param y solar year + * @param m solar month + * @param d solar day + * @return JSON object + * @eg:console.log(calendar.solar2lunar(1987,11,01)); + */ + solar2lunar: function (y, m, d) { // 参数区间1900.1.31~2100.12.31 + // 年份限定、上限 + if (y < 1900 || y > 2100) { + return -1// undefined转换为数字变为NaN + } + // 公历传参最下限 + if (y == 1900 && m == 1 && d < 31) { + return -1 + } + // 未传参 获得当天 + if (!y) { + var objDate = new Date() + } else { + var objDate = new Date(y, parseInt(m) - 1, d) + } + var i; var leap = 0; var temp = 0 + // 修正ymd参数 + var y = objDate.getFullYear() + var m = objDate.getMonth() + 1 + var d = objDate.getDate() + var offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / 86400000 + for (i = 1900; i < 2101 && offset > 0; i++) { + temp = this.lYearDays(i) + offset -= temp + } + if (offset < 0) { + offset += temp; i-- + } + + // 是否今天 + var isTodayObj = new Date() + var isToday = false + if (isTodayObj.getFullYear() == y && isTodayObj.getMonth() + 1 == m && isTodayObj.getDate() == d) { + isToday = true + } + // 星期几 + var nWeek = objDate.getDay() + var cWeek = this.nStr1[nWeek] + // 数字表示周几顺应天朝周一开始的惯例 + if (nWeek == 0) { + nWeek = 7 + } + // 农历年 + var year = i + var leap = this.leapMonth(i) // 闰哪个月 + var isLeap = false + + // 效验闰月 + for (i = 1; i < 13 && offset > 0; i++) { + // 闰月 + if (leap > 0 && i == (leap + 1) && isLeap == false) { + --i + isLeap = true; temp = this.leapDays(year) // 计算农历闰月天数 + } else { + temp = this.monthDays(year, i)// 计算农历普通月天数 + } + // 解除闰月 + if (isLeap == true && i == (leap + 1)) { isLeap = false } + offset -= temp + } + // 闰月导致数组下标重叠取反 + if (offset == 0 && leap > 0 && i == leap + 1) { + if (isLeap) { + isLeap = false + } else { + isLeap = true; --i + } + } + if (offset < 0) { + offset += temp; --i + } + // 农历月 + var month = i + // 农历日 + var day = offset + 1 + // 天干地支处理 + var sm = m - 1 + var gzY = this.toGanZhiYear(year) + + // 当月的两个节气 + // bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year` + var firstNode = this.getTerm(y, (m * 2 - 1))// 返回当月「节」为几日开始 + var secondNode = this.getTerm(y, (m * 2))// 返回当月「节」为几日开始 + + // 依据12节气修正干支月 + var gzM = this.toGanZhi((y - 1900) * 12 + m + 11) + if (d >= firstNode) { + gzM = this.toGanZhi((y - 1900) * 12 + m + 12) + } + + // 传入的日期的节气与否 + var isTerm = false + var Term = null + if (firstNode == d) { + isTerm = true + Term = this.solarTerm[m * 2 - 2] + } + if (secondNode == d) { + isTerm = true + Term = this.solarTerm[m * 2 - 1] + } + // 日柱 当月一日与 1900/1/1 相差天数 + var dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10 + var gzD = this.toGanZhi(dayCyclical + d - 1) + // 该日期所属的星座 + var astro = this.toAstro(m, d) + + return { 'lYear': year, 'lMonth': month, 'lDay': day, 'Animal': this.getAnimal(year), 'IMonthCn': (isLeap ? '\u95f0' : '') + this.toChinaMonth(month), 'IDayCn': this.toChinaDay(day), 'cYear': y, 'cMonth': m, 'cDay': d, 'gzYear': gzY, 'gzMonth': gzM, 'gzDay': gzD, 'isToday': isToday, 'isLeap': isLeap, 'nWeek': nWeek, 'ncWeek': '\u661f\u671f' + cWeek, 'isTerm': isTerm, 'Term': Term, 'astro': astro } + }, + + /** + * 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON + * @param y lunar year + * @param m lunar month + * @param d lunar day + * @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可] + * @return JSON object + * @eg:console.log(calendar.lunar2solar(1987,9,10)); + */ + lunar2solar: function (y, m, d, isLeapMonth) { // 参数区间1900.1.31~2100.12.1 + var isLeapMonth = !!isLeapMonth + var leapOffset = 0 + var leapMonth = this.leapMonth(y) + var leapDay = this.leapDays(y) + if (isLeapMonth && (leapMonth != m)) { return -1 }// 传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同 + if (y == 2100 && m == 12 && d > 1 || y == 1900 && m == 1 && d < 31) { return -1 }// 超出了最大极限值 + var day = this.monthDays(y, m) + var _day = day + // bugFix 2016-9-25 + // if month is leap, _day use leapDays method + if (isLeapMonth) { + _day = this.leapDays(y, m) + } + if (y < 1900 || y > 2100 || d > _day) { return -1 }// 参数合法性效验 + + // 计算农历的时间差 + var offset = 0 + for (var i = 1900; i < y; i++) { + offset += this.lYearDays(i) + } + var leap = 0; var isAdd = false + for (var i = 1; i < m; i++) { + leap = this.leapMonth(y) + if (!isAdd) { // 处理闰月 + if (leap <= i && leap > 0) { + offset += this.leapDays(y); isAdd = true + } + } + offset += this.monthDays(y, i) + } + // 转换闰月农历 需补充该年闰月的前一个月的时差 + if (isLeapMonth) { offset += day } + // 1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点) + var stmap = Date.UTC(1900, 1, 30, 0, 0, 0) + var calObj = new Date((offset + d - 31) * 86400000 + stmap) + var cY = calObj.getUTCFullYear() + var cM = calObj.getUTCMonth() + 1 + var cD = calObj.getUTCDate() + + return this.solar2lunar(cY, cM, cD) + } +} + +export default calendar diff --git a/uni_modules/uni-calendar/components/uni-calendar/i18n/en.json b/uni_modules/uni-calendar/components/uni-calendar/i18n/en.json new file mode 100644 index 0000000..fcbd13c --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/i18n/en.json @@ -0,0 +1,12 @@ +{ + "uni-calender.ok": "ok", + "uni-calender.cancel": "cancel", + "uni-calender.today": "today", + "uni-calender.MON": "MON", + "uni-calender.TUE": "TUE", + "uni-calender.WED": "WED", + "uni-calender.THU": "THU", + "uni-calender.FRI": "FRI", + "uni-calender.SAT": "SAT", + "uni-calender.SUN": "SUN" +} diff --git a/uni_modules/uni-calendar/components/uni-calendar/i18n/index.js b/uni_modules/uni-calendar/components/uni-calendar/i18n/index.js new file mode 100644 index 0000000..de7509c --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/i18n/index.js @@ -0,0 +1,8 @@ +import en from './en.json' +import zhHans from './zh-Hans.json' +import zhHant from './zh-Hant.json' +export default { + en, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant +} diff --git a/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hans.json b/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hans.json new file mode 100644 index 0000000..1ca43de --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hans.json @@ -0,0 +1,12 @@ +{ + "uni-calender.ok": "确定", + "uni-calender.cancel": "取消", + "uni-calender.today": "今日", + "uni-calender.SUN": "日", + "uni-calender.MON": "一", + "uni-calender.TUE": "二", + "uni-calender.WED": "三", + "uni-calender.THU": "四", + "uni-calender.FRI": "五", + "uni-calender.SAT": "六" +} diff --git a/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hant.json b/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hant.json new file mode 100644 index 0000000..e0fe33b --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/i18n/zh-Hant.json @@ -0,0 +1,12 @@ +{ + "uni-calender.ok": "確定", + "uni-calender.cancel": "取消", + "uni-calender.today": "今日", + "uni-calender.SUN": "日", + "uni-calender.MON": "一", + "uni-calender.TUE": "二", + "uni-calender.WED": "三", + "uni-calender.THU": "四", + "uni-calender.FRI": "五", + "uni-calender.SAT": "六" +} diff --git a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue new file mode 100644 index 0000000..a54135e --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue new file mode 100644 index 0000000..0beebfb --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue @@ -0,0 +1,567 @@ + + + + + diff --git a/uni_modules/uni-calendar/components/uni-calendar/util.js b/uni_modules/uni-calendar/components/uni-calendar/util.js new file mode 100644 index 0000000..e0c5103 --- /dev/null +++ b/uni_modules/uni-calendar/components/uni-calendar/util.js @@ -0,0 +1,360 @@ +import CALENDAR from './calendar.js' + +class Calendar { + constructor({ + date, + selected, + startDate, + endDate, + range + } = {}) { + // 当前日期 + this.date = this.getDate(new Date()) // 当前初入日期 + // 打点信息 + this.selected = selected || []; + // 范围开始 + this.startDate = startDate + // 范围结束 + this.endDate = endDate + this.range = range + // 多选状态 + this.cleanMultipleStatus() + // 每周日期 + this.weeks = {} + // this._getWeek(this.date.fullDate) + } + /** + * 设置日期 + * @param {Object} date + */ + setDate(date) { + this.selectDate = this.getDate(date) + this._getWeek(this.selectDate.fullDate) + } + + /** + * 清理多选状态 + */ + cleanMultipleStatus() { + this.multipleStatus = { + before: '', + after: '', + data: [] + } + } + + /** + * 重置开始日期 + */ + resetSatrtDate(startDate) { + // 范围开始 + this.startDate = startDate + + } + + /** + * 重置结束日期 + */ + resetEndDate(endDate) { + // 范围结束 + this.endDate = endDate + } + + /** + * 获取任意时间 + */ + getDate(date, AddDayCount = 0, str = 'day') { + if (!date) { + date = new Date() + } + if (typeof date !== 'object') { + date = date.replace(/-/g, '/') + } + const dd = new Date(date) + switch (str) { + case 'day': + dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期 + break + case 'month': + if (dd.getDate() === 31 && AddDayCount>0) { + dd.setDate(dd.getDate() + AddDayCount) + } else { + const preMonth = dd.getMonth() + dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期 + const nextMonth = dd.getMonth() + // 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题 + if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){ + dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount)) + } + // 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题 + if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){ + dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount)) + } + } + break + case 'year': + dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期 + break + } + const y = dd.getFullYear() + const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0 + const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0 + return { + fullDate: y + '-' + m + '-' + d, + year: y, + month: m, + date: d, + day: dd.getDay() + } + } + + + /** + * 获取上月剩余天数 + */ + _getLastMonthDays(firstDay, full) { + let dateArr = [] + for (let i = firstDay; i > 0; i--) { + const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate() + dateArr.push({ + date: beforeDate, + month: full.month - 1, + lunar: this.getlunar(full.year, full.month - 1, beforeDate), + disable: true + }) + } + return dateArr + } + /** + * 获取本月天数 + */ + _currentMonthDys(dateData, full) { + let dateArr = [] + let fullDate = this.date.fullDate + for (let i = 1; i <= dateData; i++) { + let nowDate = full.year + '-' + (full.month < 10 ? + full.month : full.month) + '-' + (i < 10 ? + '0' + i : i) + // 是否今天 + let isDay = fullDate === nowDate + // 获取打点信息 + let info = this.selected && this.selected.find((item) => { + if (this.dateEqual(nowDate, item.date)) { + return item + } + }) + + // 日期禁用 + let disableBefore = true + let disableAfter = true + if (this.startDate) { + // let dateCompBefore = this.dateCompare(this.startDate, fullDate) + // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate) + disableBefore = this.dateCompare(this.startDate, nowDate) + } + + if (this.endDate) { + // let dateCompAfter = this.dateCompare(fullDate, this.endDate) + // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate) + disableAfter = this.dateCompare(nowDate, this.endDate) + } + let multiples = this.multipleStatus.data + let checked = false + let multiplesStatus = -1 + if (this.range) { + if (multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, nowDate) + }) + } + if (multiplesStatus !== -1) { + checked = true + } + } + let data = { + fullDate: nowDate, + year: full.year, + date: i, + multiple: this.range ? checked : false, + beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate), + afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate), + month: full.month, + lunar: this.getlunar(full.year, full.month, i), + disable: !(disableBefore && disableAfter), + isDay + } + if (info) { + data.extraInfo = info + } + + dateArr.push(data) + } + return dateArr + } + /** + * 获取下月天数 + */ + _getNextMonthDays(surplus, full) { + let dateArr = [] + for (let i = 1; i < surplus + 1; i++) { + dateArr.push({ + date: i, + month: Number(full.month) + 1, + lunar: this.getlunar(full.year, Number(full.month) + 1, i), + disable: true + }) + } + return dateArr + } + + /** + * 获取当前日期详情 + * @param {Object} date + */ + getInfo(date) { + if (!date) { + date = new Date() + } + const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate) + return dateInfo + } + + /** + * 比较时间大小 + */ + dateCompare(startDate, endDate) { + // 计算截止时间 + startDate = new Date(startDate.replace('-', '/').replace('-', '/')) + // 计算详细项的截止时间 + endDate = new Date(endDate.replace('-', '/').replace('-', '/')) + if (startDate <= endDate) { + return true + } else { + return false + } + } + + /** + * 比较时间是否相等 + */ + dateEqual(before, after) { + // 计算截止时间 + before = new Date(before.replace('-', '/').replace('-', '/')) + // 计算详细项的截止时间 + after = new Date(after.replace('-', '/').replace('-', '/')) + if (before.getTime() - after.getTime() === 0) { + return true + } else { + return false + } + } + + + /** + * 获取日期范围内所有日期 + * @param {Object} begin + * @param {Object} end + */ + geDateAll(begin, end) { + var arr = [] + var ab = begin.split('-') + var ae = end.split('-') + var db = new Date() + db.setFullYear(ab[0], ab[1] - 1, ab[2]) + var de = new Date() + de.setFullYear(ae[0], ae[1] - 1, ae[2]) + var unixDb = db.getTime() - 24 * 60 * 60 * 1000 + var unixDe = de.getTime() - 24 * 60 * 60 * 1000 + for (var k = unixDb; k <= unixDe;) { + k = k + 24 * 60 * 60 * 1000 + arr.push(this.getDate(new Date(parseInt(k))).fullDate) + } + return arr + } + /** + * 计算阴历日期显示 + */ + getlunar(year, month, date) { + return CALENDAR.solar2lunar(year, month, date) + } + /** + * 设置打点 + */ + setSelectInfo(data, value) { + this.selected = value + this._getWeek(data) + } + + /** + * 获取多选状态 + */ + setMultiple(fullDate) { + let { + before, + after + } = this.multipleStatus + + if (!this.range) return + if (before && after) { + this.multipleStatus.before = fullDate + this.multipleStatus.after = '' + this.multipleStatus.data = [] + } else { + if (!before) { + this.multipleStatus.before = fullDate + } else { + this.multipleStatus.after = fullDate + if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); + } else { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); + } + } + } + this._getWeek(fullDate) + } + + /** + * 获取每周数据 + * @param {Object} dateData + */ + _getWeek(dateData) { + const { + year, + month + } = this.getDate(dateData) + let firstDay = new Date(year, month - 1, 1).getDay() + let currentDay = new Date(year, month, 0).getDate() + let dates = { + lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天 + currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数 + nextMonthDays: [], // 下个月开始几天 + weeks: [] + } + let canlender = [] + const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length) + dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData)) + canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays) + let weeks = {} + // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天 + for (let i = 0; i < canlender.length; i++) { + if (i % 7 === 0) { + weeks[parseInt(i / 7)] = new Array(7) + } + weeks[parseInt(i / 7)][i % 7] = canlender[i] + } + this.canlender = canlender + this.weeks = weeks + } + + //静态方法 + // static init(date) { + // if (!this.instance) { + // this.instance = new Calendar(date); + // } + // return this.instance; + // } +} + + +export default Calendar diff --git a/uni_modules/uni-calendar/package.json b/uni_modules/uni-calendar/package.json new file mode 100644 index 0000000..ec924e9 --- /dev/null +++ b/uni_modules/uni-calendar/package.json @@ -0,0 +1,86 @@ +{ + "id": "uni-calendar", + "displayName": "uni-calendar 日历", + "version": "1.4.12", + "description": "日历组件", + "keywords": [ + "uni-ui", + "uniui", + "日历", + "", + "打卡", + "日历选择" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y", + "alipay": "n" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} diff --git a/uni_modules/uni-calendar/readme.md b/uni_modules/uni-calendar/readme.md new file mode 100644 index 0000000..4e1748c --- /dev/null +++ b/uni_modules/uni-calendar/readme.md @@ -0,0 +1,103 @@ + + +## Calendar 日历 +> **组件名:uni-calendar** +> 代码块: `uCalendar` + + +日历组件 + +> **注意事项** +> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。 +> - 本组件农历转换使用的js是 [@1900-2100区间内的公历、农历互转](https://github.com/jjonline/calendar.js) +> - 仅支持自定义组件模式 +> - `date`属性传入的应该是一个 String ,如: 2019-06-27 ,而不是 new Date() +> - 通过 `insert` 属性来确定当前的事件是 @change 还是 @confirm 。理应合并为一个事件,但是为了区分模式,现使用两个事件,这里需要注意 +> - 弹窗模式下无法阻止后面的元素滚动,如有需要阻止,请在弹窗弹出后,手动设置滚动元素为不可滚动 + + +### 安装方式 + +本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。 + +如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) + +### 基本用法 + +在 ``template`` 中使用组件 + +```html + + + +``` + +### 通过方法打开日历 + +需要设置 `insert` 为 `false` + +```html + + + + +``` + +```javascript + +export default { + data() { + return {}; + }, + methods: { + open(){ + this.$refs.calendar.open(); + }, + confirm(e) { + console.log(e); + } + } +}; + +``` + + +## API + +### Calendar Props + +| 属性名 | 类型 | 默认值| 说明 | +| - | - | - | - | +| date | String |- | 自定义当前时间,默认为今天 | +| lunar | Boolean | false | 显示农历 | +| startDate | String |- | 日期选择范围-开始日期 | +| endDate | String |- | 日期选择范围-结束日期 | +| range | Boolean | false | 范围选择 | +| insert | Boolean | false | 插入模式,可选值,ture:插入模式;false:弹窗模式;默认为插入模式 | +|clearDate |Boolean |true |弹窗模式是否清空上次选择内容 | +| selected | Array |- | 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] | +|showMonth | Boolean | true | 是否显示月份为背景 | + +### Calendar Events + +| 事件名 | 说明 |返回值| +| - | - | - | +| open | 弹出日历组件,`insert :false` 时生效|- | + + + + + +## 组件示例 + +点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar](https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar) diff --git a/uni_modules/uni-icons/changelog.md b/uni_modules/uni-icons/changelog.md new file mode 100644 index 0000000..0261131 --- /dev/null +++ b/uni_modules/uni-icons/changelog.md @@ -0,0 +1,42 @@ +## 2.0.10(2024-06-07) +- 优化 uni-app x 中,size 属性的类型 +## 2.0.9(2024-01-12) +fix: 修复图标大小默认值错误的问题 +## 2.0.8(2023-12-14) +- 修复 项目未使用 ts 情况下,打包报错的bug +## 2.0.7(2023-12-14) +- 修复 size 属性为 string 时,不加单位导致尺寸异常的bug +## 2.0.6(2023-12-11) +- 优化 兼容老版本icon类型,如 top ,bottom 等 +## 2.0.5(2023-12-11) +- 优化 兼容老版本icon类型,如 top ,bottom 等 +## 2.0.4(2023-12-06) +- 优化 uni-app x 下示例项目图标排序 +## 2.0.3(2023-12-06) +- 修复 nvue下引入组件报错的bug +## 2.0.2(2023-12-05) +-优化 size 属性支持单位 +## 2.0.1(2023-12-05) +- 新增 uni-app x 支持定义图标 +## 1.3.5(2022-01-24) +- 优化 size 属性可以传入不带单位的字符串数值 +## 1.3.4(2022-01-24) +- 优化 size 支持其他单位 +## 1.3.3(2022-01-17) +- 修复 nvue 有些图标不显示的bug,兼容老版本图标 +## 1.3.2(2021-12-01) +- 优化 示例可复制图标名称 +## 1.3.1(2021-11-23) +- 优化 兼容旧组件 type 值 +## 1.3.0(2021-11-19) +- 新增 更多图标 +- 优化 自定义图标使用方式 +- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-icons](https://uniapp.dcloud.io/component/uniui/uni-icons) +## 1.1.7(2021-11-08) +## 1.2.0(2021-07-30) +- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) +## 1.1.5(2021-05-12) +- 新增 组件示例地址 +## 1.1.4(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue new file mode 100644 index 0000000..8740559 --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue @@ -0,0 +1,91 @@ + + + + + diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue new file mode 100644 index 0000000..7da5356 --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/uni_modules/uni-icons/components/uni-icons/uniicons.css b/uni_modules/uni-icons/components/uni-icons/uniicons.css new file mode 100644 index 0000000..0a6b6fe --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uniicons.css @@ -0,0 +1,664 @@ + +.uniui-cart-filled:before { + content: "\e6d0"; +} + +.uniui-gift-filled:before { + content: "\e6c4"; +} + +.uniui-color:before { + content: "\e6cf"; +} + +.uniui-wallet:before { + content: "\e6b1"; +} + +.uniui-settings-filled:before { + content: "\e6ce"; +} + +.uniui-auth-filled:before { + content: "\e6cc"; +} + +.uniui-shop-filled:before { + content: "\e6cd"; +} + +.uniui-staff-filled:before { + content: "\e6cb"; +} + +.uniui-vip-filled:before { + content: "\e6c6"; +} + +.uniui-plus-filled:before { + content: "\e6c7"; +} + +.uniui-folder-add-filled:before { + content: "\e6c8"; +} + +.uniui-color-filled:before { + content: "\e6c9"; +} + +.uniui-tune-filled:before { + content: "\e6ca"; +} + +.uniui-calendar-filled:before { + content: "\e6c0"; +} + +.uniui-notification-filled:before { + content: "\e6c1"; +} + +.uniui-wallet-filled:before { + content: "\e6c2"; +} + +.uniui-medal-filled:before { + content: "\e6c3"; +} + +.uniui-fire-filled:before { + content: "\e6c5"; +} + +.uniui-refreshempty:before { + content: "\e6bf"; +} + +.uniui-location-filled:before { + content: "\e6af"; +} + +.uniui-person-filled:before { + content: "\e69d"; +} + +.uniui-personadd-filled:before { + content: "\e698"; +} + +.uniui-arrowthinleft:before { + content: "\e6d2"; +} + +.uniui-arrowthinup:before { + content: "\e6d3"; +} + +.uniui-arrowthindown:before { + content: "\e6d4"; +} + +.uniui-back:before { + content: "\e6b9"; +} + +.uniui-forward:before { + content: "\e6ba"; +} + +.uniui-arrow-right:before { + content: "\e6bb"; +} + +.uniui-arrow-left:before { + content: "\e6bc"; +} + +.uniui-arrow-up:before { + content: "\e6bd"; +} + +.uniui-arrow-down:before { + content: "\e6be"; +} + +.uniui-arrowthinright:before { + content: "\e6d1"; +} + +.uniui-down:before { + content: "\e6b8"; +} + +.uniui-bottom:before { + content: "\e6b8"; +} + +.uniui-arrowright:before { + content: "\e6d5"; +} + +.uniui-right:before { + content: "\e6b5"; +} + +.uniui-up:before { + content: "\e6b6"; +} + +.uniui-top:before { + content: "\e6b6"; +} + +.uniui-left:before { + content: "\e6b7"; +} + +.uniui-arrowup:before { + content: "\e6d6"; +} + +.uniui-eye:before { + content: "\e651"; +} + +.uniui-eye-filled:before { + content: "\e66a"; +} + +.uniui-eye-slash:before { + content: "\e6b3"; +} + +.uniui-eye-slash-filled:before { + content: "\e6b4"; +} + +.uniui-info-filled:before { + content: "\e649"; +} + +.uniui-reload:before { + content: "\e6b2"; +} + +.uniui-micoff-filled:before { + content: "\e6b0"; +} + +.uniui-map-pin-ellipse:before { + content: "\e6ac"; +} + +.uniui-map-pin:before { + content: "\e6ad"; +} + +.uniui-location:before { + content: "\e6ae"; +} + +.uniui-starhalf:before { + content: "\e683"; +} + +.uniui-star:before { + content: "\e688"; +} + +.uniui-star-filled:before { + content: "\e68f"; +} + +.uniui-calendar:before { + content: "\e6a0"; +} + +.uniui-fire:before { + content: "\e6a1"; +} + +.uniui-medal:before { + content: "\e6a2"; +} + +.uniui-font:before { + content: "\e6a3"; +} + +.uniui-gift:before { + content: "\e6a4"; +} + +.uniui-link:before { + content: "\e6a5"; +} + +.uniui-notification:before { + content: "\e6a6"; +} + +.uniui-staff:before { + content: "\e6a7"; +} + +.uniui-vip:before { + content: "\e6a8"; +} + +.uniui-folder-add:before { + content: "\e6a9"; +} + +.uniui-tune:before { + content: "\e6aa"; +} + +.uniui-auth:before { + content: "\e6ab"; +} + +.uniui-person:before { + content: "\e699"; +} + +.uniui-email-filled:before { + content: "\e69a"; +} + +.uniui-phone-filled:before { + content: "\e69b"; +} + +.uniui-phone:before { + content: "\e69c"; +} + +.uniui-email:before { + content: "\e69e"; +} + +.uniui-personadd:before { + content: "\e69f"; +} + +.uniui-chatboxes-filled:before { + content: "\e692"; +} + +.uniui-contact:before { + content: "\e693"; +} + +.uniui-chatbubble-filled:before { + content: "\e694"; +} + +.uniui-contact-filled:before { + content: "\e695"; +} + +.uniui-chatboxes:before { + content: "\e696"; +} + +.uniui-chatbubble:before { + content: "\e697"; +} + +.uniui-upload-filled:before { + content: "\e68e"; +} + +.uniui-upload:before { + content: "\e690"; +} + +.uniui-weixin:before { + content: "\e691"; +} + +.uniui-compose:before { + content: "\e67f"; +} + +.uniui-qq:before { + content: "\e680"; +} + +.uniui-download-filled:before { + content: "\e681"; +} + +.uniui-pyq:before { + content: "\e682"; +} + +.uniui-sound:before { + content: "\e684"; +} + +.uniui-trash-filled:before { + content: "\e685"; +} + +.uniui-sound-filled:before { + content: "\e686"; +} + +.uniui-trash:before { + content: "\e687"; +} + +.uniui-videocam-filled:before { + content: "\e689"; +} + +.uniui-spinner-cycle:before { + content: "\e68a"; +} + +.uniui-weibo:before { + content: "\e68b"; +} + +.uniui-videocam:before { + content: "\e68c"; +} + +.uniui-download:before { + content: "\e68d"; +} + +.uniui-help:before { + content: "\e679"; +} + +.uniui-navigate-filled:before { + content: "\e67a"; +} + +.uniui-plusempty:before { + content: "\e67b"; +} + +.uniui-smallcircle:before { + content: "\e67c"; +} + +.uniui-minus-filled:before { + content: "\e67d"; +} + +.uniui-micoff:before { + content: "\e67e"; +} + +.uniui-closeempty:before { + content: "\e66c"; +} + +.uniui-clear:before { + content: "\e66d"; +} + +.uniui-navigate:before { + content: "\e66e"; +} + +.uniui-minus:before { + content: "\e66f"; +} + +.uniui-image:before { + content: "\e670"; +} + +.uniui-mic:before { + content: "\e671"; +} + +.uniui-paperplane:before { + content: "\e672"; +} + +.uniui-close:before { + content: "\e673"; +} + +.uniui-help-filled:before { + content: "\e674"; +} + +.uniui-paperplane-filled:before { + content: "\e675"; +} + +.uniui-plus:before { + content: "\e676"; +} + +.uniui-mic-filled:before { + content: "\e677"; +} + +.uniui-image-filled:before { + content: "\e678"; +} + +.uniui-locked-filled:before { + content: "\e668"; +} + +.uniui-info:before { + content: "\e669"; +} + +.uniui-locked:before { + content: "\e66b"; +} + +.uniui-camera-filled:before { + content: "\e658"; +} + +.uniui-chat-filled:before { + content: "\e659"; +} + +.uniui-camera:before { + content: "\e65a"; +} + +.uniui-circle:before { + content: "\e65b"; +} + +.uniui-checkmarkempty:before { + content: "\e65c"; +} + +.uniui-chat:before { + content: "\e65d"; +} + +.uniui-circle-filled:before { + content: "\e65e"; +} + +.uniui-flag:before { + content: "\e65f"; +} + +.uniui-flag-filled:before { + content: "\e660"; +} + +.uniui-gear-filled:before { + content: "\e661"; +} + +.uniui-home:before { + content: "\e662"; +} + +.uniui-home-filled:before { + content: "\e663"; +} + +.uniui-gear:before { + content: "\e664"; +} + +.uniui-smallcircle-filled:before { + content: "\e665"; +} + +.uniui-map-filled:before { + content: "\e666"; +} + +.uniui-map:before { + content: "\e667"; +} + +.uniui-refresh-filled:before { + content: "\e656"; +} + +.uniui-refresh:before { + content: "\e657"; +} + +.uniui-cloud-upload:before { + content: "\e645"; +} + +.uniui-cloud-download-filled:before { + content: "\e646"; +} + +.uniui-cloud-download:before { + content: "\e647"; +} + +.uniui-cloud-upload-filled:before { + content: "\e648"; +} + +.uniui-redo:before { + content: "\e64a"; +} + +.uniui-images-filled:before { + content: "\e64b"; +} + +.uniui-undo-filled:before { + content: "\e64c"; +} + +.uniui-more:before { + content: "\e64d"; +} + +.uniui-more-filled:before { + content: "\e64e"; +} + +.uniui-undo:before { + content: "\e64f"; +} + +.uniui-images:before { + content: "\e650"; +} + +.uniui-paperclip:before { + content: "\e652"; +} + +.uniui-settings:before { + content: "\e653"; +} + +.uniui-search:before { + content: "\e654"; +} + +.uniui-redo-filled:before { + content: "\e655"; +} + +.uniui-list:before { + content: "\e644"; +} + +.uniui-mail-open-filled:before { + content: "\e63a"; +} + +.uniui-hand-down-filled:before { + content: "\e63c"; +} + +.uniui-hand-down:before { + content: "\e63d"; +} + +.uniui-hand-up-filled:before { + content: "\e63e"; +} + +.uniui-hand-up:before { + content: "\e63f"; +} + +.uniui-heart-filled:before { + content: "\e641"; +} + +.uniui-mail-open:before { + content: "\e643"; +} + +.uniui-heart:before { + content: "\e639"; +} + +.uniui-loop:before { + content: "\e633"; +} + +.uniui-pulldown:before { + content: "\e632"; +} + +.uniui-scan:before { + content: "\e62a"; +} + +.uniui-bars:before { + content: "\e627"; +} + +.uniui-checkbox:before { + content: "\e62b"; +} + +.uniui-checkbox-filled:before { + content: "\e62c"; +} + +.uniui-shop:before { + content: "\e62f"; +} + +.uniui-headphones:before { + content: "\e630"; +} + +.uniui-cart:before { + content: "\e631"; +} diff --git a/uni_modules/uni-icons/components/uni-icons/uniicons.ttf b/uni_modules/uni-icons/components/uni-icons/uniicons.ttf new file mode 100644 index 0000000..14696d0 Binary files /dev/null and b/uni_modules/uni-icons/components/uni-icons/uniicons.ttf differ diff --git a/uni_modules/uni-icons/components/uni-icons/uniicons_file.ts b/uni_modules/uni-icons/components/uni-icons/uniicons_file.ts new file mode 100644 index 0000000..98e93aa --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uniicons_file.ts @@ -0,0 +1,664 @@ + +export type IconsData = { + id : string + name : string + font_family : string + css_prefix_text : string + description : string + glyphs : Array +} + +export type IconsDataItem = { + font_class : string + unicode : string +} + + +export const fontData = [ + { + "font_class": "arrow-down", + "unicode": "\ue6be" + }, + { + "font_class": "arrow-left", + "unicode": "\ue6bc" + }, + { + "font_class": "arrow-right", + "unicode": "\ue6bb" + }, + { + "font_class": "arrow-up", + "unicode": "\ue6bd" + }, + { + "font_class": "auth", + "unicode": "\ue6ab" + }, + { + "font_class": "auth-filled", + "unicode": "\ue6cc" + }, + { + "font_class": "back", + "unicode": "\ue6b9" + }, + { + "font_class": "bars", + "unicode": "\ue627" + }, + { + "font_class": "calendar", + "unicode": "\ue6a0" + }, + { + "font_class": "calendar-filled", + "unicode": "\ue6c0" + }, + { + "font_class": "camera", + "unicode": "\ue65a" + }, + { + "font_class": "camera-filled", + "unicode": "\ue658" + }, + { + "font_class": "cart", + "unicode": "\ue631" + }, + { + "font_class": "cart-filled", + "unicode": "\ue6d0" + }, + { + "font_class": "chat", + "unicode": "\ue65d" + }, + { + "font_class": "chat-filled", + "unicode": "\ue659" + }, + { + "font_class": "chatboxes", + "unicode": "\ue696" + }, + { + "font_class": "chatboxes-filled", + "unicode": "\ue692" + }, + { + "font_class": "chatbubble", + "unicode": "\ue697" + }, + { + "font_class": "chatbubble-filled", + "unicode": "\ue694" + }, + { + "font_class": "checkbox", + "unicode": "\ue62b" + }, + { + "font_class": "checkbox-filled", + "unicode": "\ue62c" + }, + { + "font_class": "checkmarkempty", + "unicode": "\ue65c" + }, + { + "font_class": "circle", + "unicode": "\ue65b" + }, + { + "font_class": "circle-filled", + "unicode": "\ue65e" + }, + { + "font_class": "clear", + "unicode": "\ue66d" + }, + { + "font_class": "close", + "unicode": "\ue673" + }, + { + "font_class": "closeempty", + "unicode": "\ue66c" + }, + { + "font_class": "cloud-download", + "unicode": "\ue647" + }, + { + "font_class": "cloud-download-filled", + "unicode": "\ue646" + }, + { + "font_class": "cloud-upload", + "unicode": "\ue645" + }, + { + "font_class": "cloud-upload-filled", + "unicode": "\ue648" + }, + { + "font_class": "color", + "unicode": "\ue6cf" + }, + { + "font_class": "color-filled", + "unicode": "\ue6c9" + }, + { + "font_class": "compose", + "unicode": "\ue67f" + }, + { + "font_class": "contact", + "unicode": "\ue693" + }, + { + "font_class": "contact-filled", + "unicode": "\ue695" + }, + { + "font_class": "down", + "unicode": "\ue6b8" + }, + { + "font_class": "bottom", + "unicode": "\ue6b8" + }, + { + "font_class": "download", + "unicode": "\ue68d" + }, + { + "font_class": "download-filled", + "unicode": "\ue681" + }, + { + "font_class": "email", + "unicode": "\ue69e" + }, + { + "font_class": "email-filled", + "unicode": "\ue69a" + }, + { + "font_class": "eye", + "unicode": "\ue651" + }, + { + "font_class": "eye-filled", + "unicode": "\ue66a" + }, + { + "font_class": "eye-slash", + "unicode": "\ue6b3" + }, + { + "font_class": "eye-slash-filled", + "unicode": "\ue6b4" + }, + { + "font_class": "fire", + "unicode": "\ue6a1" + }, + { + "font_class": "fire-filled", + "unicode": "\ue6c5" + }, + { + "font_class": "flag", + "unicode": "\ue65f" + }, + { + "font_class": "flag-filled", + "unicode": "\ue660" + }, + { + "font_class": "folder-add", + "unicode": "\ue6a9" + }, + { + "font_class": "folder-add-filled", + "unicode": "\ue6c8" + }, + { + "font_class": "font", + "unicode": "\ue6a3" + }, + { + "font_class": "forward", + "unicode": "\ue6ba" + }, + { + "font_class": "gear", + "unicode": "\ue664" + }, + { + "font_class": "gear-filled", + "unicode": "\ue661" + }, + { + "font_class": "gift", + "unicode": "\ue6a4" + }, + { + "font_class": "gift-filled", + "unicode": "\ue6c4" + }, + { + "font_class": "hand-down", + "unicode": "\ue63d" + }, + { + "font_class": "hand-down-filled", + "unicode": "\ue63c" + }, + { + "font_class": "hand-up", + "unicode": "\ue63f" + }, + { + "font_class": "hand-up-filled", + "unicode": "\ue63e" + }, + { + "font_class": "headphones", + "unicode": "\ue630" + }, + { + "font_class": "heart", + "unicode": "\ue639" + }, + { + "font_class": "heart-filled", + "unicode": "\ue641" + }, + { + "font_class": "help", + "unicode": "\ue679" + }, + { + "font_class": "help-filled", + "unicode": "\ue674" + }, + { + "font_class": "home", + "unicode": "\ue662" + }, + { + "font_class": "home-filled", + "unicode": "\ue663" + }, + { + "font_class": "image", + "unicode": "\ue670" + }, + { + "font_class": "image-filled", + "unicode": "\ue678" + }, + { + "font_class": "images", + "unicode": "\ue650" + }, + { + "font_class": "images-filled", + "unicode": "\ue64b" + }, + { + "font_class": "info", + "unicode": "\ue669" + }, + { + "font_class": "info-filled", + "unicode": "\ue649" + }, + { + "font_class": "left", + "unicode": "\ue6b7" + }, + { + "font_class": "link", + "unicode": "\ue6a5" + }, + { + "font_class": "list", + "unicode": "\ue644" + }, + { + "font_class": "location", + "unicode": "\ue6ae" + }, + { + "font_class": "location-filled", + "unicode": "\ue6af" + }, + { + "font_class": "locked", + "unicode": "\ue66b" + }, + { + "font_class": "locked-filled", + "unicode": "\ue668" + }, + { + "font_class": "loop", + "unicode": "\ue633" + }, + { + "font_class": "mail-open", + "unicode": "\ue643" + }, + { + "font_class": "mail-open-filled", + "unicode": "\ue63a" + }, + { + "font_class": "map", + "unicode": "\ue667" + }, + { + "font_class": "map-filled", + "unicode": "\ue666" + }, + { + "font_class": "map-pin", + "unicode": "\ue6ad" + }, + { + "font_class": "map-pin-ellipse", + "unicode": "\ue6ac" + }, + { + "font_class": "medal", + "unicode": "\ue6a2" + }, + { + "font_class": "medal-filled", + "unicode": "\ue6c3" + }, + { + "font_class": "mic", + "unicode": "\ue671" + }, + { + "font_class": "mic-filled", + "unicode": "\ue677" + }, + { + "font_class": "micoff", + "unicode": "\ue67e" + }, + { + "font_class": "micoff-filled", + "unicode": "\ue6b0" + }, + { + "font_class": "minus", + "unicode": "\ue66f" + }, + { + "font_class": "minus-filled", + "unicode": "\ue67d" + }, + { + "font_class": "more", + "unicode": "\ue64d" + }, + { + "font_class": "more-filled", + "unicode": "\ue64e" + }, + { + "font_class": "navigate", + "unicode": "\ue66e" + }, + { + "font_class": "navigate-filled", + "unicode": "\ue67a" + }, + { + "font_class": "notification", + "unicode": "\ue6a6" + }, + { + "font_class": "notification-filled", + "unicode": "\ue6c1" + }, + { + "font_class": "paperclip", + "unicode": "\ue652" + }, + { + "font_class": "paperplane", + "unicode": "\ue672" + }, + { + "font_class": "paperplane-filled", + "unicode": "\ue675" + }, + { + "font_class": "person", + "unicode": "\ue699" + }, + { + "font_class": "person-filled", + "unicode": "\ue69d" + }, + { + "font_class": "personadd", + "unicode": "\ue69f" + }, + { + "font_class": "personadd-filled", + "unicode": "\ue698" + }, + { + "font_class": "personadd-filled-copy", + "unicode": "\ue6d1" + }, + { + "font_class": "phone", + "unicode": "\ue69c" + }, + { + "font_class": "phone-filled", + "unicode": "\ue69b" + }, + { + "font_class": "plus", + "unicode": "\ue676" + }, + { + "font_class": "plus-filled", + "unicode": "\ue6c7" + }, + { + "font_class": "plusempty", + "unicode": "\ue67b" + }, + { + "font_class": "pulldown", + "unicode": "\ue632" + }, + { + "font_class": "pyq", + "unicode": "\ue682" + }, + { + "font_class": "qq", + "unicode": "\ue680" + }, + { + "font_class": "redo", + "unicode": "\ue64a" + }, + { + "font_class": "redo-filled", + "unicode": "\ue655" + }, + { + "font_class": "refresh", + "unicode": "\ue657" + }, + { + "font_class": "refresh-filled", + "unicode": "\ue656" + }, + { + "font_class": "refreshempty", + "unicode": "\ue6bf" + }, + { + "font_class": "reload", + "unicode": "\ue6b2" + }, + { + "font_class": "right", + "unicode": "\ue6b5" + }, + { + "font_class": "scan", + "unicode": "\ue62a" + }, + { + "font_class": "search", + "unicode": "\ue654" + }, + { + "font_class": "settings", + "unicode": "\ue653" + }, + { + "font_class": "settings-filled", + "unicode": "\ue6ce" + }, + { + "font_class": "shop", + "unicode": "\ue62f" + }, + { + "font_class": "shop-filled", + "unicode": "\ue6cd" + }, + { + "font_class": "smallcircle", + "unicode": "\ue67c" + }, + { + "font_class": "smallcircle-filled", + "unicode": "\ue665" + }, + { + "font_class": "sound", + "unicode": "\ue684" + }, + { + "font_class": "sound-filled", + "unicode": "\ue686" + }, + { + "font_class": "spinner-cycle", + "unicode": "\ue68a" + }, + { + "font_class": "staff", + "unicode": "\ue6a7" + }, + { + "font_class": "staff-filled", + "unicode": "\ue6cb" + }, + { + "font_class": "star", + "unicode": "\ue688" + }, + { + "font_class": "star-filled", + "unicode": "\ue68f" + }, + { + "font_class": "starhalf", + "unicode": "\ue683" + }, + { + "font_class": "trash", + "unicode": "\ue687" + }, + { + "font_class": "trash-filled", + "unicode": "\ue685" + }, + { + "font_class": "tune", + "unicode": "\ue6aa" + }, + { + "font_class": "tune-filled", + "unicode": "\ue6ca" + }, + { + "font_class": "undo", + "unicode": "\ue64f" + }, + { + "font_class": "undo-filled", + "unicode": "\ue64c" + }, + { + "font_class": "up", + "unicode": "\ue6b6" + }, + { + "font_class": "top", + "unicode": "\ue6b6" + }, + { + "font_class": "upload", + "unicode": "\ue690" + }, + { + "font_class": "upload-filled", + "unicode": "\ue68e" + }, + { + "font_class": "videocam", + "unicode": "\ue68c" + }, + { + "font_class": "videocam-filled", + "unicode": "\ue689" + }, + { + "font_class": "vip", + "unicode": "\ue6a8" + }, + { + "font_class": "vip-filled", + "unicode": "\ue6c6" + }, + { + "font_class": "wallet", + "unicode": "\ue6b1" + }, + { + "font_class": "wallet-filled", + "unicode": "\ue6c2" + }, + { + "font_class": "weibo", + "unicode": "\ue68b" + }, + { + "font_class": "weixin", + "unicode": "\ue691" + } +] as IconsDataItem[] + +// export const fontData = JSON.parse(fontDataJson) diff --git a/uni_modules/uni-icons/components/uni-icons/uniicons_file_vue.js b/uni_modules/uni-icons/components/uni-icons/uniicons_file_vue.js new file mode 100644 index 0000000..1cd11e1 --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uniicons_file_vue.js @@ -0,0 +1,649 @@ + +export const fontData = [ + { + "font_class": "arrow-down", + "unicode": "\ue6be" + }, + { + "font_class": "arrow-left", + "unicode": "\ue6bc" + }, + { + "font_class": "arrow-right", + "unicode": "\ue6bb" + }, + { + "font_class": "arrow-up", + "unicode": "\ue6bd" + }, + { + "font_class": "auth", + "unicode": "\ue6ab" + }, + { + "font_class": "auth-filled", + "unicode": "\ue6cc" + }, + { + "font_class": "back", + "unicode": "\ue6b9" + }, + { + "font_class": "bars", + "unicode": "\ue627" + }, + { + "font_class": "calendar", + "unicode": "\ue6a0" + }, + { + "font_class": "calendar-filled", + "unicode": "\ue6c0" + }, + { + "font_class": "camera", + "unicode": "\ue65a" + }, + { + "font_class": "camera-filled", + "unicode": "\ue658" + }, + { + "font_class": "cart", + "unicode": "\ue631" + }, + { + "font_class": "cart-filled", + "unicode": "\ue6d0" + }, + { + "font_class": "chat", + "unicode": "\ue65d" + }, + { + "font_class": "chat-filled", + "unicode": "\ue659" + }, + { + "font_class": "chatboxes", + "unicode": "\ue696" + }, + { + "font_class": "chatboxes-filled", + "unicode": "\ue692" + }, + { + "font_class": "chatbubble", + "unicode": "\ue697" + }, + { + "font_class": "chatbubble-filled", + "unicode": "\ue694" + }, + { + "font_class": "checkbox", + "unicode": "\ue62b" + }, + { + "font_class": "checkbox-filled", + "unicode": "\ue62c" + }, + { + "font_class": "checkmarkempty", + "unicode": "\ue65c" + }, + { + "font_class": "circle", + "unicode": "\ue65b" + }, + { + "font_class": "circle-filled", + "unicode": "\ue65e" + }, + { + "font_class": "clear", + "unicode": "\ue66d" + }, + { + "font_class": "close", + "unicode": "\ue673" + }, + { + "font_class": "closeempty", + "unicode": "\ue66c" + }, + { + "font_class": "cloud-download", + "unicode": "\ue647" + }, + { + "font_class": "cloud-download-filled", + "unicode": "\ue646" + }, + { + "font_class": "cloud-upload", + "unicode": "\ue645" + }, + { + "font_class": "cloud-upload-filled", + "unicode": "\ue648" + }, + { + "font_class": "color", + "unicode": "\ue6cf" + }, + { + "font_class": "color-filled", + "unicode": "\ue6c9" + }, + { + "font_class": "compose", + "unicode": "\ue67f" + }, + { + "font_class": "contact", + "unicode": "\ue693" + }, + { + "font_class": "contact-filled", + "unicode": "\ue695" + }, + { + "font_class": "down", + "unicode": "\ue6b8" + }, + { + "font_class": "bottom", + "unicode": "\ue6b8" + }, + { + "font_class": "download", + "unicode": "\ue68d" + }, + { + "font_class": "download-filled", + "unicode": "\ue681" + }, + { + "font_class": "email", + "unicode": "\ue69e" + }, + { + "font_class": "email-filled", + "unicode": "\ue69a" + }, + { + "font_class": "eye", + "unicode": "\ue651" + }, + { + "font_class": "eye-filled", + "unicode": "\ue66a" + }, + { + "font_class": "eye-slash", + "unicode": "\ue6b3" + }, + { + "font_class": "eye-slash-filled", + "unicode": "\ue6b4" + }, + { + "font_class": "fire", + "unicode": "\ue6a1" + }, + { + "font_class": "fire-filled", + "unicode": "\ue6c5" + }, + { + "font_class": "flag", + "unicode": "\ue65f" + }, + { + "font_class": "flag-filled", + "unicode": "\ue660" + }, + { + "font_class": "folder-add", + "unicode": "\ue6a9" + }, + { + "font_class": "folder-add-filled", + "unicode": "\ue6c8" + }, + { + "font_class": "font", + "unicode": "\ue6a3" + }, + { + "font_class": "forward", + "unicode": "\ue6ba" + }, + { + "font_class": "gear", + "unicode": "\ue664" + }, + { + "font_class": "gear-filled", + "unicode": "\ue661" + }, + { + "font_class": "gift", + "unicode": "\ue6a4" + }, + { + "font_class": "gift-filled", + "unicode": "\ue6c4" + }, + { + "font_class": "hand-down", + "unicode": "\ue63d" + }, + { + "font_class": "hand-down-filled", + "unicode": "\ue63c" + }, + { + "font_class": "hand-up", + "unicode": "\ue63f" + }, + { + "font_class": "hand-up-filled", + "unicode": "\ue63e" + }, + { + "font_class": "headphones", + "unicode": "\ue630" + }, + { + "font_class": "heart", + "unicode": "\ue639" + }, + { + "font_class": "heart-filled", + "unicode": "\ue641" + }, + { + "font_class": "help", + "unicode": "\ue679" + }, + { + "font_class": "help-filled", + "unicode": "\ue674" + }, + { + "font_class": "home", + "unicode": "\ue662" + }, + { + "font_class": "home-filled", + "unicode": "\ue663" + }, + { + "font_class": "image", + "unicode": "\ue670" + }, + { + "font_class": "image-filled", + "unicode": "\ue678" + }, + { + "font_class": "images", + "unicode": "\ue650" + }, + { + "font_class": "images-filled", + "unicode": "\ue64b" + }, + { + "font_class": "info", + "unicode": "\ue669" + }, + { + "font_class": "info-filled", + "unicode": "\ue649" + }, + { + "font_class": "left", + "unicode": "\ue6b7" + }, + { + "font_class": "link", + "unicode": "\ue6a5" + }, + { + "font_class": "list", + "unicode": "\ue644" + }, + { + "font_class": "location", + "unicode": "\ue6ae" + }, + { + "font_class": "location-filled", + "unicode": "\ue6af" + }, + { + "font_class": "locked", + "unicode": "\ue66b" + }, + { + "font_class": "locked-filled", + "unicode": "\ue668" + }, + { + "font_class": "loop", + "unicode": "\ue633" + }, + { + "font_class": "mail-open", + "unicode": "\ue643" + }, + { + "font_class": "mail-open-filled", + "unicode": "\ue63a" + }, + { + "font_class": "map", + "unicode": "\ue667" + }, + { + "font_class": "map-filled", + "unicode": "\ue666" + }, + { + "font_class": "map-pin", + "unicode": "\ue6ad" + }, + { + "font_class": "map-pin-ellipse", + "unicode": "\ue6ac" + }, + { + "font_class": "medal", + "unicode": "\ue6a2" + }, + { + "font_class": "medal-filled", + "unicode": "\ue6c3" + }, + { + "font_class": "mic", + "unicode": "\ue671" + }, + { + "font_class": "mic-filled", + "unicode": "\ue677" + }, + { + "font_class": "micoff", + "unicode": "\ue67e" + }, + { + "font_class": "micoff-filled", + "unicode": "\ue6b0" + }, + { + "font_class": "minus", + "unicode": "\ue66f" + }, + { + "font_class": "minus-filled", + "unicode": "\ue67d" + }, + { + "font_class": "more", + "unicode": "\ue64d" + }, + { + "font_class": "more-filled", + "unicode": "\ue64e" + }, + { + "font_class": "navigate", + "unicode": "\ue66e" + }, + { + "font_class": "navigate-filled", + "unicode": "\ue67a" + }, + { + "font_class": "notification", + "unicode": "\ue6a6" + }, + { + "font_class": "notification-filled", + "unicode": "\ue6c1" + }, + { + "font_class": "paperclip", + "unicode": "\ue652" + }, + { + "font_class": "paperplane", + "unicode": "\ue672" + }, + { + "font_class": "paperplane-filled", + "unicode": "\ue675" + }, + { + "font_class": "person", + "unicode": "\ue699" + }, + { + "font_class": "person-filled", + "unicode": "\ue69d" + }, + { + "font_class": "personadd", + "unicode": "\ue69f" + }, + { + "font_class": "personadd-filled", + "unicode": "\ue698" + }, + { + "font_class": "personadd-filled-copy", + "unicode": "\ue6d1" + }, + { + "font_class": "phone", + "unicode": "\ue69c" + }, + { + "font_class": "phone-filled", + "unicode": "\ue69b" + }, + { + "font_class": "plus", + "unicode": "\ue676" + }, + { + "font_class": "plus-filled", + "unicode": "\ue6c7" + }, + { + "font_class": "plusempty", + "unicode": "\ue67b" + }, + { + "font_class": "pulldown", + "unicode": "\ue632" + }, + { + "font_class": "pyq", + "unicode": "\ue682" + }, + { + "font_class": "qq", + "unicode": "\ue680" + }, + { + "font_class": "redo", + "unicode": "\ue64a" + }, + { + "font_class": "redo-filled", + "unicode": "\ue655" + }, + { + "font_class": "refresh", + "unicode": "\ue657" + }, + { + "font_class": "refresh-filled", + "unicode": "\ue656" + }, + { + "font_class": "refreshempty", + "unicode": "\ue6bf" + }, + { + "font_class": "reload", + "unicode": "\ue6b2" + }, + { + "font_class": "right", + "unicode": "\ue6b5" + }, + { + "font_class": "scan", + "unicode": "\ue62a" + }, + { + "font_class": "search", + "unicode": "\ue654" + }, + { + "font_class": "settings", + "unicode": "\ue653" + }, + { + "font_class": "settings-filled", + "unicode": "\ue6ce" + }, + { + "font_class": "shop", + "unicode": "\ue62f" + }, + { + "font_class": "shop-filled", + "unicode": "\ue6cd" + }, + { + "font_class": "smallcircle", + "unicode": "\ue67c" + }, + { + "font_class": "smallcircle-filled", + "unicode": "\ue665" + }, + { + "font_class": "sound", + "unicode": "\ue684" + }, + { + "font_class": "sound-filled", + "unicode": "\ue686" + }, + { + "font_class": "spinner-cycle", + "unicode": "\ue68a" + }, + { + "font_class": "staff", + "unicode": "\ue6a7" + }, + { + "font_class": "staff-filled", + "unicode": "\ue6cb" + }, + { + "font_class": "star", + "unicode": "\ue688" + }, + { + "font_class": "star-filled", + "unicode": "\ue68f" + }, + { + "font_class": "starhalf", + "unicode": "\ue683" + }, + { + "font_class": "trash", + "unicode": "\ue687" + }, + { + "font_class": "trash-filled", + "unicode": "\ue685" + }, + { + "font_class": "tune", + "unicode": "\ue6aa" + }, + { + "font_class": "tune-filled", + "unicode": "\ue6ca" + }, + { + "font_class": "undo", + "unicode": "\ue64f" + }, + { + "font_class": "undo-filled", + "unicode": "\ue64c" + }, + { + "font_class": "up", + "unicode": "\ue6b6" + }, + { + "font_class": "top", + "unicode": "\ue6b6" + }, + { + "font_class": "upload", + "unicode": "\ue690" + }, + { + "font_class": "upload-filled", + "unicode": "\ue68e" + }, + { + "font_class": "videocam", + "unicode": "\ue68c" + }, + { + "font_class": "videocam-filled", + "unicode": "\ue689" + }, + { + "font_class": "vip", + "unicode": "\ue6a8" + }, + { + "font_class": "vip-filled", + "unicode": "\ue6c6" + }, + { + "font_class": "wallet", + "unicode": "\ue6b1" + }, + { + "font_class": "wallet-filled", + "unicode": "\ue6c2" + }, + { + "font_class": "weibo", + "unicode": "\ue68b" + }, + { + "font_class": "weixin", + "unicode": "\ue691" + } +] + +// export const fontData = JSON.parse(fontDataJson) diff --git a/uni_modules/uni-icons/package.json b/uni_modules/uni-icons/package.json new file mode 100644 index 0000000..6b681b4 --- /dev/null +++ b/uni_modules/uni-icons/package.json @@ -0,0 +1,89 @@ +{ + "id": "uni-icons", + "displayName": "uni-icons 图标", + "version": "2.0.10", + "description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。", + "keywords": [ + "uni-ui", + "uniui", + "icon", + "图标" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "^3.2.14" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": ["uni-scss"], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y", + "alipay": "n" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y", + "app-uvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y", + "钉钉": "y", + "快手": "y", + "飞书": "y", + "京东": "y" + }, + "快应用": { + "华为": "y", + "联盟": "y" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} diff --git a/uni_modules/uni-icons/readme.md b/uni_modules/uni-icons/readme.md new file mode 100644 index 0000000..86234ba --- /dev/null +++ b/uni_modules/uni-icons/readme.md @@ -0,0 +1,8 @@ +## Icons 图标 +> **组件名:uni-icons** +> 代码块: `uIcons` + +用于展示 icons 图标 。 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-icons) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 diff --git a/uni_modules/uni-scss/changelog.md b/uni_modules/uni-scss/changelog.md new file mode 100644 index 0000000..b863bb0 --- /dev/null +++ b/uni_modules/uni-scss/changelog.md @@ -0,0 +1,8 @@ +## 1.0.3(2022-01-21) +- 优化 组件示例 +## 1.0.2(2021-11-22) +- 修复 / 符号在 vue 不同版本兼容问题引起的报错问题 +## 1.0.1(2021-11-22) +- 修复 vue3中scss语法兼容问题 +## 1.0.0(2021-11-18) +- init diff --git a/uni_modules/uni-scss/index.scss b/uni_modules/uni-scss/index.scss new file mode 100644 index 0000000..1744a5f --- /dev/null +++ b/uni_modules/uni-scss/index.scss @@ -0,0 +1 @@ +@import './styles/index.scss'; diff --git a/uni_modules/uni-scss/package.json b/uni_modules/uni-scss/package.json new file mode 100644 index 0000000..7cc0ccb --- /dev/null +++ b/uni_modules/uni-scss/package.json @@ -0,0 +1,82 @@ +{ + "id": "uni-scss", + "displayName": "uni-scss 辅助样式", + "version": "1.0.3", + "description": "uni-sass是uni-ui提供的一套全局样式 ,通过一些简单的类名和sass变量,实现简单的页面布局操作,比如颜色、边距、圆角等。", + "keywords": [ + "uni-scss", + "uni-ui", + "辅助样式" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "^3.1.0" + }, + "dcloudext": { + "category": [ + "JS SDK", + "通用 SDK" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "u" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "n", + "联盟": "n" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} diff --git a/uni_modules/uni-scss/readme.md b/uni_modules/uni-scss/readme.md new file mode 100644 index 0000000..b7d1c25 --- /dev/null +++ b/uni_modules/uni-scss/readme.md @@ -0,0 +1,4 @@ +`uni-sass` 是 `uni-ui`提供的一套全局样式 ,通过一些简单的类名和`sass`变量,实现简单的页面布局操作,比如颜色、边距、圆角等。 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-sass) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 \ No newline at end of file diff --git a/uni_modules/uni-scss/styles/index.scss b/uni_modules/uni-scss/styles/index.scss new file mode 100644 index 0000000..ffac4fe --- /dev/null +++ b/uni_modules/uni-scss/styles/index.scss @@ -0,0 +1,7 @@ +@import './setting/_variables.scss'; +@import './setting/_border.scss'; +@import './setting/_color.scss'; +@import './setting/_space.scss'; +@import './setting/_radius.scss'; +@import './setting/_text.scss'; +@import './setting/_styles.scss'; diff --git a/uni_modules/uni-scss/styles/setting/_border.scss b/uni_modules/uni-scss/styles/setting/_border.scss new file mode 100644 index 0000000..12a11c3 --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_border.scss @@ -0,0 +1,3 @@ +.uni-border { + border: 1px $uni-border-1 solid; +} \ No newline at end of file diff --git a/uni_modules/uni-scss/styles/setting/_color.scss b/uni_modules/uni-scss/styles/setting/_color.scss new file mode 100644 index 0000000..1ededd9 --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_color.scss @@ -0,0 +1,66 @@ + +// TODO 暂时不需要 class ,需要用户使用变量实现 ,如果使用类名其实并不推荐 +// @mixin get-styles($k,$c) { +// @if $k == size or $k == weight{ +// font-#{$k}:#{$c} +// }@else{ +// #{$k}:#{$c} +// } +// } +$uni-ui-color:( + // 主色 + primary: $uni-primary, + primary-disable: $uni-primary-disable, + primary-light: $uni-primary-light, + // 辅助色 + success: $uni-success, + success-disable: $uni-success-disable, + success-light: $uni-success-light, + warning: $uni-warning, + warning-disable: $uni-warning-disable, + warning-light: $uni-warning-light, + error: $uni-error, + error-disable: $uni-error-disable, + error-light: $uni-error-light, + info: $uni-info, + info-disable: $uni-info-disable, + info-light: $uni-info-light, + // 中性色 + main-color: $uni-main-color, + base-color: $uni-base-color, + secondary-color: $uni-secondary-color, + extra-color: $uni-extra-color, + // 背景色 + bg-color: $uni-bg-color, + // 边框颜色 + border-1: $uni-border-1, + border-2: $uni-border-2, + border-3: $uni-border-3, + border-4: $uni-border-4, + // 黑色 + black:$uni-black, + // 白色 + white:$uni-white, + // 透明 + transparent:$uni-transparent +) !default; +@each $key, $child in $uni-ui-color { + .uni-#{"" + $key} { + color: $child; + } + .uni-#{"" + $key}-bg { + background-color: $child; + } +} +.uni-shadow-sm { + box-shadow: $uni-shadow-sm; +} +.uni-shadow-base { + box-shadow: $uni-shadow-base; +} +.uni-shadow-lg { + box-shadow: $uni-shadow-lg; +} +.uni-mask { + background-color:$uni-mask; +} diff --git a/uni_modules/uni-scss/styles/setting/_radius.scss b/uni_modules/uni-scss/styles/setting/_radius.scss new file mode 100644 index 0000000..9a0428b --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_radius.scss @@ -0,0 +1,55 @@ +@mixin radius($r,$d:null ,$important: false){ + $radius-value:map-get($uni-radius, $r) if($important, !important, null); + // Key exists within the $uni-radius variable + @if (map-has-key($uni-radius, $r) and $d){ + @if $d == t { + border-top-left-radius:$radius-value; + border-top-right-radius:$radius-value; + }@else if $d == r { + border-top-right-radius:$radius-value; + border-bottom-right-radius:$radius-value; + }@else if $d == b { + border-bottom-left-radius:$radius-value; + border-bottom-right-radius:$radius-value; + }@else if $d == l { + border-top-left-radius:$radius-value; + border-bottom-left-radius:$radius-value; + }@else if $d == tl { + border-top-left-radius:$radius-value; + }@else if $d == tr { + border-top-right-radius:$radius-value; + }@else if $d == br { + border-bottom-right-radius:$radius-value; + }@else if $d == bl { + border-bottom-left-radius:$radius-value; + } + }@else{ + border-radius:$radius-value; + } +} + +@each $key, $child in $uni-radius { + @if($key){ + .uni-radius-#{"" + $key} { + @include radius($key) + } + }@else{ + .uni-radius { + @include radius($key) + } + } +} + +@each $direction in t, r, b, l,tl, tr, br, bl { + @each $key, $child in $uni-radius { + @if($key){ + .uni-radius-#{"" + $direction}-#{"" + $key} { + @include radius($key,$direction,false) + } + }@else{ + .uni-radius-#{$direction} { + @include radius($key,$direction,false) + } + } + } +} diff --git a/uni_modules/uni-scss/styles/setting/_space.scss b/uni_modules/uni-scss/styles/setting/_space.scss new file mode 100644 index 0000000..3c89528 --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_space.scss @@ -0,0 +1,56 @@ + +@mixin fn($space,$direction,$size,$n) { + @if $n { + #{$space}-#{$direction}: #{$size*$uni-space-root}px + } @else { + #{$space}-#{$direction}: #{-$size*$uni-space-root}px + } +} +@mixin get-styles($direction,$i,$space,$n){ + @if $direction == t { + @include fn($space, top,$i,$n); + } + @if $direction == r { + @include fn($space, right,$i,$n); + } + @if $direction == b { + @include fn($space, bottom,$i,$n); + } + @if $direction == l { + @include fn($space, left,$i,$n); + } + @if $direction == x { + @include fn($space, left,$i,$n); + @include fn($space, right,$i,$n); + } + @if $direction == y { + @include fn($space, top,$i,$n); + @include fn($space, bottom,$i,$n); + } + @if $direction == a { + @if $n { + #{$space}:#{$i*$uni-space-root}px; + } @else { + #{$space}:#{-$i*$uni-space-root}px; + } + } +} + +@each $orientation in m,p { + $space: margin; + @if $orientation == m { + $space: margin; + } @else { + $space: padding; + } + @for $i from 0 through 16 { + @each $direction in t, r, b, l, x, y, a { + .uni-#{$orientation}#{$direction}-#{$i} { + @include get-styles($direction,$i,$space,true); + } + .uni-#{$orientation}#{$direction}-n#{$i} { + @include get-styles($direction,$i,$space,false); + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-scss/styles/setting/_styles.scss b/uni_modules/uni-scss/styles/setting/_styles.scss new file mode 100644 index 0000000..689afec --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_styles.scss @@ -0,0 +1,167 @@ +/* #ifndef APP-NVUE */ + +$-color-white:#fff; +$-color-black:#000; +@mixin base-style($color) { + color: #fff; + background-color: $color; + border-color: mix($-color-black, $color, 8%); + &:not([hover-class]):active { + background: mix($-color-black, $color, 10%); + border-color: mix($-color-black, $color, 20%); + color: $-color-white; + outline: none; + } +} +@mixin is-color($color) { + @include base-style($color); + &[loading] { + @include base-style($color); + &::before { + margin-right:5px; + } + } + &[disabled] { + &, + &[loading], + &:not([hover-class]):active { + color: $-color-white; + border-color: mix(darken($color,10%), $-color-white); + background-color: mix($color, $-color-white); + } + } + +} +@mixin base-plain-style($color) { + color:$color; + background-color: mix($-color-white, $color, 90%); + border-color: mix($-color-white, $color, 70%); + &:not([hover-class]):active { + background: mix($-color-white, $color, 80%); + color: $color; + outline: none; + border-color: mix($-color-white, $color, 50%); + } +} +@mixin is-plain($color){ + &[plain] { + @include base-plain-style($color); + &[loading] { + @include base-plain-style($color); + &::before { + margin-right:5px; + } + } + &[disabled] { + &, + &:active { + color: mix($-color-white, $color, 40%); + background-color: mix($-color-white, $color, 90%); + border-color: mix($-color-white, $color, 80%); + } + } + } +} + + +.uni-btn { + margin: 5px; + color: #393939; + border:1px solid #ccc; + font-size: 16px; + font-weight: 200; + background-color: #F9F9F9; + // TODO 暂时处理边框隐藏一边的问题 + overflow: visible; + &::after{ + border: none; + } + + &:not([type]),&[type=default] { + color: #999; + &[loading] { + background: none; + &::before { + margin-right:5px; + } + } + + + + &[disabled]{ + color: mix($-color-white, #999, 60%); + &, + &[loading], + &:active { + color: mix($-color-white, #999, 60%); + background-color: mix($-color-white,$-color-black , 98%); + border-color: mix($-color-white, #999, 85%); + } + } + + &[plain] { + color: #999; + background: none; + border-color: $uni-border-1; + &:not([hover-class]):active { + background: none; + color: mix($-color-white, $-color-black, 80%); + border-color: mix($-color-white, $-color-black, 90%); + outline: none; + } + &[disabled]{ + &, + &[loading], + &:active { + background: none; + color: mix($-color-white, #999, 60%); + border-color: mix($-color-white, #999, 85%); + } + } + } + } + + &:not([hover-class]):active { + color: mix($-color-white, $-color-black, 50%); + } + + &[size=mini] { + font-size: 16px; + font-weight: 200; + border-radius: 8px; + } + + + + &.uni-btn-small { + font-size: 14px; + } + &.uni-btn-mini { + font-size: 12px; + } + + &.uni-btn-radius { + border-radius: 999px; + } + &[type=primary] { + @include is-color($uni-primary); + @include is-plain($uni-primary) + } + &[type=success] { + @include is-color($uni-success); + @include is-plain($uni-success) + } + &[type=error] { + @include is-color($uni-error); + @include is-plain($uni-error) + } + &[type=warning] { + @include is-color($uni-warning); + @include is-plain($uni-warning) + } + &[type=info] { + @include is-color($uni-info); + @include is-plain($uni-info) + } +} +/* #endif */ diff --git a/uni_modules/uni-scss/styles/setting/_text.scss b/uni_modules/uni-scss/styles/setting/_text.scss new file mode 100644 index 0000000..a34d08f --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_text.scss @@ -0,0 +1,24 @@ +@mixin get-styles($k,$c) { + @if $k == size or $k == weight{ + font-#{$k}:#{$c} + }@else{ + #{$k}:#{$c} + } +} + +@each $key, $child in $uni-headings { + /* #ifndef APP-NVUE */ + .uni-#{$key} { + @each $k, $c in $child { + @include get-styles($k,$c) + } + } + /* #endif */ + /* #ifdef APP-NVUE */ + .container .uni-#{$key} { + @each $k, $c in $child { + @include get-styles($k,$c) + } + } + /* #endif */ +} diff --git a/uni_modules/uni-scss/styles/setting/_variables.scss b/uni_modules/uni-scss/styles/setting/_variables.scss new file mode 100644 index 0000000..557d3d7 --- /dev/null +++ b/uni_modules/uni-scss/styles/setting/_variables.scss @@ -0,0 +1,146 @@ +// @use "sass:math"; +@import '../tools/functions.scss'; +// 间距基础倍数 +$uni-space-root: 2 !default; +// 边框半径默认值 +$uni-radius-root:5px !default; +$uni-radius: () !default; +// 边框半径断点 +$uni-radius: map-deep-merge( + ( + 0: 0, + // TODO 当前版本暂时不支持 sm 属性 + // 'sm': math.div($uni-radius-root, 2), + null: $uni-radius-root, + 'lg': $uni-radius-root * 2, + 'xl': $uni-radius-root * 6, + 'pill': 9999px, + 'circle': 50% + ), + $uni-radius +); +// 字体家族 +$body-font-family: 'Roboto', sans-serif !default; +// 文本 +$heading-font-family: $body-font-family !default; +$uni-headings: () !default; +$letterSpacing: -0.01562em; +$uni-headings: map-deep-merge( + ( + 'h1': ( + size: 32px, + weight: 300, + line-height: 50px, + // letter-spacing:-0.01562em + ), + 'h2': ( + size: 28px, + weight: 300, + line-height: 40px, + // letter-spacing: -0.00833em + ), + 'h3': ( + size: 24px, + weight: 400, + line-height: 32px, + // letter-spacing: normal + ), + 'h4': ( + size: 20px, + weight: 400, + line-height: 30px, + // letter-spacing: 0.00735em + ), + 'h5': ( + size: 16px, + weight: 400, + line-height: 24px, + // letter-spacing: normal + ), + 'h6': ( + size: 14px, + weight: 500, + line-height: 18px, + // letter-spacing: 0.0125em + ), + 'subtitle': ( + size: 12px, + weight: 400, + line-height: 20px, + // letter-spacing: 0.00937em + ), + 'body': ( + font-size: 14px, + font-weight: 400, + line-height: 22px, + // letter-spacing: 0.03125em + ), + 'caption': ( + 'size': 12px, + 'weight': 400, + 'line-height': 20px, + // 'letter-spacing': 0.03333em, + // 'text-transform': false + ) + ), + $uni-headings +); + + + +// 主色 +$uni-primary: #2979ff !default; +$uni-primary-disable:lighten($uni-primary,20%) !default; +$uni-primary-light: lighten($uni-primary,25%) !default; + +// 辅助色 +// 除了主色外的场景色,需要在不同的场景中使用(例如危险色表示危险的操作)。 +$uni-success: #18bc37 !default; +$uni-success-disable:lighten($uni-success,20%) !default; +$uni-success-light: lighten($uni-success,25%) !default; + +$uni-warning: #f3a73f !default; +$uni-warning-disable:lighten($uni-warning,20%) !default; +$uni-warning-light: lighten($uni-warning,25%) !default; + +$uni-error: #e43d33 !default; +$uni-error-disable:lighten($uni-error,20%) !default; +$uni-error-light: lighten($uni-error,25%) !default; + +$uni-info: #8f939c !default; +$uni-info-disable:lighten($uni-info,20%) !default; +$uni-info-light: lighten($uni-info,25%) !default; + +// 中性色 +// 中性色用于文本、背景和边框颜色。通过运用不同的中性色,来表现层次结构。 +$uni-main-color: #3a3a3a !default; // 主要文字 +$uni-base-color: #6a6a6a !default; // 常规文字 +$uni-secondary-color: #909399 !default; // 次要文字 +$uni-extra-color: #c7c7c7 !default; // 辅助说明 + +// 边框颜色 +$uni-border-1: #F0F0F0 !default; +$uni-border-2: #EDEDED !default; +$uni-border-3: #DCDCDC !default; +$uni-border-4: #B9B9B9 !default; + +// 常规色 +$uni-black: #000000 !default; +$uni-white: #ffffff !default; +$uni-transparent: rgba($color: #000000, $alpha: 0) !default; + +// 背景色 +$uni-bg-color: #f7f7f7 !default; + +/* 水平间距 */ +$uni-spacing-sm: 8px !default; +$uni-spacing-base: 15px !default; +$uni-spacing-lg: 30px !default; + +// 阴影 +$uni-shadow-sm:0 0 5px rgba($color: #d8d8d8, $alpha: 0.5) !default; +$uni-shadow-base:0 1px 8px 1px rgba($color: #a5a5a5, $alpha: 0.2) !default; +$uni-shadow-lg:0px 1px 10px 2px rgba($color: #a5a4a4, $alpha: 0.5) !default; + +// 蒙版 +$uni-mask: rgba($color: #000000, $alpha: 0.4) !default; diff --git a/uni_modules/uni-scss/styles/tools/functions.scss b/uni_modules/uni-scss/styles/tools/functions.scss new file mode 100644 index 0000000..ac6f63e --- /dev/null +++ b/uni_modules/uni-scss/styles/tools/functions.scss @@ -0,0 +1,19 @@ +// 合并 map +@function map-deep-merge($parent-map, $child-map){ + $result: $parent-map; + @each $key, $child in $child-map { + $parent-has-key: map-has-key($result, $key); + $parent-value: map-get($result, $key); + $parent-type: type-of($parent-value); + $child-type: type-of($child); + $parent-is-map: $parent-type == map; + $child-is-map: $child-type == map; + + @if (not $parent-has-key) or ($parent-type != $child-type) or (not ($parent-is-map and $child-is-map)){ + $result: map-merge($result, ( $key: $child )); + }@else { + $result: map-merge($result, ( $key: map-deep-merge($parent-value, $child) )); + } + } + @return $result; +}; diff --git a/uni_modules/uni-scss/theme.scss b/uni_modules/uni-scss/theme.scss new file mode 100644 index 0000000..80ee62f --- /dev/null +++ b/uni_modules/uni-scss/theme.scss @@ -0,0 +1,31 @@ +// 间距基础倍数 +$uni-space-root: 2; +// 边框半径默认值 +$uni-radius-root:5px; +// 主色 +$uni-primary: #2979ff; +// 辅助色 +$uni-success: #4cd964; +// 警告色 +$uni-warning: #f0ad4e; +// 错误色 +$uni-error: #dd524d; +// 描述色 +$uni-info: #909399; +// 中性色 +$uni-main-color: #303133; +$uni-base-color: #606266; +$uni-secondary-color: #909399; +$uni-extra-color: #C0C4CC; +// 背景色 +$uni-bg-color: #f5f5f5; +// 边框颜色 +$uni-border-1: #DCDFE6; +$uni-border-2: #E4E7ED; +$uni-border-3: #EBEEF5; +$uni-border-4: #F2F6FC; + +// 常规色 +$uni-black: #000000; +$uni-white: #ffffff; +$uni-transparent: rgba($color: #000000, $alpha: 0); diff --git a/uni_modules/uni-scss/variables.scss b/uni_modules/uni-scss/variables.scss new file mode 100644 index 0000000..1c062d4 --- /dev/null +++ b/uni_modules/uni-scss/variables.scss @@ -0,0 +1,62 @@ +@import './styles/setting/_variables.scss'; +// 间距基础倍数 +$uni-space-root: 2; +// 边框半径默认值 +$uni-radius-root:5px; + +// 主色 +$uni-primary: #2979ff; +$uni-primary-disable:mix(#fff,$uni-primary,50%); +$uni-primary-light: mix(#fff,$uni-primary,80%); + +// 辅助色 +// 除了主色外的场景色,需要在不同的场景中使用(例如危险色表示危险的操作)。 +$uni-success: #18bc37; +$uni-success-disable:mix(#fff,$uni-success,50%); +$uni-success-light: mix(#fff,$uni-success,80%); + +$uni-warning: #f3a73f; +$uni-warning-disable:mix(#fff,$uni-warning,50%); +$uni-warning-light: mix(#fff,$uni-warning,80%); + +$uni-error: #e43d33; +$uni-error-disable:mix(#fff,$uni-error,50%); +$uni-error-light: mix(#fff,$uni-error,80%); + +$uni-info: #8f939c; +$uni-info-disable:mix(#fff,$uni-info,50%); +$uni-info-light: mix(#fff,$uni-info,80%); + +// 中性色 +// 中性色用于文本、背景和边框颜色。通过运用不同的中性色,来表现层次结构。 +$uni-main-color: #3a3a3a; // 主要文字 +$uni-base-color: #6a6a6a; // 常规文字 +$uni-secondary-color: #909399; // 次要文字 +$uni-extra-color: #c7c7c7; // 辅助说明 + +// 边框颜色 +$uni-border-1: #F0F0F0; +$uni-border-2: #EDEDED; +$uni-border-3: #DCDCDC; +$uni-border-4: #B9B9B9; + +// 常规色 +$uni-black: #000000; +$uni-white: #ffffff; +$uni-transparent: rgba($color: #000000, $alpha: 0); + +// 背景色 +$uni-bg-color: #f7f7f7; + +/* 水平间距 */ +$uni-spacing-sm: 8px; +$uni-spacing-base: 15px; +$uni-spacing-lg: 30px; + +// 阴影 +$uni-shadow-sm:0 0 5px rgba($color: #d8d8d8, $alpha: 0.5); +$uni-shadow-base:0 1px 8px 1px rgba($color: #a5a5a5, $alpha: 0.2); +$uni-shadow-lg:0px 1px 10px 2px rgba($color: #a5a4a4, $alpha: 0.5); + +// 蒙版 +$uni-mask: rgba($color: #000000, $alpha: 0.4); diff --git a/uni_modules/uni-steps/changelog.md b/uni_modules/uni-steps/changelog.md new file mode 100644 index 0000000..04367d8 --- /dev/null +++ b/uni_modules/uni-steps/changelog.md @@ -0,0 +1,18 @@ +## 1.1.2(2024-03-28) +- 修复 uni-steps为竖排列时,文本长度过长引起点错乱的bug +## 1.1.1(2021-11-22) +- 修复 vue3中某些scss变量无法找到的问题 +## 1.1.0(2021-11-19) +- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-steps](https://uniapp.dcloud.io/component/uniui/uni-steps) +## 1.0.8(2021-05-12) +- 新增 项目示例地址 +## 1.0.7(2021-05-06) +- 修复 uni-steps 横向布局时,多行文字高度不合理的 bug +## 1.0.6(2021-04-21) +- 优化 添加依赖 uni-icons, 导入后自动下载依赖 +## 1.0.5(2021-02-05) +- 优化 组件引用关系,通过uni_modules引用组件 + +## 1.0.4(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-steps/components/uni-steps/uni-steps.vue b/uni_modules/uni-steps/components/uni-steps/uni-steps.vue new file mode 100644 index 0000000..81017fc --- /dev/null +++ b/uni_modules/uni-steps/components/uni-steps/uni-steps.vue @@ -0,0 +1,280 @@ + + + + + diff --git a/uni_modules/uni-steps/package.json b/uni_modules/uni-steps/package.json new file mode 100644 index 0000000..4145ce9 --- /dev/null +++ b/uni_modules/uni-steps/package.json @@ -0,0 +1,87 @@ +{ + "id": "uni-steps", + "displayName": "uni-steps 步骤条", + "version": "1.1.2", + "description": "步骤条组件,提供横向和纵向两种布局格式。", + "keywords": [ + "uni-ui", + "uniui", + "步骤条", + "时间轴" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [ + "uni-scss", + "uni-icons" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y", + "alipay": "n" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-steps/readme.md b/uni_modules/uni-steps/readme.md new file mode 100644 index 0000000..da7a4bf --- /dev/null +++ b/uni_modules/uni-steps/readme.md @@ -0,0 +1,13 @@ + + +## Steps 步骤条 +> **组件名:uni-steps** +> 代码块: `uSteps` + + +步骤条,常用于显示进度 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-steps) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 + + diff --git a/utils/ruoyi.js b/utils/ruoyi.js index 5bc3a70..28b53be 100644 --- a/utils/ruoyi.js +++ b/utils/ruoyi.js @@ -3,6 +3,8 @@ * Copyright (c) 2019 ruoyi */ +import dayjs from '@/uni_modules/uview-ui/libs/util/dayjs.js' + // 日期格式化 export function parseTime(time, pattern) { if (arguments.length === 0 || !time) { @@ -44,4 +46,28 @@ export function parseTime(time, pattern) { return value || 0 }) return time_str +} + + +/** + * 时间日期转换 + * @param {dayjs.ConfigType} date 当前时间,new Date() 格式 + * @param {string} format 需要转换的时间格式字符串 + * @description format 字符串随意,如 `YYYY-mm、YYYY-mm-dd` + * @description format 季度:"YYYY-mm-dd HH:MM:SS QQQQ" + * @description format 星期:"YYYY-mm-dd HH:MM:SS WWW" + * @description format 几周:"YYYY-mm-dd HH:MM:SS ZZZ" + * @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ" + * @returns {string} 返回拼接后的时间字符串 + */ +export function formatDate(date, format = 'YYYY-MM-DD HH:mm:ss') { + // 日期不存在,则返回空 + if (!date) { + return ''; + } + // 日期存在,则进行格式化 + if (format === undefined) { + format = 'YYYY-MM-DD HH:mm:ss'; + } + return dayjs(date).format(format); } \ No newline at end of file diff --git a/wxcomponents/vant/action-sheet/index.d.ts b/wxcomponents/vant/action-sheet/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/action-sheet/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/action-sheet/index.js b/wxcomponents/vant/action-sheet/index.js new file mode 100644 index 0000000..9c4879c --- /dev/null +++ b/wxcomponents/vant/action-sheet/index.js @@ -0,0 +1,75 @@ +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +VantComponent({ + classes: ['list-class'], + mixins: [button], + props: { + show: Boolean, + title: String, + cancelText: String, + description: String, + round: { + type: Boolean, + value: true, + }, + zIndex: { + type: Number, + value: 100, + }, + actions: { + type: Array, + value: [], + }, + overlay: { + type: Boolean, + value: true, + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + }, + closeOnClickAction: { + type: Boolean, + value: true, + }, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + rootPortal: { + type: Boolean, + value: false, + }, + }, + methods: { + onSelect(event) { + const { index } = event.currentTarget.dataset; + const { actions, closeOnClickAction, canIUseGetUserProfile } = this.data; + const item = actions[index]; + if (item) { + this.$emit('select', item); + if (closeOnClickAction) { + this.onClose(); + } + if (item.openType === 'getUserInfo' && canIUseGetUserProfile) { + wx.getUserProfile({ + desc: item.getUserProfileDesc || ' ', + complete: (userProfile) => { + this.$emit('getuserinfo', userProfile); + }, + }); + } + } + }, + onCancel() { + this.$emit('cancel'); + }, + onClose() { + this.$emit('close'); + }, + onClickOverlay() { + this.$emit('click-overlay'); + this.onClose(); + }, + }, +}); diff --git a/wxcomponents/vant/action-sheet/index.json b/wxcomponents/vant/action-sheet/index.json new file mode 100644 index 0000000..19bf989 --- /dev/null +++ b/wxcomponents/vant/action-sheet/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-popup": "../popup/index", + "van-loading": "../loading/index" + } +} diff --git a/wxcomponents/vant/action-sheet/index.wxml b/wxcomponents/vant/action-sheet/index.wxml new file mode 100644 index 0000000..6311e33 --- /dev/null +++ b/wxcomponents/vant/action-sheet/index.wxml @@ -0,0 +1,70 @@ + + + + + {{ title }} + + + + {{ description }} + + + + + + + + + + {{ cancelText }} + + + diff --git a/wxcomponents/vant/action-sheet/index.wxss b/wxcomponents/vant/action-sheet/index.wxss new file mode 100644 index 0000000..eedd361 --- /dev/null +++ b/wxcomponents/vant/action-sheet/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-action-sheet{color:var(--action-sheet-item-text-color,#323233);max-height:var(--action-sheet-max-height,90%)!important}.van-action-sheet__cancel,.van-action-sheet__item{background-color:var(--action-sheet-item-background,#fff);font-size:var(--action-sheet-item-font-size,16px);line-height:var(--action-sheet-item-line-height,22px);padding:14px 16px;text-align:center}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel:after,.van-action-sheet__item:after{border-width:0}.van-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,#646566)}.van-action-sheet__gap{background-color:var(--action-sheet-cancel-padding-color,#f7f8fa);display:block;height:var(--action-sheet-cancel-padding-top,8px)}.van-action-sheet__item--disabled{color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{color:var(--action-sheet-subname-color,#969799);font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.van-action-sheet__header{font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--font-weight-bold,500);line-height:var(--action-sheet-header-height,48px);text-align:center}.van-action-sheet__description{color:var(--action-sheet-description-color,#969799);font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.van-action-sheet__close{color:var(--action-sheet-close-icon-color,#c8c9cc);font-size:var(--action-sheet-close-icon-size,22px)!important;line-height:inherit!important;padding:var(--action-sheet-close-icon-padding,0 16px);position:absolute!important;right:0;top:0}.van-action-sheet__loading{display:flex!important} \ No newline at end of file diff --git a/wxcomponents/vant/area/index.d.ts b/wxcomponents/vant/area/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/area/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/area/index.js b/wxcomponents/vant/area/index.js new file mode 100644 index 0000000..9cf1edd --- /dev/null +++ b/wxcomponents/vant/area/index.js @@ -0,0 +1,220 @@ +import { VantComponent } from '../common/component'; +import { pickerProps } from '../picker/shared'; +import { requestAnimationFrame } from '../common/utils'; +const EMPTY_CODE = '000000'; +VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: Object.assign(Object.assign({}, pickerProps), { showToolbar: { + type: Boolean, + value: true, + }, value: { + type: String, + observer(value) { + this.code = value; + this.setValues(); + }, + }, areaList: { + type: Object, + value: {}, + observer: 'setValues', + }, columnsNum: { + type: null, + value: 3, + }, columnsPlaceholder: { + type: Array, + observer(val) { + this.setData({ + typeToColumnsPlaceholder: { + province: val[0] || '', + city: val[1] || '', + county: val[2] || '', + }, + }); + }, + } }), + data: { + columns: [{ values: [] }, { values: [] }, { values: [] }], + typeToColumnsPlaceholder: {}, + }, + mounted() { + requestAnimationFrame(() => { + this.setValues(); + }); + }, + methods: { + getPicker() { + if (this.picker == null) { + this.picker = this.selectComponent('.van-area__picker'); + } + return this.picker; + }, + onCancel(event) { + this.emit('cancel', event.detail); + }, + onConfirm(event) { + const { index } = event.detail; + let { value } = event.detail; + value = this.parseValues(value); + this.emit('confirm', { value, index }); + }, + emit(type, detail) { + detail.values = detail.value; + delete detail.value; + this.$emit(type, detail); + }, + parseValues(values) { + const { columnsPlaceholder } = this.data; + return values.map((value, index) => { + if (value && + (!value.code || value.name === columnsPlaceholder[index])) { + return Object.assign(Object.assign({}, value), { code: '', name: '' }); + } + return value; + }); + }, + onChange(event) { + var _a; + const { index, picker, value } = event.detail; + this.code = value[index].code; + (_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(() => { + this.$emit('change', { + picker, + values: this.parseValues(picker.getValues()), + index, + }); + }); + }, + getConfig(type) { + const { areaList } = this.data; + return (areaList && areaList[`${type}_list`]) || {}; + }, + getList(type, code) { + if (type !== 'province' && !code) { + return []; + } + const { typeToColumnsPlaceholder } = this.data; + const list = this.getConfig(type); + let result = Object.keys(list).map((code) => ({ + code, + name: list[code], + })); + if (code != null) { + // oversea code + if (code[0] === '9' && type === 'city') { + code = '9'; + } + result = result.filter((item) => item.code.indexOf(code) === 0); + } + if (typeToColumnsPlaceholder[type] && result.length) { + // set columns placeholder + const codeFill = type === 'province' + ? '' + : type === 'city' + ? EMPTY_CODE.slice(2, 4) + : EMPTY_CODE.slice(4, 6); + result.unshift({ + code: `${code}${codeFill}`, + name: typeToColumnsPlaceholder[type], + }); + } + return result; + }, + getIndex(type, code) { + let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; + const list = this.getList(type, code.slice(0, compareNum - 2)); + // oversea code + if (code[0] === '9' && type === 'province') { + compareNum = 1; + } + code = code.slice(0, compareNum); + for (let i = 0; i < list.length; i++) { + if (list[i].code.slice(0, compareNum) === code) { + return i; + } + } + return 0; + }, + setValues() { + const picker = this.getPicker(); + if (!picker) { + return; + } + let code = this.code || this.getDefaultCode(); + const provinceList = this.getList('province'); + const cityList = this.getList('city', code.slice(0, 2)); + const stack = []; + const indexes = []; + const { columnsNum } = this.data; + if (columnsNum >= 1) { + stack.push(picker.setColumnValues(0, provinceList, false)); + indexes.push(this.getIndex('province', code)); + } + if (columnsNum >= 2) { + stack.push(picker.setColumnValues(1, cityList, false)); + indexes.push(this.getIndex('city', code)); + if (cityList.length && code.slice(2, 4) === '00') { + [{ code }] = cityList; + } + } + if (columnsNum === 3) { + stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false)); + indexes.push(this.getIndex('county', code)); + } + return Promise.all(stack) + .catch(() => { }) + .then(() => picker.setIndexes(indexes)) + .catch(() => { }); + }, + getDefaultCode() { + const { columnsPlaceholder } = this.data; + if (columnsPlaceholder.length) { + return EMPTY_CODE; + } + const countyCodes = Object.keys(this.getConfig('county')); + if (countyCodes[0]) { + return countyCodes[0]; + } + const cityCodes = Object.keys(this.getConfig('city')); + if (cityCodes[0]) { + return cityCodes[0]; + } + return ''; + }, + getValues() { + const picker = this.getPicker(); + if (!picker) { + return []; + } + return this.parseValues(picker.getValues().filter((value) => !!value)); + }, + getDetail() { + const values = this.getValues(); + const area = { + code: '', + country: '', + province: '', + city: '', + county: '', + }; + if (!values.length) { + return area; + } + const names = values.map((item) => item.name); + area.code = values[values.length - 1].code; + if (area.code[0] === '9') { + area.country = names[1] || ''; + area.province = names[2] || ''; + } + else { + area.province = names[0] || ''; + area.city = names[1] || ''; + area.county = names[2] || ''; + } + return area; + }, + reset(code) { + this.code = code || ''; + return this.setValues(); + }, + }, +}); diff --git a/wxcomponents/vant/area/index.json b/wxcomponents/vant/area/index.json new file mode 100644 index 0000000..a778e91 --- /dev/null +++ b/wxcomponents/vant/area/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-picker": "../picker/index" + } +} diff --git a/wxcomponents/vant/area/index.wxml b/wxcomponents/vant/area/index.wxml new file mode 100644 index 0000000..3a437b7 --- /dev/null +++ b/wxcomponents/vant/area/index.wxml @@ -0,0 +1,20 @@ + + + diff --git a/wxcomponents/vant/area/index.wxs b/wxcomponents/vant/area/index.wxs new file mode 100644 index 0000000..07723c1 --- /dev/null +++ b/wxcomponents/vant/area/index.wxs @@ -0,0 +1,8 @@ +/* eslint-disable */ +function displayColumns(columns, columnsNum) { + return columns.slice(0, +columnsNum); +} + +module.exports = { + displayColumns: displayColumns, +}; diff --git a/wxcomponents/vant/area/index.wxss b/wxcomponents/vant/area/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/wxcomponents/vant/area/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/wxcomponents/vant/button/index.d.ts b/wxcomponents/vant/button/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/button/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/button/index.js b/wxcomponents/vant/button/index.js new file mode 100644 index 0000000..0e3c134 --- /dev/null +++ b/wxcomponents/vant/button/index.js @@ -0,0 +1,64 @@ +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +import { canIUseFormFieldButton } from '../common/version'; +const mixins = [button]; +if (canIUseFormFieldButton()) { + mixins.push('wx://form-field-button'); +} +VantComponent({ + mixins, + classes: ['hover-class', 'loading-class'], + data: { + baseStyle: '', + }, + props: { + formType: String, + icon: String, + classPrefix: { + type: String, + value: 'van-icon', + }, + plain: Boolean, + block: Boolean, + round: Boolean, + square: Boolean, + loading: Boolean, + hairline: Boolean, + disabled: Boolean, + loadingText: String, + customStyle: String, + loadingType: { + type: String, + value: 'circular', + }, + type: { + type: String, + value: 'default', + }, + dataset: null, + size: { + type: String, + value: 'normal', + }, + loadingSize: { + type: String, + value: '20px', + }, + color: String, + }, + methods: { + onClick(event) { + this.$emit('click', event); + const { canIUseGetUserProfile, openType, getUserProfileDesc, lang, } = this.data; + if (openType === 'getUserInfo' && canIUseGetUserProfile) { + wx.getUserProfile({ + desc: getUserProfileDesc || ' ', + lang: lang || 'en', + complete: (userProfile) => { + this.$emit('getuserinfo', userProfile); + }, + }); + } + }, + }, +}); diff --git a/wxcomponents/vant/button/index.json b/wxcomponents/vant/button/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/wxcomponents/vant/button/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/wxcomponents/vant/button/index.wxml b/wxcomponents/vant/button/index.wxml new file mode 100644 index 0000000..e7f60f1 --- /dev/null +++ b/wxcomponents/vant/button/index.wxml @@ -0,0 +1,56 @@ + + + + diff --git a/wxcomponents/vant/button/index.wxs b/wxcomponents/vant/button/index.wxs new file mode 100644 index 0000000..8b649fe --- /dev/null +++ b/wxcomponents/vant/button/index.wxs @@ -0,0 +1,39 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); + +function rootStyle(data) { + if (!data.color) { + return data.customStyle; + } + + var properties = { + color: data.plain ? data.color : '#fff', + background: data.plain ? null : data.color, + }; + + // hide border when color is linear-gradient + if (data.color.indexOf('gradient') !== -1) { + properties.border = 0; + } else { + properties['border-color'] = data.color; + } + + return style([properties, data.customStyle]); +} + +function loadingColor(data) { + if (data.plain) { + return data.color ? data.color : '#c9c9c9'; + } + + if (data.type === 'default') { + return '#c9c9c9'; + } + + return '#fff'; +} + +module.exports = { + rootStyle: rootStyle, + loadingColor: loadingColor, +}; diff --git a/wxcomponents/vant/button/index.wxss b/wxcomponents/vant/button/index.wxss new file mode 100644 index 0000000..bd8bb5a --- /dev/null +++ b/wxcomponents/vant/button/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-button{-webkit-text-size-adjust:100%;align-items:center;-webkit-appearance:none;border-radius:var(--button-border-radius,2px);box-sizing:border-box;display:inline-flex;font-size:var(--button-default-font-size,16px);height:var(--button-default-height,44px);justify-content:center;line-height:var(--button-line-height,20px);padding:0;position:relative;text-align:center;transition:opacity .2s;vertical-align:middle}.van-button:before{background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";height:100%;left:50%;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:100%}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{background:var(--button-default-background-color,#fff);border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0);color:var(--button-default-color,#323233)}.van-button--primary{background:var(--button-primary-background-color,#07c160);border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160);color:var(--button-primary-color,#fff)}.van-button--info{background:var(--button-info-background-color,#1989fa);border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa);color:var(--button-info-color,#fff)}.van-button--danger{background:var(--button-danger-background-color,#ee0a24);border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24);color:var(--button-danger-color,#fff)}.van-button--warning{background:var(--button-warning-background-color,#ff976a);border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a);color:var(--button-warning-color,#fff)}.van-button--plain{background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:var(--button-warning-background-color,#ff976a)}.van-button--large{height:var(--button-large-height,50px);width:100%}.van-button--normal{font-size:var(--button-normal-font-size,14px);padding:0 15px}.van-button--small{font-size:var(--button-small-font-size,12px);height:var(--button-small-height,30px);min-width:var(--button-small-min-width,60px);padding:0 var(--padding-xs,8px)}.van-button--mini{display:inline-block;font-size:var(--button-mini-font-size,10px);height:var(--button-mini-height,22px);min-width:var(--button-mini-min-width,50px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:flex;width:100%}.van-button--round{border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{line-height:inherit!important;min-width:1em;vertical-align:top}.van-button--hairline{border-width:0;padding-top:1px}.van-button--hairline:after{border-color:inherit;border-radius:calc(var(--button-border-radius, 2px)*2);border-width:1px}.van-button--hairline.van-button--round:after{border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/wxcomponents/vant/calendar/calendar.wxml b/wxcomponents/vant/calendar/calendar.wxml new file mode 100644 index 0000000..2ddb048 --- /dev/null +++ b/wxcomponents/vant/calendar/calendar.wxml @@ -0,0 +1,70 @@ + + + +
+ +
+ + + + + + + + + + + + {{ + computed.getButtonDisabled(type, currentDate, minRange) + ? confirmDisabledText + : confirmText + }} + + +
diff --git a/wxcomponents/vant/calendar/components/header/index.d.ts b/wxcomponents/vant/calendar/components/header/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/calendar/components/header/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/calendar/components/header/index.js b/wxcomponents/vant/calendar/components/header/index.js new file mode 100644 index 0000000..8fb3682 --- /dev/null +++ b/wxcomponents/vant/calendar/components/header/index.js @@ -0,0 +1,37 @@ +import { VantComponent } from '../../../common/component'; +VantComponent({ + props: { + title: { + type: String, + value: '日期选择', + }, + subtitle: String, + showTitle: Boolean, + showSubtitle: Boolean, + firstDayOfWeek: { + type: Number, + observer: 'initWeekDay', + }, + }, + data: { + weekdays: [], + }, + created() { + this.initWeekDay(); + }, + methods: { + initWeekDay() { + const defaultWeeks = ['日', '一', '二', '三', '四', '五', '六']; + const firstDayOfWeek = this.data.firstDayOfWeek || 0; + this.setData({ + weekdays: [ + ...defaultWeeks.slice(firstDayOfWeek, 7), + ...defaultWeeks.slice(0, firstDayOfWeek), + ], + }); + }, + onClickSubtitle(event) { + this.$emit('click-subtitle', event); + }, + }, +}); diff --git a/wxcomponents/vant/calendar/components/header/index.json b/wxcomponents/vant/calendar/components/header/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/calendar/components/header/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/calendar/components/header/index.wxml b/wxcomponents/vant/calendar/components/header/index.wxml new file mode 100644 index 0000000..7e56c83 --- /dev/null +++ b/wxcomponents/vant/calendar/components/header/index.wxml @@ -0,0 +1,16 @@ + + + + {{ title }} + + + + {{ subtitle }} + + + + + {{ item }} + + + diff --git a/wxcomponents/vant/calendar/components/header/index.wxss b/wxcomponents/vant/calendar/components/header/index.wxss new file mode 100644 index 0000000..272537e --- /dev/null +++ b/wxcomponents/vant/calendar/components/header/index.wxss @@ -0,0 +1 @@ +@import '../../../common/index.wxss';.van-calendar__header{box-shadow:var(--calendar-header-box-shadow,0 2px 10px hsla(220,1%,50%,.16));flex-shrink:0}.van-calendar__header-subtitle,.van-calendar__header-title{font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.van-calendar__header-title+.van-calendar__header-title,.van-calendar__header-title:empty{display:none}.van-calendar__header-title:empty+.van-calendar__header-title{display:block!important}.van-calendar__weekdays{display:flex}.van-calendar__weekday{flex:1;font-size:var(--calendar-weekdays-font-size,12px);line-height:var(--calendar-weekdays-height,30px);text-align:center} \ No newline at end of file diff --git a/wxcomponents/vant/calendar/components/month/index.d.ts b/wxcomponents/vant/calendar/components/month/index.d.ts new file mode 100644 index 0000000..3ccf85a --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.d.ts @@ -0,0 +1,6 @@ +export interface Day { + date: Date; + type: string; + text: number; + bottomInfo?: string; +} diff --git a/wxcomponents/vant/calendar/components/month/index.js b/wxcomponents/vant/calendar/components/month/index.js new file mode 100644 index 0000000..d04c0fe --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.js @@ -0,0 +1,154 @@ +import { VantComponent } from '../../../common/component'; +import { getMonthEndDay, compareDay, getPrevDay, getNextDay, } from '../../utils'; +VantComponent({ + props: { + date: { + type: null, + observer: 'setDays', + }, + type: { + type: String, + observer: 'setDays', + }, + color: String, + minDate: { + type: null, + observer: 'setDays', + }, + maxDate: { + type: null, + observer: 'setDays', + }, + showMark: Boolean, + rowHeight: null, + formatter: { + type: null, + observer: 'setDays', + }, + currentDate: { + type: null, + observer: 'setDays', + }, + firstDayOfWeek: { + type: Number, + observer: 'setDays', + }, + allowSameDay: Boolean, + showSubtitle: Boolean, + showMonthTitle: Boolean, + }, + data: { + visible: true, + days: [], + }, + methods: { + onClick(event) { + const { index } = event.currentTarget.dataset; + const item = this.data.days[index]; + if (item.type !== 'disabled') { + this.$emit('click', item); + } + }, + setDays() { + const days = []; + const startDate = new Date(this.data.date); + const year = startDate.getFullYear(); + const month = startDate.getMonth(); + const totalDay = getMonthEndDay(startDate.getFullYear(), startDate.getMonth() + 1); + for (let day = 1; day <= totalDay; day++) { + const date = new Date(year, month, day); + const type = this.getDayType(date); + let config = { + date, + type, + text: day, + bottomInfo: this.getBottomInfo(type), + }; + if (this.data.formatter) { + config = this.data.formatter(config); + } + days.push(config); + } + this.setData({ days }); + }, + getMultipleDayType(day) { + const { currentDate } = this.data; + if (!Array.isArray(currentDate)) { + return ''; + } + const isSelected = (date) => currentDate.some((item) => compareDay(item, date) === 0); + if (isSelected(day)) { + const prevDay = getPrevDay(day); + const nextDay = getNextDay(day); + const prevSelected = isSelected(prevDay); + const nextSelected = isSelected(nextDay); + if (prevSelected && nextSelected) { + return 'multiple-middle'; + } + if (prevSelected) { + return 'end'; + } + return nextSelected ? 'start' : 'multiple-selected'; + } + return ''; + }, + getRangeDayType(day) { + const { currentDate, allowSameDay } = this.data; + if (!Array.isArray(currentDate)) { + return ''; + } + const [startDay, endDay] = currentDate; + if (!startDay) { + return ''; + } + const compareToStart = compareDay(day, startDay); + if (!endDay) { + return compareToStart === 0 ? 'start' : ''; + } + const compareToEnd = compareDay(day, endDay); + if (compareToStart === 0 && compareToEnd === 0 && allowSameDay) { + return 'start-end'; + } + if (compareToStart === 0) { + return 'start'; + } + if (compareToEnd === 0) { + return 'end'; + } + if (compareToStart > 0 && compareToEnd < 0) { + return 'middle'; + } + return ''; + }, + getDayType(day) { + const { type, minDate, maxDate, currentDate } = this.data; + if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) { + return 'disabled'; + } + if (type === 'single') { + return compareDay(day, currentDate) === 0 ? 'selected' : ''; + } + if (type === 'multiple') { + return this.getMultipleDayType(day); + } + /* istanbul ignore else */ + if (type === 'range') { + return this.getRangeDayType(day); + } + return ''; + }, + getBottomInfo(type) { + if (this.data.type === 'range') { + if (type === 'start') { + return '开始'; + } + if (type === 'end') { + return '结束'; + } + if (type === 'start-end') { + return '开始/结束'; + } + } + }, + }, +}); diff --git a/wxcomponents/vant/calendar/components/month/index.json b/wxcomponents/vant/calendar/components/month/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/calendar/components/month/index.wxml b/wxcomponents/vant/calendar/components/month/index.wxml new file mode 100644 index 0000000..0c73b2f --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.wxml @@ -0,0 +1,39 @@ + + + + + + {{ computed.formatMonthTitle(date) }} + + + + + {{ computed.getMark(date) }} + + + + + {{ item.topInfo }} + {{ item.text }} + + {{ item.bottomInfo }} + + + + + {{ item.topInfo }} + {{ item.text }} + + {{ item.bottomInfo }} + + + + + diff --git a/wxcomponents/vant/calendar/components/month/index.wxs b/wxcomponents/vant/calendar/components/month/index.wxs new file mode 100644 index 0000000..55e45a5 --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.wxs @@ -0,0 +1,71 @@ +/* eslint-disable */ +var utils = require('../../utils.wxs'); + +function getMark(date) { + return getDate(date).getMonth() + 1; +} + +var ROW_HEIGHT = 64; + +function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) { + var style = []; + var current = getDate(date).getDay() || 7; + var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) : + current === 7 && firstDayOfWeek === 0 ? 0 : + (current - firstDayOfWeek); + + if (index === 0) { + style.push(['margin-left', (100 * offset) / 7 + '%']); + } + + if (rowHeight !== ROW_HEIGHT) { + style.push(['height', rowHeight + 'px']); + } + + if (color) { + if ( + type === 'start' || + type === 'end' || + type === 'start-end' || + type === 'multiple-selected' || + type === 'multiple-middle' + ) { + style.push(['background', color]); + } else if (type === 'middle') { + style.push(['color', color]); + } + } + + return style + .map(function(item) { + return item.join(':'); + }) + .join(';'); +} + +function formatMonthTitle(date) { + date = getDate(date); + return date.getFullYear() + '年' + (date.getMonth() + 1) + '月'; +} + +function getMonthStyle(visible, date, rowHeight) { + if (!visible) { + date = getDate(date); + + var totalDay = utils.getMonthEndDay( + date.getFullYear(), + date.getMonth() + 1 + ); + var offset = getDate(date).getDay(); + var padding = Math.ceil((totalDay + offset) / 7) * rowHeight; + + return 'padding-bottom:' + padding + 'px'; + } +} + +module.exports = { + getMark: getMark, + getDayStyle: getDayStyle, + formatMonthTitle: formatMonthTitle, + getMonthStyle: getMonthStyle +}; diff --git a/wxcomponents/vant/calendar/components/month/index.wxss b/wxcomponents/vant/calendar/components/month/index.wxss new file mode 100644 index 0000000..9aee73d --- /dev/null +++ b/wxcomponents/vant/calendar/components/month/index.wxss @@ -0,0 +1 @@ +@import '../../../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:100%}.van-calendar__month-title{font-size:var(--calendar-month-title-font-size,14px);font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.van-calendar__days{display:flex;flex-wrap:wrap;position:relative;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{color:var(--calendar-month-mark-color,rgba(242,243,245,.8));font-size:var(--calendar-month-mark-font-size,160px);left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:0}.van-calendar__day,.van-calendar__selected-day{align-items:center;display:flex;justify-content:center;text-align:center}.van-calendar__day{font-size:var(--calendar-day-font-size,16px);height:var(--calendar-day-height,64px);position:relative;width:14.285%}.van-calendar__day--end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected,.van-calendar__day--start,.van-calendar__day--start-end{background-color:var(--calendar-range-edge-background-color,#ee0a24);color:var(--calendar-range-edge-color,#fff)}.van-calendar__day--start{border-radius:4px 0 0 4px}.van-calendar__day--end{border-radius:0 4px 4px 0}.van-calendar__day--multiple-selected,.van-calendar__day--start-end{border-radius:4px}.van-calendar__day--middle{color:var(--calendar-range-middle-color,#ee0a24)}.van-calendar__day--middle:after{background-color:currentColor;bottom:0;content:"";left:0;opacity:var(--calendar-range-middle-background-opacity,.1);position:absolute;right:0;top:0}.van-calendar__day--disabled{color:var(--calendar-day-disabled-color,#c8c9cc);cursor:default}.van-calendar__bottom-info,.van-calendar__top-info{font-size:var(--calendar-info-font-size,10px);left:0;line-height:var(--calendar-info-line-height,14px);position:absolute;right:0}@media (max-width:350px){.van-calendar__bottom-info,.van-calendar__top-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:6px}.van-calendar__selected-day{background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;color:var(--calendar-selected-day-color,#fff);height:var(--calendar-selected-day-size,54px);width:var(--calendar-selected-day-size,54px)} \ No newline at end of file diff --git a/wxcomponents/vant/calendar/index.d.ts b/wxcomponents/vant/calendar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/calendar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/calendar/index.js b/wxcomponents/vant/calendar/index.js new file mode 100644 index 0000000..515de42 --- /dev/null +++ b/wxcomponents/vant/calendar/index.js @@ -0,0 +1,360 @@ +import { VantComponent } from '../common/component'; +import { ROW_HEIGHT, getPrevDay, getNextDay, getToday, compareDay, copyDates, calcDateNum, formatMonthTitle, compareMonth, getMonths, getDayByOffset, } from './utils'; +import Toast from '../toast/toast'; +import { requestAnimationFrame } from '../common/utils'; +const initialMinDate = getToday().getTime(); +const initialMaxDate = (() => { + const now = getToday(); + return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()).getTime(); +})(); +const getTime = (date) => date instanceof Date ? date.getTime() : date; +VantComponent({ + props: { + title: { + type: String, + value: '日期选择', + }, + color: String, + show: { + type: Boolean, + observer(val) { + if (val) { + this.initRect(); + this.scrollIntoView(); + } + }, + }, + formatter: null, + confirmText: { + type: String, + value: '确定', + }, + confirmDisabledText: { + type: String, + value: '确定', + }, + rangePrompt: String, + showRangePrompt: { + type: Boolean, + value: true, + }, + defaultDate: { + type: null, + value: getToday().getTime(), + observer(val) { + this.setData({ currentDate: val }); + this.scrollIntoView(); + }, + }, + allowSameDay: Boolean, + type: { + type: String, + value: 'single', + observer: 'reset', + }, + minDate: { + type: Number, + value: initialMinDate, + }, + maxDate: { + type: Number, + value: initialMaxDate, + }, + position: { + type: String, + value: 'bottom', + }, + rowHeight: { + type: null, + value: ROW_HEIGHT, + }, + round: { + type: Boolean, + value: true, + }, + poppable: { + type: Boolean, + value: true, + }, + showMark: { + type: Boolean, + value: true, + }, + showTitle: { + type: Boolean, + value: true, + }, + showConfirm: { + type: Boolean, + value: true, + }, + showSubtitle: { + type: Boolean, + value: true, + }, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + }, + maxRange: { + type: null, + value: null, + }, + minRange: { + type: Number, + value: 1, + }, + firstDayOfWeek: { + type: Number, + value: 0, + }, + readonly: Boolean, + rootPortal: { + type: Boolean, + value: false, + }, + }, + data: { + subtitle: '', + currentDate: null, + scrollIntoView: '', + }, + watch: { + minDate() { + this.initRect(); + }, + maxDate() { + this.initRect(); + }, + }, + created() { + this.setData({ + currentDate: this.getInitialDate(this.data.defaultDate), + }); + }, + mounted() { + if (this.data.show || !this.data.poppable) { + this.initRect(); + this.scrollIntoView(); + } + }, + methods: { + reset() { + this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) }); + this.scrollIntoView(); + }, + initRect() { + if (this.contentObserver != null) { + this.contentObserver.disconnect(); + } + const contentObserver = this.createIntersectionObserver({ + thresholds: [0, 0.1, 0.9, 1], + observeAll: true, + }); + this.contentObserver = contentObserver; + contentObserver.relativeTo('.van-calendar__body'); + contentObserver.observe('.month', (res) => { + if (res.boundingClientRect.top <= res.relativeRect.top) { + // @ts-ignore + this.setData({ subtitle: formatMonthTitle(res.dataset.date) }); + } + }); + }, + limitDateRange(date, minDate = null, maxDate = null) { + minDate = minDate || this.data.minDate; + maxDate = maxDate || this.data.maxDate; + if (compareDay(date, minDate) === -1) { + return minDate; + } + if (compareDay(date, maxDate) === 1) { + return maxDate; + } + return date; + }, + getInitialDate(defaultDate = null) { + const { type, minDate, maxDate, allowSameDay } = this.data; + if (!defaultDate) + return []; + const now = getToday().getTime(); + if (type === 'range') { + if (!Array.isArray(defaultDate)) { + defaultDate = []; + } + const [startDay, endDay] = defaultDate || []; + const startDate = getTime(startDay || now); + const start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : getPrevDay(new Date(maxDate)).getTime()); + const date = getTime(endDay || now); + const end = this.limitDateRange(date, allowSameDay ? date : getNextDay(new Date(minDate)).getTime()); + return [start, end]; + } + if (type === 'multiple') { + if (Array.isArray(defaultDate)) { + return defaultDate.map((date) => this.limitDateRange(date)); + } + return [this.limitDateRange(now)]; + } + if (!defaultDate || Array.isArray(defaultDate)) { + defaultDate = now; + } + return this.limitDateRange(defaultDate); + }, + scrollIntoView() { + requestAnimationFrame(() => { + const { currentDate, type, show, poppable, minDate, maxDate } = this.data; + if (!currentDate) + return; + // @ts-ignore + const targetDate = type === 'single' ? currentDate : currentDate[0]; + const displayed = show || !poppable; + if (!targetDate || !displayed) { + return; + } + const months = getMonths(minDate, maxDate); + months.some((month, index) => { + if (compareMonth(month, targetDate) === 0) { + this.setData({ scrollIntoView: `month${index}` }); + return true; + } + return false; + }); + }); + }, + onOpen() { + this.$emit('open'); + }, + onOpened() { + this.$emit('opened'); + }, + onClose() { + this.$emit('close'); + }, + onClosed() { + this.$emit('closed'); + }, + onClickDay(event) { + if (this.data.readonly) { + return; + } + let { date } = event.detail; + const { type, currentDate, allowSameDay } = this.data; + if (type === 'range') { + // @ts-ignore + const [startDay, endDay] = currentDate; + if (startDay && !endDay) { + const compareToStart = compareDay(date, startDay); + if (compareToStart === 1) { + const { days } = this.selectComponent('.month').data; + days.some((day, index) => { + const isDisabled = day.type === 'disabled' && + getTime(startDay) < getTime(day.date) && + getTime(day.date) < getTime(date); + if (isDisabled) { + ({ date } = days[index - 1]); + } + return isDisabled; + }); + this.select([startDay, date], true); + } + else if (compareToStart === -1) { + this.select([date, null]); + } + else if (allowSameDay) { + this.select([date, date], true); + } + } + else { + this.select([date, null]); + } + } + else if (type === 'multiple') { + let selectedIndex; + // @ts-ignore + const selected = currentDate.some((dateItem, index) => { + const equal = compareDay(dateItem, date) === 0; + if (equal) { + selectedIndex = index; + } + return equal; + }); + if (selected) { + // @ts-ignore + const cancelDate = currentDate.splice(selectedIndex, 1); + this.setData({ currentDate }); + this.unselect(cancelDate); + } + else { + // @ts-ignore + this.select([...currentDate, date]); + } + } + else { + this.select(date, true); + } + }, + unselect(dateArray) { + const date = dateArray[0]; + if (date) { + this.$emit('unselect', copyDates(date)); + } + }, + select(date, complete) { + if (complete && this.data.type === 'range') { + const valid = this.checkRange(date); + if (!valid) { + // auto selected to max range if showConfirm + if (this.data.showConfirm) { + this.emit([ + date[0], + getDayByOffset(date[0], this.data.maxRange - 1), + ]); + } + else { + this.emit(date); + } + return; + } + } + this.emit(date); + if (complete && !this.data.showConfirm) { + this.onConfirm(); + } + }, + emit(date) { + this.setData({ + currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date), + }); + this.$emit('select', copyDates(date)); + }, + checkRange(date) { + const { maxRange, rangePrompt, showRangePrompt } = this.data; + if (maxRange && calcDateNum(date) > maxRange) { + if (showRangePrompt) { + Toast({ + context: this, + message: rangePrompt || `选择天数不能超过 ${maxRange} 天`, + }); + } + this.$emit('over-range'); + return false; + } + return true; + }, + onConfirm() { + if (this.data.type === 'range' && + !this.checkRange(this.data.currentDate)) { + return; + } + wx.nextTick(() => { + // @ts-ignore + this.$emit('confirm', copyDates(this.data.currentDate)); + }); + }, + onClickSubtitle(event) { + this.$emit('click-subtitle', event); + }, + }, +}); diff --git a/wxcomponents/vant/calendar/index.json b/wxcomponents/vant/calendar/index.json new file mode 100644 index 0000000..397d5ae --- /dev/null +++ b/wxcomponents/vant/calendar/index.json @@ -0,0 +1,10 @@ +{ + "component": true, + "usingComponents": { + "header": "./components/header/index", + "month": "./components/month/index", + "van-button": "../button/index", + "van-popup": "../popup/index", + "van-toast": "../toast/index" + } +} diff --git a/wxcomponents/vant/calendar/index.wxml b/wxcomponents/vant/calendar/index.wxml new file mode 100644 index 0000000..9d0fc6b --- /dev/null +++ b/wxcomponents/vant/calendar/index.wxml @@ -0,0 +1,27 @@ + + + + + + + + + + + + diff --git a/wxcomponents/vant/calendar/index.wxs b/wxcomponents/vant/calendar/index.wxs new file mode 100644 index 0000000..0a56646 --- /dev/null +++ b/wxcomponents/vant/calendar/index.wxs @@ -0,0 +1,37 @@ +/* eslint-disable */ +var utils = require('./utils.wxs'); + +function getMonths(minDate, maxDate) { + var months = []; + var cursor = getDate(minDate); + + cursor.setDate(1); + + do { + months.push(cursor.getTime()); + cursor.setMonth(cursor.getMonth() + 1); + } while (utils.compareMonth(cursor, getDate(maxDate)) !== 1); + + return months; +} + +function getButtonDisabled(type, currentDate, minRange) { + if (currentDate == null) { + return true; + } + + if (type === 'range') { + return !currentDate[0] || !currentDate[1]; + } + + if (type === 'multiple') { + return currentDate.length < minRange; + } + + return !currentDate; +} + +module.exports = { + getMonths: getMonths, + getButtonDisabled: getButtonDisabled +}; diff --git a/wxcomponents/vant/calendar/index.wxss b/wxcomponents/vant/calendar/index.wxss new file mode 100644 index 0000000..a1f1cf0 --- /dev/null +++ b/wxcomponents/vant/calendar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:var(--calendar-height,100%)}.van-calendar__close-icon{top:11px}.van-calendar__popup--bottom,.van-calendar__popup--top{height:var(--calendar-popup-height,90%)}.van-calendar__popup--left,.van-calendar__popup--right{height:100%}.van-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.van-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.van-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.van-calendar__footer+.van-calendar__footer,.van-calendar__footer:empty{display:none}.van-calendar__footer:empty+.van-calendar__footer{display:block!important}.van-calendar__confirm{height:var(--calendar-confirm-button-height,36px)!important;line-height:var(--calendar-confirm-button-line-height,34px)!important;margin:var(--calendar-confirm-button-margin,7px 0)!important} \ No newline at end of file diff --git a/wxcomponents/vant/calendar/utils.d.ts b/wxcomponents/vant/calendar/utils.d.ts new file mode 100644 index 0000000..889e6e7 --- /dev/null +++ b/wxcomponents/vant/calendar/utils.d.ts @@ -0,0 +1,12 @@ +export declare const ROW_HEIGHT = 64; +export declare function formatMonthTitle(date: Date): string; +export declare function compareMonth(date1: Date | number, date2: Date | number): 0 | 1 | -1; +export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1; +export declare function getDayByOffset(date: Date, offset: number): Date; +export declare function getPrevDay(date: Date): Date; +export declare function getNextDay(date: Date): Date; +export declare function getToday(): Date; +export declare function calcDateNum(date: [Date, Date]): number; +export declare function copyDates(dates: Date | Date[]): Date | Date[]; +export declare function getMonthEndDay(year: number, month: number): number; +export declare function getMonths(minDate: number, maxDate: number): number[]; diff --git a/wxcomponents/vant/calendar/utils.js b/wxcomponents/vant/calendar/utils.js new file mode 100644 index 0000000..83d6971 --- /dev/null +++ b/wxcomponents/vant/calendar/utils.js @@ -0,0 +1,83 @@ +export const ROW_HEIGHT = 64; +export function formatMonthTitle(date) { + if (!(date instanceof Date)) { + date = new Date(date); + } + return `${date.getFullYear()}年${date.getMonth() + 1}月`; +} +export function compareMonth(date1, date2) { + if (!(date1 instanceof Date)) { + date1 = new Date(date1); + } + if (!(date2 instanceof Date)) { + date2 = new Date(date2); + } + const year1 = date1.getFullYear(); + const year2 = date2.getFullYear(); + const month1 = date1.getMonth(); + const month2 = date2.getMonth(); + if (year1 === year2) { + return month1 === month2 ? 0 : month1 > month2 ? 1 : -1; + } + return year1 > year2 ? 1 : -1; +} +export function compareDay(day1, day2) { + if (!(day1 instanceof Date)) { + day1 = new Date(day1); + } + if (!(day2 instanceof Date)) { + day2 = new Date(day2); + } + const compareMonthResult = compareMonth(day1, day2); + if (compareMonthResult === 0) { + const date1 = day1.getDate(); + const date2 = day2.getDate(); + return date1 === date2 ? 0 : date1 > date2 ? 1 : -1; + } + return compareMonthResult; +} +export function getDayByOffset(date, offset) { + date = new Date(date); + date.setDate(date.getDate() + offset); + return date; +} +export function getPrevDay(date) { + return getDayByOffset(date, -1); +} +export function getNextDay(date) { + return getDayByOffset(date, 1); +} +export function getToday() { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; +} +export function calcDateNum(date) { + const day1 = new Date(date[0]).getTime(); + const day2 = new Date(date[1]).getTime(); + return (day2 - day1) / (1000 * 60 * 60 * 24) + 1; +} +export function copyDates(dates) { + if (Array.isArray(dates)) { + return dates.map((date) => { + if (date === null) { + return date; + } + return new Date(date); + }); + } + return new Date(dates); +} +export function getMonthEndDay(year, month) { + return 32 - new Date(year, month - 1, 32).getDate(); +} +export function getMonths(minDate, maxDate) { + const months = []; + const cursor = new Date(minDate); + cursor.setDate(1); + do { + months.push(cursor.getTime()); + cursor.setMonth(cursor.getMonth() + 1); + } while (compareMonth(cursor, maxDate) !== 1); + return months; +} diff --git a/wxcomponents/vant/calendar/utils.wxs b/wxcomponents/vant/calendar/utils.wxs new file mode 100644 index 0000000..e57f6b3 --- /dev/null +++ b/wxcomponents/vant/calendar/utils.wxs @@ -0,0 +1,25 @@ +/* eslint-disable */ +function getMonthEndDay(year, month) { + return 32 - getDate(year, month - 1, 32).getDate(); +} + +function compareMonth(date1, date2) { + date1 = getDate(date1); + date2 = getDate(date2); + + var year1 = date1.getFullYear(); + var year2 = date2.getFullYear(); + var month1 = date1.getMonth(); + var month2 = date2.getMonth(); + + if (year1 === year2) { + return month1 === month2 ? 0 : month1 > month2 ? 1 : -1; + } + + return year1 > year2 ? 1 : -1; +} + +module.exports = { + getMonthEndDay: getMonthEndDay, + compareMonth: compareMonth +}; diff --git a/wxcomponents/vant/card/index.d.ts b/wxcomponents/vant/card/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/card/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/card/index.js b/wxcomponents/vant/card/index.js new file mode 100644 index 0000000..5bbd212 --- /dev/null +++ b/wxcomponents/vant/card/index.js @@ -0,0 +1,49 @@ +import { link } from '../mixins/link'; +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'num-class', + 'desc-class', + 'thumb-class', + 'title-class', + 'price-class', + 'origin-price-class', + ], + mixins: [link], + props: { + tag: String, + num: String, + desc: String, + thumb: String, + title: String, + price: { + type: String, + observer: 'updatePrice', + }, + centered: Boolean, + lazyLoad: Boolean, + thumbLink: String, + originPrice: String, + thumbMode: { + type: String, + value: 'aspectFit', + }, + currency: { + type: String, + value: '¥', + }, + }, + methods: { + updatePrice() { + const { price } = this.data; + const priceArr = price.toString().split('.'); + this.setData({ + integerStr: priceArr[0], + decimalStr: priceArr[1] ? `.${priceArr[1]}` : '', + }); + }, + onClickThumb() { + this.jumpLink('thumbLink'); + }, + }, +}); diff --git a/wxcomponents/vant/card/index.json b/wxcomponents/vant/card/index.json new file mode 100644 index 0000000..e917407 --- /dev/null +++ b/wxcomponents/vant/card/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-tag": "../tag/index" + } +} diff --git a/wxcomponents/vant/card/index.wxml b/wxcomponents/vant/card/index.wxml new file mode 100644 index 0000000..62173e4 --- /dev/null +++ b/wxcomponents/vant/card/index.wxml @@ -0,0 +1,56 @@ + + + + + + + + + {{ tag }} + + + + + + + {{ title }} + + + {{ desc }} + + + + + + + + + {{ currency }} + {{ integerStr }} + {{ decimalStr }} + + + {{ currency }} {{ originPrice }} + + x {{ num }} + + + + + + + + + + diff --git a/wxcomponents/vant/card/index.wxss b/wxcomponents/vant/card/index.wxss new file mode 100644 index 0000000..0f4d7c5 --- /dev/null +++ b/wxcomponents/vant/card/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-card{background-color:var(--card-background-color,#fafafa);box-sizing:border-box;color:var(--card-text-color,#323233);font-size:var(--card-font-size,12px);padding:var(--card-padding,8px 16px);position:relative}.van-card__header{display:flex}.van-card__header--center{align-items:center;justify-content:center}.van-card__thumb{flex:none;height:var(--card-thumb-size,88px);margin-right:var(--padding-xs,8px);position:relative;width:var(--card-thumb-size,88px)}.van-card__thumb:empty{display:none}.van-card__img{border-radius:8px;height:100%;width:100%}.van-card__content{display:flex;flex:1;flex-direction:column;justify-content:space-between;min-height:var(--card-thumb-size,88px);min-width:0;position:relative}.van-card__content--center{justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:var(--card-title-line-height,16px)}.van-card__desc{color:var(--card-desc-color,#646566);line-height:var(--card-desc-line-height,20px)}.van-card__bottom{line-height:20px}.van-card__price{color:var(--card-price-color,#ee0a24);display:inline-block;font-size:var(--card-price-font-size,12px);font-weight:700}.van-card__price-integer{font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{color:var(--card-origin-price-color,#646566);display:inline-block;font-size:var(--card-origin-price-font-size,10px);margin-left:5px;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{left:0;position:absolute!important;top:2px}.van-card__footer{flex:none;text-align:right;width:100%} \ No newline at end of file diff --git a/wxcomponents/vant/cascader/index.d.ts b/wxcomponents/vant/cascader/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/cascader/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/cascader/index.js b/wxcomponents/vant/cascader/index.js new file mode 100644 index 0000000..c566451 --- /dev/null +++ b/wxcomponents/vant/cascader/index.js @@ -0,0 +1,214 @@ +import { VantComponent } from '../common/component'; +var FieldName; +(function (FieldName) { + FieldName["TEXT"] = "text"; + FieldName["VALUE"] = "value"; + FieldName["CHILDREN"] = "children"; +})(FieldName || (FieldName = {})); +const defaultFieldNames = { + text: FieldName.TEXT, + value: FieldName.VALUE, + children: FieldName.CHILDREN, +}; +VantComponent({ + props: { + title: String, + value: { + type: String, + }, + placeholder: { + type: String, + value: '请选择', + }, + activeColor: { + type: String, + value: '#1989fa', + }, + options: { + type: Array, + value: [], + }, + swipeable: { + type: Boolean, + value: false, + }, + closeable: { + type: Boolean, + value: true, + }, + ellipsis: { + type: Boolean, + value: true, + }, + showHeader: { + type: Boolean, + value: true, + }, + closeIcon: { + type: String, + value: 'cross', + }, + fieldNames: { + type: Object, + value: defaultFieldNames, + observer: 'updateFieldNames', + }, + useTitleSlot: Boolean, + }, + data: { + tabs: [], + activeTab: 0, + textKey: FieldName.TEXT, + valueKey: FieldName.VALUE, + childrenKey: FieldName.CHILDREN, + innerValue: '', + }, + watch: { + options() { + this.updateTabs(); + }, + value(newVal) { + this.updateValue(newVal); + }, + }, + created() { + this.updateTabs(); + }, + methods: { + updateValue(val) { + if (val !== undefined) { + const values = this.data.tabs.map((tab) => tab.selected && tab.selected[this.data.valueKey]); + if (values.indexOf(val) > -1) { + return; + } + } + this.innerValue = val; + this.updateTabs(); + }, + updateFieldNames() { + const { text = 'text', value = 'value', children = 'children', } = this.data.fieldNames || defaultFieldNames; + this.setData({ + textKey: text, + valueKey: value, + childrenKey: children, + }); + }, + getSelectedOptionsByValue(options, value) { + for (let i = 0; i < options.length; i++) { + const option = options[i]; + if (option[this.data.valueKey] === value) { + return [option]; + } + if (option[this.data.childrenKey]) { + const selectedOptions = this.getSelectedOptionsByValue(option[this.data.childrenKey], value); + if (selectedOptions) { + return [option, ...selectedOptions]; + } + } + } + }, + updateTabs() { + const { options } = this.data; + const { innerValue } = this; + if (!options.length) { + return; + } + if (innerValue !== undefined) { + const selectedOptions = this.getSelectedOptionsByValue(options, innerValue); + if (selectedOptions) { + let optionsCursor = options; + const tabs = selectedOptions.map((option) => { + const tab = { + options: optionsCursor, + selected: option, + }; + const next = optionsCursor.find((item) => item[this.data.valueKey] === option[this.data.valueKey]); + if (next) { + optionsCursor = next[this.data.childrenKey]; + } + return tab; + }); + if (optionsCursor) { + tabs.push({ + options: optionsCursor, + selected: null, + }); + } + this.setData({ + tabs, + }); + wx.nextTick(() => { + this.setData({ + activeTab: tabs.length - 1, + }); + }); + return; + } + } + this.setData({ + tabs: [ + { + options, + selected: null, + }, + ], + activeTab: 0, + }); + }, + onClose() { + this.$emit('close'); + }, + onClickTab(e) { + const { index: tabIndex, title } = e.detail; + this.$emit('click-tab', { title, tabIndex }); + this.setData({ + activeTab: tabIndex, + }); + }, + // 选中 + onSelect(e) { + const { option, tabIndex } = e.currentTarget.dataset; + if (option && option.disabled) { + return; + } + const { valueKey, childrenKey } = this.data; + let { tabs } = this.data; + tabs[tabIndex].selected = option; + if (tabs.length > tabIndex + 1) { + tabs = tabs.slice(0, tabIndex + 1); + } + if (option[childrenKey]) { + const nextTab = { + options: option[childrenKey], + selected: null, + }; + if (tabs[tabIndex + 1]) { + tabs[tabIndex + 1] = nextTab; + } + else { + tabs.push(nextTab); + } + wx.nextTick(() => { + this.setData({ + activeTab: tabIndex + 1, + }); + }); + } + this.setData({ + tabs, + }); + const selectedOptions = tabs.map((tab) => tab.selected).filter(Boolean); + const value = option[valueKey]; + const params = { + value, + tabIndex, + selectedOptions, + }; + this.innerValue = value; + this.$emit('change', params); + if (!option[childrenKey]) { + this.$emit('finish', params); + } + }, + }, +}); diff --git a/wxcomponents/vant/cascader/index.json b/wxcomponents/vant/cascader/index.json new file mode 100644 index 0000000..d0f75eb --- /dev/null +++ b/wxcomponents/vant/cascader/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-tab": "../tab/index", + "van-tabs": "../tabs/index" + } +} \ No newline at end of file diff --git a/wxcomponents/vant/cascader/index.wxml b/wxcomponents/vant/cascader/index.wxml new file mode 100644 index 0000000..8a5ab25 --- /dev/null +++ b/wxcomponents/vant/cascader/index.wxml @@ -0,0 +1,55 @@ + + + + + {{ title }} + + + + + + + + + + + {{ option[textKey] }} + + + + + + + diff --git a/wxcomponents/vant/cascader/index.wxs b/wxcomponents/vant/cascader/index.wxs new file mode 100644 index 0000000..b1aab58 --- /dev/null +++ b/wxcomponents/vant/cascader/index.wxs @@ -0,0 +1,24 @@ +var utils = require('../wxs/utils.wxs'); +var style = require('../wxs/style.wxs'); + +function isSelected(tab, valueKey, option) { + return tab.selected && tab.selected[valueKey] === option[valueKey] +} + +function optionClass(tab, valueKey, option) { + return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled }) +} + +function optionStyle(data) { + var color = data.option.color || (isSelected(data.tab, data.valueKey, data.option) ? data.activeColor : undefined); + return style({ + color + }); +} + + +module.exports = { + isSelected: isSelected, + optionClass: optionClass, + optionStyle: optionStyle, +}; \ No newline at end of file diff --git a/wxcomponents/vant/cascader/index.wxss b/wxcomponents/vant/cascader/index.wxss new file mode 100644 index 0000000..7062486 --- /dev/null +++ b/wxcomponents/vant/cascader/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cascader__header{align-items:center;display:flex;height:48px;justify-content:space-between;padding:0 16px}.van-cascader__title{font-size:16px;font-weight:600;line-height:20px}.van-cascader__close-icon{color:#c8c9cc;font-size:22px;height:22px}.van-cascader__tabs-wrap{height:48px!important;padding:0 8px}.van-cascader__tab{color:#323233!important;flex:none!important;font-weight:600!important;padding:0 8px!important}.van-cascader__tab--unselected{color:#969799!important;font-weight:400!important}.van-cascader__option{align-items:center;cursor:pointer;display:flex;font-size:14px;justify-content:space-between;line-height:20px;padding:10px 16px}.van-cascader__option:active{background-color:#f2f3f5}.van-cascader__option--selected{color:#1989fa;font-weight:600}.van-cascader__option--disabled{color:#c8c9cc;cursor:not-allowed}.van-cascader__option--disabled:active{background-color:initial}.van-cascader__options{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:384px;overflow-y:auto;padding-top:6px} \ No newline at end of file diff --git a/wxcomponents/vant/cell-group/index.d.ts b/wxcomponents/vant/cell-group/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/cell-group/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/cell-group/index.js b/wxcomponents/vant/cell-group/index.js new file mode 100644 index 0000000..170760f --- /dev/null +++ b/wxcomponents/vant/cell-group/index.js @@ -0,0 +1,11 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + title: String, + border: { + type: Boolean, + value: true, + }, + inset: Boolean, + }, +}); diff --git a/wxcomponents/vant/cell-group/index.json b/wxcomponents/vant/cell-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/cell-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/cell-group/index.wxml b/wxcomponents/vant/cell-group/index.wxml new file mode 100644 index 0000000..311e064 --- /dev/null +++ b/wxcomponents/vant/cell-group/index.wxml @@ -0,0 +1,11 @@ + + + + {{ title }} + + + + diff --git a/wxcomponents/vant/cell-group/index.wxss b/wxcomponents/vant/cell-group/index.wxss new file mode 100644 index 0000000..08b252f --- /dev/null +++ b/wxcomponents/vant/cell-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell-group--inset{border-radius:var(--cell-group-inset-border-radius,8px);margin:var(--cell-group-inset-padding,0 16px);overflow:hidden}.van-cell-group__title{color:var(--cell-group-title-color,#969799);font-size:var(--cell-group-title-font-size,14px);line-height:var(--cell-group-title-line-height,16px);padding:var(--cell-group-title-padding,16px 16px 8px)}.van-cell-group__title--inset{padding:var(--cell-group-inset-title-padding,16px 16px 8px 32px)} \ No newline at end of file diff --git a/wxcomponents/vant/cell/index.d.ts b/wxcomponents/vant/cell/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/cell/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/cell/index.js b/wxcomponents/vant/cell/index.js new file mode 100644 index 0000000..35548b9 --- /dev/null +++ b/wxcomponents/vant/cell/index.js @@ -0,0 +1,38 @@ +import { link } from '../mixins/link'; +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'title-class', + 'label-class', + 'value-class', + 'right-icon-class', + 'hover-class', + ], + mixins: [link], + props: { + title: null, + value: null, + icon: String, + size: String, + label: String, + center: Boolean, + isLink: Boolean, + required: Boolean, + clickable: Boolean, + titleWidth: String, + customStyle: String, + arrowDirection: String, + useLabelSlot: Boolean, + border: { + type: Boolean, + value: true, + }, + titleStyle: String, + }, + methods: { + onClick(event) { + this.$emit('click', event.detail); + this.jumpLink(); + }, + }, +}); diff --git a/wxcomponents/vant/cell/index.json b/wxcomponents/vant/cell/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/wxcomponents/vant/cell/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/wxcomponents/vant/cell/index.wxml b/wxcomponents/vant/cell/index.wxml new file mode 100644 index 0000000..8387c3c --- /dev/null +++ b/wxcomponents/vant/cell/index.wxml @@ -0,0 +1,47 @@ + + + + + + + + + + {{ title }} + + + + + {{ label }} + + + + + {{ value }} + + + + + + + + diff --git a/wxcomponents/vant/cell/index.wxs b/wxcomponents/vant/cell/index.wxs new file mode 100644 index 0000000..e3500c4 --- /dev/null +++ b/wxcomponents/vant/cell/index.wxs @@ -0,0 +1,17 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); +var addUnit = require('../wxs/add-unit.wxs'); + +function titleStyle(data) { + return style([ + { + 'max-width': addUnit(data.titleWidth), + 'min-width': addUnit(data.titleWidth), + }, + data.titleStyle, + ]); +} + +module.exports = { + titleStyle: titleStyle, +}; diff --git a/wxcomponents/vant/cell/index.wxss b/wxcomponents/vant/cell/index.wxss new file mode 100644 index 0000000..1802f8e --- /dev/null +++ b/wxcomponents/vant/cell/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell{background-color:var(--cell-background-color,#fff);box-sizing:border-box;color:var(--cell-text-color,#323233);display:flex;font-size:var(--cell-font-size,14px);line-height:var(--cell-line-height,24px);padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);position:relative;width:100%}.van-cell:after{border-bottom:1px solid #ebedf0;bottom:0;box-sizing:border-box;content:" ";left:16px;pointer-events:none;position:absolute;right:16px;transform:scaleY(.5);transform-origin:center}.van-cell--borderless:after{display:none}.van-cell-group{background-color:var(--cell-background-color,#fff)}.van-cell__label{color:var(--cell-label-color,#969799);font-size:var(--cell-label-font-size,12px);line-height:var(--cell-label-line-height,18px);margin-top:var(--cell-label-margin-top,3px)}.van-cell__value{color:var(--cell-value-color,#969799);overflow:hidden;text-align:right;vertical-align:middle}.van-cell__title,.van-cell__value{flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{align-items:center;display:flex;font-size:var(--cell-icon-size,16px);height:var(--cell-line-height,24px)}.van-cell__left-icon-wrap{margin-right:var(--padding-base,4px)}.van-cell__right-icon-wrap{color:var(--cell-right-icon-color,#969799);margin-left:var(--padding-base,4px)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{color:var(--cell-required-color,#ee0a24);content:"*";font-size:var(--cell-font-size,14px);left:var(--padding-xs,8px);position:absolute}.van-cell--center{align-items:center}.van-cell--large{padding-bottom:var(--cell-large-vertical-padding,12px);padding-top:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:var(--cell-large-label-font-size,14px)} \ No newline at end of file diff --git a/wxcomponents/vant/checkbox-group/index.d.ts b/wxcomponents/vant/checkbox-group/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/checkbox-group/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/checkbox-group/index.js b/wxcomponents/vant/checkbox-group/index.js new file mode 100644 index 0000000..c47d97d --- /dev/null +++ b/wxcomponents/vant/checkbox-group/index.js @@ -0,0 +1,36 @@ +import { useChildren } from '../common/relation'; +import { VantComponent } from '../common/component'; +VantComponent({ + field: true, + relation: useChildren('checkbox', function (target) { + this.updateChild(target); + }), + props: { + max: Number, + value: { + type: Array, + observer: 'updateChildren', + }, + disabled: { + type: Boolean, + observer: 'updateChildren', + }, + direction: { + type: String, + value: 'vertical', + }, + }, + methods: { + updateChildren() { + this.children.forEach((child) => this.updateChild(child)); + }, + updateChild(child) { + const { value, disabled, direction } = this.data; + child.setData({ + value: value.indexOf(child.data.name) !== -1, + parentDisabled: disabled, + direction, + }); + }, + }, +}); diff --git a/wxcomponents/vant/checkbox-group/index.json b/wxcomponents/vant/checkbox-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/checkbox-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/checkbox-group/index.wxml b/wxcomponents/vant/checkbox-group/index.wxml new file mode 100644 index 0000000..638bf9d --- /dev/null +++ b/wxcomponents/vant/checkbox-group/index.wxml @@ -0,0 +1,5 @@ + + + + + diff --git a/wxcomponents/vant/checkbox-group/index.wxss b/wxcomponents/vant/checkbox-group/index.wxss new file mode 100644 index 0000000..c5666d7 --- /dev/null +++ b/wxcomponents/vant/checkbox-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-checkbox-group--horizontal{display:flex;flex-wrap:wrap} \ No newline at end of file diff --git a/wxcomponents/vant/checkbox/index.d.ts b/wxcomponents/vant/checkbox/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/checkbox/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/checkbox/index.js b/wxcomponents/vant/checkbox/index.js new file mode 100644 index 0000000..e3b78ab --- /dev/null +++ b/wxcomponents/vant/checkbox/index.js @@ -0,0 +1,77 @@ +import { useParent } from '../common/relation'; +import { VantComponent } from '../common/component'; +function emit(target, value) { + target.$emit('input', value); + target.$emit('change', value); +} +VantComponent({ + field: true, + relation: useParent('checkbox-group'), + classes: ['icon-class', 'label-class'], + props: { + value: Boolean, + disabled: Boolean, + useIconSlot: Boolean, + checkedColor: String, + labelPosition: { + type: String, + value: 'right', + }, + labelDisabled: Boolean, + shape: { + type: String, + value: 'round', + }, + iconSize: { + type: null, + value: 20, + }, + }, + data: { + parentDisabled: false, + direction: 'vertical', + }, + methods: { + emitChange(value) { + if (this.parent) { + this.setParentValue(this.parent, value); + } + else { + emit(this, value); + } + }, + toggle() { + const { parentDisabled, disabled, value } = this.data; + if (!disabled && !parentDisabled) { + this.emitChange(!value); + } + }, + onClickLabel() { + const { labelDisabled, parentDisabled, disabled, value } = this.data; + if (!disabled && !labelDisabled && !parentDisabled) { + this.emitChange(!value); + } + }, + setParentValue(parent, value) { + const parentValue = parent.data.value.slice(); + const { name } = this.data; + const { max } = parent.data; + if (value) { + if (max && parentValue.length >= max) { + return; + } + if (parentValue.indexOf(name) === -1) { + parentValue.push(name); + emit(parent, parentValue); + } + } + else { + const index = parentValue.indexOf(name); + if (index !== -1) { + parentValue.splice(index, 1); + emit(parent, parentValue); + } + } + }, + }, +}); diff --git a/wxcomponents/vant/checkbox/index.json b/wxcomponents/vant/checkbox/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/wxcomponents/vant/checkbox/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/wxcomponents/vant/checkbox/index.wxml b/wxcomponents/vant/checkbox/index.wxml new file mode 100644 index 0000000..39a7bb0 --- /dev/null +++ b/wxcomponents/vant/checkbox/index.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/wxcomponents/vant/checkbox/index.wxs b/wxcomponents/vant/checkbox/index.wxs new file mode 100644 index 0000000..eb9c772 --- /dev/null +++ b/wxcomponents/vant/checkbox/index.wxs @@ -0,0 +1,20 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); +var addUnit = require('../wxs/add-unit.wxs'); + +function iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) { + var styles = { + 'font-size': addUnit(iconSize), + }; + + if (checkedColor && value && !disabled && !parentDisabled) { + styles['border-color'] = checkedColor; + styles['background-color'] = checkedColor; + } + + return style(styles); +} + +module.exports = { + iconStyle: iconStyle, +}; diff --git a/wxcomponents/vant/checkbox/index.wxss b/wxcomponents/vant/checkbox/index.wxss new file mode 100644 index 0000000..da2272a --- /dev/null +++ b/wxcomponents/vant/checkbox/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-checkbox{align-items:center;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox--horizontal{margin-right:12px}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{flex:none}.van-checkbox__icon{align-items:center;border:1px solid var(--checkbox-border-color,#c8c9cc);box-sizing:border-box;color:transparent;display:flex;font-size:var(--checkbox-size,20px);height:1em;justify-content:center;text-align:center;transition-duration:var(--checkbox-transition-duration,.2s);transition-property:color,border-color,background-color;width:1em}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:var(--checkbox-checked-icon-color,#1989fa);color:#fff}.van-checkbox__icon--disabled{background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;color:var(--checkbox-label-color,#323233);padding-left:var(--checkbox-label-margin,10px)}.van-checkbox__label--left{float:left;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file diff --git a/wxcomponents/vant/circle/canvas.d.ts b/wxcomponents/vant/circle/canvas.d.ts new file mode 100644 index 0000000..8a0b71e --- /dev/null +++ b/wxcomponents/vant/circle/canvas.d.ts @@ -0,0 +1,4 @@ +/// +type CanvasContext = WechatMiniprogram.CanvasContext; +export declare function adaptor(ctx: CanvasContext & Record): CanvasContext; +export {}; diff --git a/wxcomponents/vant/circle/canvas.js b/wxcomponents/vant/circle/canvas.js new file mode 100644 index 0000000..3ade4cd --- /dev/null +++ b/wxcomponents/vant/circle/canvas.js @@ -0,0 +1,43 @@ +export function adaptor(ctx) { + // @ts-ignore + return Object.assign(ctx, { + setStrokeStyle(val) { + ctx.strokeStyle = val; + }, + setLineWidth(val) { + ctx.lineWidth = val; + }, + setLineCap(val) { + ctx.lineCap = val; + }, + setFillStyle(val) { + ctx.fillStyle = val; + }, + setFontSize(val) { + ctx.font = String(val); + }, + setGlobalAlpha(val) { + ctx.globalAlpha = val; + }, + setLineJoin(val) { + ctx.lineJoin = val; + }, + setTextAlign(val) { + ctx.textAlign = val; + }, + setMiterLimit(val) { + ctx.miterLimit = val; + }, + setShadow(offsetX, offsetY, blur, color) { + ctx.shadowOffsetX = offsetX; + ctx.shadowOffsetY = offsetY; + ctx.shadowBlur = blur; + ctx.shadowColor = color; + }, + setTextBaseline(val) { + ctx.textBaseline = val; + }, + createCircularGradient() { }, + draw() { }, + }); +} diff --git a/wxcomponents/vant/circle/index.d.ts b/wxcomponents/vant/circle/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/circle/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/circle/index.js b/wxcomponents/vant/circle/index.js new file mode 100644 index 0000000..0b60888 --- /dev/null +++ b/wxcomponents/vant/circle/index.js @@ -0,0 +1,197 @@ +import { BLUE, WHITE } from '../common/color'; +import { VantComponent } from '../common/component'; +import { getSystemInfoSync } from '../common/utils'; +import { isObj } from '../common/validator'; +import { canIUseCanvas2d } from '../common/version'; +import { adaptor } from './canvas'; +function format(rate) { + return Math.min(Math.max(rate, 0), 100); +} +const PERIMETER = 2 * Math.PI; +const BEGIN_ANGLE = -Math.PI / 2; +const STEP = 1; +VantComponent({ + props: { + text: String, + lineCap: { + type: String, + value: 'round', + }, + value: { + type: Number, + value: 0, + observer: 'reRender', + }, + speed: { + type: Number, + value: 50, + }, + size: { + type: Number, + value: 100, + observer() { + this.drawCircle(this.currentValue); + }, + }, + fill: String, + layerColor: { + type: String, + value: WHITE, + }, + color: { + type: null, + value: BLUE, + observer() { + this.setHoverColor().then(() => { + this.drawCircle(this.currentValue); + }); + }, + }, + type: { + type: String, + value: '', + }, + strokeWidth: { + type: Number, + value: 4, + }, + clockwise: { + type: Boolean, + value: true, + }, + }, + data: { + hoverColor: BLUE, + }, + methods: { + getContext() { + const { type, size } = this.data; + if (type === '' || !canIUseCanvas2d()) { + const ctx = wx.createCanvasContext('van-circle', this); + return Promise.resolve(ctx); + } + const dpr = getSystemInfoSync().pixelRatio; + return new Promise((resolve) => { + wx.createSelectorQuery() + .in(this) + .select('#van-circle') + .node() + .exec((res) => { + const canvas = res[0].node; + const ctx = canvas.getContext(type); + if (!this.inited) { + this.inited = true; + canvas.width = size * dpr; + canvas.height = size * dpr; + ctx.scale(dpr, dpr); + } + resolve(adaptor(ctx)); + }); + }); + }, + setHoverColor() { + const { color, size } = this.data; + if (isObj(color)) { + return this.getContext().then((context) => { + if (!context) + return; + const LinearColor = context.createLinearGradient(size, 0, 0, 0); + Object.keys(color) + .sort((a, b) => parseFloat(a) - parseFloat(b)) + .map((key) => LinearColor.addColorStop(parseFloat(key) / 100, color[key])); + this.hoverColor = LinearColor; + }); + } + this.hoverColor = color; + return Promise.resolve(); + }, + presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) { + const { strokeWidth, lineCap, clockwise, size } = this.data; + const position = size / 2; + const radius = position - strokeWidth / 2; + context.setStrokeStyle(strokeStyle); + context.setLineWidth(strokeWidth); + context.setLineCap(lineCap); + context.beginPath(); + context.arc(position, position, radius, beginAngle, endAngle, !clockwise); + context.stroke(); + if (fill) { + context.setFillStyle(fill); + context.fill(); + } + }, + renderLayerCircle(context) { + const { layerColor, fill } = this.data; + this.presetCanvas(context, layerColor, 0, PERIMETER, fill); + }, + renderHoverCircle(context, formatValue) { + const { clockwise } = this.data; + // 结束角度 + const progress = PERIMETER * (formatValue / 100); + const endAngle = clockwise + ? BEGIN_ANGLE + progress + : 3 * Math.PI - (BEGIN_ANGLE + progress); + this.presetCanvas(context, this.hoverColor, BEGIN_ANGLE, endAngle); + }, + drawCircle(currentValue) { + const { size } = this.data; + this.getContext().then((context) => { + if (!context) + return; + context.clearRect(0, 0, size, size); + this.renderLayerCircle(context); + const formatValue = format(currentValue); + if (formatValue !== 0) { + this.renderHoverCircle(context, formatValue); + } + context.draw(); + }); + }, + reRender() { + // tofector 动画暂时没有想到好的解决方案 + const { value, speed } = this.data; + if (speed <= 0 || speed > 1000) { + this.drawCircle(value); + return; + } + this.clearMockInterval(); + this.currentValue = this.currentValue || 0; + const run = () => { + this.interval = setTimeout(() => { + if (this.currentValue !== value) { + if (Math.abs(this.currentValue - value) < STEP) { + this.currentValue = value; + } + else if (this.currentValue < value) { + this.currentValue += STEP; + } + else { + this.currentValue -= STEP; + } + this.drawCircle(this.currentValue); + run(); + } + else { + this.clearMockInterval(); + } + }, 1000 / speed); + }; + run(); + }, + clearMockInterval() { + if (this.interval) { + clearTimeout(this.interval); + this.interval = null; + } + }, + }, + mounted() { + this.currentValue = this.data.value; + this.setHoverColor().then(() => { + this.drawCircle(this.currentValue); + }); + }, + destroyed() { + this.clearMockInterval(); + }, +}); diff --git a/wxcomponents/vant/circle/index.json b/wxcomponents/vant/circle/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/circle/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/circle/index.wxml b/wxcomponents/vant/circle/index.wxml new file mode 100644 index 0000000..52bc59f --- /dev/null +++ b/wxcomponents/vant/circle/index.wxml @@ -0,0 +1,9 @@ + + + + + + + + {{ text }} + diff --git a/wxcomponents/vant/circle/index.wxss b/wxcomponents/vant/circle/index.wxss new file mode 100644 index 0000000..2200751 --- /dev/null +++ b/wxcomponents/vant/circle/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-circle{display:inline-block;position:relative;text-align:center}.van-circle__text{color:var(--circle-text-color,#323233);left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%} \ No newline at end of file diff --git a/wxcomponents/vant/col/index.d.ts b/wxcomponents/vant/col/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/col/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/col/index.js b/wxcomponents/vant/col/index.js new file mode 100644 index 0000000..02bb78d --- /dev/null +++ b/wxcomponents/vant/col/index.js @@ -0,0 +1,9 @@ +import { useParent } from '../common/relation'; +import { VantComponent } from '../common/component'; +VantComponent({ + relation: useParent('row'), + props: { + span: Number, + offset: Number, + }, +}); diff --git a/wxcomponents/vant/col/index.json b/wxcomponents/vant/col/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/col/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/col/index.wxml b/wxcomponents/vant/col/index.wxml new file mode 100644 index 0000000..975348b --- /dev/null +++ b/wxcomponents/vant/col/index.wxml @@ -0,0 +1,9 @@ + + + + + + diff --git a/wxcomponents/vant/col/index.wxs b/wxcomponents/vant/col/index.wxs new file mode 100644 index 0000000..507c1cb --- /dev/null +++ b/wxcomponents/vant/col/index.wxs @@ -0,0 +1,18 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); +var addUnit = require('../wxs/add-unit.wxs'); + +function rootStyle(data) { + if (!data.gutter) { + return ''; + } + + return style({ + 'padding-right': addUnit(data.gutter / 2), + 'padding-left': addUnit(data.gutter / 2), + }); +} + +module.exports = { + rootStyle: rootStyle, +}; diff --git a/wxcomponents/vant/col/index.wxss b/wxcomponents/vant/col/index.wxss new file mode 100644 index 0000000..2fa265e --- /dev/null +++ b/wxcomponents/vant/col/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-col{box-sizing:border-box;float:left}.van-col--1{width:4.16666667%}.van-col--offset-1{margin-left:4.16666667%}.van-col--2{width:8.33333333%}.van-col--offset-2{margin-left:8.33333333%}.van-col--3{width:12.5%}.van-col--offset-3{margin-left:12.5%}.van-col--4{width:16.66666667%}.van-col--offset-4{margin-left:16.66666667%}.van-col--5{width:20.83333333%}.van-col--offset-5{margin-left:20.83333333%}.van-col--6{width:25%}.van-col--offset-6{margin-left:25%}.van-col--7{width:29.16666667%}.van-col--offset-7{margin-left:29.16666667%}.van-col--8{width:33.33333333%}.van-col--offset-8{margin-left:33.33333333%}.van-col--9{width:37.5%}.van-col--offset-9{margin-left:37.5%}.van-col--10{width:41.66666667%}.van-col--offset-10{margin-left:41.66666667%}.van-col--11{width:45.83333333%}.van-col--offset-11{margin-left:45.83333333%}.van-col--12{width:50%}.van-col--offset-12{margin-left:50%}.van-col--13{width:54.16666667%}.van-col--offset-13{margin-left:54.16666667%}.van-col--14{width:58.33333333%}.van-col--offset-14{margin-left:58.33333333%}.van-col--15{width:62.5%}.van-col--offset-15{margin-left:62.5%}.van-col--16{width:66.66666667%}.van-col--offset-16{margin-left:66.66666667%}.van-col--17{width:70.83333333%}.van-col--offset-17{margin-left:70.83333333%}.van-col--18{width:75%}.van-col--offset-18{margin-left:75%}.van-col--19{width:79.16666667%}.van-col--offset-19{margin-left:79.16666667%}.van-col--20{width:83.33333333%}.van-col--offset-20{margin-left:83.33333333%}.van-col--21{width:87.5%}.van-col--offset-21{margin-left:87.5%}.van-col--22{width:91.66666667%}.van-col--offset-22{margin-left:91.66666667%}.van-col--23{width:95.83333333%}.van-col--offset-23{margin-left:95.83333333%}.van-col--24{width:100%}.van-col--offset-24{margin-left:100%} \ No newline at end of file diff --git a/wxcomponents/vant/collapse-item/animate.d.ts b/wxcomponents/vant/collapse-item/animate.d.ts new file mode 100644 index 0000000..32157b6 --- /dev/null +++ b/wxcomponents/vant/collapse-item/animate.d.ts @@ -0,0 +1,2 @@ +/// +export declare function setContentAnimate(context: WechatMiniprogram.Component.TrivialInstance, expanded: boolean, mounted: boolean): void; diff --git a/wxcomponents/vant/collapse-item/animate.js b/wxcomponents/vant/collapse-item/animate.js new file mode 100644 index 0000000..f966ac5 --- /dev/null +++ b/wxcomponents/vant/collapse-item/animate.js @@ -0,0 +1,39 @@ +import { getRect } from '../common/utils'; +function useAnimation(context, expanded, mounted, height) { + const animation = wx.createAnimation({ + duration: 0, + timingFunction: 'ease-in-out', + }); + if (expanded) { + if (height === 0) { + animation.height('auto').top(1).step(); + } + else { + animation + .height(height) + .top(1) + .step({ + duration: mounted ? 300 : 1, + }) + .height('auto') + .step(); + } + context.setData({ + animation: animation.export(), + }); + return; + } + animation.height(height).top(0).step({ duration: 1 }).height(0).step({ + duration: 300, + }); + context.setData({ + animation: animation.export(), + }); +} +export function setContentAnimate(context, expanded, mounted) { + getRect(context, '.van-collapse-item__content') + .then((rect) => rect.height) + .then((height) => { + useAnimation(context, expanded, mounted, height); + }); +} diff --git a/wxcomponents/vant/collapse-item/index.d.ts b/wxcomponents/vant/collapse-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/collapse-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/collapse-item/index.js b/wxcomponents/vant/collapse-item/index.js new file mode 100644 index 0000000..e8ce052 --- /dev/null +++ b/wxcomponents/vant/collapse-item/index.js @@ -0,0 +1,61 @@ +import { VantComponent } from '../common/component'; +import { useParent } from '../common/relation'; +import { setContentAnimate } from './animate'; +VantComponent({ + classes: ['title-class', 'content-class'], + relation: useParent('collapse'), + props: { + size: String, + name: null, + title: null, + value: null, + icon: String, + label: String, + disabled: Boolean, + clickable: Boolean, + border: { + type: Boolean, + value: true, + }, + isLink: { + type: Boolean, + value: true, + }, + }, + data: { + expanded: false, + parentBorder: true, + }, + mounted() { + this.updateExpanded(); + this.mounted = true; + }, + methods: { + updateExpanded() { + if (!this.parent) { + return; + } + const { value, accordion, border } = this.parent.data; + const { children = [] } = this.parent; + const { name } = this.data; + const index = children.indexOf(this); + const currentName = name == null ? index : name; + const expanded = accordion + ? value === currentName + : (value || []).some((name) => name === currentName); + if (expanded !== this.data.expanded) { + setContentAnimate(this, expanded, this.mounted); + } + this.setData({ index, expanded, parentBorder: border }); + }, + onClick() { + if (this.data.disabled) { + return; + } + const { name, expanded } = this.data; + const index = this.parent.children.indexOf(this); + const currentName = name == null ? index : name; + this.parent.switch(currentName, !expanded); + }, + }, +}); diff --git a/wxcomponents/vant/collapse-item/index.json b/wxcomponents/vant/collapse-item/index.json new file mode 100644 index 0000000..0e5425c --- /dev/null +++ b/wxcomponents/vant/collapse-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index" + } +} diff --git a/wxcomponents/vant/collapse-item/index.wxml b/wxcomponents/vant/collapse-item/index.wxml new file mode 100644 index 0000000..23a27e4 --- /dev/null +++ b/wxcomponents/vant/collapse-item/index.wxml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + diff --git a/wxcomponents/vant/collapse-item/index.wxss b/wxcomponents/vant/collapse-item/index.wxss new file mode 100644 index 0000000..4a65b5a --- /dev/null +++ b/wxcomponents/vant/collapse-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{transform:rotate(90deg);transition:transform var(--collapse-item-transition-duration,.3s)}.van-collapse-item__title--expanded .van-cell__right-icon{transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:var(--collapse-item-title-disabled-color,#c8c9cc)!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__content{background-color:var(--collapse-item-content-background-color,#fff);color:var(--collapse-item-content-text-color,#969799);font-size:var(--collapse-item-content-font-size,13px);line-height:var(--collapse-item-content-line-height,1.5);padding:var(--collapse-item-content-padding,15px)} \ No newline at end of file diff --git a/wxcomponents/vant/collapse/index.d.ts b/wxcomponents/vant/collapse/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/collapse/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/collapse/index.js b/wxcomponents/vant/collapse/index.js new file mode 100644 index 0000000..3616087 --- /dev/null +++ b/wxcomponents/vant/collapse/index.js @@ -0,0 +1,46 @@ +import { VantComponent } from '../common/component'; +import { useChildren } from '../common/relation'; +VantComponent({ + relation: useChildren('collapse-item'), + props: { + value: { + type: null, + observer: 'updateExpanded', + }, + accordion: { + type: Boolean, + observer: 'updateExpanded', + }, + border: { + type: Boolean, + value: true, + }, + }, + methods: { + updateExpanded() { + this.children.forEach((child) => { + child.updateExpanded(); + }); + }, + switch(name, expanded) { + const { accordion, value } = this.data; + const changeItem = name; + if (!accordion) { + name = expanded + ? (value || []).concat(name) + : (value || []).filter((activeName) => activeName !== name); + } + else { + name = expanded ? name : ''; + } + if (expanded) { + this.$emit('open', changeItem); + } + else { + this.$emit('close', changeItem); + } + this.$emit('change', name); + this.$emit('input', name); + }, + }, +}); diff --git a/wxcomponents/vant/collapse/index.json b/wxcomponents/vant/collapse/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/collapse/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/collapse/index.wxml b/wxcomponents/vant/collapse/index.wxml new file mode 100644 index 0000000..fd4e171 --- /dev/null +++ b/wxcomponents/vant/collapse/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/wxcomponents/vant/collapse/index.wxss b/wxcomponents/vant/collapse/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/wxcomponents/vant/collapse/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/wxcomponents/vant/common/color.d.ts b/wxcomponents/vant/common/color.d.ts new file mode 100644 index 0000000..386f307 --- /dev/null +++ b/wxcomponents/vant/common/color.d.ts @@ -0,0 +1,7 @@ +export declare const RED = "#ee0a24"; +export declare const BLUE = "#1989fa"; +export declare const WHITE = "#fff"; +export declare const GREEN = "#07c160"; +export declare const ORANGE = "#ff976a"; +export declare const GRAY = "#323233"; +export declare const GRAY_DARK = "#969799"; diff --git a/wxcomponents/vant/common/color.js b/wxcomponents/vant/common/color.js new file mode 100644 index 0000000..6b285bd --- /dev/null +++ b/wxcomponents/vant/common/color.js @@ -0,0 +1,7 @@ +export const RED = '#ee0a24'; +export const BLUE = '#1989fa'; +export const WHITE = '#fff'; +export const GREEN = '#07c160'; +export const ORANGE = '#ff976a'; +export const GRAY = '#323233'; +export const GRAY_DARK = '#969799'; diff --git a/wxcomponents/vant/common/component.d.ts b/wxcomponents/vant/common/component.d.ts new file mode 100644 index 0000000..1d0fd27 --- /dev/null +++ b/wxcomponents/vant/common/component.d.ts @@ -0,0 +1,4 @@ +/// +import { VantComponentOptions } from 'definitions/index'; +declare function VantComponent(vantOptions: VantComponentOptions): void; +export { VantComponent }; diff --git a/wxcomponents/vant/common/component.js b/wxcomponents/vant/common/component.js new file mode 100644 index 0000000..938d96b --- /dev/null +++ b/wxcomponents/vant/common/component.js @@ -0,0 +1,46 @@ +import { basic } from '../mixins/basic'; +function mapKeys(source, target, map) { + Object.keys(map).forEach((key) => { + if (source[key]) { + target[map[key]] = source[key]; + } + }); +} +function VantComponent(vantOptions) { + const options = {}; + mapKeys(vantOptions, options, { + data: 'data', + props: 'properties', + watch: 'observers', + mixins: 'behaviors', + methods: 'methods', + beforeCreate: 'created', + created: 'attached', + mounted: 'ready', + destroyed: 'detached', + classes: 'externalClasses', + }); + // add default externalClasses + options.externalClasses = options.externalClasses || []; + options.externalClasses.push('custom-class'); + // add default behaviors + options.behaviors = options.behaviors || []; + options.behaviors.push(basic); + // add relations + const { relation } = vantOptions; + if (relation) { + options.relations = relation.relations; + options.behaviors.push(relation.mixin); + } + // map field to form-field behavior + if (vantOptions.field) { + options.behaviors.push('wx://form-field'); + } + // add default options + options.options = { + multipleSlots: true, + addGlobalClass: true, + }; + Component(options); +} +export { VantComponent }; diff --git a/wxcomponents/vant/common/index.wxss b/wxcomponents/vant/common/index.wxss new file mode 100644 index 0000000..a73bb7a --- /dev/null +++ b/wxcomponents/vant/common/index.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden;text-overflow:ellipsis}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{clear:both;content:"";display:table}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{border:0 solid #ebedf0;bottom:-50%;box-sizing:border-box;content:" ";left:-50%;pointer-events:none;position:absolute;right:-50%;top:-50%;transform:scale(.5);transform-origin:center}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/wxcomponents/vant/common/relation.d.ts b/wxcomponents/vant/common/relation.d.ts new file mode 100644 index 0000000..10193fa --- /dev/null +++ b/wxcomponents/vant/common/relation.d.ts @@ -0,0 +1,15 @@ +/// +type TrivialInstance = WechatMiniprogram.Component.TrivialInstance; +export declare function useParent(name: string, onEffect?: (this: TrivialInstance) => void): { + relations: { + [x: string]: WechatMiniprogram.Component.RelationOption; + }; + mixin: string; +}; +export declare function useChildren(name: string, onEffect?: (this: TrivialInstance, target: TrivialInstance) => void): { + relations: { + [x: string]: WechatMiniprogram.Component.RelationOption; + }; + mixin: string; +}; +export {}; diff --git a/wxcomponents/vant/common/relation.js b/wxcomponents/vant/common/relation.js new file mode 100644 index 0000000..04e2934 --- /dev/null +++ b/wxcomponents/vant/common/relation.js @@ -0,0 +1,56 @@ +export function useParent(name, onEffect) { + const path = `../${name}/index`; + return { + relations: { + [path]: { + type: 'ancestor', + linked() { + onEffect && onEffect.call(this); + }, + linkChanged() { + onEffect && onEffect.call(this); + }, + unlinked() { + onEffect && onEffect.call(this); + }, + }, + }, + mixin: Behavior({ + created() { + Object.defineProperty(this, 'parent', { + get: () => this.getRelationNodes(path)[0], + }); + Object.defineProperty(this, 'index', { + // @ts-ignore + get: () => { var _a, _b; return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.indexOf(this); }, + }); + }, + }), + }; +} +export function useChildren(name, onEffect) { + const path = `../${name}/index`; + return { + relations: { + [path]: { + type: 'descendant', + linked(target) { + onEffect && onEffect.call(this, target); + }, + linkChanged(target) { + onEffect && onEffect.call(this, target); + }, + unlinked(target) { + onEffect && onEffect.call(this, target); + }, + }, + }, + mixin: Behavior({ + created() { + Object.defineProperty(this, 'children', { + get: () => this.getRelationNodes(path) || [], + }); + }, + }), + }; +} diff --git a/wxcomponents/vant/common/style/clearfix.wxss b/wxcomponents/vant/common/style/clearfix.wxss new file mode 100644 index 0000000..442246f --- /dev/null +++ b/wxcomponents/vant/common/style/clearfix.wxss @@ -0,0 +1 @@ +.van-clearfix:after{clear:both;content:"";display:table} \ No newline at end of file diff --git a/wxcomponents/vant/common/style/ellipsis.wxss b/wxcomponents/vant/common/style/ellipsis.wxss new file mode 100644 index 0000000..ee701df --- /dev/null +++ b/wxcomponents/vant/common/style/ellipsis.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden;text-overflow:ellipsis}.van-multi-ellipsis--l3{-webkit-line-clamp:3} \ No newline at end of file diff --git a/wxcomponents/vant/common/style/hairline.wxss b/wxcomponents/vant/common/style/hairline.wxss new file mode 100644 index 0000000..f7c6260 --- /dev/null +++ b/wxcomponents/vant/common/style/hairline.wxss @@ -0,0 +1 @@ +.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{border:0 solid #ebedf0;bottom:-50%;box-sizing:border-box;content:" ";left:-50%;pointer-events:none;position:absolute;right:-50%;top:-50%;transform:scale(.5);transform-origin:center}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/wxcomponents/vant/common/style/mixins/clearfix.wxss b/wxcomponents/vant/common/style/mixins/clearfix.wxss new file mode 100644 index 0000000..e69de29 diff --git a/wxcomponents/vant/common/style/mixins/ellipsis.wxss b/wxcomponents/vant/common/style/mixins/ellipsis.wxss new file mode 100644 index 0000000..e69de29 diff --git a/wxcomponents/vant/common/style/mixins/hairline.wxss b/wxcomponents/vant/common/style/mixins/hairline.wxss new file mode 100644 index 0000000..e69de29 diff --git a/wxcomponents/vant/common/style/var.wxss b/wxcomponents/vant/common/style/var.wxss new file mode 100644 index 0000000..e69de29 diff --git a/wxcomponents/vant/common/utils.d.ts b/wxcomponents/vant/common/utils.d.ts new file mode 100644 index 0000000..a77d8c6 --- /dev/null +++ b/wxcomponents/vant/common/utils.d.ts @@ -0,0 +1,21 @@ +/// +/// +/// +/// +/// +export { isDef } from './validator'; +export { getSystemInfoSync } from './version'; +export declare function range(num: number, min: number, max: number): number; +export declare function nextTick(cb: (...args: any[]) => void): void; +export declare function addUnit(value?: string | number): string | undefined; +export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout; +export declare function pickExclude(obj: unknown, keys: string[]): {}; +export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise; +export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise; +export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void; +export declare function toPromise(promiseLike: Promise | unknown): Promise; +export declare function addNumber(num1: any, num2: any): number; +export declare const clamp: (num: any, min: any, max: any) => number; +export declare function getCurrentPage(): T & WechatMiniprogram.OptionalInterface & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods & WechatMiniprogram.Page.Data & WechatMiniprogram.IAnyObject; +export declare const isPC: boolean; +export declare const isWxWork: boolean; diff --git a/wxcomponents/vant/common/utils.js b/wxcomponents/vant/common/utils.js new file mode 100644 index 0000000..c84e32b --- /dev/null +++ b/wxcomponents/vant/common/utils.js @@ -0,0 +1,86 @@ +import { isDef, isNumber, isPlainObject, isPromise } from './validator'; +import { canIUseGroupSetData, canIUseNextTick, getSystemInfoSync, } from './version'; +export { isDef } from './validator'; +export { getSystemInfoSync } from './version'; +export function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +export function nextTick(cb) { + if (canIUseNextTick()) { + wx.nextTick(cb); + } + else { + setTimeout(() => { + cb(); + }, 1000 / 30); + } +} +export function addUnit(value) { + if (!isDef(value)) { + return undefined; + } + value = String(value); + return isNumber(value) ? `${value}px` : value; +} +export function requestAnimationFrame(cb) { + return setTimeout(() => { + cb(); + }, 1000 / 30); +} +export function pickExclude(obj, keys) { + if (!isPlainObject(obj)) { + return {}; + } + return Object.keys(obj).reduce((prev, key) => { + if (!keys.includes(key)) { + prev[key] = obj[key]; + } + return prev; + }, {}); +} +export function getRect(context, selector) { + return new Promise((resolve) => { + wx.createSelectorQuery() + .in(context) + .select(selector) + .boundingClientRect() + .exec((rect = []) => resolve(rect[0])); + }); +} +export function getAllRect(context, selector) { + return new Promise((resolve) => { + wx.createSelectorQuery() + .in(context) + .selectAll(selector) + .boundingClientRect() + .exec((rect = []) => resolve(rect[0])); + }); +} +export function groupSetData(context, cb) { + if (canIUseGroupSetData()) { + context.groupSetData(cb); + } + else { + cb(); + } +} +export function toPromise(promiseLike) { + if (isPromise(promiseLike)) { + return promiseLike; + } + return Promise.resolve(promiseLike); +} +// 浮点数精度处理 +export function addNumber(num1, num2) { + const cardinal = Math.pow(10, 10); + return Math.round((num1 + num2) * cardinal) / cardinal; +} +// 限制value在[min, max]之间 +export const clamp = (num, min, max) => Math.min(Math.max(num, min), max); +export function getCurrentPage() { + const pages = getCurrentPages(); + return pages[pages.length - 1]; +} +export const isPC = ['mac', 'windows'].includes(getSystemInfoSync().platform); +// 是否企业微信 +export const isWxWork = getSystemInfoSync().environment === 'wxwork'; diff --git a/wxcomponents/vant/common/validator.d.ts b/wxcomponents/vant/common/validator.d.ts new file mode 100644 index 0000000..152894a --- /dev/null +++ b/wxcomponents/vant/common/validator.d.ts @@ -0,0 +1,9 @@ +export declare function isFunction(val: unknown): val is Function; +export declare function isPlainObject(val: unknown): val is Record; +export declare function isPromise(val: unknown): val is Promise; +export declare function isDef(value: unknown): boolean; +export declare function isObj(x: unknown): x is Record; +export declare function isNumber(value: string): boolean; +export declare function isBoolean(value: unknown): value is boolean; +export declare function isImageUrl(url: string): boolean; +export declare function isVideoUrl(url: string): boolean; diff --git a/wxcomponents/vant/common/validator.js b/wxcomponents/vant/common/validator.js new file mode 100644 index 0000000..f11f844 --- /dev/null +++ b/wxcomponents/vant/common/validator.js @@ -0,0 +1,31 @@ +// eslint-disable-next-line @typescript-eslint/ban-types +export function isFunction(val) { + return typeof val === 'function'; +} +export function isPlainObject(val) { + return val !== null && typeof val === 'object' && !Array.isArray(val); +} +export function isPromise(val) { + return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch); +} +export function isDef(value) { + return value !== undefined && value !== null; +} +export function isObj(x) { + const type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} +export function isNumber(value) { + return /^\d+(\.\d+)?$/.test(value); +} +export function isBoolean(value) { + return typeof value === 'boolean'; +} +const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i; +const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i; +export function isImageUrl(url) { + return IMAGE_REGEXP.test(url); +} +export function isVideoUrl(url) { + return VIDEO_REGEXP.test(url); +} diff --git a/wxcomponents/vant/common/version.d.ts b/wxcomponents/vant/common/version.d.ts new file mode 100644 index 0000000..3393221 --- /dev/null +++ b/wxcomponents/vant/common/version.d.ts @@ -0,0 +1,15 @@ +/// +interface WxWorkSystemInfo extends WechatMiniprogram.SystemInfo { + environment?: 'wxwork'; +} +interface SystemInfo extends WxWorkSystemInfo, WechatMiniprogram.SystemInfo { +} +export declare function getSystemInfoSync(): SystemInfo; +export declare function canIUseModel(): boolean; +export declare function canIUseFormFieldButton(): boolean; +export declare function canIUseAnimate(): boolean; +export declare function canIUseGroupSetData(): boolean; +export declare function canIUseNextTick(): boolean; +export declare function canIUseCanvas2d(): boolean; +export declare function canIUseGetUserProfile(): boolean; +export {}; diff --git a/wxcomponents/vant/common/version.js b/wxcomponents/vant/common/version.js new file mode 100644 index 0000000..c675e1f --- /dev/null +++ b/wxcomponents/vant/common/version.js @@ -0,0 +1,59 @@ +let systemInfo; +export function getSystemInfoSync() { + if (systemInfo == null) { + systemInfo = wx.getSystemInfoSync(); + } + return systemInfo; +} +function compareVersion(v1, v2) { + v1 = v1.split('.'); + v2 = v2.split('.'); + const len = Math.max(v1.length, v2.length); + while (v1.length < len) { + v1.push('0'); + } + while (v2.length < len) { + v2.push('0'); + } + for (let i = 0; i < len; i++) { + const num1 = parseInt(v1[i], 10); + const num2 = parseInt(v2[i], 10); + if (num1 > num2) { + return 1; + } + if (num1 < num2) { + return -1; + } + } + return 0; +} +function gte(version) { + const system = getSystemInfoSync(); + return compareVersion(system.SDKVersion, version) >= 0; +} +export function canIUseModel() { + return gte('2.9.3'); +} +export function canIUseFormFieldButton() { + return gte('2.10.3'); +} +export function canIUseAnimate() { + return gte('2.9.0'); +} +export function canIUseGroupSetData() { + return gte('2.4.0'); +} +export function canIUseNextTick() { + try { + return wx.canIUse('nextTick'); + } + catch (e) { + return gte('2.7.1'); + } +} +export function canIUseCanvas2d() { + return gte('2.9.0'); +} +export function canIUseGetUserProfile() { + return !!wx.getUserProfile; +} diff --git a/wxcomponents/vant/config-provider/index.d.ts b/wxcomponents/vant/config-provider/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/config-provider/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/config-provider/index.js b/wxcomponents/vant/config-provider/index.js new file mode 100644 index 0000000..0cb23f4 --- /dev/null +++ b/wxcomponents/vant/config-provider/index.js @@ -0,0 +1,9 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + themeVars: { + type: Object, + value: {}, + }, + }, +}); diff --git a/wxcomponents/vant/config-provider/index.json b/wxcomponents/vant/config-provider/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/config-provider/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/config-provider/index.wxml b/wxcomponents/vant/config-provider/index.wxml new file mode 100644 index 0000000..3cfb461 --- /dev/null +++ b/wxcomponents/vant/config-provider/index.wxml @@ -0,0 +1,5 @@ + + + + + diff --git a/wxcomponents/vant/config-provider/index.wxs b/wxcomponents/vant/config-provider/index.wxs new file mode 100644 index 0000000..7ca0203 --- /dev/null +++ b/wxcomponents/vant/config-provider/index.wxs @@ -0,0 +1,29 @@ +/* eslint-disable */ +var object = require('../wxs/object.wxs'); +var style = require('../wxs/style.wxs'); + +function kebabCase(word) { + var newWord = word + .replace(getRegExp("[A-Z]", 'g'), function (i) { + return '-' + i; + }) + .toLowerCase() + .replace(getRegExp("^-"), ''); + + return newWord; +} + +function mapThemeVarsToCSSVars(themeVars) { + var cssVars = {}; + object.keys(themeVars).forEach(function (key) { + var cssVarsKey = '--' + kebabCase(key); + cssVars[cssVarsKey] = themeVars[key]; + }); + + return style(cssVars); +} + +module.exports = { + kebabCase: kebabCase, + mapThemeVarsToCSSVars: mapThemeVarsToCSSVars, +}; diff --git a/wxcomponents/vant/count-down/index.d.ts b/wxcomponents/vant/count-down/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/count-down/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/count-down/index.js b/wxcomponents/vant/count-down/index.js new file mode 100644 index 0000000..da24145 --- /dev/null +++ b/wxcomponents/vant/count-down/index.js @@ -0,0 +1,100 @@ +import { VantComponent } from '../common/component'; +import { isSameSecond, parseFormat, parseTimeData } from './utils'; +function simpleTick(fn) { + return setTimeout(fn, 30); +} +VantComponent({ + props: { + useSlot: Boolean, + millisecond: Boolean, + time: { + type: Number, + observer: 'reset', + }, + format: { + type: String, + value: 'HH:mm:ss', + }, + autoStart: { + type: Boolean, + value: true, + }, + }, + data: { + timeData: parseTimeData(0), + formattedTime: '0', + }, + destroyed() { + clearTimeout(this.tid); + this.tid = null; + }, + methods: { + // 开始 + start() { + if (this.counting) { + return; + } + this.counting = true; + this.endTime = Date.now() + this.remain; + this.tick(); + }, + // 暂停 + pause() { + this.counting = false; + clearTimeout(this.tid); + }, + // 重置 + reset() { + this.pause(); + this.remain = this.data.time; + this.setRemain(this.remain); + if (this.data.autoStart) { + this.start(); + } + }, + tick() { + if (this.data.millisecond) { + this.microTick(); + } + else { + this.macroTick(); + } + }, + microTick() { + this.tid = simpleTick(() => { + this.setRemain(this.getRemain()); + if (this.remain !== 0) { + this.microTick(); + } + }); + }, + macroTick() { + this.tid = simpleTick(() => { + const remain = this.getRemain(); + if (!isSameSecond(remain, this.remain) || remain === 0) { + this.setRemain(remain); + } + if (this.remain !== 0) { + this.macroTick(); + } + }); + }, + getRemain() { + return Math.max(this.endTime - Date.now(), 0); + }, + setRemain(remain) { + this.remain = remain; + const timeData = parseTimeData(remain); + if (this.data.useSlot) { + this.$emit('change', timeData); + } + this.setData({ + formattedTime: parseFormat(this.data.format, timeData), + }); + if (remain === 0) { + this.pause(); + this.$emit('finish'); + } + }, + }, +}); diff --git a/wxcomponents/vant/count-down/index.json b/wxcomponents/vant/count-down/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/count-down/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/count-down/index.wxml b/wxcomponents/vant/count-down/index.wxml new file mode 100644 index 0000000..e206e16 --- /dev/null +++ b/wxcomponents/vant/count-down/index.wxml @@ -0,0 +1,4 @@ + + + {{ formattedTime }} + diff --git a/wxcomponents/vant/count-down/index.wxss b/wxcomponents/vant/count-down/index.wxss new file mode 100644 index 0000000..8b957f7 --- /dev/null +++ b/wxcomponents/vant/count-down/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-count-down{color:var(--count-down-text-color,#323233);font-size:var(--count-down-font-size,14px);line-height:var(--count-down-line-height,20px)} \ No newline at end of file diff --git a/wxcomponents/vant/count-down/utils.d.ts b/wxcomponents/vant/count-down/utils.d.ts new file mode 100644 index 0000000..876a6c1 --- /dev/null +++ b/wxcomponents/vant/count-down/utils.d.ts @@ -0,0 +1,10 @@ +export type TimeData = { + days: number; + hours: number; + minutes: number; + seconds: number; + milliseconds: number; +}; +export declare function parseTimeData(time: number): TimeData; +export declare function parseFormat(format: string, timeData: TimeData): string; +export declare function isSameSecond(time1: number, time2: number): boolean; diff --git a/wxcomponents/vant/count-down/utils.js b/wxcomponents/vant/count-down/utils.js new file mode 100644 index 0000000..cbdbd79 --- /dev/null +++ b/wxcomponents/vant/count-down/utils.js @@ -0,0 +1,57 @@ +function padZero(num, targetLength = 2) { + let str = num + ''; + while (str.length < targetLength) { + str = '0' + str; + } + return str; +} +const SECOND = 1000; +const MINUTE = 60 * SECOND; +const HOUR = 60 * MINUTE; +const DAY = 24 * HOUR; +export function parseTimeData(time) { + const days = Math.floor(time / DAY); + const hours = Math.floor((time % DAY) / HOUR); + const minutes = Math.floor((time % HOUR) / MINUTE); + const seconds = Math.floor((time % MINUTE) / SECOND); + const milliseconds = Math.floor(time % SECOND); + return { + days, + hours, + minutes, + seconds, + milliseconds, + }; +} +export function parseFormat(format, timeData) { + const { days } = timeData; + let { hours, minutes, seconds, milliseconds } = timeData; + if (format.indexOf('DD') === -1) { + hours += days * 24; + } + else { + format = format.replace('DD', padZero(days)); + } + if (format.indexOf('HH') === -1) { + minutes += hours * 60; + } + else { + format = format.replace('HH', padZero(hours)); + } + if (format.indexOf('mm') === -1) { + seconds += minutes * 60; + } + else { + format = format.replace('mm', padZero(minutes)); + } + if (format.indexOf('ss') === -1) { + milliseconds += seconds * 1000; + } + else { + format = format.replace('ss', padZero(seconds)); + } + return format.replace('SSS', padZero(milliseconds, 3)); +} +export function isSameSecond(time1, time2) { + return Math.floor(time1 / 1000) === Math.floor(time2 / 1000); +} diff --git a/wxcomponents/vant/datetime-picker/index.d.ts b/wxcomponents/vant/datetime-picker/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/datetime-picker/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/datetime-picker/index.js b/wxcomponents/vant/datetime-picker/index.js new file mode 100644 index 0000000..3334170 --- /dev/null +++ b/wxcomponents/vant/datetime-picker/index.js @@ -0,0 +1,295 @@ +import { VantComponent } from '../common/component'; +import { isDef } from '../common/validator'; +import { pickerProps } from '../picker/shared'; +const currentYear = new Date().getFullYear(); +function isValidDate(date) { + return isDef(date) && !isNaN(new Date(date).getTime()); +} +function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +function padZero(val) { + return `00${val}`.slice(-2); +} +function times(n, iteratee) { + let index = -1; + const result = Array(n < 0 ? 0 : n); + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} +function getTrueValue(formattedValue) { + if (formattedValue === undefined) { + formattedValue = '1'; + } + while (isNaN(parseInt(formattedValue, 10))) { + formattedValue = formattedValue.slice(1); + } + return parseInt(formattedValue, 10); +} +function getMonthEndDay(year, month) { + return 32 - new Date(year, month - 1, 32).getDate(); +} +const defaultFormatter = (type, value) => value; +VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: Object.assign(Object.assign({}, pickerProps), { value: { + type: null, + observer: 'updateValue', + }, filter: null, type: { + type: String, + value: 'datetime', + observer: 'updateValue', + }, showToolbar: { + type: Boolean, + value: true, + }, formatter: { + type: null, + value: defaultFormatter, + }, minDate: { + type: Number, + value: new Date(currentYear - 10, 0, 1).getTime(), + observer: 'updateValue', + }, maxDate: { + type: Number, + value: new Date(currentYear + 10, 11, 31).getTime(), + observer: 'updateValue', + }, minHour: { + type: Number, + value: 0, + observer: 'updateValue', + }, maxHour: { + type: Number, + value: 23, + observer: 'updateValue', + }, minMinute: { + type: Number, + value: 0, + observer: 'updateValue', + }, maxMinute: { + type: Number, + value: 59, + observer: 'updateValue', + } }), + data: { + innerValue: Date.now(), + columns: [], + }, + methods: { + updateValue() { + const { data } = this; + const val = this.correctValue(data.value); + const isEqual = val === data.innerValue; + this.updateColumnValue(val).then(() => { + if (!isEqual) { + this.$emit('input', val); + } + }); + }, + getPicker() { + if (this.picker == null) { + this.picker = this.selectComponent('.van-datetime-picker'); + const { picker } = this; + const { setColumnValues } = picker; + picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]); + } + return this.picker; + }, + updateColumns() { + const { formatter = defaultFormatter } = this.data; + const results = this.getOriginColumns().map((column) => ({ + values: column.values.map((value) => formatter(column.type, value)), + })); + return this.set({ columns: results }); + }, + getOriginColumns() { + const { filter } = this.data; + const results = this.getRanges().map(({ type, range }) => { + let values = times(range[1] - range[0] + 1, (index) => { + const value = range[0] + index; + return type === 'year' ? `${value}` : padZero(value); + }); + if (filter) { + values = filter(type, values); + } + return { type, values }; + }); + return results; + }, + getRanges() { + const { data } = this; + if (data.type === 'time') { + return [ + { + type: 'hour', + range: [data.minHour, data.maxHour], + }, + { + type: 'minute', + range: [data.minMinute, data.maxMinute], + }, + ]; + } + const { maxYear, maxDate, maxMonth, maxHour, maxMinute, } = this.getBoundary('max', data.innerValue); + const { minYear, minDate, minMonth, minHour, minMinute, } = this.getBoundary('min', data.innerValue); + const result = [ + { + type: 'year', + range: [minYear, maxYear], + }, + { + type: 'month', + range: [minMonth, maxMonth], + }, + { + type: 'day', + range: [minDate, maxDate], + }, + { + type: 'hour', + range: [minHour, maxHour], + }, + { + type: 'minute', + range: [minMinute, maxMinute], + }, + ]; + if (data.type === 'date') + result.splice(3, 2); + if (data.type === 'year-month') + result.splice(2, 3); + return result; + }, + correctValue(value) { + const { data } = this; + // validate value + const isDateType = data.type !== 'time'; + if (isDateType && !isValidDate(value)) { + value = data.minDate; + } + else if (!isDateType && !value) { + const { minHour } = data; + value = `${padZero(minHour)}:00`; + } + // time type + if (!isDateType) { + let [hour, minute] = value.split(':'); + hour = padZero(range(hour, data.minHour, data.maxHour)); + minute = padZero(range(minute, data.minMinute, data.maxMinute)); + return `${hour}:${minute}`; + } + // date type + value = Math.max(value, data.minDate); + value = Math.min(value, data.maxDate); + return value; + }, + getBoundary(type, innerValue) { + const value = new Date(innerValue); + const boundary = new Date(this.data[`${type}Date`]); + const year = boundary.getFullYear(); + let month = 1; + let date = 1; + let hour = 0; + let minute = 0; + if (type === 'max') { + month = 12; + date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1); + hour = 23; + minute = 59; + } + if (value.getFullYear() === year) { + month = boundary.getMonth() + 1; + if (value.getMonth() + 1 === month) { + date = boundary.getDate(); + if (value.getDate() === date) { + hour = boundary.getHours(); + if (value.getHours() === hour) { + minute = boundary.getMinutes(); + } + } + } + } + return { + [`${type}Year`]: year, + [`${type}Month`]: month, + [`${type}Date`]: date, + [`${type}Hour`]: hour, + [`${type}Minute`]: minute, + }; + }, + onCancel() { + this.$emit('cancel'); + }, + onConfirm() { + this.$emit('confirm', this.data.innerValue); + }, + onChange() { + const { data } = this; + let value; + const picker = this.getPicker(); + const originColumns = this.getOriginColumns(); + if (data.type === 'time') { + const indexes = picker.getIndexes(); + value = `${+originColumns[0].values[indexes[0]]}:${+originColumns[1] + .values[indexes[1]]}`; + } + else { + const indexes = picker.getIndexes(); + const values = indexes.map((value, index) => originColumns[index].values[value]); + const year = getTrueValue(values[0]); + const month = getTrueValue(values[1]); + const maxDate = getMonthEndDay(year, month); + let date = getTrueValue(values[2]); + if (data.type === 'year-month') { + date = 1; + } + date = date > maxDate ? maxDate : date; + let hour = 0; + let minute = 0; + if (data.type === 'datetime') { + hour = getTrueValue(values[3]); + minute = getTrueValue(values[4]); + } + value = new Date(year, month - 1, date, hour, minute); + } + value = this.correctValue(value); + this.updateColumnValue(value).then(() => { + this.$emit('input', value); + this.$emit('change', picker); + }); + }, + updateColumnValue(value) { + let values = []; + const { type } = this.data; + const formatter = this.data.formatter || defaultFormatter; + const picker = this.getPicker(); + if (type === 'time') { + const pair = value.split(':'); + values = [formatter('hour', pair[0]), formatter('minute', pair[1])]; + } + else { + const date = new Date(value); + values = [ + formatter('year', `${date.getFullYear()}`), + formatter('month', padZero(date.getMonth() + 1)), + ]; + if (type === 'date') { + values.push(formatter('day', padZero(date.getDate()))); + } + if (type === 'datetime') { + values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes()))); + } + } + return this.set({ innerValue: value }) + .then(() => this.updateColumns()) + .then(() => picker.setValues(values)); + }, + }, + created() { + const innerValue = this.correctValue(this.data.value); + this.updateColumnValue(innerValue).then(() => { + this.$emit('input', innerValue); + }); + }, +}); diff --git a/wxcomponents/vant/datetime-picker/index.json b/wxcomponents/vant/datetime-picker/index.json new file mode 100644 index 0000000..a778e91 --- /dev/null +++ b/wxcomponents/vant/datetime-picker/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-picker": "../picker/index" + } +} diff --git a/wxcomponents/vant/datetime-picker/index.wxml b/wxcomponents/vant/datetime-picker/index.wxml new file mode 100644 index 0000000..ade2202 --- /dev/null +++ b/wxcomponents/vant/datetime-picker/index.wxml @@ -0,0 +1,16 @@ + diff --git a/wxcomponents/vant/datetime-picker/index.wxss b/wxcomponents/vant/datetime-picker/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/wxcomponents/vant/datetime-picker/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/wxcomponents/vant/definitions/index.d.ts b/wxcomponents/vant/definitions/index.d.ts new file mode 100644 index 0000000..c90321f --- /dev/null +++ b/wxcomponents/vant/definitions/index.d.ts @@ -0,0 +1,29 @@ +/// +interface VantComponentInstance { + parent: WechatMiniprogram.Component.TrivialInstance; + children: WechatMiniprogram.Component.TrivialInstance[]; + index: number; + $emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void; + setView: (value: Record, callback?: () => void) => void; +} +export type VantComponentOptions = { + data?: Data; + field?: boolean; + classes?: string[]; + mixins?: string[]; + props?: Props; + relation?: { + relations: Record; + mixin: string; + }; + watch?: Record any>; + methods?: Methods; + beforeCreate?: () => void; + created?: () => void; + mounted?: () => void; + destroyed?: () => void; +} & ThisType, Props, Methods> & Record>; +export {}; diff --git a/wxcomponents/vant/definitions/index.js b/wxcomponents/vant/definitions/index.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/definitions/index.js @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/dialog/dialog.d.ts b/wxcomponents/vant/dialog/dialog.d.ts new file mode 100644 index 0000000..db2da5f --- /dev/null +++ b/wxcomponents/vant/dialog/dialog.d.ts @@ -0,0 +1,55 @@ +/// +/// +export type Action = 'confirm' | 'cancel' | 'overlay'; +type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance; +interface DialogOptions { + lang?: string; + show?: boolean; + title?: string; + width?: string | number | null; + zIndex?: number; + theme?: string; + context?: (() => DialogContext) | DialogContext; + message?: string; + overlay?: boolean; + selector?: string; + ariaLabel?: string; + /** + * @deprecated use custom-class instead + */ + className?: string; + customStyle?: string; + transition?: string; + /** + * @deprecated use beforeClose instead + */ + asyncClose?: boolean; + beforeClose?: null | ((action: Action) => Promise | void); + businessId?: number; + sessionFrom?: string; + overlayStyle?: string; + appParameter?: string; + messageAlign?: string; + sendMessageImg?: string; + showMessageCard?: boolean; + sendMessagePath?: string; + sendMessageTitle?: string; + confirmButtonText?: string; + cancelButtonText?: string; + showConfirmButton?: boolean; + showCancelButton?: boolean; + closeOnClickOverlay?: boolean; + confirmButtonOpenType?: string; +} +declare const Dialog: { + (options: DialogOptions): Promise; + alert(options: DialogOptions): Promise; + confirm(options: DialogOptions): Promise; + close(): void; + stopLoading(): void; + currentOptions: DialogOptions; + defaultOptions: DialogOptions; + setDefaultOptions(options: DialogOptions): void; + resetDefaultOptions(): void; +}; +export default Dialog; diff --git a/wxcomponents/vant/dialog/dialog.js b/wxcomponents/vant/dialog/dialog.js new file mode 100644 index 0000000..a96ec08 --- /dev/null +++ b/wxcomponents/vant/dialog/dialog.js @@ -0,0 +1,77 @@ +let queue = []; +const defaultOptions = { + show: false, + title: '', + width: null, + theme: 'default', + message: '', + zIndex: 100, + overlay: true, + selector: '#van-dialog', + className: '', + asyncClose: false, + beforeClose: null, + transition: 'scale', + customStyle: '', + messageAlign: '', + overlayStyle: '', + confirmButtonText: '确认', + cancelButtonText: '取消', + showConfirmButton: true, + showCancelButton: false, + closeOnClickOverlay: false, + confirmButtonOpenType: '', +}; +let currentOptions = Object.assign({}, defaultOptions); +function getContext() { + const pages = getCurrentPages(); + return pages[pages.length - 1]; +} +const Dialog = (options) => { + options = Object.assign(Object.assign({}, currentOptions), options); + return new Promise((resolve, reject) => { + const context = (typeof options.context === 'function' + ? options.context() + : options.context) || getContext(); + const dialog = context.selectComponent(options.selector); + delete options.context; + delete options.selector; + if (dialog) { + dialog.setData(Object.assign({ callback: (action, instance) => { + action === 'confirm' ? resolve(instance) : reject(instance); + } }, options)); + wx.nextTick(() => { + dialog.setData({ show: true }); + }); + queue.push(dialog); + } + else { + console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确'); + } + }); +}; +Dialog.alert = (options) => Dialog(options); +Dialog.confirm = (options) => Dialog(Object.assign({ showCancelButton: true }, options)); +Dialog.close = () => { + queue.forEach((dialog) => { + dialog.close(); + }); + queue = []; +}; +Dialog.stopLoading = () => { + queue.forEach((dialog) => { + dialog.stopLoading(); + }); +}; +Dialog.currentOptions = currentOptions; +Dialog.defaultOptions = defaultOptions; +Dialog.setDefaultOptions = (options) => { + currentOptions = Object.assign(Object.assign({}, currentOptions), options); + Dialog.currentOptions = currentOptions; +}; +Dialog.resetDefaultOptions = () => { + currentOptions = Object.assign({}, defaultOptions); + Dialog.currentOptions = currentOptions; +}; +Dialog.resetDefaultOptions(); +export default Dialog; diff --git a/wxcomponents/vant/dialog/index.d.ts b/wxcomponents/vant/dialog/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/dialog/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/dialog/index.js b/wxcomponents/vant/dialog/index.js new file mode 100644 index 0000000..8cfb988 --- /dev/null +++ b/wxcomponents/vant/dialog/index.js @@ -0,0 +1,132 @@ +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +import { GRAY, RED } from '../common/color'; +import { toPromise } from '../common/utils'; +VantComponent({ + mixins: [button], + classes: ['cancle-button-class', 'confirm-button-class'], + props: { + show: { + type: Boolean, + observer(show) { + !show && this.stopLoading(); + }, + }, + title: String, + message: String, + theme: { + type: String, + value: 'default', + }, + confirmButtonId: String, + className: String, + customStyle: String, + asyncClose: Boolean, + messageAlign: String, + beforeClose: null, + overlayStyle: String, + useSlot: Boolean, + useTitleSlot: Boolean, + useConfirmButtonSlot: Boolean, + useCancelButtonSlot: Boolean, + showCancelButton: Boolean, + closeOnClickOverlay: Boolean, + confirmButtonOpenType: String, + width: null, + zIndex: { + type: Number, + value: 2000, + }, + confirmButtonText: { + type: String, + value: '确认', + }, + cancelButtonText: { + type: String, + value: '取消', + }, + confirmButtonColor: { + type: String, + value: RED, + }, + cancelButtonColor: { + type: String, + value: GRAY, + }, + showConfirmButton: { + type: Boolean, + value: true, + }, + overlay: { + type: Boolean, + value: true, + }, + transition: { + type: String, + value: 'scale', + }, + rootPortal: { + type: Boolean, + value: false, + }, + }, + data: { + loading: { + confirm: false, + cancel: false, + }, + callback: (() => { }), + }, + methods: { + onConfirm() { + this.handleAction('confirm'); + }, + onCancel() { + this.handleAction('cancel'); + }, + onClickOverlay() { + this.close('overlay'); + }, + close(action) { + this.setData({ show: false }); + this.closeAction = action; + }, + onAfterLeave() { + const { closeAction: action } = this; + this.$emit('close', action); + const { callback } = this.data; + if (callback) { + callback(action, this); + } + }, + stopLoading() { + this.setData({ + loading: { + confirm: false, + cancel: false, + }, + }); + }, + handleAction(action) { + this.$emit(action, { dialog: this }); + const { asyncClose, beforeClose } = this.data; + if (!asyncClose && !beforeClose) { + this.close(action); + return; + } + this.setData({ + [`loading.${action}`]: true, + }); + if (beforeClose) { + toPromise(beforeClose(action)).then((value) => { + if (value) { + this.close(action); + } + else { + this.stopLoading(); + } + }); + } + }, + }, +}); diff --git a/wxcomponents/vant/dialog/index.json b/wxcomponents/vant/dialog/index.json new file mode 100644 index 0000000..43417fc --- /dev/null +++ b/wxcomponents/vant/dialog/index.json @@ -0,0 +1,9 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-button": "../button/index", + "van-goods-action": "../goods-action/index", + "van-goods-action-button": "../goods-action-button/index" + } +} diff --git a/wxcomponents/vant/dialog/index.wxml b/wxcomponents/vant/dialog/index.wxml new file mode 100644 index 0000000..99a6264 --- /dev/null +++ b/wxcomponents/vant/dialog/index.wxml @@ -0,0 +1,126 @@ + + + + + + {{ title }} + + + + + {{ message }} + + + + + {{ cancelButtonText }} + + + {{ confirmButtonText }} + + + + + + + + + {{ cancelButtonText }} + + + + + + + + {{ confirmButtonText }} + + + + diff --git a/wxcomponents/vant/dialog/index.wxss b/wxcomponents/vant/dialog/index.wxss new file mode 100644 index 0000000..507a789 --- /dev/null +++ b/wxcomponents/vant/dialog/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)} \ No newline at end of file diff --git a/wxcomponents/vant/divider/index.d.ts b/wxcomponents/vant/divider/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/divider/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/divider/index.js b/wxcomponents/vant/divider/index.js new file mode 100644 index 0000000..9596edd --- /dev/null +++ b/wxcomponents/vant/divider/index.js @@ -0,0 +1,12 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + dashed: Boolean, + hairline: Boolean, + contentPosition: String, + fontSize: String, + borderColor: String, + textColor: String, + customStyle: String, + }, +}); diff --git a/wxcomponents/vant/divider/index.json b/wxcomponents/vant/divider/index.json new file mode 100644 index 0000000..a89ef4d --- /dev/null +++ b/wxcomponents/vant/divider/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/wxcomponents/vant/divider/index.wxml b/wxcomponents/vant/divider/index.wxml new file mode 100644 index 0000000..f6a5a45 --- /dev/null +++ b/wxcomponents/vant/divider/index.wxml @@ -0,0 +1,9 @@ + + + + + + diff --git a/wxcomponents/vant/divider/index.wxs b/wxcomponents/vant/divider/index.wxs new file mode 100644 index 0000000..215b14f --- /dev/null +++ b/wxcomponents/vant/divider/index.wxs @@ -0,0 +1,18 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); +var addUnit = require('../wxs/add-unit.wxs'); + +function rootStyle(data) { + return style([ + { + 'border-color': data.borderColor, + color: data.textColor, + 'font-size': addUnit(data.fontSize), + }, + data.customStyle, + ]); +} + +module.exports = { + rootStyle: rootStyle, +}; diff --git a/wxcomponents/vant/divider/index.wxss b/wxcomponents/vant/divider/index.wxss new file mode 100644 index 0000000..e91dc44 --- /dev/null +++ b/wxcomponents/vant/divider/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-divider{align-items:center;border:0 solid var(--divider-border-color,#ebedf0);color:var(--divider-text-color,#969799);display:flex;font-size:var(--divider-font-size,14px);line-height:var(--divider-line-height,24px);margin:var(--divider-margin,16px 0)}.van-divider:after,.van-divider:before{border-color:inherit;border-style:inherit;border-width:1px 0 0;box-sizing:border-box;display:block;flex:1;height:1px}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:var(--divider-content-padding,16px)}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{content:"";margin-left:var(--divider-content-padding,16px)}.van-divider--left:before{max-width:var(--divider-content-left-width,10%)}.van-divider--right:after{max-width:var(--divider-content-right-width,10%)} \ No newline at end of file diff --git a/wxcomponents/vant/dropdown-item/index.d.ts b/wxcomponents/vant/dropdown-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/dropdown-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/dropdown-item/index.js b/wxcomponents/vant/dropdown-item/index.js new file mode 100644 index 0000000..fd61a47 --- /dev/null +++ b/wxcomponents/vant/dropdown-item/index.js @@ -0,0 +1,130 @@ +import { useParent } from '../common/relation'; +import { VantComponent } from '../common/component'; +VantComponent({ + classes: ['item-title-class'], + field: true, + relation: useParent('dropdown-menu', function () { + this.updateDataFromParent(); + }), + props: { + value: { + type: null, + observer: 'rerender', + }, + title: { + type: String, + observer: 'rerender', + }, + disabled: Boolean, + titleClass: { + type: String, + observer: 'rerender', + }, + options: { + type: Array, + value: [], + observer: 'rerender', + }, + popupStyle: String, + useBeforeToggle: { + type: Boolean, + value: false, + }, + rootPortal: { + type: Boolean, + value: false, + }, + }, + data: { + transition: true, + showPopup: false, + showWrapper: false, + displayTitle: '', + safeAreaTabBar: false, + }, + methods: { + rerender() { + wx.nextTick(() => { + var _a; + (_a = this.parent) === null || _a === void 0 ? void 0 : _a.updateItemListData(); + }); + }, + updateDataFromParent() { + if (this.parent) { + const { overlay, duration, activeColor, closeOnClickOverlay, direction, safeAreaTabBar, } = this.parent.data; + this.setData({ + overlay, + duration, + activeColor, + closeOnClickOverlay, + direction, + safeAreaTabBar, + }); + } + }, + onOpen() { + this.$emit('open'); + }, + onOpened() { + this.$emit('opened'); + }, + onClose() { + this.$emit('close'); + }, + onClosed() { + this.$emit('closed'); + this.setData({ showWrapper: false }); + }, + onOptionTap(event) { + const { option } = event.currentTarget.dataset; + const { value } = option; + const shouldEmitChange = this.data.value !== value; + this.setData({ showPopup: false, value }); + this.$emit('close'); + this.rerender(); + if (shouldEmitChange) { + this.$emit('change', value); + } + }, + toggle(show, options = {}) { + const { showPopup } = this.data; + if (typeof show !== 'boolean') { + show = !showPopup; + } + if (show === showPopup) { + return; + } + this.onBeforeToggle(show).then((status) => { + var _a; + if (!status) { + return; + } + this.setData({ + transition: !options.immediate, + showPopup: show, + }); + if (show) { + (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => { + this.setData({ wrapperStyle, showWrapper: true }); + this.rerender(); + }); + } + else { + this.rerender(); + } + }); + }, + onBeforeToggle(status) { + const { useBeforeToggle } = this.data; + if (!useBeforeToggle) { + return Promise.resolve(true); + } + return new Promise((resolve) => { + this.$emit('before-toggle', { + status, + callback: (value) => resolve(value), + }); + }); + }, + }, +}); diff --git a/wxcomponents/vant/dropdown-item/index.json b/wxcomponents/vant/dropdown-item/index.json new file mode 100644 index 0000000..88d5409 --- /dev/null +++ b/wxcomponents/vant/dropdown-item/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} diff --git a/wxcomponents/vant/dropdown-item/index.wxml b/wxcomponents/vant/dropdown-item/index.wxml new file mode 100644 index 0000000..63904f4 --- /dev/null +++ b/wxcomponents/vant/dropdown-item/index.wxml @@ -0,0 +1,50 @@ + + + + + + + {{ item.text }} + + + + + + + diff --git a/wxcomponents/vant/dropdown-item/index.wxss b/wxcomponents/vant/dropdown-item/index.wxss new file mode 100644 index 0000000..80505e9 --- /dev/null +++ b/wxcomponents/vant/dropdown-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-item{left:0;overflow:hidden;position:fixed;right:0}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:var(--dropdown-menu-option-active-color,#ee0a24)}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file diff --git a/wxcomponents/vant/dropdown-item/shared.d.ts b/wxcomponents/vant/dropdown-item/shared.d.ts new file mode 100644 index 0000000..774eb4c --- /dev/null +++ b/wxcomponents/vant/dropdown-item/shared.d.ts @@ -0,0 +1,5 @@ +export interface Option { + text: string; + value: string | number; + icon: string; +} diff --git a/wxcomponents/vant/dropdown-item/shared.js b/wxcomponents/vant/dropdown-item/shared.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/dropdown-item/shared.js @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/dropdown-menu/index.d.ts b/wxcomponents/vant/dropdown-menu/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/dropdown-menu/index.js b/wxcomponents/vant/dropdown-menu/index.js new file mode 100644 index 0000000..9858ab3 --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.js @@ -0,0 +1,117 @@ +import { VantComponent } from '../common/component'; +import { useChildren } from '../common/relation'; +import { addUnit, getRect, getSystemInfoSync } from '../common/utils'; +let ARRAY = []; +VantComponent({ + field: true, + classes: ['title-class'], + relation: useChildren('dropdown-item', function () { + this.updateItemListData(); + }), + props: { + activeColor: { + type: String, + observer: 'updateChildrenData', + }, + overlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData', + }, + zIndex: { + type: Number, + value: 10, + }, + duration: { + type: Number, + value: 200, + observer: 'updateChildrenData', + }, + direction: { + type: String, + value: 'down', + observer: 'updateChildrenData', + }, + safeAreaTabBar: { + type: Boolean, + value: false, + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData', + }, + closeOnClickOutside: { + type: Boolean, + value: true, + }, + }, + data: { + itemListData: [], + }, + beforeCreate() { + const { windowHeight } = getSystemInfoSync(); + this.windowHeight = windowHeight; + ARRAY.push(this); + }, + destroyed() { + ARRAY = ARRAY.filter((item) => item !== this); + }, + methods: { + updateItemListData() { + this.setData({ + itemListData: this.children.map((child) => child.data), + }); + }, + updateChildrenData() { + this.children.forEach((child) => { + child.updateDataFromParent(); + }); + }, + toggleItem(active) { + this.children.forEach((item, index) => { + const { showPopup } = item.data; + if (index === active) { + item.toggle(); + } + else if (showPopup) { + item.toggle(false, { immediate: true }); + } + }); + }, + close() { + this.children.forEach((child) => { + child.toggle(false, { immediate: true }); + }); + }, + getChildWrapperStyle() { + const { zIndex, direction } = this.data; + return getRect(this, '.van-dropdown-menu').then((rect) => { + const { top = 0, bottom = 0 } = rect; + const offset = direction === 'down' ? bottom : this.windowHeight - top; + let wrapperStyle = `z-index: ${zIndex};`; + if (direction === 'down') { + wrapperStyle += `top: ${addUnit(offset)};`; + } + else { + wrapperStyle += `bottom: ${addUnit(offset)};`; + } + return wrapperStyle; + }); + }, + onTitleTap(event) { + const { index } = event.currentTarget.dataset; + const child = this.children[index]; + if (!child.data.disabled) { + ARRAY.forEach((menuItem) => { + if (menuItem && + menuItem.data.closeOnClickOutside && + menuItem !== this) { + menuItem.close(); + } + }); + this.toggleItem(index); + } + }, + }, +}); diff --git a/wxcomponents/vant/dropdown-menu/index.json b/wxcomponents/vant/dropdown-menu/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/wxcomponents/vant/dropdown-menu/index.wxml b/wxcomponents/vant/dropdown-menu/index.wxml new file mode 100644 index 0000000..ec165a9 --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + {{ computed.displayTitle(item) }} + + + + + + diff --git a/wxcomponents/vant/dropdown-menu/index.wxs b/wxcomponents/vant/dropdown-menu/index.wxs new file mode 100644 index 0000000..6538854 --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.wxs @@ -0,0 +1,16 @@ +/* eslint-disable */ +function displayTitle(item) { + if (item.title) { + return item.title; + } + + var match = item.options.filter(function(option) { + return option.value === item.value; + }); + var displayTitle = match.length ? match[0].text : ''; + return displayTitle; +} + +module.exports = { + displayTitle: displayTitle +}; diff --git a/wxcomponents/vant/dropdown-menu/index.wxss b/wxcomponents/vant/dropdown-menu/index.wxss new file mode 100644 index 0000000..dba000e --- /dev/null +++ b/wxcomponents/vant/dropdown-menu/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-menu{background-color:var(--dropdown-menu-background-color,#fff);box-shadow:var(--dropdown-menu-box-shadow,0 2px 12px hsla(210,1%,40%,.12));display:flex;height:var(--dropdown-menu-height,50px);-webkit-user-select:none;user-select:none}.van-dropdown-menu__item{align-items:center;display:flex;flex:1;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{box-sizing:border-box;color:var(--dropdown-menu-title-text-color,#323233);font-size:var(--dropdown-menu-title-font-size,15px);line-height:var(--dropdown-menu-title-line-height,18px);max-width:100%;padding:var(--dropdown-menu-title-padding,0 24px 0 8px);position:relative}.van-dropdown-menu__title:after{border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;content:"";margin-top:-5px;opacity:.8;position:absolute;right:11px;top:50%;transform:rotate(-45deg)}.van-dropdown-menu__title--active{color:var(--dropdown-menu-title-active-text-color,#ee0a24)}.van-dropdown-menu__title--down:after{margin-top:-1px;transform:rotate(135deg)} \ No newline at end of file diff --git a/wxcomponents/vant/empty/index.d.ts b/wxcomponents/vant/empty/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/empty/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/empty/index.js b/wxcomponents/vant/empty/index.js new file mode 100644 index 0000000..842e1bb --- /dev/null +++ b/wxcomponents/vant/empty/index.js @@ -0,0 +1,10 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + description: String, + image: { + type: String, + value: 'default', + }, + }, +}); diff --git a/wxcomponents/vant/empty/index.json b/wxcomponents/vant/empty/index.json new file mode 100644 index 0000000..a89ef4d --- /dev/null +++ b/wxcomponents/vant/empty/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/wxcomponents/vant/empty/index.wxml b/wxcomponents/vant/empty/index.wxml new file mode 100644 index 0000000..9c7b719 --- /dev/null +++ b/wxcomponents/vant/empty/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + {{ description }} + + + + + + diff --git a/wxcomponents/vant/empty/index.wxs b/wxcomponents/vant/empty/index.wxs new file mode 100644 index 0000000..cf92ece --- /dev/null +++ b/wxcomponents/vant/empty/index.wxs @@ -0,0 +1,15 @@ +/* eslint-disable */ +var PRESETS = ['error', 'search', 'default', 'network']; + +function imageUrl(image) { + if (PRESETS.indexOf(image) !== -1) { + return 'https://img.yzcdn.cn/vant/empty-image-' + image + '.png'; + } + + return image; +} + +module.exports = { + imageUrl: imageUrl, +}; + diff --git a/wxcomponents/vant/empty/index.wxss b/wxcomponents/vant/empty/index.wxss new file mode 100644 index 0000000..0fb74fe --- /dev/null +++ b/wxcomponents/vant/empty/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-empty{align-items:center;box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;padding:32px 0}.van-empty__image{height:160px;width:160px}.van-empty__image:empty{display:none}.van-empty__image__img{height:100%;width:100%}.van-empty__image:not(:empty)+.van-empty__image{display:none}.van-empty__description{color:#969799;font-size:14px;line-height:20px;margin-top:16px;padding:0 60px}.van-empty__description:empty,.van-empty__description:not(:empty)+.van-empty__description{display:none}.van-empty__bottom{margin-top:24px} \ No newline at end of file diff --git a/wxcomponents/vant/field/index.d.ts b/wxcomponents/vant/field/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/wxcomponents/vant/field/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/wxcomponents/vant/field/index.js b/wxcomponents/vant/field/index.js new file mode 100644 index 0000000..76522c8 --- /dev/null +++ b/wxcomponents/vant/field/index.js @@ -0,0 +1,138 @@ +import { nextTick } from '../common/utils'; +import { VantComponent } from '../common/component'; +import { commonProps, inputProps, textareaProps } from './props'; +VantComponent({ + field: true, + classes: ['input-class', 'right-icon-class', 'label-class'], + props: Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), inputProps), textareaProps), { size: String, icon: String, label: String, error: Boolean, center: Boolean, isLink: Boolean, leftIcon: String, rightIcon: String, autosize: null, required: Boolean, iconClass: String, clickable: Boolean, inputAlign: String, customStyle: String, errorMessage: String, arrowDirection: String, showWordLimit: Boolean, errorMessageAlign: String, readonly: { + type: Boolean, + observer: 'setShowClear', + }, clearable: { + type: Boolean, + observer: 'setShowClear', + }, clearTrigger: { + type: String, + value: 'focus', + }, border: { + type: Boolean, + value: true, + }, titleWidth: { + type: String, + value: '6.2em', + }, clearIcon: { + type: String, + value: 'clear', + }, extraEventParams: { + type: Boolean, + value: false, + } }), + data: { + focused: false, + innerValue: '', + showClear: false, + }, + watch: { + value(value) { + if (value !== this.value) { + this.setData({ innerValue: value }); + this.value = value; + this.setShowClear(); + } + }, + clearTrigger() { + this.setShowClear(); + }, + }, + created() { + this.value = this.data.value; + this.setData({ innerValue: this.value }); + }, + methods: { + formatValue(value) { + const { maxlength } = this.data; + if (maxlength !== -1 && value.length > maxlength) { + return value.slice(0, maxlength); + } + return value; + }, + onInput(event) { + const { value = '' } = event.detail || {}; + const formatValue = this.formatValue(value); + this.value = formatValue; + this.setShowClear(); + return this.emitChange(Object.assign(Object.assign({}, event.detail), { value: formatValue })); + }, + onFocus(event) { + this.focused = true; + this.setShowClear(); + this.$emit('focus', event.detail); + }, + onBlur(event) { + this.focused = false; + this.setShowClear(); + this.$emit('blur', event.detail); + }, + onClickIcon() { + this.$emit('click-icon'); + }, + onClickInput(event) { + this.$emit('click-input', event.detail); + }, + onClear() { + this.setData({ innerValue: '' }); + this.value = ''; + this.setShowClear(); + nextTick(() => { + this.emitChange({ value: '' }); + this.$emit('clear', ''); + }); + }, + onConfirm(event) { + const { value = '' } = event.detail || {}; + this.value = value; + this.setShowClear(); + this.$emit('confirm', value); + }, + setValue(value) { + this.value = value; + this.setShowClear(); + if (value === '') { + this.setData({ innerValue: '' }); + } + this.emitChange({ value }); + }, + onLineChange(event) { + this.$emit('linechange', event.detail); + }, + onKeyboardHeightChange(event) { + this.$emit('keyboardheightchange', event.detail); + }, + onBindNicknameReview(event) { + this.$emit('nicknamereview', event.detail); + }, + emitChange(detail) { + const { extraEventParams } = this.data; + this.setData({ value: detail.value }); + let result; + const data = extraEventParams + ? Object.assign(Object.assign({}, detail), { callback: (data) => { + result = data; + } }) : detail.value; + this.$emit('input', data); + this.$emit('change', data); + return result; + }, + setShowClear() { + const { clearable, readonly, clearTrigger } = this.data; + const { focused, value } = this; + let showClear = false; + if (clearable && !readonly) { + const hasValue = !!value; + const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused); + showClear = hasValue && trigger; + } + this.setView({ showClear }); + }, + noop() { }, + }, +}); diff --git a/wxcomponents/vant/field/index.json b/wxcomponents/vant/field/index.json new file mode 100644 index 0000000..5906c50 --- /dev/null +++ b/wxcomponents/vant/field/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} diff --git a/wxcomponents/vant/field/index.wxml b/wxcomponents/vant/field/index.wxml new file mode 100644 index 0000000..6018993 --- /dev/null +++ b/wxcomponents/vant/field/index.wxml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wxcomponents/vant/field/index.wxs b/wxcomponents/vant/field/index.wxs new file mode 100644 index 0000000..78575b9 --- /dev/null +++ b/wxcomponents/vant/field/index.wxs @@ -0,0 +1,18 @@ +/* eslint-disable */ +var style = require('../wxs/style.wxs'); +var addUnit = require('../wxs/add-unit.wxs'); + +function inputStyle(autosize) { + if (autosize && autosize.constructor === 'Object') { + return style({ + 'min-height': addUnit(autosize.minHeight), + 'max-height': addUnit(autosize.maxHeight), + }); + } + + return ''; +} + +module.exports = { + inputStyle: inputStyle, +}; diff --git a/wxcomponents/vant/field/index.wxss b/wxcomponents/vant/field/index.wxss new file mode 100644 index 0000000..5f7d306 --- /dev/null +++ b/wxcomponents/vant/field/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-field{--cell-icon-size:var(--field-icon-size,16px)}.van-field__label{color:var(--field-label-color,#646566)}.van-field__label--disabled{color:var(--field-disabled-text-color,#c8c9cc)}.van-field__body{align-items:center;display:flex}.van-field__body--textarea{box-sizing:border-box;line-height:1.2em;min-height:var(--cell-line-height,24px);padding:3.6px 0}.van-field__control:empty+.van-field__control{display:block}.van-field__control{background-color:initial;border:0;box-sizing:border-box;color:var(--field-input-text-color,#323233);display:none;height:var(--cell-line-height,24px);line-height:inherit;margin:0;min-height:var(--cell-line-height,24px);padding:0;position:relative;resize:none;text-align:left;width:100%}.van-field__control:empty{display:none}.van-field__control--textarea{height:var(--field-text-area-min-height,18px);min-height:var(--field-text-area-min-height,18px)}.van-field__control--error{color:var(--field-input-error-text-color,#ee0a24)}.van-field__control--disabled{background-color:initial;color:var(--field-input-disabled-text-color,#c8c9cc);opacity:1}.van-field__control--center{text-align:center}.van-field__control--right{text-align:right}.van-field__control--custom{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__placeholder{color:var(--field-placeholder-text-color,#c8c9cc);left:0;pointer-events:none;position:absolute;right:0;top:0}.van-field__placeholder--error{color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;margin-right:calc(var(--padding-xs, 8px)*-1);padding:0 var(--padding-xs,8px);vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{flex-shrink:0}.van-field__clear-root{color:var(--field-clear-icon-color,#c8c9cc);font-size:var(--field-clear-icon-size,16px)}.van-field__icon-container{color:var(--field-icon-container-color,#969799);font-size:var(--field-icon-size,16px)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{color:var(--field-error-message-color,#ee0a24);display:block;font-size:var(--field-error-message-text-font-size,12px);text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}.van-field__word-limit{color:var(--field-word-limit-color,#646566);font-size:var(--field-word-limit-font-size,12px);line-height:var(--field-word-limit-line-height,16px);margin-top:var(--padding-base,4px);text-align:right}.van-field__word-num{display:inline}.van-field__word-num--full{color:var(--field-word-num-full-color,#ee0a24)} \ No newline at end of file diff --git a/wxcomponents/vant/field/input.wxml b/wxcomponents/vant/field/input.wxml new file mode 100644 index 0000000..86b288b --- /dev/null +++ b/wxcomponents/vant/field/input.wxml @@ -0,0 +1,31 @@ + + diff --git a/wxcomponents/vant/field/props.d.ts b/wxcomponents/vant/field/props.d.ts new file mode 100644 index 0000000..5cd130a --- /dev/null +++ b/wxcomponents/vant/field/props.d.ts @@ -0,0 +1,4 @@ +/// +export declare const commonProps: WechatMiniprogram.Component.PropertyOption; +export declare const inputProps: WechatMiniprogram.Component.PropertyOption; +export declare const textareaProps: WechatMiniprogram.Component.PropertyOption; diff --git a/wxcomponents/vant/field/props.js b/wxcomponents/vant/field/props.js new file mode 100644 index 0000000..ba3e0a7 --- /dev/null +++ b/wxcomponents/vant/field/props.js @@ -0,0 +1,56 @@ +export const commonProps = { + value: String, + placeholder: String, + placeholderStyle: String, + placeholderClass: String, + disabled: Boolean, + maxlength: { + type: Number, + value: -1, + }, + cursorSpacing: { + type: Number, + value: 50, + }, + autoFocus: Boolean, + focus: Boolean, + cursor: { + type: Number, + value: -1, + }, + selectionStart: { + type: Number, + value: -1, + }, + selectionEnd: { + type: Number, + value: -1, + }, + adjustPosition: { + type: Boolean, + value: true, + }, + holdKeyboard: Boolean, +}; +export const inputProps = { + type: { + type: String, + value: 'text', + }, + password: Boolean, + confirmType: String, + confirmHold: Boolean, + alwaysEmbed: Boolean, +}; +export const textareaProps = { + autoHeight: Boolean, + fixed: Boolean, + showConfirmBar: { + type: Boolean, + value: true, + }, + disableDefaultPadding: { + type: Boolean, + value: true, + }, +}; diff --git a/wxcomponents/vant/field/textarea.wxml b/wxcomponents/vant/field/textarea.wxml new file mode 100644 index 0000000..945d03e --- /dev/null +++ b/wxcomponents/vant/field/textarea.wxml @@ -0,0 +1,32 @@ + + +