From ff0296c41a9776b6db691a5ad75ca0bfe5083bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AF=B8=E8=B5=B7?= Date: Thu, 21 May 2020 14:18:05 +0800 Subject: [PATCH 01/28] =?UTF-8?q?feat(Button):=20=E4=BC=98=E5=8C=96Button?= =?UTF-8?q?=E7=BB=84=E4=BB=B6hover=E5=8F=8Adisabled=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/styles/_base.less | 79 ++++++++++--------- config/styles/_mixins.less | 15 ++++ src/behaviors/validator.js | 2 +- src/button/index.less | 6 +- src/button/index.wxml | 2 +- src/card/index.js | 2 +- src/checkbox-group/index.js | 2 +- src/core/utils/node-util.js | 11 --- src/form/index.js | 2 +- src/index-list/index.js | 53 +++---------- src/index-list/index.less | 10 +-- src/index-list/index.wxml | 4 +- src/input/index.js | 2 +- src/radio-group/index.js | 2 +- src/rate/index.js | 2 +- src/textarea/index.js | 2 +- .../utils/event-bus.js => utils/eventBus.js} | 0 17 files changed, 84 insertions(+), 112 deletions(-) rename src/{core/utils/event-bus.js => utils/eventBus.js} (100%) diff --git a/config/styles/_base.less b/config/styles/_base.less index 41e47305..3eb499da 100644 --- a/config/styles/_base.less +++ b/config/styles/_base.less @@ -1,37 +1,38 @@ @import "_theme"; // Color -@default-color : @theme-color; -@success-color : #34BFA3; -@warning-color : #FFE57F; -@error-color : #F4516C; -@disabled-color : #DEE2E6; -@selected-color : fade(@default-color, 90%); -@tooltip-color : #fff; -@subsidiary-color : #80848f; -@rate-star-color : #f5a623; +@default-color : @theme-color; +@success-color : #34BFA3; +@warning-color : #FFE57F; +@error-color : #F4516C; +@disabled-color : #DEE2E6; +@selected-color : fade(@default-color, 90%); +@tooltip-color : #fff; +@subsidiary-color : #80848f; +@rate-star-color : #f5a623; +@active-color : #333; // steps -@step-color : #C4C9D2; -@step-active-color : @theme-color; +@step-color : #C4C9D2; +@step-active-color : @theme-color; // Text -@title-color : #333; -@text-color : #888; +@title-color : #333; +@text-color : #888; // Background Color -@background-color-base : #f8f8f8; // base +@background-color-base : #f8f8f8; // base // Border color -@border-color-base : #dddee1; // outside -@border-color-split : #e9eaec; // inside +@border-color-base : #dddee1; // outside +@border-color-split : #e9eaec; // inside // Size -@size-grid-icon : 28rpx; -@size-font-base : 28rpx; -@size-font-mini : 24rpx; -@size-font-large : 32rpx; +@size-grid-icon : 28rpx; +@size-font-base : 28rpx; +@size-font-mini : 24rpx; +@size-font-large : 32rpx; // Button @btn-font-weight : normal; @@ -57,8 +58,8 @@ @btn-width : 180rpx; @btn-height-large : 88rpx; @btn-width-large : 710rpx; -@btn-height-mini : 60rpx; -@btn-width-mini : 140rpx; +@btn-height-mini : 60rpx; +@btn-width-mini : 140rpx; @btn-loading-color : #fff; @btn-circle-size : 40rpx; @btn-circle-size-mini : 30rpx; @@ -66,28 +67,28 @@ // icon -@icon-font-size : 32px; // 图标字体大小 默认 -@icon-font-size-large : 42px; // 图标字体大小 大号 -@icon-font-size-small : 22px; // 图标字体大小 小号 -@icon-font-color : #80848f; +@icon-font-size : 32px; // 图标字体大小 默认 +@icon-font-size-large : 42px; // 图标字体大小 大号 +@icon-font-size-small : 22px; // 图标字体大小 小号 +@icon-font-color : #80848f; // Avatar -@avatar-bg : #ccc; -@avatar-color : #fff; -@avatar-size-base : 32px; -@avatar-size-lg : 40px; -@avatar-size-sm : 24px; -@avatar-font-size-base : 18px; -@avatar-font-size-lg : 24px; -@avatar-font-size-sm : 14px; -@avatar-border-radius : @border-radius-small; -@border-radius-small : 4px; +@avatar-bg : #ccc; +@avatar-color : #fff; +@avatar-size-base : 32px; +@avatar-size-lg : 40px; +@avatar-size-sm : 24px; +@avatar-font-size-base : 18px; +@avatar-font-size-lg : 24px; +@avatar-font-size-sm : 14px; +@avatar-border-radius : @border-radius-small; +@border-radius-small : 4px; // Animation -@animation-time : .3s; -@transition-time : .2s; -@ease-in-out : ease-in-out; +@animation-time : .3s; +@transition-time : .2s; +@ease-in-out : ease-in-out; // Progress @progress-active-color : @theme-color; \ No newline at end of file diff --git a/config/styles/_mixins.less b/config/styles/_mixins.less index bac2dde9..796d15bc 100644 --- a/config/styles/_mixins.less +++ b/config/styles/_mixins.less @@ -12,4 +12,19 @@ pointer-events: none; box-sizing: border-box; border: 0 solid @border-color-split; +} + +.active() { + opacity: 0.15; + position: absolute; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + border: inherit; + border-radius: inherit; /* inherit parent's border radius */ + transform: translate(-50%, -50%); + content: ' '; + background-color: @active-color; + border-color: @active-color; } \ No newline at end of file diff --git a/src/behaviors/validator.js b/src/behaviors/validator.js index 92ff671f..e2a5f950 100644 --- a/src/behaviors/validator.js +++ b/src/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue)) { + if (!options.includes(newValue) && newValue) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; diff --git a/src/button/index.less b/src/button/index.less index 47316990..398eab2d 100644 --- a/src/button/index.less +++ b/src/button/index.less @@ -1,7 +1,8 @@ @import "../../config/styles/_base.less"; +@import "../../config/styles/_mixins.less"; -.btn-hover{ - opacity: 0.8; +.btn-hover::before{ + .active(); } .special-container{ @@ -154,7 +155,6 @@ // Disabled &-disabled{ opacity: 0.8; - background-color: @disabled-color; } } diff --git a/src/button/index.wxml b/src/button/index.wxml index 38b071a8..3738cc7c 100644 --- a/src/button/index.wxml +++ b/src/button/index.wxml @@ -6,7 +6,7 @@ { - component - .createSelectorQuery() - .select(selector) - .fields(fields, (res) => { - resolve(res) - }).exec() - }) - } } const nodeUtil = new NodeUtil() diff --git a/src/form/index.js b/src/form/index.js index 3fecb2ab..2b9add22 100644 --- a/src/form/index.js +++ b/src/form/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus.js'; +import eventBus from '../utils/eventBus.js'; Component({ /** * 组件的属性列表 diff --git a/src/index-list/index.js b/src/index-list/index.js index 5153d51c..e8e322e0 100644 --- a/src/index-list/index.js +++ b/src/index-list/index.js @@ -28,7 +28,7 @@ Component({ }, lifetimes: { - attached() { + async attached() { this.init() } }, @@ -75,9 +75,7 @@ Component({ // 改变量用于标识是否正在滑动 Sidebar // 滑动侧栏的时候需要禁止页面滚动去改变 Sidebar 激活项 // 不然会出现 Sidebar 激活项乱跳动的问题 - isMoving: false, - // sidebar-item 节点 rect 信息 - sidebarItemRect: {} + isMoving: false }, // Anchor 节点信息 _anchor: { @@ -97,9 +95,7 @@ Component({ // Tip 提示绝对定位的top值 tipTop: 0, // 是否显示 Tip - showTip: false, - // tip 高度 - tipHeight: 0 + showTip: false }, observers: { @@ -126,7 +122,7 @@ Component({ // 解析 Sidebar Rect 信息 await this.parseSidebarRect() // 解析 SidebarItem Rect 信息 - await this.parseSidebarItemRect() + this.parseSidebarItemRect() // 获取 index-anchor 所有组件实例 await this.parseIndexAnchors() // 解析 Anchor Rect 信息 @@ -156,39 +152,18 @@ Component({ * 把 Sidebar 每个 Item 的中点位置存到 data 中 * 用于 Tip 定位使用 */ - async parseSidebarItemRect() { + parseSidebarItemRect() { // Sidebar 索引个数 const sidebarLength = this.data.sidebarData.length - // 获取 sidebar-item 节点 - const sidebarItemRect = await nodeUtil.getNodeRectFromComponent(this, '.sidebar-item') - // Sidebar 单个索引高度(包含了 margin 空隙) + // Sidebar 单个索引高度 const sidebarItemHeight = this.data._sidebar.height / sidebarLength - // Sidebar 单个索引真实高度 - const sidebarItemRealHeight = sidebarItemRect.height - // 获取 sidebar-item margin-top 属性 - const sidebarItemFields = await nodeUtil.getNodeFieldsFromComponent(this, '.sidebar-item', { - computedStyle: ['margin-top'] - }) - // 获取 tip height 属性 - // 只能用 height 获取高度,因为 tip 旋转后,rect的宽高发生了变化 - const tipFields = await nodeUtil.getNodeFieldsFromComponent(this, '.tip', { - computedStyle: ['height'] - }) - const sidebarItemCenterPoints = [] - const sidebarItemMarginTop = sidebarItemFields['margin-top'].replace('px', '') - for (let i = 1; i <= sidebarLength; i++) { - sidebarItemCenterPoints.push((i * 2 - 1) * sidebarItemRealHeight / 2 + i * parseInt(sidebarItemMarginTop)) + const sidebarItemCenterPoints = [] + for (let i = 0; i < sidebarLength; i++) { + sidebarItemCenterPoints.push(i * sidebarItemHeight) } - - const tipHeight = parseInt(tipFields.height.replace('px', '')) this.setData({ - tipHeight, - // tip 旋转后,中线位置下移了 20.5% - tipHeightOverflow: tipHeight * 0.205, - ['_sidebar.sidebarItemRect']: sidebarItemRect, ['_sidebar.sidebarItemHeight']: sidebarItemHeight, - ['_sidebar.sidebarItemRealHeight']: sidebarItemRealHeight, ['_sidebar.sidebarItemCenterPoints']: sidebarItemCenterPoints }) }, @@ -428,16 +403,8 @@ Component({ // 300 毫秒后隐藏 Tip setTimeout(() => { this.switchTipShow(false) - }, 500) + }, 300) this.switchIsMovingSidebar(false) - }, - - /** - * 监听 点击侧边栏 - */ - onTapSidebar(event) { - // 把事件对象传入触摸滑动监听函数即可 - this.onTouchMove(event) } } }) diff --git a/src/index-list/index.less b/src/index-list/index.less index 3dd68028..2c57d328 100644 --- a/src/index-list/index.less +++ b/src/index-list/index.less @@ -3,9 +3,9 @@ .index-list { //侧栏样式 .sidebar { - font-size: 24rpx; + font-size: 20rpx; position: fixed; - right: 30rpx; + right: 20rpx; width: 20rpx; top: 50%; transform: translateY(-50%); @@ -14,13 +14,13 @@ align-items: center; &-item { - width: 40rpx; - height: 40rpx; + width: 16px; + height: 16px; border-radius: 50%; display: flex; justify-content: center; align-items: center; - margin-top: 8rpx; + margin-top: 6rpx; } &-item-active { diff --git a/src/index-list/index.wxml b/src/index-list/index.wxml index b67ef6f4..0c39e872 100644 --- a/src/index-list/index.wxml +++ b/src/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/src/input/index.js b/src/input/index.js index c263721c..877117ff 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -1,5 +1,5 @@ // input/input.js -import eventBus from '../core/utils/event-bus.js'; +import eventBus from '../utils/eventBus.js'; import validator from '../behaviors/validator'; import rules from '../behaviors/rules'; Component({ diff --git a/src/radio-group/index.js b/src/radio-group/index.js index 7a657746..d57cc7fe 100644 --- a/src/radio-group/index.js +++ b/src/radio-group/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; import rules from '../behaviors/rules'; diff --git a/src/rate/index.js b/src/rate/index.js index bf9a43c4..4549f606 100644 --- a/src/rate/index.js +++ b/src/rate/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; Component({ /** diff --git a/src/textarea/index.js b/src/textarea/index.js index a3300c4a..141a59b5 100644 --- a/src/textarea/index.js +++ b/src/textarea/index.js @@ -1,6 +1,6 @@ // input/input.js import rules from '../behaviors/rules'; -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; Component({ /** diff --git a/src/core/utils/event-bus.js b/src/utils/eventBus.js similarity index 100% rename from src/core/utils/event-bus.js rename to src/utils/eventBus.js From 95c478af59fe1c368b08d5d0b44e66a1cd574ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AF=B8=E8=B5=B7?= Date: Thu, 21 May 2020 14:23:39 +0800 Subject: [PATCH 02/28] =?UTF-8?q?feat(Card):=20=E6=9B=B4=E6=96=B0validator?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=99=A8=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/behaviors/validator.js | 2 +- dist/button/index.wxml | 2 +- dist/button/index.wxss | 2 +- dist/card/index.js | 2 +- dist/checkbox-group/index.js | 2 +- dist/core/utils/event-bus.js | 1 - dist/core/utils/node-util.js | 2 +- dist/form/index.js | 2 +- dist/index-list/index.js | 2 +- dist/index-list/index.wxml | 4 +- dist/index-list/index.wxss | 2 +- dist/input/index.js | 2 +- dist/progress/index.js | 2 +- dist/radio-group/index.js | 2 +- dist/rate/index.js | 2 +- dist/textarea/index.js | 2 +- dist/utils/data-util.js | 1 - dist/utils/event-util.js | 1 - dist/utils/node-util.js | 1 - dist/utils/pixel-util.js | 1 - dist/utils/wxml-util.js | 1 - examples/dist/behaviors/validator.js | 2 +- examples/dist/button/index.wxml | 2 +- examples/dist/button/index.wxss | 2 +- examples/dist/card/index.js | 2 +- examples/dist/checkbox-group/index.js | 2 +- examples/dist/core/utils/event-bus.js | 78 --------------------------- examples/dist/core/utils/node-util.js | 11 ---- examples/dist/form/index.js | 2 +- examples/dist/index-list/index.js | 53 ++++-------------- examples/dist/index-list/index.wxml | 4 +- examples/dist/index-list/index.wxss | 2 +- examples/dist/input/index.js | 2 +- examples/dist/radio-group/index.js | 2 +- examples/dist/rate/index.js | 2 +- examples/dist/textarea/index.js | 2 +- examples/dist/utils/data-util.js | 25 --------- examples/dist/utils/event-util.js | 12 ----- examples/dist/utils/node-util.js | 38 ------------- examples/dist/utils/pixel-util.js | 33 ------------ examples/dist/utils/wxml-util.js | 38 ------------- 41 files changed, 39 insertions(+), 313 deletions(-) delete mode 100644 dist/core/utils/event-bus.js delete mode 100644 dist/utils/data-util.js delete mode 100644 dist/utils/event-util.js delete mode 100644 dist/utils/node-util.js delete mode 100644 dist/utils/pixel-util.js delete mode 100644 dist/utils/wxml-util.js delete mode 100644 examples/dist/core/utils/event-bus.js delete mode 100644 examples/dist/utils/data-util.js delete mode 100644 examples/dist/utils/event-util.js delete mode 100644 examples/dist/utils/node-util.js delete mode 100644 examples/dist/utils/pixel-util.js delete mode 100644 examples/dist/utils/wxml-util.js diff --git a/dist/behaviors/validator.js b/dist/behaviors/validator.js index 9b43b561..ae390caf 100644 --- a/dist/behaviors/validator.js +++ b/dist/behaviors/validator.js @@ -1 +1 @@ -export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){t.includes(o)||console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file +export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){!t.includes(o)&&o&&console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file diff --git a/dist/button/index.wxml b/dist/button/index.wxml index 81fba9c5..82159c9c 100644 --- a/dist/button/index.wxml +++ b/dist/button/index.wxml @@ -5,7 +5,7 @@ - + diff --git a/dist/button/index.wxss b/dist/button/index.wxss index da04df64..2597fc32 100644 --- a/dist/button/index.wxss +++ b/dist/button/index.wxss @@ -1 +1 @@ -.btn-hover{opacity:.8}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8;background-color:#dee2e6}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file +.btn-hover::before{opacity:.15;position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;transform:translate(-50%,-50%);content:' ';background-color:#333;border-color:#333}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/dist/card/index.js b/dist/card/index.js index 26ae5f69..f6b45b00 100644 --- a/dist/card/index.js +++ b/dist/card/index.js @@ -1 +1 @@ -import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file +import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar","cover"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file diff --git a/dist/checkbox-group/index.js b/dist/checkbox-group/index.js index ece05a24..995fbf16 100644 --- a/dist/checkbox-group/index.js +++ b/dist/checkbox-group/index.js @@ -1 +1 @@ -import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){return this._selected={},this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file +import eventBus from"../utils/eventBus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){this._selected={};return this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file diff --git a/dist/core/utils/event-bus.js b/dist/core/utils/event-bus.js deleted file mode 100644 index 5307356a..00000000 --- a/dist/core/utils/event-bus.js +++ /dev/null @@ -1 +0,0 @@ -let EventBus=function(){};var objBus=[],arrBus=[];EventBus.prototype={obj:{set:function(r,u){if(r&&u){var n={};n.k=r,n.v=u;for(var t=0,s=objBus.length;t{r()})},on:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},arr:{push:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},pop:function(r){if(r)for(var u=0,n=arrBus.length;u{e.createSelectorQuery().select(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(o=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodeFieldsFromComponent(e,t,o){return await new Promise(n=>{e.createSelectorQuery().select(t).fields(o,e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file +class NodeUtil{async getNodeRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{n(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file diff --git a/dist/form/index.js b/dist/form/index.js index 0064e0ee..f153d0c9 100644 --- a/dist/form/index.js +++ b/dist/form/index.js @@ -1 +1 @@ -import eventBus from"../core/utils/event-bus.js";Component({externalClasses:["l-form-container-class","l-form-submit-class","l-form-reset-class","l-form-btn-class"],options:{multipleSlots:!0},relations:{"../form-item/index":{type:"child",linked:function(t){this._initItem(t)},linkChanged:function(){},unlinked:function(){}}},properties:{name:{type:String,value:""},isSubmitValidate:{type:Boolean,value:!0}},attached(){this._init()},data:{_this:null},methods:{_init(){wx.lin=wx.lin||{},wx.lin.forms=wx.lin.forms||{},wx.lin.forms[this.properties.name]=this,wx.lin.initValidateForm=t=>{wx.lin._instantiation=t},wx.lin.submitForm=function(t){wx.lin.forms[t].submit()},wx.lin.resetForm=function(t){wx.lin.forms[t].reset()}},_initItem(t){this._keys=this._keys||{},this._errors=this._errors||{};const e=t.properties.name;if(eventBus.on("lin-form-blur-"+e,t=>{this._validateItem(t,"blur")}),eventBus.on("lin-form-change-"+e,t=>{clearTimeout(this.change_time),this.change_time=setTimeout(()=>{this._validateItem(t,"change")},200)}),this._keys[e])throw new Error("表单项存在重复的name:"+e);this._keys[e]="",this._errors[e]=[]},_validateItem(t,e){let i=wx.lin._instantiation,s=this._getValues();const r=this.getRelationNodes("../form-item/index").find(e=>e.properties.name===t);if(!i.selectComponent("#"+t))throw new Error("表单项不存在name:"+t);return r.validatorData(s,e),this._errors[t]=r.data.errors,r.data.errors},_forEachNodes(t,e){let i=this.getRelationNodes("../form-item/index");e&&i.reverse(),i.forEach((e,i)=>{t(e,i)})},_validateForm(){let t=wx.lin._instantiation,e=[],i=this._getValues();return this._forEachNodes(s=>{const r=s.properties.name;if(!t.selectComponent("#"+r))throw new Error("表单项不存在name:"+r);s.validatorData(i),this._errors[r]=s.data.errors,e=e.concat(s.data.errors)},!0),e},_getValues(){let t={},e=wx.lin._instantiation;return this._forEachNodes(i=>{const s=i.properties.name,r=e.selectComponent("#"+s);r&&(t[s]=r.getValues())}),t},submit(){let t=this.data.isSubmitValidate?this._validateForm():[];this.triggerEvent("linsubmit",{values:this._getValues(),errors:this.data.isSubmitValidate?this._errors:{},isValidate:0===t.length})},reset(){let t=wx.lin._instantiation;this._forEachNodes(e=>{e.setData({errorText:""});const i=e.properties.name,s=t.selectComponent("#"+i);s&&s.reset()})}}}); \ No newline at end of file +import eventBus from"../utils/eventBus.js";Component({externalClasses:["l-form-container-class","l-form-submit-class","l-form-reset-class","l-form-btn-class"],options:{multipleSlots:!0},relations:{"../form-item/index":{type:"child",linked:function(t){this._initItem(t)},linkChanged:function(){},unlinked:function(){}}},properties:{name:{type:String,value:""},isSubmitValidate:{type:Boolean,value:!0}},attached(){this._init()},data:{_this:null},methods:{_init(){wx.lin=wx.lin||{},wx.lin.forms=wx.lin.forms||{},wx.lin.forms[this.properties.name]=this,wx.lin.initValidateForm=t=>{wx.lin._instantiation=t},wx.lin.submitForm=function(t){wx.lin.forms[t].submit()},wx.lin.resetForm=function(t){wx.lin.forms[t].reset()}},_initItem(t){this._keys=this._keys||{},this._errors=this._errors||{};const e=t.properties.name;if(eventBus.on("lin-form-blur-"+e,t=>{this._validateItem(t,"blur")}),eventBus.on("lin-form-change-"+e,t=>{clearTimeout(this.change_time),this.change_time=setTimeout(()=>{this._validateItem(t,"change")},200)}),this._keys[e])throw new Error("表单项存在重复的name:"+e);this._keys[e]="",this._errors[e]=[]},_validateItem(t,e){let i=wx.lin._instantiation,s=this._getValues();const n=this.getRelationNodes("../form-item/index").find(e=>e.properties.name===t);if(!i.selectComponent("#"+t))throw new Error("表单项不存在name:"+t);return n.validatorData(s,e),this._errors[t]=n.data.errors,n.data.errors},_forEachNodes(t,e){let i=this.getRelationNodes("../form-item/index");e&&i.reverse(),i.forEach((e,i)=>{t(e,i)})},_validateForm(){let t=wx.lin._instantiation,e=[],i=this._getValues();return this._forEachNodes(s=>{const n=s.properties.name;if(!t.selectComponent("#"+n))throw new Error("表单项不存在name:"+n);s.validatorData(i),this._errors[n]=s.data.errors,e=e.concat(s.data.errors)},!0),e},_getValues(){let t={},e=wx.lin._instantiation;return this._forEachNodes(i=>{const s=i.properties.name,n=e.selectComponent("#"+s);n&&(t[s]=n.getValues())}),t},submit(){let t=this.data.isSubmitValidate?this._validateForm():[];this.triggerEvent("linsubmit",{values:this._getValues(),errors:this.data.isSubmitValidate?this._errors:{},isValidate:0===t.length})},reset(){let t=wx.lin._instantiation;this._forEachNodes(e=>{e.setData({errorText:""});const i=e.properties.name,s=t.selectComponent("#"+i);s&&s.reset()})}}}); \ No newline at end of file diff --git a/dist/index-list/index.js b/dist/index-list/index.js index aaea86de..327e568a 100644 --- a/dist/index-list/index.js +++ b/dist/index-list/index.js @@ -1 +1 @@ -import nodeUtil from"../core/utils/node-util";import dataUtil from"../core/utils/data-util";import eventUtil from"../core/utils/event-util";import pixelUtil from"../core/utils/pixel-util";const defaultSidebarData=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];Component({externalClasses:["l-tip-class","l-tip-text-class","l-sidebar-class","l-selected-class","l-unselected-class"],relations:{"../index-anchor/index":{type:"child"}},options:{multipleSlots:!0,pureDataPattern:/^_/},lifetimes:{attached(){this.init()}},properties:{isStick:{type:Boolean,value:!1},scrollTop:{type:Number,value:0},sidebarData:{type:Array,value:defaultSidebarData},showSidebar:{type:Boolean,value:!0},stickOffsetTop:{type:Number,value:0}},data:{_sidebar:{top:0,height:0,sidebarItemCenterPoints:[],isMoving:!1,sidebarItemRect:{}},_anchor:{anchorTopLocations:[],indexAnchorComponents:[],currentStickAnchorIndex:-1,anchorItemsHeight:[]},_stickOffsetTopPx:0,activeSidebarItem:0,tipTop:0,showTip:!1,tipHeight:0},observers:{scrollTop:function(t){this.setIndexListStyle(t)},stickOffsetTop:function(t){this.setData({_stickOffsetTopPx:pixelUtil.rpx2px(t)})}},methods:{async init(){await this.parseSidebarRect(),await this.parseSidebarItemRect(),await this.parseIndexAnchors(),this.parseAnchorRect(),wx.lin=wx.lin||{},wx.lin.setScrollTop=t=>{dataUtil.setDiffData(this,{scrollTop:t})}},async parseSidebarRect(){const t=await nodeUtil.getNodeRectFromComponent(this,".sidebar");this.setData({"_sidebar.height":t.height,"_sidebar.top":t.top})},async parseSidebarItemRect(){const t=this.data.sidebarData.length,e=await nodeUtil.getNodeRectFromComponent(this,".sidebar-item"),i=this.data._sidebar.height/t,a=e.height,s=await nodeUtil.getNodeFieldsFromComponent(this,".sidebar-item",{computedStyle:["margin-top"]}),o=await nodeUtil.getNodeFieldsFromComponent(this,".tip",{computedStyle:["height"]}),n=[],r=s["margin-top"].replace("px","");for(let e=1;e<=t;e++)n.push((2*e-1)*a/2+e*parseInt(r));const h=parseInt(o.height.replace("px",""));this.setData({tipHeight:h,tipHeightOverflow:.205*h,"_sidebar.sidebarItemRect":e,"_sidebar.sidebarItemHeight":i,"_sidebar.sidebarItemRealHeight":a,"_sidebar.sidebarItemCenterPoints":n})},parseIndexAnchors(){const t=this.getRelationNodes("../index-anchor/index");if(t){this.setData({"_anchor.indexAnchorComponents":t});for(let e=0;e=n&&t+c<=h-r&&!o.isFixed()){o.setFixed(this.data.stickOffsetTop,r);for(let t=0;th-r&&t+ca-1&&(o=a-1);const n=this.data.sidebarData[o];dataUtil.setDiffData(this,{tipText:n,activeSidebarItem:o,tipTop:this.data._sidebar.sidebarItemCenterPoints[o]});let r=this.data._anchor.anchorTopLocations[o]-this.data._stickOffsetTopPx;wx.pageScrollTo({duration:0,scrollTop:r}),eventUtil.emit(this,"linselected",{index:o,tipText:n})},onTouchend(){setTimeout(()=>{this.switchTipShow(!1)},500),this.switchIsMovingSidebar(!1)},onTapSidebar(t){this.onTouchMove(t)}}}); \ No newline at end of file +import nodeUtil from"../core/utils/node-util";import dataUtil from"../core/utils/data-util";import eventUtil from"../core/utils/event-util";import pixelUtil from"../core/utils/pixel-util";const defaultSidebarData=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];Component({externalClasses:["l-tip-class","l-tip-text-class","l-sidebar-class","l-selected-class","l-unselected-class"],relations:{"../index-anchor/index":{type:"child"}},options:{multipleSlots:!0,pureDataPattern:/^_/},lifetimes:{async attached(){this.init()}},properties:{isStick:{type:Boolean,value:!1},scrollTop:{type:Number,value:0},sidebarData:{type:Array,value:defaultSidebarData},showSidebar:{type:Boolean,value:!0},stickOffsetTop:{type:Number,value:0}},data:{_sidebar:{top:0,height:0,sidebarItemCenterPoints:[],isMoving:!1},_anchor:{anchorTopLocations:[],indexAnchorComponents:[],currentStickAnchorIndex:-1,anchorItemsHeight:[]},_stickOffsetTopPx:0,activeSidebarItem:0,tipTop:0,showTip:!1},observers:{scrollTop:function(t){this.setIndexListStyle(t)},stickOffsetTop:function(t){this.setData({_stickOffsetTopPx:pixelUtil.rpx2px(t)})}},methods:{async init(){await this.parseSidebarRect(),this.parseSidebarItemRect(),await this.parseIndexAnchors(),this.parseAnchorRect(),wx.lin=wx.lin||{},wx.lin.setScrollTop=t=>{dataUtil.setDiffData(this,{scrollTop:t})}},async parseSidebarRect(){const t=await nodeUtil.getNodeRectFromComponent(this,".sidebar");this.setData({"_sidebar.height":t.height,"_sidebar.top":t.top})},parseSidebarItemRect(){const t=this.data.sidebarData.length,e=this.data._sidebar.height/t,i=[];for(let a=0;a=n&&t+c<=h-r&&!o.isFixed()){o.setFixed(this.data.stickOffsetTop,r);for(let t=0;th-r&&t+ca-1&&(o=a-1);const n=this.data.sidebarData[o];dataUtil.setDiffData(this,{tipText:n,activeSidebarItem:o,tipTop:this.data._sidebar.sidebarItemCenterPoints[o]});let r=this.data._anchor.anchorTopLocations[o]-this.data._stickOffsetTopPx;wx.pageScrollTo({duration:0,scrollTop:r}),eventUtil.emit(this,"linselected",{index:o,tipText:n})},onTouchend(){setTimeout(()=>{this.switchTipShow(!1)},300),this.switchIsMovingSidebar(!1)}}}); \ No newline at end of file diff --git a/dist/index-list/index.wxml b/dist/index-list/index.wxml index acbc8630..9f391a40 100644 --- a/dist/index-list/index.wxml +++ b/dist/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/dist/index-list/index.wxss b/dist/index-list/index.wxss index 9b5ddd9a..7e39d16f 100644 --- a/dist/index-list/index.wxss +++ b/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:20rpx;position:fixed;right:20rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:16px;height:16px;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:6rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/dist/input/index.js b/dist/input/index.js index cd75c083..bc905f3e 100644 --- a/dist/input/index.js +++ b/dist/input/index.js @@ -1 +1 @@ -import eventBus from"../core/utils/event-bus.js";import validator from"../behaviors/validator";import rules from"../behaviors/rules";Component({options:{multipleSlots:!0},behaviors:["wx://form-field",validator,rules],externalClasses:["l-class","l-label-class","l-error-text","l-error-text-class"],properties:{label:String,hideLabel:Boolean,labelCustom:Boolean,showRow:{type:Boolean,value:!0},required:Boolean,placeholder:String,type:{type:String,value:"text",options:["text","idcard","digit","password","number"]},value:String,colon:Boolean,focus:Boolean,clear:Boolean,maxlength:{type:Number,value:140},width:{type:Number,value:750},labelWidth:{type:Number,value:200},labelLayout:{type:String,value:"left",options:["left","right"]},disabled:Boolean,placeholderStyle:String},data:{},attached(){},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),this.triggerEvent("linconfirm",e.detail)},onClearTap(e){this.setData({value:""}),this.triggerEvent("linclear",e.detail)},getValues(){return this.data.value},reset(){this.setData({value:""})}}}); \ No newline at end of file +import eventBus from"../utils/eventBus.js";import validator from"../behaviors/validator";import rules from"../behaviors/rules";Component({options:{multipleSlots:!0},behaviors:["wx://form-field",validator,rules],externalClasses:["l-class","l-label-class","l-error-text","l-error-text-class"],properties:{label:String,hideLabel:Boolean,labelCustom:Boolean,showRow:{type:Boolean,value:!0},required:Boolean,placeholder:String,type:{type:String,value:"text",options:["text","idcard","digit","password","number"]},value:String,colon:Boolean,focus:Boolean,clear:Boolean,maxlength:{type:Number,value:140},width:{type:Number,value:750},labelWidth:{type:Number,value:200},labelLayout:{type:String,value:"left",options:["left","right"]},disabled:Boolean,placeholderStyle:String},data:{},attached(){},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),this.triggerEvent("linconfirm",e.detail)},onClearTap(e){this.setData({value:""}),this.triggerEvent("linclear",e.detail)},getValues(){return this.data.value},reset(){this.setData({value:""})}}}); \ No newline at end of file diff --git a/dist/progress/index.js b/dist/progress/index.js index dd94aad2..3894e649 100644 --- a/dist/progress/index.js +++ b/dist/progress/index.js @@ -1 +1 @@ -import{px2rpx}from"../utils/util.js";import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-text-class","l-active-class","l-background-class"],behaviors:[validator],properties:{percent:{type:Number,value:0},strokeWidth:{type:Number,value:12},borderRadius:{type:Number,value:6},activeColor:{type:String},backgroundColor:{type:String,value:"#EBEBEB"},showInfo:{type:Boolean,value:!1},textPosition:{type:String,value:"right",options:["left","right"]},textColor:{type:String},interval:{type:Number,value:20},active:{type:Boolean,value:!1},duration:{type:Number,value:30}},options:{multipleSlots:!0,pureDataPattern:/^_/},data:{_slotWidth:0,_slotHeight:0,_progressWidth:0,_progressHeight:0,_marginBottom:0,marginLeft:0,marginTop:0,_useSlot:!1},observers:{"_slotWidth, _slotHeight, _progressWidth, _progressHeight, percent,_useSlot":function(t,e,r,i,s,a){if(a){const a=-(e-i)/2,o=(r-t)*s/100;this.setData({marginTop:a,marginLeft:o})}}},lifetimes:{attached(){this.data.percent>100&&this.setData({percent:100}),wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec(),wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{e100&&this.setData({percent:100});wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec();wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{ee.data.key);const r=this.isRepeat(t);if(!1!==r)throw new Error("keys有重复元素, radio的key属性不能重复:"+r)},isRepeat(e){let t={};for(let r in e){if(t[e[r]])return e[r];t[e[r]]=!0}return!1},init(){const e=this.getRelationNodes("../radio/index");this.checkedKeyRepeat(e),this.onChangeHandle(e)},onChangeHandle(e){e.forEach(e=>{let t=this.properties.current===e.data.key;e.setChecked(t,e.data.key)})},onEmitEventHandle(e,t){this.properties.current=t?e.key:null;const r=this.getRelationNodes("../radio/index");this.onChangeHandle(r),Object.assign(e,{currentKey:this.properties.current}),this.validatorData({[this.data.name]:this.data.current}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.current},reset(){this.data.current=""}},observers:{current:function(){this.init()}}}); \ No newline at end of file +import eventBus from"../utils/eventBus";import rules from"../behaviors/rules";Component({externalClasses:["l-class","l-error-text","l-error-text-class"],behaviors:["wx://form-field",rules],relations:{"../radio/index":{type:"child",linked(){this.init()},linkChanged(){},unlinked(){this.init()}}},properties:{current:{type:String},noneChecked:{type:Boolean,value:!0},placement:{type:String,value:"column"}},data:{currentLength:0},methods:{checkedKeyRepeat(e){let t=e.map(e=>e.data.key);const r=this.isRepeat(t);if(!1!==r)throw new Error("keys有重复元素, radio的key属性不能重复:"+r)},isRepeat(e){let t={};for(let r in e){if(t[e[r]])return e[r];t[e[r]]=!0}return!1},init(){const e=this.getRelationNodes("../radio/index");this.checkedKeyRepeat(e),this.onChangeHandle(e)},onChangeHandle(e){e.forEach(e=>{let t=this.properties.current===e.data.key;e.setChecked(t,e.data.key)})},onEmitEventHandle(e,t){this.properties.current=t?e.key:null;const r=this.getRelationNodes("../radio/index");this.onChangeHandle(r),Object.assign(e,{currentKey:this.properties.current}),this.validatorData({[this.data.name]:this.data.current}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.current},reset(){this.data.current=""}},observers:{current:function(){this.init()}}}); \ No newline at end of file diff --git a/dist/rate/index.js b/dist/rate/index.js index 5b360c9b..8e314df7 100644 --- a/dist/rate/index.js +++ b/dist/rate/index.js @@ -1 +1 @@ -import eventBus from"../core/utils/event-bus";Component({externalClasses:["l-class","l-class-icon","l-class-image","l-icon-class","l-image-class"],options:{multipleSlots:!0},properties:{count:{type:Number,value:5},score:{type:Number,value:0},size:{type:String,value:"36"},disabled:Boolean,activeColor:{type:String,value:"#FF5252"},inActiveColor:{type:String,value:"#FFE5E5"},name:{type:String,value:"favor-fill"},activeImage:String,inActiveImage:String},data:{},methods:{handleClick(e){if(this.data.disabled)return;const{index:t}=e.currentTarget.dataset;this.setData({score:t+1}),this.triggerEvent("linchange",{score:t+1}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.score},reset(){this.setData({score:0})}}}); \ No newline at end of file +import eventBus from"../utils/eventBus";Component({externalClasses:["l-class","l-class-icon","l-class-image","l-icon-class","l-image-class"],options:{multipleSlots:!0},properties:{count:{type:Number,value:5},score:{type:Number,value:0},size:{type:String,value:"36"},disabled:Boolean,activeColor:{type:String,value:"#FF5252"},inActiveColor:{type:String,value:"#FFE5E5"},name:{type:String,value:"favor-fill"},activeImage:String,inActiveImage:String},data:{},methods:{handleClick(e){if(this.data.disabled)return;const{index:t}=e.currentTarget.dataset;this.setData({score:t+1}),this.triggerEvent("linchange",{score:t+1}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.score},reset(){this.setData({score:0})}}}); \ No newline at end of file diff --git a/dist/textarea/index.js b/dist/textarea/index.js index 5a1df7f8..83246737 100644 --- a/dist/textarea/index.js +++ b/dist/textarea/index.js @@ -1 +1 @@ -import rules from"../behaviors/rules";import eventBus from"../core/utils/event-bus";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class","l-inner-class"],properties:{placeholder:{type:String,value:""},value:{type:String,value:""},focus:{type:Boolean,value:!1},maxlength:{type:Number,value:140},indicator:{type:Boolean,value:!0},autoHeight:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1},border:{type:Boolean,value:!0},rules:{type:Object},placeholderStyle:{type:String,value:""}},data:{},attached(){this.initRules()},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){this.triggerEvent("linconfirm",e.detail)},getValues(){return this.data.value},reset(){this.data.value=""}}}); \ No newline at end of file +import rules from"../behaviors/rules";import eventBus from"../utils/eventBus";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class","l-inner-class"],properties:{placeholder:{type:String,value:""},value:{type:String,value:""},focus:{type:Boolean,value:!1},maxlength:{type:Number,value:140},indicator:{type:Boolean,value:!0},autoHeight:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1},border:{type:Boolean,value:!0},rules:{type:Object},placeholderStyle:{type:String,value:""}},data:{},attached(){this.initRules()},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){this.triggerEvent("linconfirm",e.detail)},getValues(){return this.data.value},reset(){this.data.value=""}}}); \ No newline at end of file diff --git a/dist/utils/data-util.js b/dist/utils/data-util.js deleted file mode 100644 index b05b799b..00000000 --- a/dist/utils/data-util.js +++ /dev/null @@ -1 +0,0 @@ -class DataUtil{setDiffData(t,a){const e={};Object.keys(a).forEach(s=>{t.data[s]!==a[s]&&(e[s]=a[s])}),Object.keys(e).length&&t.setData(e)}}const dataUtil=new DataUtil;export default dataUtil; \ No newline at end of file diff --git a/dist/utils/event-util.js b/dist/utils/event-util.js deleted file mode 100644 index 65d6890e..00000000 --- a/dist/utils/event-util.js +++ /dev/null @@ -1 +0,0 @@ -class EventUtil{emit(e,t,l){e.triggerEvent(t,l,{bubbles:!0,composed:!0,capturePhase:!0})}}const eventUtil=new EventUtil;export default eventUtil; \ No newline at end of file diff --git a/dist/utils/node-util.js b/dist/utils/node-util.js deleted file mode 100644 index de728191..00000000 --- a/dist/utils/node-util.js +++ /dev/null @@ -1 +0,0 @@ -class NodeUtil{async getNodeRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{n(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file diff --git a/dist/utils/pixel-util.js b/dist/utils/pixel-util.js deleted file mode 100644 index 7b6e2707..00000000 --- a/dist/utils/pixel-util.js +++ /dev/null @@ -1 +0,0 @@ -class PixelUtil{constructor(t){this.systemInfo=t}px2rpx(t){return 750/this.systemInfo.screenWidth*t}rpx2px(t){return t/750*this.systemInfo.screenWidth}}const pixelUtil=new PixelUtil(wx.getSystemInfoSync());export default pixelUtil; \ No newline at end of file diff --git a/dist/utils/wxml-util.js b/dist/utils/wxml-util.js deleted file mode 100644 index 0f474645..00000000 --- a/dist/utils/wxml-util.js +++ /dev/null @@ -1 +0,0 @@ -class WxmlUtil{async getNodeRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{l(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{l(e)}).exec()})}}const wxmlUtil=new WxmlUtil;export default wxmlUtil; \ No newline at end of file diff --git a/examples/dist/behaviors/validator.js b/examples/dist/behaviors/validator.js index 92ff671f..e2a5f950 100644 --- a/examples/dist/behaviors/validator.js +++ b/examples/dist/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue)) { + if (!options.includes(newValue) && newValue) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; diff --git a/examples/dist/button/index.wxml b/examples/dist/button/index.wxml index 38b071a8..3738cc7c 100644 --- a/examples/dist/button/index.wxml +++ b/examples/dist/button/index.wxml @@ -6,7 +6,7 @@ { resolve();}); - }, - on: function (key, action) { - if (key && action) { - var map = {}; - map.k = key; - map.v = action; - arrBus.push(map); - } - }, - arr: { - push: function (key, action) { - if (key && action) { - var map = {}; - map.k = key; - map.v = action; - arrBus.push(map); - } - }, - pop: function (key) { - if (key) { - for (var i = 0, busLength = arrBus.length; i < busLength; i++) { - var map = arrBus[i]; - if (map.k === key) { - map.v(); - } - } - } - } - } -}; -var eventBus = new EventBus(); -export default eventBus; -// module.exports = { -// eventBus: eventBus -// } diff --git a/examples/dist/core/utils/node-util.js b/examples/dist/core/utils/node-util.js index 608aa64b..a90415c0 100644 --- a/examples/dist/core/utils/node-util.js +++ b/examples/dist/core/utils/node-util.js @@ -32,17 +32,6 @@ class NodeUtil { }).exec() }) } - - async getNodeFieldsFromComponent(component, selector, fields) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .select(selector) - .fields(fields, (res) => { - resolve(res) - }).exec() - }) - } } const nodeUtil = new NodeUtil() diff --git a/examples/dist/form/index.js b/examples/dist/form/index.js index 3fecb2ab..2b9add22 100644 --- a/examples/dist/form/index.js +++ b/examples/dist/form/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus.js'; +import eventBus from '../utils/eventBus.js'; Component({ /** * 组件的属性列表 diff --git a/examples/dist/index-list/index.js b/examples/dist/index-list/index.js index 5153d51c..e8e322e0 100644 --- a/examples/dist/index-list/index.js +++ b/examples/dist/index-list/index.js @@ -28,7 +28,7 @@ Component({ }, lifetimes: { - attached() { + async attached() { this.init() } }, @@ -75,9 +75,7 @@ Component({ // 改变量用于标识是否正在滑动 Sidebar // 滑动侧栏的时候需要禁止页面滚动去改变 Sidebar 激活项 // 不然会出现 Sidebar 激活项乱跳动的问题 - isMoving: false, - // sidebar-item 节点 rect 信息 - sidebarItemRect: {} + isMoving: false }, // Anchor 节点信息 _anchor: { @@ -97,9 +95,7 @@ Component({ // Tip 提示绝对定位的top值 tipTop: 0, // 是否显示 Tip - showTip: false, - // tip 高度 - tipHeight: 0 + showTip: false }, observers: { @@ -126,7 +122,7 @@ Component({ // 解析 Sidebar Rect 信息 await this.parseSidebarRect() // 解析 SidebarItem Rect 信息 - await this.parseSidebarItemRect() + this.parseSidebarItemRect() // 获取 index-anchor 所有组件实例 await this.parseIndexAnchors() // 解析 Anchor Rect 信息 @@ -156,39 +152,18 @@ Component({ * 把 Sidebar 每个 Item 的中点位置存到 data 中 * 用于 Tip 定位使用 */ - async parseSidebarItemRect() { + parseSidebarItemRect() { // Sidebar 索引个数 const sidebarLength = this.data.sidebarData.length - // 获取 sidebar-item 节点 - const sidebarItemRect = await nodeUtil.getNodeRectFromComponent(this, '.sidebar-item') - // Sidebar 单个索引高度(包含了 margin 空隙) + // Sidebar 单个索引高度 const sidebarItemHeight = this.data._sidebar.height / sidebarLength - // Sidebar 单个索引真实高度 - const sidebarItemRealHeight = sidebarItemRect.height - // 获取 sidebar-item margin-top 属性 - const sidebarItemFields = await nodeUtil.getNodeFieldsFromComponent(this, '.sidebar-item', { - computedStyle: ['margin-top'] - }) - // 获取 tip height 属性 - // 只能用 height 获取高度,因为 tip 旋转后,rect的宽高发生了变化 - const tipFields = await nodeUtil.getNodeFieldsFromComponent(this, '.tip', { - computedStyle: ['height'] - }) - const sidebarItemCenterPoints = [] - const sidebarItemMarginTop = sidebarItemFields['margin-top'].replace('px', '') - for (let i = 1; i <= sidebarLength; i++) { - sidebarItemCenterPoints.push((i * 2 - 1) * sidebarItemRealHeight / 2 + i * parseInt(sidebarItemMarginTop)) + const sidebarItemCenterPoints = [] + for (let i = 0; i < sidebarLength; i++) { + sidebarItemCenterPoints.push(i * sidebarItemHeight) } - - const tipHeight = parseInt(tipFields.height.replace('px', '')) this.setData({ - tipHeight, - // tip 旋转后,中线位置下移了 20.5% - tipHeightOverflow: tipHeight * 0.205, - ['_sidebar.sidebarItemRect']: sidebarItemRect, ['_sidebar.sidebarItemHeight']: sidebarItemHeight, - ['_sidebar.sidebarItemRealHeight']: sidebarItemRealHeight, ['_sidebar.sidebarItemCenterPoints']: sidebarItemCenterPoints }) }, @@ -428,16 +403,8 @@ Component({ // 300 毫秒后隐藏 Tip setTimeout(() => { this.switchTipShow(false) - }, 500) + }, 300) this.switchIsMovingSidebar(false) - }, - - /** - * 监听 点击侧边栏 - */ - onTapSidebar(event) { - // 把事件对象传入触摸滑动监听函数即可 - this.onTouchMove(event) } } }) diff --git a/examples/dist/index-list/index.wxml b/examples/dist/index-list/index.wxml index b67ef6f4..0c39e872 100644 --- a/examples/dist/index-list/index.wxml +++ b/examples/dist/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/examples/dist/index-list/index.wxss b/examples/dist/index-list/index.wxss index 9b5ddd9a..7e39d16f 100644 --- a/examples/dist/index-list/index.wxss +++ b/examples/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:20rpx;position:fixed;right:20rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:16px;height:16px;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:6rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/examples/dist/input/index.js b/examples/dist/input/index.js index c263721c..877117ff 100644 --- a/examples/dist/input/index.js +++ b/examples/dist/input/index.js @@ -1,5 +1,5 @@ // input/input.js -import eventBus from '../core/utils/event-bus.js'; +import eventBus from '../utils/eventBus.js'; import validator from '../behaviors/validator'; import rules from '../behaviors/rules'; Component({ diff --git a/examples/dist/radio-group/index.js b/examples/dist/radio-group/index.js index 7a657746..d57cc7fe 100644 --- a/examples/dist/radio-group/index.js +++ b/examples/dist/radio-group/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; import rules from '../behaviors/rules'; diff --git a/examples/dist/rate/index.js b/examples/dist/rate/index.js index bf9a43c4..4549f606 100644 --- a/examples/dist/rate/index.js +++ b/examples/dist/rate/index.js @@ -1,4 +1,4 @@ -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; Component({ /** diff --git a/examples/dist/textarea/index.js b/examples/dist/textarea/index.js index a3300c4a..141a59b5 100644 --- a/examples/dist/textarea/index.js +++ b/examples/dist/textarea/index.js @@ -1,6 +1,6 @@ // input/input.js import rules from '../behaviors/rules'; -import eventBus from '../core/utils/event-bus'; +import eventBus from '../utils/eventBus'; Component({ /** diff --git a/examples/dist/utils/data-util.js b/examples/dist/utils/data-util.js deleted file mode 100644 index 853b7067..00000000 --- a/examples/dist/utils/data-util.js +++ /dev/null @@ -1,25 +0,0 @@ -class DataUtil { - /** - * 设置差异数据 - * @param component - * @param data - */ - setDiffData(component, data) { - const diffData = {} - - // 遍历获取到有差异的数据 - Object.keys(data).forEach(key => { - if (component.data[key] !== data[key]) { - diffData[key] = data[key] - } - }) - - // 设置数据 - if (Object.keys(diffData).length) { - component.setData(diffData) - } - } -} - -const dataUtil = new DataUtil -export default dataUtil diff --git a/examples/dist/utils/event-util.js b/examples/dist/utils/event-util.js deleted file mode 100644 index 44caea7e..00000000 --- a/examples/dist/utils/event-util.js +++ /dev/null @@ -1,12 +0,0 @@ -class EventUtil { - emit(component, eventName, detail) { - component.triggerEvent(eventName, detail, { - bubbles: true, - composed: true, - capturePhase: true - }) - } -} - -const eventUtil = new EventUtil() -export default eventUtil diff --git a/examples/dist/utils/node-util.js b/examples/dist/utils/node-util.js deleted file mode 100644 index a90415c0..00000000 --- a/examples/dist/utils/node-util.js +++ /dev/null @@ -1,38 +0,0 @@ -class NodeUtil { - /** - * 获取组件内部节点位置信息(单个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodeRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .select(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } - - /** - * 获取组件内部节点位置信息(多个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodesRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .selectAll(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } -} - -const nodeUtil = new NodeUtil() -export default nodeUtil diff --git a/examples/dist/utils/pixel-util.js b/examples/dist/utils/pixel-util.js deleted file mode 100644 index 51b55ceb..00000000 --- a/examples/dist/utils/pixel-util.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 像素工具 - */ -class PixelUtil { - /** - * 构造函数 - * @param systemInfo 设备信息 - */ - constructor(systemInfo) { - this.systemInfo = systemInfo - } - - /** - * px 转 rpx - * @param pxNumber px数值 - * @returns {number} rpx数值 - */ - px2rpx(pxNumber) { - return (750 / this.systemInfo.screenWidth) * pxNumber - } - - /** - * rpx 转 px - * @param rpxNumber rpx数值 - * @returns {number} px数值 - */ - rpx2px(rpxNumber){ - return (rpxNumber / 750) * this.systemInfo.screenWidth - } -} - -const pixelUtil = new PixelUtil(wx.getSystemInfoSync()) -export default pixelUtil diff --git a/examples/dist/utils/wxml-util.js b/examples/dist/utils/wxml-util.js deleted file mode 100644 index bca64b23..00000000 --- a/examples/dist/utils/wxml-util.js +++ /dev/null @@ -1,38 +0,0 @@ -class WxmlUtil { - /** - * 获取组件内部节点位置信息(单个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodeRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .select(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } - - /** - * 获取组件内部节点位置信息(多个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodesRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .selectAll(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } -} - -const wxmlUtil = new WxmlUtil() -export default wxmlUtil From d1a3688a6feae84373c0e704afb84d6abe638195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AF=B8=E8=B5=B7?= Date: Thu, 21 May 2020 14:24:33 +0800 Subject: [PATCH 03/28] =?UTF-8?q?chore(commitlint):=20=E6=9B=B4=E6=96=B0ru?= =?UTF-8?q?les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commitlint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commitlint.config.js b/commitlint.config.js index a3bb25ce..2217e548 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -17,6 +17,7 @@ module.exports = { '.editorconfig', '.gitignore', 'commitlint', + 'Behaviors', 'Example', 'Button', 'Icon', From f25bc63848a868d2af8d6ca6131c8c74413cf1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sat, 23 May 2020 17:52:31 +0800 Subject: [PATCH 04/28] =?UTF-8?q?Revert=20"chore(commitlint):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0rules"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d1a3688a6feae84373c0e704afb84d6abe638195. --- commitlint.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 2217e548..a3bb25ce 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -17,7 +17,6 @@ module.exports = { '.editorconfig', '.gitignore', 'commitlint', - 'Behaviors', 'Example', 'Button', 'Icon', From ab382ffe948c8ffd8301500df901cc543d724d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sat, 23 May 2020 17:52:49 +0800 Subject: [PATCH 05/28] =?UTF-8?q?Revert=20"feat(Card):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0validator=E6=A0=A1=E9=AA=8C=E5=99=A8=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E8=A7=84=E5=88=99"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 95c478af59fe1c368b08d5d0b44e66a1cd574ff3. --- dist/behaviors/validator.js | 2 +- dist/button/index.wxml | 2 +- dist/button/index.wxss | 2 +- dist/card/index.js | 2 +- dist/checkbox-group/index.js | 2 +- dist/core/utils/event-bus.js | 1 + dist/core/utils/node-util.js | 2 +- dist/form/index.js | 2 +- dist/index-list/index.js | 2 +- dist/index-list/index.wxml | 4 +- dist/index-list/index.wxss | 2 +- dist/input/index.js | 2 +- dist/progress/index.js | 2 +- dist/radio-group/index.js | 2 +- dist/rate/index.js | 2 +- dist/textarea/index.js | 2 +- dist/utils/data-util.js | 1 + dist/utils/event-util.js | 1 + dist/utils/node-util.js | 1 + dist/utils/pixel-util.js | 1 + dist/utils/wxml-util.js | 1 + examples/dist/behaviors/validator.js | 2 +- examples/dist/button/index.wxml | 2 +- examples/dist/button/index.wxss | 2 +- examples/dist/card/index.js | 2 +- examples/dist/checkbox-group/index.js | 2 +- examples/dist/core/utils/event-bus.js | 78 +++++++++++++++++++++++++++ examples/dist/core/utils/node-util.js | 11 ++++ examples/dist/form/index.js | 2 +- examples/dist/index-list/index.js | 53 ++++++++++++++---- examples/dist/index-list/index.wxml | 4 +- examples/dist/index-list/index.wxss | 2 +- examples/dist/input/index.js | 2 +- examples/dist/radio-group/index.js | 2 +- examples/dist/rate/index.js | 2 +- examples/dist/textarea/index.js | 2 +- examples/dist/utils/data-util.js | 25 +++++++++ examples/dist/utils/event-util.js | 12 +++++ examples/dist/utils/node-util.js | 38 +++++++++++++ examples/dist/utils/pixel-util.js | 33 ++++++++++++ examples/dist/utils/wxml-util.js | 38 +++++++++++++ 41 files changed, 313 insertions(+), 39 deletions(-) create mode 100644 dist/core/utils/event-bus.js create mode 100644 dist/utils/data-util.js create mode 100644 dist/utils/event-util.js create mode 100644 dist/utils/node-util.js create mode 100644 dist/utils/pixel-util.js create mode 100644 dist/utils/wxml-util.js create mode 100644 examples/dist/core/utils/event-bus.js create mode 100644 examples/dist/utils/data-util.js create mode 100644 examples/dist/utils/event-util.js create mode 100644 examples/dist/utils/node-util.js create mode 100644 examples/dist/utils/pixel-util.js create mode 100644 examples/dist/utils/wxml-util.js diff --git a/dist/behaviors/validator.js b/dist/behaviors/validator.js index ae390caf..9b43b561 100644 --- a/dist/behaviors/validator.js +++ b/dist/behaviors/validator.js @@ -1 +1 @@ -export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){!t.includes(o)&&o&&console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file +export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){t.includes(o)||console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file diff --git a/dist/button/index.wxml b/dist/button/index.wxml index 82159c9c..81fba9c5 100644 --- a/dist/button/index.wxml +++ b/dist/button/index.wxml @@ -5,7 +5,7 @@ - + diff --git a/dist/button/index.wxss b/dist/button/index.wxss index 2597fc32..da04df64 100644 --- a/dist/button/index.wxss +++ b/dist/button/index.wxss @@ -1 +1 @@ -.btn-hover::before{opacity:.15;position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;transform:translate(-50%,-50%);content:' ';background-color:#333;border-color:#333}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file +.btn-hover{opacity:.8}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8;background-color:#dee2e6}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/dist/card/index.js b/dist/card/index.js index f6b45b00..26ae5f69 100644 --- a/dist/card/index.js +++ b/dist/card/index.js @@ -1 +1 @@ -import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar","cover"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file +import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file diff --git a/dist/checkbox-group/index.js b/dist/checkbox-group/index.js index 995fbf16..ece05a24 100644 --- a/dist/checkbox-group/index.js +++ b/dist/checkbox-group/index.js @@ -1 +1 @@ -import eventBus from"../utils/eventBus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){this._selected={};return this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){return this._selected={},this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file diff --git a/dist/core/utils/event-bus.js b/dist/core/utils/event-bus.js new file mode 100644 index 00000000..5307356a --- /dev/null +++ b/dist/core/utils/event-bus.js @@ -0,0 +1 @@ +let EventBus=function(){};var objBus=[],arrBus=[];EventBus.prototype={obj:{set:function(r,u){if(r&&u){var n={};n.k=r,n.v=u;for(var t=0,s=objBus.length;t{r()})},on:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},arr:{push:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},pop:function(r){if(r)for(var u=0,n=arrBus.length;u{e.createSelectorQuery().select(t).boundingClientRect(e=>{n(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file +class NodeUtil{async getNodeRectFromComponent(e,t){return await new Promise(o=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(o=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodeFieldsFromComponent(e,t,o){return await new Promise(n=>{e.createSelectorQuery().select(t).fields(o,e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file diff --git a/dist/form/index.js b/dist/form/index.js index f153d0c9..0064e0ee 100644 --- a/dist/form/index.js +++ b/dist/form/index.js @@ -1 +1 @@ -import eventBus from"../utils/eventBus.js";Component({externalClasses:["l-form-container-class","l-form-submit-class","l-form-reset-class","l-form-btn-class"],options:{multipleSlots:!0},relations:{"../form-item/index":{type:"child",linked:function(t){this._initItem(t)},linkChanged:function(){},unlinked:function(){}}},properties:{name:{type:String,value:""},isSubmitValidate:{type:Boolean,value:!0}},attached(){this._init()},data:{_this:null},methods:{_init(){wx.lin=wx.lin||{},wx.lin.forms=wx.lin.forms||{},wx.lin.forms[this.properties.name]=this,wx.lin.initValidateForm=t=>{wx.lin._instantiation=t},wx.lin.submitForm=function(t){wx.lin.forms[t].submit()},wx.lin.resetForm=function(t){wx.lin.forms[t].reset()}},_initItem(t){this._keys=this._keys||{},this._errors=this._errors||{};const e=t.properties.name;if(eventBus.on("lin-form-blur-"+e,t=>{this._validateItem(t,"blur")}),eventBus.on("lin-form-change-"+e,t=>{clearTimeout(this.change_time),this.change_time=setTimeout(()=>{this._validateItem(t,"change")},200)}),this._keys[e])throw new Error("表单项存在重复的name:"+e);this._keys[e]="",this._errors[e]=[]},_validateItem(t,e){let i=wx.lin._instantiation,s=this._getValues();const n=this.getRelationNodes("../form-item/index").find(e=>e.properties.name===t);if(!i.selectComponent("#"+t))throw new Error("表单项不存在name:"+t);return n.validatorData(s,e),this._errors[t]=n.data.errors,n.data.errors},_forEachNodes(t,e){let i=this.getRelationNodes("../form-item/index");e&&i.reverse(),i.forEach((e,i)=>{t(e,i)})},_validateForm(){let t=wx.lin._instantiation,e=[],i=this._getValues();return this._forEachNodes(s=>{const n=s.properties.name;if(!t.selectComponent("#"+n))throw new Error("表单项不存在name:"+n);s.validatorData(i),this._errors[n]=s.data.errors,e=e.concat(s.data.errors)},!0),e},_getValues(){let t={},e=wx.lin._instantiation;return this._forEachNodes(i=>{const s=i.properties.name,n=e.selectComponent("#"+s);n&&(t[s]=n.getValues())}),t},submit(){let t=this.data.isSubmitValidate?this._validateForm():[];this.triggerEvent("linsubmit",{values:this._getValues(),errors:this.data.isSubmitValidate?this._errors:{},isValidate:0===t.length})},reset(){let t=wx.lin._instantiation;this._forEachNodes(e=>{e.setData({errorText:""});const i=e.properties.name,s=t.selectComponent("#"+i);s&&s.reset()})}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus.js";Component({externalClasses:["l-form-container-class","l-form-submit-class","l-form-reset-class","l-form-btn-class"],options:{multipleSlots:!0},relations:{"../form-item/index":{type:"child",linked:function(t){this._initItem(t)},linkChanged:function(){},unlinked:function(){}}},properties:{name:{type:String,value:""},isSubmitValidate:{type:Boolean,value:!0}},attached(){this._init()},data:{_this:null},methods:{_init(){wx.lin=wx.lin||{},wx.lin.forms=wx.lin.forms||{},wx.lin.forms[this.properties.name]=this,wx.lin.initValidateForm=t=>{wx.lin._instantiation=t},wx.lin.submitForm=function(t){wx.lin.forms[t].submit()},wx.lin.resetForm=function(t){wx.lin.forms[t].reset()}},_initItem(t){this._keys=this._keys||{},this._errors=this._errors||{};const e=t.properties.name;if(eventBus.on("lin-form-blur-"+e,t=>{this._validateItem(t,"blur")}),eventBus.on("lin-form-change-"+e,t=>{clearTimeout(this.change_time),this.change_time=setTimeout(()=>{this._validateItem(t,"change")},200)}),this._keys[e])throw new Error("表单项存在重复的name:"+e);this._keys[e]="",this._errors[e]=[]},_validateItem(t,e){let i=wx.lin._instantiation,s=this._getValues();const r=this.getRelationNodes("../form-item/index").find(e=>e.properties.name===t);if(!i.selectComponent("#"+t))throw new Error("表单项不存在name:"+t);return r.validatorData(s,e),this._errors[t]=r.data.errors,r.data.errors},_forEachNodes(t,e){let i=this.getRelationNodes("../form-item/index");e&&i.reverse(),i.forEach((e,i)=>{t(e,i)})},_validateForm(){let t=wx.lin._instantiation,e=[],i=this._getValues();return this._forEachNodes(s=>{const r=s.properties.name;if(!t.selectComponent("#"+r))throw new Error("表单项不存在name:"+r);s.validatorData(i),this._errors[r]=s.data.errors,e=e.concat(s.data.errors)},!0),e},_getValues(){let t={},e=wx.lin._instantiation;return this._forEachNodes(i=>{const s=i.properties.name,r=e.selectComponent("#"+s);r&&(t[s]=r.getValues())}),t},submit(){let t=this.data.isSubmitValidate?this._validateForm():[];this.triggerEvent("linsubmit",{values:this._getValues(),errors:this.data.isSubmitValidate?this._errors:{},isValidate:0===t.length})},reset(){let t=wx.lin._instantiation;this._forEachNodes(e=>{e.setData({errorText:""});const i=e.properties.name,s=t.selectComponent("#"+i);s&&s.reset()})}}}); \ No newline at end of file diff --git a/dist/index-list/index.js b/dist/index-list/index.js index 327e568a..aaea86de 100644 --- a/dist/index-list/index.js +++ b/dist/index-list/index.js @@ -1 +1 @@ -import nodeUtil from"../core/utils/node-util";import dataUtil from"../core/utils/data-util";import eventUtil from"../core/utils/event-util";import pixelUtil from"../core/utils/pixel-util";const defaultSidebarData=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];Component({externalClasses:["l-tip-class","l-tip-text-class","l-sidebar-class","l-selected-class","l-unselected-class"],relations:{"../index-anchor/index":{type:"child"}},options:{multipleSlots:!0,pureDataPattern:/^_/},lifetimes:{async attached(){this.init()}},properties:{isStick:{type:Boolean,value:!1},scrollTop:{type:Number,value:0},sidebarData:{type:Array,value:defaultSidebarData},showSidebar:{type:Boolean,value:!0},stickOffsetTop:{type:Number,value:0}},data:{_sidebar:{top:0,height:0,sidebarItemCenterPoints:[],isMoving:!1},_anchor:{anchorTopLocations:[],indexAnchorComponents:[],currentStickAnchorIndex:-1,anchorItemsHeight:[]},_stickOffsetTopPx:0,activeSidebarItem:0,tipTop:0,showTip:!1},observers:{scrollTop:function(t){this.setIndexListStyle(t)},stickOffsetTop:function(t){this.setData({_stickOffsetTopPx:pixelUtil.rpx2px(t)})}},methods:{async init(){await this.parseSidebarRect(),this.parseSidebarItemRect(),await this.parseIndexAnchors(),this.parseAnchorRect(),wx.lin=wx.lin||{},wx.lin.setScrollTop=t=>{dataUtil.setDiffData(this,{scrollTop:t})}},async parseSidebarRect(){const t=await nodeUtil.getNodeRectFromComponent(this,".sidebar");this.setData({"_sidebar.height":t.height,"_sidebar.top":t.top})},parseSidebarItemRect(){const t=this.data.sidebarData.length,e=this.data._sidebar.height/t,i=[];for(let a=0;a=n&&t+c<=h-r&&!o.isFixed()){o.setFixed(this.data.stickOffsetTop,r);for(let t=0;th-r&&t+ca-1&&(o=a-1);const n=this.data.sidebarData[o];dataUtil.setDiffData(this,{tipText:n,activeSidebarItem:o,tipTop:this.data._sidebar.sidebarItemCenterPoints[o]});let r=this.data._anchor.anchorTopLocations[o]-this.data._stickOffsetTopPx;wx.pageScrollTo({duration:0,scrollTop:r}),eventUtil.emit(this,"linselected",{index:o,tipText:n})},onTouchend(){setTimeout(()=>{this.switchTipShow(!1)},300),this.switchIsMovingSidebar(!1)}}}); \ No newline at end of file +import nodeUtil from"../core/utils/node-util";import dataUtil from"../core/utils/data-util";import eventUtil from"../core/utils/event-util";import pixelUtil from"../core/utils/pixel-util";const defaultSidebarData=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];Component({externalClasses:["l-tip-class","l-tip-text-class","l-sidebar-class","l-selected-class","l-unselected-class"],relations:{"../index-anchor/index":{type:"child"}},options:{multipleSlots:!0,pureDataPattern:/^_/},lifetimes:{attached(){this.init()}},properties:{isStick:{type:Boolean,value:!1},scrollTop:{type:Number,value:0},sidebarData:{type:Array,value:defaultSidebarData},showSidebar:{type:Boolean,value:!0},stickOffsetTop:{type:Number,value:0}},data:{_sidebar:{top:0,height:0,sidebarItemCenterPoints:[],isMoving:!1,sidebarItemRect:{}},_anchor:{anchorTopLocations:[],indexAnchorComponents:[],currentStickAnchorIndex:-1,anchorItemsHeight:[]},_stickOffsetTopPx:0,activeSidebarItem:0,tipTop:0,showTip:!1,tipHeight:0},observers:{scrollTop:function(t){this.setIndexListStyle(t)},stickOffsetTop:function(t){this.setData({_stickOffsetTopPx:pixelUtil.rpx2px(t)})}},methods:{async init(){await this.parseSidebarRect(),await this.parseSidebarItemRect(),await this.parseIndexAnchors(),this.parseAnchorRect(),wx.lin=wx.lin||{},wx.lin.setScrollTop=t=>{dataUtil.setDiffData(this,{scrollTop:t})}},async parseSidebarRect(){const t=await nodeUtil.getNodeRectFromComponent(this,".sidebar");this.setData({"_sidebar.height":t.height,"_sidebar.top":t.top})},async parseSidebarItemRect(){const t=this.data.sidebarData.length,e=await nodeUtil.getNodeRectFromComponent(this,".sidebar-item"),i=this.data._sidebar.height/t,a=e.height,s=await nodeUtil.getNodeFieldsFromComponent(this,".sidebar-item",{computedStyle:["margin-top"]}),o=await nodeUtil.getNodeFieldsFromComponent(this,".tip",{computedStyle:["height"]}),n=[],r=s["margin-top"].replace("px","");for(let e=1;e<=t;e++)n.push((2*e-1)*a/2+e*parseInt(r));const h=parseInt(o.height.replace("px",""));this.setData({tipHeight:h,tipHeightOverflow:.205*h,"_sidebar.sidebarItemRect":e,"_sidebar.sidebarItemHeight":i,"_sidebar.sidebarItemRealHeight":a,"_sidebar.sidebarItemCenterPoints":n})},parseIndexAnchors(){const t=this.getRelationNodes("../index-anchor/index");if(t){this.setData({"_anchor.indexAnchorComponents":t});for(let e=0;e=n&&t+c<=h-r&&!o.isFixed()){o.setFixed(this.data.stickOffsetTop,r);for(let t=0;th-r&&t+ca-1&&(o=a-1);const n=this.data.sidebarData[o];dataUtil.setDiffData(this,{tipText:n,activeSidebarItem:o,tipTop:this.data._sidebar.sidebarItemCenterPoints[o]});let r=this.data._anchor.anchorTopLocations[o]-this.data._stickOffsetTopPx;wx.pageScrollTo({duration:0,scrollTop:r}),eventUtil.emit(this,"linselected",{index:o,tipText:n})},onTouchend(){setTimeout(()=>{this.switchTipShow(!1)},500),this.switchIsMovingSidebar(!1)},onTapSidebar(t){this.onTouchMove(t)}}}); \ No newline at end of file diff --git a/dist/index-list/index.wxml b/dist/index-list/index.wxml index 9f391a40..acbc8630 100644 --- a/dist/index-list/index.wxml +++ b/dist/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/dist/index-list/index.wxss b/dist/index-list/index.wxss index 7e39d16f..9b5ddd9a 100644 --- a/dist/index-list/index.wxss +++ b/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:20rpx;position:fixed;right:20rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:16px;height:16px;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:6rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/dist/input/index.js b/dist/input/index.js index bc905f3e..cd75c083 100644 --- a/dist/input/index.js +++ b/dist/input/index.js @@ -1 +1 @@ -import eventBus from"../utils/eventBus.js";import validator from"../behaviors/validator";import rules from"../behaviors/rules";Component({options:{multipleSlots:!0},behaviors:["wx://form-field",validator,rules],externalClasses:["l-class","l-label-class","l-error-text","l-error-text-class"],properties:{label:String,hideLabel:Boolean,labelCustom:Boolean,showRow:{type:Boolean,value:!0},required:Boolean,placeholder:String,type:{type:String,value:"text",options:["text","idcard","digit","password","number"]},value:String,colon:Boolean,focus:Boolean,clear:Boolean,maxlength:{type:Number,value:140},width:{type:Number,value:750},labelWidth:{type:Number,value:200},labelLayout:{type:String,value:"left",options:["left","right"]},disabled:Boolean,placeholderStyle:String},data:{},attached(){},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),this.triggerEvent("linconfirm",e.detail)},onClearTap(e){this.setData({value:""}),this.triggerEvent("linclear",e.detail)},getValues(){return this.data.value},reset(){this.setData({value:""})}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus.js";import validator from"../behaviors/validator";import rules from"../behaviors/rules";Component({options:{multipleSlots:!0},behaviors:["wx://form-field",validator,rules],externalClasses:["l-class","l-label-class","l-error-text","l-error-text-class"],properties:{label:String,hideLabel:Boolean,labelCustom:Boolean,showRow:{type:Boolean,value:!0},required:Boolean,placeholder:String,type:{type:String,value:"text",options:["text","idcard","digit","password","number"]},value:String,colon:Boolean,focus:Boolean,clear:Boolean,maxlength:{type:Number,value:140},width:{type:Number,value:750},labelWidth:{type:Number,value:200},labelLayout:{type:String,value:"left",options:["left","right"]},disabled:Boolean,placeholderStyle:String},data:{},attached(){},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),this.triggerEvent("linconfirm",e.detail)},onClearTap(e){this.setData({value:""}),this.triggerEvent("linclear",e.detail)},getValues(){return this.data.value},reset(){this.setData({value:""})}}}); \ No newline at end of file diff --git a/dist/progress/index.js b/dist/progress/index.js index 3894e649..dd94aad2 100644 --- a/dist/progress/index.js +++ b/dist/progress/index.js @@ -1 +1 @@ -import{px2rpx}from"../utils/util.js";import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-text-class","l-active-class","l-background-class"],behaviors:[validator],properties:{percent:{type:Number,value:0},strokeWidth:{type:Number,value:12},borderRadius:{type:Number,value:6},activeColor:{type:String},backgroundColor:{type:String,value:"#EBEBEB"},showInfo:{type:Boolean,value:!1},textPosition:{type:String,value:"right",options:["left","right"]},textColor:{type:String},interval:{type:Number,value:20},active:{type:Boolean,value:!1},duration:{type:Number,value:30}},options:{multipleSlots:!0,pureDataPattern:/^_/},data:{_slotWidth:0,_slotHeight:0,_progressWidth:0,_progressHeight:0,_marginBottom:0,marginLeft:0,marginTop:0,_useSlot:!1},observers:{"_slotWidth, _slotHeight, _progressWidth, _progressHeight, percent,_useSlot":function(t,e,r,i,s,a){if(a){const a=-(e-i)/2,o=(r-t)*s/100;this.setData({marginTop:a,marginLeft:o})}}},lifetimes:{attached(){this.data.percent>100&&this.setData({percent:100});wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec();wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{e100&&this.setData({percent:100}),wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec(),wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{ee.data.key);const r=this.isRepeat(t);if(!1!==r)throw new Error("keys有重复元素, radio的key属性不能重复:"+r)},isRepeat(e){let t={};for(let r in e){if(t[e[r]])return e[r];t[e[r]]=!0}return!1},init(){const e=this.getRelationNodes("../radio/index");this.checkedKeyRepeat(e),this.onChangeHandle(e)},onChangeHandle(e){e.forEach(e=>{let t=this.properties.current===e.data.key;e.setChecked(t,e.data.key)})},onEmitEventHandle(e,t){this.properties.current=t?e.key:null;const r=this.getRelationNodes("../radio/index");this.onChangeHandle(r),Object.assign(e,{currentKey:this.properties.current}),this.validatorData({[this.data.name]:this.data.current}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.current},reset(){this.data.current=""}},observers:{current:function(){this.init()}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({externalClasses:["l-class","l-error-text","l-error-text-class"],behaviors:["wx://form-field",rules],relations:{"../radio/index":{type:"child",linked(){this.init()},linkChanged(){},unlinked(){this.init()}}},properties:{current:{type:String},noneChecked:{type:Boolean,value:!0},placement:{type:String,value:"column"}},data:{currentLength:0},methods:{checkedKeyRepeat(e){let t=e.map(e=>e.data.key);const r=this.isRepeat(t);if(!1!==r)throw new Error("keys有重复元素, radio的key属性不能重复:"+r)},isRepeat(e){let t={};for(let r in e){if(t[e[r]])return e[r];t[e[r]]=!0}return!1},init(){const e=this.getRelationNodes("../radio/index");this.checkedKeyRepeat(e),this.onChangeHandle(e)},onChangeHandle(e){e.forEach(e=>{let t=this.properties.current===e.data.key;e.setChecked(t,e.data.key)})},onEmitEventHandle(e,t){this.properties.current=t?e.key:null;const r=this.getRelationNodes("../radio/index");this.onChangeHandle(r),Object.assign(e,{currentKey:this.properties.current}),this.validatorData({[this.data.name]:this.data.current}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.current},reset(){this.data.current=""}},observers:{current:function(){this.init()}}}); \ No newline at end of file diff --git a/dist/rate/index.js b/dist/rate/index.js index 8e314df7..5b360c9b 100644 --- a/dist/rate/index.js +++ b/dist/rate/index.js @@ -1 +1 @@ -import eventBus from"../utils/eventBus";Component({externalClasses:["l-class","l-class-icon","l-class-image","l-icon-class","l-image-class"],options:{multipleSlots:!0},properties:{count:{type:Number,value:5},score:{type:Number,value:0},size:{type:String,value:"36"},disabled:Boolean,activeColor:{type:String,value:"#FF5252"},inActiveColor:{type:String,value:"#FFE5E5"},name:{type:String,value:"favor-fill"},activeImage:String,inActiveImage:String},data:{},methods:{handleClick(e){if(this.data.disabled)return;const{index:t}=e.currentTarget.dataset;this.setData({score:t+1}),this.triggerEvent("linchange",{score:t+1}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.score},reset(){this.setData({score:0})}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus";Component({externalClasses:["l-class","l-class-icon","l-class-image","l-icon-class","l-image-class"],options:{multipleSlots:!0},properties:{count:{type:Number,value:5},score:{type:Number,value:0},size:{type:String,value:"36"},disabled:Boolean,activeColor:{type:String,value:"#FF5252"},inActiveColor:{type:String,value:"#FFE5E5"},name:{type:String,value:"favor-fill"},activeImage:String,inActiveImage:String},data:{},methods:{handleClick(e){if(this.data.disabled)return;const{index:t}=e.currentTarget.dataset;this.setData({score:t+1}),this.triggerEvent("linchange",{score:t+1}),eventBus.emit("lin-form-change-"+this.id,this.id)},getValues(){return this.data.score},reset(){this.setData({score:0})}}}); \ No newline at end of file diff --git a/dist/textarea/index.js b/dist/textarea/index.js index 83246737..5a1df7f8 100644 --- a/dist/textarea/index.js +++ b/dist/textarea/index.js @@ -1 +1 @@ -import rules from"../behaviors/rules";import eventBus from"../utils/eventBus";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class","l-inner-class"],properties:{placeholder:{type:String,value:""},value:{type:String,value:""},focus:{type:Boolean,value:!1},maxlength:{type:Number,value:140},indicator:{type:Boolean,value:!0},autoHeight:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1},border:{type:Boolean,value:!0},rules:{type:Object},placeholderStyle:{type:String,value:""}},data:{},attached(){this.initRules()},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){this.triggerEvent("linconfirm",e.detail)},getValues(){return this.data.value},reset(){this.data.value=""}}}); \ No newline at end of file +import rules from"../behaviors/rules";import eventBus from"../core/utils/event-bus";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class","l-inner-class"],properties:{placeholder:{type:String,value:""},value:{type:String,value:""},focus:{type:Boolean,value:!1},maxlength:{type:Number,value:140},indicator:{type:Boolean,value:!0},autoHeight:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1},border:{type:Boolean,value:!0},rules:{type:Object},placeholderStyle:{type:String,value:""}},data:{},attached(){this.initRules()},methods:{handleInputChange(e){const{detail:t={}}=e,{value:l=""}=t;this.setData({value:l}),eventBus.emit("lin-form-change-"+this.id,this.id),this.triggerEvent("lininput",e.detail)},handleInputFocus(e){this.triggerEvent("linfocus",e.detail)},handleInputBlur(e){this.validatorData({[this.data.name]:e.detail.value}),eventBus.emit("lin-form-blur-"+this.id,this.id),this.triggerEvent("linblur",e.detail)},handleInputConfirm(e){this.triggerEvent("linconfirm",e.detail)},getValues(){return this.data.value},reset(){this.data.value=""}}}); \ No newline at end of file diff --git a/dist/utils/data-util.js b/dist/utils/data-util.js new file mode 100644 index 00000000..b05b799b --- /dev/null +++ b/dist/utils/data-util.js @@ -0,0 +1 @@ +class DataUtil{setDiffData(t,a){const e={};Object.keys(a).forEach(s=>{t.data[s]!==a[s]&&(e[s]=a[s])}),Object.keys(e).length&&t.setData(e)}}const dataUtil=new DataUtil;export default dataUtil; \ No newline at end of file diff --git a/dist/utils/event-util.js b/dist/utils/event-util.js new file mode 100644 index 00000000..65d6890e --- /dev/null +++ b/dist/utils/event-util.js @@ -0,0 +1 @@ +class EventUtil{emit(e,t,l){e.triggerEvent(t,l,{bubbles:!0,composed:!0,capturePhase:!0})}}const eventUtil=new EventUtil;export default eventUtil; \ No newline at end of file diff --git a/dist/utils/node-util.js b/dist/utils/node-util.js new file mode 100644 index 00000000..de728191 --- /dev/null +++ b/dist/utils/node-util.js @@ -0,0 +1 @@ +class NodeUtil{async getNodeRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{n(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file diff --git a/dist/utils/pixel-util.js b/dist/utils/pixel-util.js new file mode 100644 index 00000000..7b6e2707 --- /dev/null +++ b/dist/utils/pixel-util.js @@ -0,0 +1 @@ +class PixelUtil{constructor(t){this.systemInfo=t}px2rpx(t){return 750/this.systemInfo.screenWidth*t}rpx2px(t){return t/750*this.systemInfo.screenWidth}}const pixelUtil=new PixelUtil(wx.getSystemInfoSync());export default pixelUtil; \ No newline at end of file diff --git a/dist/utils/wxml-util.js b/dist/utils/wxml-util.js new file mode 100644 index 00000000..0f474645 --- /dev/null +++ b/dist/utils/wxml-util.js @@ -0,0 +1 @@ +class WxmlUtil{async getNodeRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{l(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{l(e)}).exec()})}}const wxmlUtil=new WxmlUtil;export default wxmlUtil; \ No newline at end of file diff --git a/examples/dist/behaviors/validator.js b/examples/dist/behaviors/validator.js index e2a5f950..92ff671f 100644 --- a/examples/dist/behaviors/validator.js +++ b/examples/dist/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue) && newValue) { + if (!options.includes(newValue)) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; diff --git a/examples/dist/button/index.wxml b/examples/dist/button/index.wxml index 3738cc7c..38b071a8 100644 --- a/examples/dist/button/index.wxml +++ b/examples/dist/button/index.wxml @@ -6,7 +6,7 @@ { resolve();}); + }, + on: function (key, action) { + if (key && action) { + var map = {}; + map.k = key; + map.v = action; + arrBus.push(map); + } + }, + arr: { + push: function (key, action) { + if (key && action) { + var map = {}; + map.k = key; + map.v = action; + arrBus.push(map); + } + }, + pop: function (key) { + if (key) { + for (var i = 0, busLength = arrBus.length; i < busLength; i++) { + var map = arrBus[i]; + if (map.k === key) { + map.v(); + } + } + } + } + } +}; +var eventBus = new EventBus(); +export default eventBus; +// module.exports = { +// eventBus: eventBus +// } diff --git a/examples/dist/core/utils/node-util.js b/examples/dist/core/utils/node-util.js index a90415c0..608aa64b 100644 --- a/examples/dist/core/utils/node-util.js +++ b/examples/dist/core/utils/node-util.js @@ -32,6 +32,17 @@ class NodeUtil { }).exec() }) } + + async getNodeFieldsFromComponent(component, selector, fields) { + return await new Promise((resolve) => { + component + .createSelectorQuery() + .select(selector) + .fields(fields, (res) => { + resolve(res) + }).exec() + }) + } } const nodeUtil = new NodeUtil() diff --git a/examples/dist/form/index.js b/examples/dist/form/index.js index 2b9add22..3fecb2ab 100644 --- a/examples/dist/form/index.js +++ b/examples/dist/form/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus.js'; +import eventBus from '../core/utils/event-bus.js'; Component({ /** * 组件的属性列表 diff --git a/examples/dist/index-list/index.js b/examples/dist/index-list/index.js index e8e322e0..5153d51c 100644 --- a/examples/dist/index-list/index.js +++ b/examples/dist/index-list/index.js @@ -28,7 +28,7 @@ Component({ }, lifetimes: { - async attached() { + attached() { this.init() } }, @@ -75,7 +75,9 @@ Component({ // 改变量用于标识是否正在滑动 Sidebar // 滑动侧栏的时候需要禁止页面滚动去改变 Sidebar 激活项 // 不然会出现 Sidebar 激活项乱跳动的问题 - isMoving: false + isMoving: false, + // sidebar-item 节点 rect 信息 + sidebarItemRect: {} }, // Anchor 节点信息 _anchor: { @@ -95,7 +97,9 @@ Component({ // Tip 提示绝对定位的top值 tipTop: 0, // 是否显示 Tip - showTip: false + showTip: false, + // tip 高度 + tipHeight: 0 }, observers: { @@ -122,7 +126,7 @@ Component({ // 解析 Sidebar Rect 信息 await this.parseSidebarRect() // 解析 SidebarItem Rect 信息 - this.parseSidebarItemRect() + await this.parseSidebarItemRect() // 获取 index-anchor 所有组件实例 await this.parseIndexAnchors() // 解析 Anchor Rect 信息 @@ -152,18 +156,39 @@ Component({ * 把 Sidebar 每个 Item 的中点位置存到 data 中 * 用于 Tip 定位使用 */ - parseSidebarItemRect() { + async parseSidebarItemRect() { // Sidebar 索引个数 const sidebarLength = this.data.sidebarData.length - // Sidebar 单个索引高度 + // 获取 sidebar-item 节点 + const sidebarItemRect = await nodeUtil.getNodeRectFromComponent(this, '.sidebar-item') + // Sidebar 单个索引高度(包含了 margin 空隙) const sidebarItemHeight = this.data._sidebar.height / sidebarLength - + // Sidebar 单个索引真实高度 + const sidebarItemRealHeight = sidebarItemRect.height + // 获取 sidebar-item margin-top 属性 + const sidebarItemFields = await nodeUtil.getNodeFieldsFromComponent(this, '.sidebar-item', { + computedStyle: ['margin-top'] + }) + // 获取 tip height 属性 + // 只能用 height 获取高度,因为 tip 旋转后,rect的宽高发生了变化 + const tipFields = await nodeUtil.getNodeFieldsFromComponent(this, '.tip', { + computedStyle: ['height'] + }) const sidebarItemCenterPoints = [] - for (let i = 0; i < sidebarLength; i++) { - sidebarItemCenterPoints.push(i * sidebarItemHeight) + const sidebarItemMarginTop = sidebarItemFields['margin-top'].replace('px', '') + + for (let i = 1; i <= sidebarLength; i++) { + sidebarItemCenterPoints.push((i * 2 - 1) * sidebarItemRealHeight / 2 + i * parseInt(sidebarItemMarginTop)) } + + const tipHeight = parseInt(tipFields.height.replace('px', '')) this.setData({ + tipHeight, + // tip 旋转后,中线位置下移了 20.5% + tipHeightOverflow: tipHeight * 0.205, + ['_sidebar.sidebarItemRect']: sidebarItemRect, ['_sidebar.sidebarItemHeight']: sidebarItemHeight, + ['_sidebar.sidebarItemRealHeight']: sidebarItemRealHeight, ['_sidebar.sidebarItemCenterPoints']: sidebarItemCenterPoints }) }, @@ -403,8 +428,16 @@ Component({ // 300 毫秒后隐藏 Tip setTimeout(() => { this.switchTipShow(false) - }, 300) + }, 500) this.switchIsMovingSidebar(false) + }, + + /** + * 监听 点击侧边栏 + */ + onTapSidebar(event) { + // 把事件对象传入触摸滑动监听函数即可 + this.onTouchMove(event) } } }) diff --git a/examples/dist/index-list/index.wxml b/examples/dist/index-list/index.wxml index 0c39e872..b67ef6f4 100644 --- a/examples/dist/index-list/index.wxml +++ b/examples/dist/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/examples/dist/index-list/index.wxss b/examples/dist/index-list/index.wxss index 7e39d16f..9b5ddd9a 100644 --- a/examples/dist/index-list/index.wxss +++ b/examples/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:20rpx;position:fixed;right:20rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:16px;height:16px;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:6rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/examples/dist/input/index.js b/examples/dist/input/index.js index 877117ff..c263721c 100644 --- a/examples/dist/input/index.js +++ b/examples/dist/input/index.js @@ -1,5 +1,5 @@ // input/input.js -import eventBus from '../utils/eventBus.js'; +import eventBus from '../core/utils/event-bus.js'; import validator from '../behaviors/validator'; import rules from '../behaviors/rules'; Component({ diff --git a/examples/dist/radio-group/index.js b/examples/dist/radio-group/index.js index d57cc7fe..7a657746 100644 --- a/examples/dist/radio-group/index.js +++ b/examples/dist/radio-group/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; import rules from '../behaviors/rules'; diff --git a/examples/dist/rate/index.js b/examples/dist/rate/index.js index 4549f606..bf9a43c4 100644 --- a/examples/dist/rate/index.js +++ b/examples/dist/rate/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; Component({ /** diff --git a/examples/dist/textarea/index.js b/examples/dist/textarea/index.js index 141a59b5..a3300c4a 100644 --- a/examples/dist/textarea/index.js +++ b/examples/dist/textarea/index.js @@ -1,6 +1,6 @@ // input/input.js import rules from '../behaviors/rules'; -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; Component({ /** diff --git a/examples/dist/utils/data-util.js b/examples/dist/utils/data-util.js new file mode 100644 index 00000000..853b7067 --- /dev/null +++ b/examples/dist/utils/data-util.js @@ -0,0 +1,25 @@ +class DataUtil { + /** + * 设置差异数据 + * @param component + * @param data + */ + setDiffData(component, data) { + const diffData = {} + + // 遍历获取到有差异的数据 + Object.keys(data).forEach(key => { + if (component.data[key] !== data[key]) { + diffData[key] = data[key] + } + }) + + // 设置数据 + if (Object.keys(diffData).length) { + component.setData(diffData) + } + } +} + +const dataUtil = new DataUtil +export default dataUtil diff --git a/examples/dist/utils/event-util.js b/examples/dist/utils/event-util.js new file mode 100644 index 00000000..44caea7e --- /dev/null +++ b/examples/dist/utils/event-util.js @@ -0,0 +1,12 @@ +class EventUtil { + emit(component, eventName, detail) { + component.triggerEvent(eventName, detail, { + bubbles: true, + composed: true, + capturePhase: true + }) + } +} + +const eventUtil = new EventUtil() +export default eventUtil diff --git a/examples/dist/utils/node-util.js b/examples/dist/utils/node-util.js new file mode 100644 index 00000000..a90415c0 --- /dev/null +++ b/examples/dist/utils/node-util.js @@ -0,0 +1,38 @@ +class NodeUtil { + /** + * 获取组件内部节点位置信息(单个) + * @param component 组件实例 + * @param selector {String} css选择器 + * @returns boundingClientRect() 回调函数的值 + */ + async getNodeRectFromComponent(component, selector) { + return await new Promise((resolve) => { + component + .createSelectorQuery() + .select(selector) + .boundingClientRect((res) => { + resolve(res) + }).exec() + }) + } + + /** + * 获取组件内部节点位置信息(多个) + * @param component 组件实例 + * @param selector {String} css选择器 + * @returns boundingClientRect() 回调函数的值 + */ + async getNodesRectFromComponent(component, selector) { + return await new Promise((resolve) => { + component + .createSelectorQuery() + .selectAll(selector) + .boundingClientRect((res) => { + resolve(res) + }).exec() + }) + } +} + +const nodeUtil = new NodeUtil() +export default nodeUtil diff --git a/examples/dist/utils/pixel-util.js b/examples/dist/utils/pixel-util.js new file mode 100644 index 00000000..51b55ceb --- /dev/null +++ b/examples/dist/utils/pixel-util.js @@ -0,0 +1,33 @@ +/** + * 像素工具 + */ +class PixelUtil { + /** + * 构造函数 + * @param systemInfo 设备信息 + */ + constructor(systemInfo) { + this.systemInfo = systemInfo + } + + /** + * px 转 rpx + * @param pxNumber px数值 + * @returns {number} rpx数值 + */ + px2rpx(pxNumber) { + return (750 / this.systemInfo.screenWidth) * pxNumber + } + + /** + * rpx 转 px + * @param rpxNumber rpx数值 + * @returns {number} px数值 + */ + rpx2px(rpxNumber){ + return (rpxNumber / 750) * this.systemInfo.screenWidth + } +} + +const pixelUtil = new PixelUtil(wx.getSystemInfoSync()) +export default pixelUtil diff --git a/examples/dist/utils/wxml-util.js b/examples/dist/utils/wxml-util.js new file mode 100644 index 00000000..bca64b23 --- /dev/null +++ b/examples/dist/utils/wxml-util.js @@ -0,0 +1,38 @@ +class WxmlUtil { + /** + * 获取组件内部节点位置信息(单个) + * @param component 组件实例 + * @param selector {String} css选择器 + * @returns boundingClientRect() 回调函数的值 + */ + async getNodeRectFromComponent(component, selector) { + return await new Promise((resolve) => { + component + .createSelectorQuery() + .select(selector) + .boundingClientRect((res) => { + resolve(res) + }).exec() + }) + } + + /** + * 获取组件内部节点位置信息(多个) + * @param component 组件实例 + * @param selector {String} css选择器 + * @returns boundingClientRect() 回调函数的值 + */ + async getNodesRectFromComponent(component, selector) { + return await new Promise((resolve) => { + component + .createSelectorQuery() + .selectAll(selector) + .boundingClientRect((res) => { + resolve(res) + }).exec() + }) + } +} + +const wxmlUtil = new WxmlUtil() +export default wxmlUtil From 84d685c3e721b83f192551e98ce36c28ae6e4b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sat, 23 May 2020 17:53:00 +0800 Subject: [PATCH 06/28] =?UTF-8?q?Revert=20"feat(Button):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96Button=E7=BB=84=E4=BB=B6hover=E5=8F=8Adisabled?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84=E6=A0=B7=E5=BC=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ff0296c41a9776b6db691a5ad75ca0bfe5083bc3. --- config/styles/_base.less | 79 +++++++++---------- config/styles/_mixins.less | 15 ---- src/behaviors/validator.js | 2 +- src/button/index.less | 6 +- src/button/index.wxml | 2 +- src/card/index.js | 2 +- src/checkbox-group/index.js | 2 +- .../eventBus.js => core/utils/event-bus.js} | 0 src/core/utils/node-util.js | 11 +++ src/form/index.js | 2 +- src/index-list/index.js | 53 ++++++++++--- src/index-list/index.less | 10 +-- src/index-list/index.wxml | 4 +- src/input/index.js | 2 +- src/radio-group/index.js | 2 +- src/rate/index.js | 2 +- src/textarea/index.js | 2 +- 17 files changed, 112 insertions(+), 84 deletions(-) rename src/{utils/eventBus.js => core/utils/event-bus.js} (100%) diff --git a/config/styles/_base.less b/config/styles/_base.less index 3eb499da..41e47305 100644 --- a/config/styles/_base.less +++ b/config/styles/_base.less @@ -1,38 +1,37 @@ @import "_theme"; // Color -@default-color : @theme-color; -@success-color : #34BFA3; -@warning-color : #FFE57F; -@error-color : #F4516C; -@disabled-color : #DEE2E6; -@selected-color : fade(@default-color, 90%); -@tooltip-color : #fff; -@subsidiary-color : #80848f; -@rate-star-color : #f5a623; -@active-color : #333; +@default-color : @theme-color; +@success-color : #34BFA3; +@warning-color : #FFE57F; +@error-color : #F4516C; +@disabled-color : #DEE2E6; +@selected-color : fade(@default-color, 90%); +@tooltip-color : #fff; +@subsidiary-color : #80848f; +@rate-star-color : #f5a623; // steps -@step-color : #C4C9D2; -@step-active-color : @theme-color; +@step-color : #C4C9D2; +@step-active-color : @theme-color; // Text -@title-color : #333; -@text-color : #888; +@title-color : #333; +@text-color : #888; // Background Color -@background-color-base : #f8f8f8; // base +@background-color-base : #f8f8f8; // base // Border color -@border-color-base : #dddee1; // outside -@border-color-split : #e9eaec; // inside +@border-color-base : #dddee1; // outside +@border-color-split : #e9eaec; // inside // Size -@size-grid-icon : 28rpx; -@size-font-base : 28rpx; -@size-font-mini : 24rpx; -@size-font-large : 32rpx; +@size-grid-icon : 28rpx; +@size-font-base : 28rpx; +@size-font-mini : 24rpx; +@size-font-large : 32rpx; // Button @btn-font-weight : normal; @@ -58,8 +57,8 @@ @btn-width : 180rpx; @btn-height-large : 88rpx; @btn-width-large : 710rpx; -@btn-height-mini : 60rpx; -@btn-width-mini : 140rpx; +@btn-height-mini : 60rpx; +@btn-width-mini : 140rpx; @btn-loading-color : #fff; @btn-circle-size : 40rpx; @btn-circle-size-mini : 30rpx; @@ -67,28 +66,28 @@ // icon -@icon-font-size : 32px; // 图标字体大小 默认 -@icon-font-size-large : 42px; // 图标字体大小 大号 -@icon-font-size-small : 22px; // 图标字体大小 小号 -@icon-font-color : #80848f; +@icon-font-size : 32px; // 图标字体大小 默认 +@icon-font-size-large : 42px; // 图标字体大小 大号 +@icon-font-size-small : 22px; // 图标字体大小 小号 +@icon-font-color : #80848f; // Avatar -@avatar-bg : #ccc; -@avatar-color : #fff; -@avatar-size-base : 32px; -@avatar-size-lg : 40px; -@avatar-size-sm : 24px; -@avatar-font-size-base : 18px; -@avatar-font-size-lg : 24px; -@avatar-font-size-sm : 14px; -@avatar-border-radius : @border-radius-small; -@border-radius-small : 4px; +@avatar-bg : #ccc; +@avatar-color : #fff; +@avatar-size-base : 32px; +@avatar-size-lg : 40px; +@avatar-size-sm : 24px; +@avatar-font-size-base : 18px; +@avatar-font-size-lg : 24px; +@avatar-font-size-sm : 14px; +@avatar-border-radius : @border-radius-small; +@border-radius-small : 4px; // Animation -@animation-time : .3s; -@transition-time : .2s; -@ease-in-out : ease-in-out; +@animation-time : .3s; +@transition-time : .2s; +@ease-in-out : ease-in-out; // Progress @progress-active-color : @theme-color; \ No newline at end of file diff --git a/config/styles/_mixins.less b/config/styles/_mixins.less index 796d15bc..bac2dde9 100644 --- a/config/styles/_mixins.less +++ b/config/styles/_mixins.less @@ -12,19 +12,4 @@ pointer-events: none; box-sizing: border-box; border: 0 solid @border-color-split; -} - -.active() { - opacity: 0.15; - position: absolute; - top: 50%; - left: 50%; - width: 100%; - height: 100%; - border: inherit; - border-radius: inherit; /* inherit parent's border radius */ - transform: translate(-50%, -50%); - content: ' '; - background-color: @active-color; - border-color: @active-color; } \ No newline at end of file diff --git a/src/behaviors/validator.js b/src/behaviors/validator.js index e2a5f950..92ff671f 100644 --- a/src/behaviors/validator.js +++ b/src/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue) && newValue) { + if (!options.includes(newValue)) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; diff --git a/src/button/index.less b/src/button/index.less index 398eab2d..47316990 100644 --- a/src/button/index.less +++ b/src/button/index.less @@ -1,8 +1,7 @@ @import "../../config/styles/_base.less"; -@import "../../config/styles/_mixins.less"; -.btn-hover::before{ - .active(); +.btn-hover{ + opacity: 0.8; } .special-container{ @@ -155,6 +154,7 @@ // Disabled &-disabled{ opacity: 0.8; + background-color: @disabled-color; } } diff --git a/src/button/index.wxml b/src/button/index.wxml index 3738cc7c..38b071a8 100644 --- a/src/button/index.wxml +++ b/src/button/index.wxml @@ -6,7 +6,7 @@ { + component + .createSelectorQuery() + .select(selector) + .fields(fields, (res) => { + resolve(res) + }).exec() + }) + } } const nodeUtil = new NodeUtil() diff --git a/src/form/index.js b/src/form/index.js index 2b9add22..3fecb2ab 100644 --- a/src/form/index.js +++ b/src/form/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus.js'; +import eventBus from '../core/utils/event-bus.js'; Component({ /** * 组件的属性列表 diff --git a/src/index-list/index.js b/src/index-list/index.js index e8e322e0..5153d51c 100644 --- a/src/index-list/index.js +++ b/src/index-list/index.js @@ -28,7 +28,7 @@ Component({ }, lifetimes: { - async attached() { + attached() { this.init() } }, @@ -75,7 +75,9 @@ Component({ // 改变量用于标识是否正在滑动 Sidebar // 滑动侧栏的时候需要禁止页面滚动去改变 Sidebar 激活项 // 不然会出现 Sidebar 激活项乱跳动的问题 - isMoving: false + isMoving: false, + // sidebar-item 节点 rect 信息 + sidebarItemRect: {} }, // Anchor 节点信息 _anchor: { @@ -95,7 +97,9 @@ Component({ // Tip 提示绝对定位的top值 tipTop: 0, // 是否显示 Tip - showTip: false + showTip: false, + // tip 高度 + tipHeight: 0 }, observers: { @@ -122,7 +126,7 @@ Component({ // 解析 Sidebar Rect 信息 await this.parseSidebarRect() // 解析 SidebarItem Rect 信息 - this.parseSidebarItemRect() + await this.parseSidebarItemRect() // 获取 index-anchor 所有组件实例 await this.parseIndexAnchors() // 解析 Anchor Rect 信息 @@ -152,18 +156,39 @@ Component({ * 把 Sidebar 每个 Item 的中点位置存到 data 中 * 用于 Tip 定位使用 */ - parseSidebarItemRect() { + async parseSidebarItemRect() { // Sidebar 索引个数 const sidebarLength = this.data.sidebarData.length - // Sidebar 单个索引高度 + // 获取 sidebar-item 节点 + const sidebarItemRect = await nodeUtil.getNodeRectFromComponent(this, '.sidebar-item') + // Sidebar 单个索引高度(包含了 margin 空隙) const sidebarItemHeight = this.data._sidebar.height / sidebarLength - + // Sidebar 单个索引真实高度 + const sidebarItemRealHeight = sidebarItemRect.height + // 获取 sidebar-item margin-top 属性 + const sidebarItemFields = await nodeUtil.getNodeFieldsFromComponent(this, '.sidebar-item', { + computedStyle: ['margin-top'] + }) + // 获取 tip height 属性 + // 只能用 height 获取高度,因为 tip 旋转后,rect的宽高发生了变化 + const tipFields = await nodeUtil.getNodeFieldsFromComponent(this, '.tip', { + computedStyle: ['height'] + }) const sidebarItemCenterPoints = [] - for (let i = 0; i < sidebarLength; i++) { - sidebarItemCenterPoints.push(i * sidebarItemHeight) + const sidebarItemMarginTop = sidebarItemFields['margin-top'].replace('px', '') + + for (let i = 1; i <= sidebarLength; i++) { + sidebarItemCenterPoints.push((i * 2 - 1) * sidebarItemRealHeight / 2 + i * parseInt(sidebarItemMarginTop)) } + + const tipHeight = parseInt(tipFields.height.replace('px', '')) this.setData({ + tipHeight, + // tip 旋转后,中线位置下移了 20.5% + tipHeightOverflow: tipHeight * 0.205, + ['_sidebar.sidebarItemRect']: sidebarItemRect, ['_sidebar.sidebarItemHeight']: sidebarItemHeight, + ['_sidebar.sidebarItemRealHeight']: sidebarItemRealHeight, ['_sidebar.sidebarItemCenterPoints']: sidebarItemCenterPoints }) }, @@ -403,8 +428,16 @@ Component({ // 300 毫秒后隐藏 Tip setTimeout(() => { this.switchTipShow(false) - }, 300) + }, 500) this.switchIsMovingSidebar(false) + }, + + /** + * 监听 点击侧边栏 + */ + onTapSidebar(event) { + // 把事件对象传入触摸滑动监听函数即可 + this.onTouchMove(event) } } }) diff --git a/src/index-list/index.less b/src/index-list/index.less index 2c57d328..3dd68028 100644 --- a/src/index-list/index.less +++ b/src/index-list/index.less @@ -3,9 +3,9 @@ .index-list { //侧栏样式 .sidebar { - font-size: 20rpx; + font-size: 24rpx; position: fixed; - right: 20rpx; + right: 30rpx; width: 20rpx; top: 50%; transform: translateY(-50%); @@ -14,13 +14,13 @@ align-items: center; &-item { - width: 16px; - height: 16px; + width: 40rpx; + height: 40rpx; border-radius: 50%; display: flex; justify-content: center; align-items: center; - margin-top: 6rpx; + margin-top: 8rpx; } &-item-active { diff --git a/src/index-list/index.wxml b/src/index-list/index.wxml index 0c39e872..b67ef6f4 100644 --- a/src/index-list/index.wxml +++ b/src/index-list/index.wxml @@ -1,12 +1,12 @@ - + {{sidebarItem}} - + {{tipText}} diff --git a/src/input/index.js b/src/input/index.js index 877117ff..c263721c 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -1,5 +1,5 @@ // input/input.js -import eventBus from '../utils/eventBus.js'; +import eventBus from '../core/utils/event-bus.js'; import validator from '../behaviors/validator'; import rules from '../behaviors/rules'; Component({ diff --git a/src/radio-group/index.js b/src/radio-group/index.js index d57cc7fe..7a657746 100644 --- a/src/radio-group/index.js +++ b/src/radio-group/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; import rules from '../behaviors/rules'; diff --git a/src/rate/index.js b/src/rate/index.js index 4549f606..bf9a43c4 100644 --- a/src/rate/index.js +++ b/src/rate/index.js @@ -1,4 +1,4 @@ -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; Component({ /** diff --git a/src/textarea/index.js b/src/textarea/index.js index 141a59b5..a3300c4a 100644 --- a/src/textarea/index.js +++ b/src/textarea/index.js @@ -1,6 +1,6 @@ // input/input.js import rules from '../behaviors/rules'; -import eventBus from '../utils/eventBus'; +import eventBus from '../core/utils/event-bus'; Component({ /** From 2580c7651e2356d2cd91bccb4d4c311458bfaaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sat, 23 May 2020 17:59:46 +0800 Subject: [PATCH 07/28] =?UTF-8?q?fix(Card):=20=E4=BF=AE=E5=A4=8D=20type=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=A0=A1=E9=AA=8C=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #838 --- dist/card/index.js | 2 +- examples/dist/card/index.js | 2 +- src/card/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/card/index.js b/dist/card/index.js index 26ae5f69..f6b45b00 100644 --- a/dist/card/index.js +++ b/dist/card/index.js @@ -1 +1 @@ -import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file +import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar","cover"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}}); \ No newline at end of file diff --git a/examples/dist/card/index.js b/examples/dist/card/index.js index dd776e86..08c48cf7 100644 --- a/examples/dist/card/index.js +++ b/examples/dist/card/index.js @@ -23,7 +23,7 @@ Component({ type: { type: String, value: 'primary', - options: ['primary', 'avatar'] + options: ['primary', 'avatar','cover'] }, imageMode: { type: String, diff --git a/src/card/index.js b/src/card/index.js index dd776e86..08c48cf7 100644 --- a/src/card/index.js +++ b/src/card/index.js @@ -23,7 +23,7 @@ Component({ type: { type: String, value: 'primary', - options: ['primary', 'avatar'] + options: ['primary', 'avatar','cover'] }, imageMode: { type: String, From 7520d0ac19fd5b1fbe68b61437352cee5b42d264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sun, 24 May 2020 13:27:23 +0800 Subject: [PATCH 08/28] =?UTF-8?q?chore(Tag):=20=E4=BF=AE=E5=A4=8D=20Demo?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E6=A0=A1=E9=AA=8C=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/pages/components/view/pages/tag/index.wxml | 2 +- examples/pages/components/view/pages/tag/tag-nav.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pages/components/view/pages/tag/index.wxml b/examples/pages/components/view/pages/tag/index.wxml index 2ef744b3..957acc6b 100644 --- a/examples/pages/components/view/pages/tag/index.wxml +++ b/examples/pages/components/view/pages/tag/index.wxml @@ -3,7 +3,7 @@ - {{tag.content}} + {{tag.content}} diff --git a/examples/pages/components/view/pages/tag/tag-nav.js b/examples/pages/components/view/pages/tag/tag-nav.js index 6f3db860..3ce40036 100644 --- a/examples/pages/components/view/pages/tag/tag-nav.js +++ b/examples/pages/components/view/pages/tag/tag-nav.js @@ -11,7 +11,7 @@ const tagNaviConfigs = [{ iconName: '', iconSize: '20', iconColor: '#fff', - location: 'r' + location: 'right' }, { content: '欺负我小', size: 'mini', @@ -23,7 +23,7 @@ const tagNaviConfigs = [{ iconName: '', iconSize: '20', iconColor: '#fff', - location: 'r' + location: 'right' }, { content: '唉 我也不大', From f075baef4536c36eda42885b2adf8b06ff613e24 Mon Sep 17 00:00:00 2001 From: daipengpeng <16602124116@163.com> Date: Mon, 25 May 2020 10:30:04 +0800 Subject: [PATCH 09/28] =?UTF-8?q?fix(Popup):=20=E4=BF=AE=E5=A4=8D=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BA=8B=E4=BB=B6=E7=A9=BF=E9=80=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/popup/index.wxml | 8 ++++---- examples/dist/popup/index.wxml | 8 ++++---- src/popup/index.wxml | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/popup/index.wxml b/dist/popup/index.wxml index 898cb0b6..b32c9446 100644 --- a/dist/popup/index.wxml +++ b/dist/popup/index.wxml @@ -1,13 +1,13 @@ - - + + - + - + diff --git a/examples/dist/popup/index.wxml b/examples/dist/popup/index.wxml index b00587ee..390d0163 100644 --- a/examples/dist/popup/index.wxml +++ b/examples/dist/popup/index.wxml @@ -1,6 +1,6 @@ - - + + - + - + diff --git a/src/popup/index.wxml b/src/popup/index.wxml index b00587ee..390d0163 100644 --- a/src/popup/index.wxml +++ b/src/popup/index.wxml @@ -1,6 +1,6 @@ - - + + - + - + From 78f1d1921befd4d02d005b28bfd8b7c40a4132e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Wed, 27 May 2020 08:44:56 +0800 Subject: [PATCH 10/28] =?UTF-8?q?fix(Segment):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=20tab=20=E6=97=A0=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在对 segment-item 的 tab 属性就行动态修改时, segment-item 的数量如果与之前一致,页面视图将不会更新。 该 commit 修复了此问题 close #845 --- dist/segment/index.js | 2 +- examples/dist/segment/index.js | 36 +++++++++++++++++++--------------- src/segment/index.js | 36 +++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/dist/segment/index.js b/dist/segment/index.js index 231a17b1..92152001 100644 --- a/dist/segment/index.js +++ b/dist/segment/index.js @@ -1 +1 @@ -import scrollCenter from"../behaviors/scrollCenter";Component({behaviors:[scrollCenter],externalClasses:["l-class","l-header-class","l-class-active","l-active-class","l-class-inactive","l-inactive-class","l-class-tabimage","l-tab-image-class","l-class-header-line","l-header-line-class","l-class-line","l-line-class","l-class-icon","l-icon-class","l-class-badge","l-badge-class"],options:{multipleSlots:!0},relations:{"../segment-item/index":{type:"child",linked(){this.initTabs()}}},properties:{activeKey:{type:String,value:"",observer:"changeCurrent"},placement:{type:String,value:"top"},scrollable:Boolean,hasLine:{type:Boolean,value:!0},animatedForLine:Boolean,activeColor:{type:String},inactiveColor:{type:String},equalWidth:{type:Boolean,value:!0},even:{type:Boolean,value:!0},width:Number,height:Number,itemHeight:Number,itemWidth:Number},observers:{activeKey:function(e){if(!e)return;const t=this.data.tabList.findIndex(t=>t.key===e);this.setData({currentIndex:t},()=>{this.data.scrollable&&this.queryMultipleNodes()})}},data:{tabList:[],currentIndex:0},methods:{initTabs(e=this.data.activeKey){let t=this.getRelationNodes("../segment-item/index");if(t.length>0){if(t.length===this.data.tabList.length)return;let a=e,s=this.data.currentIndex;const l=t.map((t,l)=>(a=e||0!==l?a:t.data.key,s=t.data.key===a?l:s,{...t.data}));this.setData({tabList:l,activeKey:a,currentIndex:s},()=>{this.data.scrollable&&this.queryMultipleNodes()})}},handleChange(e){const t=e.currentTarget.dataset.key,a=e.currentTarget.dataset.index;this._setChangeData({activeKey:t,currentIndex:a})},_setChangeData({activeKey:e,currentIndex:t}){this.setData({activeKey:e,currentIndex:t},()=>{this.data.scrollable&&this.queryMultipleNodes()}),this.triggerEvent("linchange",{activeKey:e,currentIndex:t})}}}); \ No newline at end of file +import scrollCenter from"../behaviors/scrollCenter";Component({behaviors:[scrollCenter],externalClasses:["l-class","l-header-class","l-class-active","l-active-class","l-class-inactive","l-inactive-class","l-class-tabimage","l-tab-image-class","l-class-header-line","l-header-line-class","l-class-line","l-line-class","l-class-icon","l-icon-class","l-class-badge","l-badge-class"],options:{multipleSlots:!0,pureDataPattern:/^_/},relations:{"../segment-item/index":{type:"child",linked(e){this.initTabs(e)}}},properties:{activeKey:{type:String,value:"",observer:"changeCurrent"},placement:{type:String,value:"top"},scrollable:Boolean,hasLine:{type:Boolean,value:!0},animatedForLine:Boolean,activeColor:{type:String},inactiveColor:{type:String},equalWidth:{type:Boolean,value:!0},even:{type:Boolean,value:!0},width:Number,height:Number,itemHeight:Number,itemWidth:Number},observers:{activeKey:function(e){if(!e)return;const t=this.data.tabList.findIndex(t=>t.key===e);this.setData({currentIndex:t},()=>{this.data.scrollable&&this.queryMultipleNodes()})}},data:{tabList:[],currentIndex:0,_segmentItemInstances:[]},methods:{initTabs(e){const t=this.data.activeKey;let a=this.getRelationNodes("../segment-item/index");if(a.length>0){if(a.length===this.data.tabList.length&&this.data._segmentItemInstances.indexOf(e)>0)return;let s=t,i=this.data.currentIndex;const n=a.map((e,a)=>(s=t||0!==a?s:e.data.key,i=e.data.key===s?a:i,{...e.data}));this.setData({tabList:n,activeKey:s,currentIndex:i,_segmentItemInstances:a},()=>{this.data.scrollable&&this.queryMultipleNodes()})}},handleChange(e){const t=e.currentTarget.dataset.key,a=e.currentTarget.dataset.index;this._setChangeData({activeKey:t,currentIndex:a})},_setChangeData({activeKey:e,currentIndex:t}){this.setData({activeKey:e,currentIndex:t},()=>{this.data.scrollable&&this.queryMultipleNodes()}),this.triggerEvent("linchange",{activeKey:e,currentIndex:t})}}}); \ No newline at end of file diff --git a/examples/dist/segment/index.js b/examples/dist/segment/index.js index 7ec1e71b..788c9719 100644 --- a/examples/dist/segment/index.js +++ b/examples/dist/segment/index.js @@ -2,8 +2,8 @@ import scrollCenter from '../behaviors/scrollCenter'; Component({ /** - * 组件的属性列表 - */ + * 组件的属性列表 + */ behaviors: [scrollCenter], externalClasses: [ 'l-class', @@ -24,15 +24,16 @@ Component({ 'l-badge-class' ], options: { - multipleSlots: true // 在组件定义时的选项中启用多slot支持 + multipleSlots: true, + pureDataPattern: /^_/ }, relations: { '../segment-item/index': { type: 'child', - linked() { + linked(target) { // 每次有子节点被插入时执行,target是该节点实例对象,触发在该节点attached生命周期之后 - this.initTabs(); + this.initTabs(target); } }, }, @@ -74,11 +75,11 @@ Component({ observers: { 'activeKey': function (newKey) { - if(!newKey) return; - const index = this.data.tabList.findIndex(tab=>tab.key===newKey); + if (!newKey) return; + const index = this.data.tabList.findIndex(tab => tab.key === newKey); this.setData({ - currentIndex:index - },() => { + currentIndex: index + }, () => { if (this.data.scrollable) { this.queryMultipleNodes(); } @@ -87,21 +88,23 @@ Component({ }, /** - * 组件的初始数据 - */ + * 组件的初始数据 + */ data: { tabList: [], - currentIndex: 0 + currentIndex: 0, + _segmentItemInstances: [] }, /** - * 组件的方法列表 - */ + * 组件的方法列表 + */ methods: { - initTabs(val = this.data.activeKey) { + initTabs(segmentItemInstance) { + const val = this.data.activeKey let items = this.getRelationNodes('../segment-item/index'); if (items.length > 0) { - if (items.length === this.data.tabList.length) return; + if (items.length === this.data.tabList.length && this.data._segmentItemInstances.indexOf(segmentItemInstance) > 0) return; let activeKey = val, currentIndex = this.data.currentIndex; const tab = items.map((item, index) => { @@ -115,6 +118,7 @@ Component({ tabList: tab, activeKey, currentIndex, + _segmentItemInstances: items }, () => { if (this.data.scrollable) { this.queryMultipleNodes(); diff --git a/src/segment/index.js b/src/segment/index.js index 7ec1e71b..788c9719 100644 --- a/src/segment/index.js +++ b/src/segment/index.js @@ -2,8 +2,8 @@ import scrollCenter from '../behaviors/scrollCenter'; Component({ /** - * 组件的属性列表 - */ + * 组件的属性列表 + */ behaviors: [scrollCenter], externalClasses: [ 'l-class', @@ -24,15 +24,16 @@ Component({ 'l-badge-class' ], options: { - multipleSlots: true // 在组件定义时的选项中启用多slot支持 + multipleSlots: true, + pureDataPattern: /^_/ }, relations: { '../segment-item/index': { type: 'child', - linked() { + linked(target) { // 每次有子节点被插入时执行,target是该节点实例对象,触发在该节点attached生命周期之后 - this.initTabs(); + this.initTabs(target); } }, }, @@ -74,11 +75,11 @@ Component({ observers: { 'activeKey': function (newKey) { - if(!newKey) return; - const index = this.data.tabList.findIndex(tab=>tab.key===newKey); + if (!newKey) return; + const index = this.data.tabList.findIndex(tab => tab.key === newKey); this.setData({ - currentIndex:index - },() => { + currentIndex: index + }, () => { if (this.data.scrollable) { this.queryMultipleNodes(); } @@ -87,21 +88,23 @@ Component({ }, /** - * 组件的初始数据 - */ + * 组件的初始数据 + */ data: { tabList: [], - currentIndex: 0 + currentIndex: 0, + _segmentItemInstances: [] }, /** - * 组件的方法列表 - */ + * 组件的方法列表 + */ methods: { - initTabs(val = this.data.activeKey) { + initTabs(segmentItemInstance) { + const val = this.data.activeKey let items = this.getRelationNodes('../segment-item/index'); if (items.length > 0) { - if (items.length === this.data.tabList.length) return; + if (items.length === this.data.tabList.length && this.data._segmentItemInstances.indexOf(segmentItemInstance) > 0) return; let activeKey = val, currentIndex = this.data.currentIndex; const tab = items.map((item, index) => { @@ -115,6 +118,7 @@ Component({ tabList: tab, activeKey, currentIndex, + _segmentItemInstances: items }, () => { if (this.data.scrollable) { this.queryMultipleNodes(); From 234f07091ca3f97d8dcdd0248c7b78eb4a203f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Wed, 27 May 2020 20:28:54 +0800 Subject: [PATCH 11/28] =?UTF-8?q?chore(Example):=20=E4=BF=AE=E5=A4=8D=20fi?= =?UTF-8?q?lter=20wx:key=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/pages/navigator/filter/index.wxml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pages/navigator/filter/index.wxml b/examples/pages/navigator/filter/index.wxml index 8748a10f..b6a5e621 100644 --- a/examples/pages/navigator/filter/index.wxml +++ b/examples/pages/navigator/filter/index.wxml @@ -18,7 +18,7 @@ Date: Sun, 24 May 2020 14:09:39 +0800 Subject: [PATCH 12/28] =?UTF-8?q?chore(Example):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E6=A3=80=E6=9F=A5=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/app.js | 7 ++++--- examples/utils/version-util.js | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 examples/utils/version-util.js diff --git a/examples/app.js b/examples/app.js index 47fee7f3..e4880762 100644 --- a/examples/app.js +++ b/examples/app.js @@ -1,10 +1,11 @@ -//app.js +import versionUtil from './utils/version-util' App({ onLaunch: function() { - + // 检查更新 + versionUtil.checkUpdate() }, globalData: { } -}); \ No newline at end of file +}); diff --git a/examples/utils/version-util.js b/examples/utils/version-util.js new file mode 100644 index 00000000..aa458269 --- /dev/null +++ b/examples/utils/version-util.js @@ -0,0 +1,37 @@ +// 小程序启动时检查版本 +class VersionUtil { + /** + * 检查更新 + */ + checkUpdate(){ + const updateManager = wx.getUpdateManager() + updateManager.onCheckForUpdate((hasUpdate)=>{ + if(hasUpdate){ + updateManager.onUpdateReady(()=>{ + wx.showModal({ + title:'更新提示', + content:'有新版本啦!要更新看看吗', + success(res){ + if(res.confirm){ + updateManager.applyUpdate() + } + } + }) + }) + + updateManager.onUpdateFailed(function () { + // 新版本下载失败 + wx.showModal({ + title: '更新提示', + content: '有新版本啦!删除当前小程序,重新打开就能更新啦!' + }) + }) + } + }) + + + } +} + +const versionUtil = new VersionUtil() +export default versionUtil From dbf1d4e9adf27d822b0b7585f14e7009f00d9e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Wed, 27 May 2020 20:40:52 +0800 Subject: [PATCH 13/28] =?UTF-8?q?chore(Example):=20=E5=88=A0=E9=99=A4=20ap?= =?UTF-8?q?p.json=20=E4=B8=AD=E7=9A=84=20navigateToMiniProgramAppIdList=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从2020年4月28日起,无需再设置navigateToMiniProgramAppIdList 详见:http://t.cn/AipuKjsh --- examples/app.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/app.json b/examples/app.json index c4e2bbc8..6f8db6f0 100644 --- a/examples/app.json +++ b/examples/app.json @@ -11,9 +11,6 @@ "navigationBarTitleText": "Lin UI", "navigationBarTextStyle": "black" }, - "navigateToMiniProgramAppIdList": [ - "wxb05fa7b69aa7e5b7" - ], "tabBar": { "color": "#bbbbbb", "selectedColor": "#3963BC", From e4c19b3df6948ee172897066956a9a65f4c55df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Fri, 29 May 2020 22:44:36 +0800 Subject: [PATCH 14/28] =?UTF-8?q?feat(NoticeBar):=20=E6=96=B0=E5=A2=9E=20l?= =?UTF-8?q?-icon-class=20=E5=A4=96=E9=83=A8=E6=A0=B7=E5=BC=8F=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #850 --- dist/notice-bar/index.js | 2 +- dist/notice-bar/index.wxml | 2 +- examples/dist/notice-bar/index.js | 2 +- examples/dist/notice-bar/index.wxml | 2 +- src/notice-bar/index.js | 2 +- src/notice-bar/index.wxml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/notice-bar/index.js b/dist/notice-bar/index.js index 86d94e1a..100bf043 100644 --- a/dist/notice-bar/index.js +++ b/dist/notice-bar/index.js @@ -1 +1 @@ -Component({externalClasses:["l-class"],properties:{type:{type:String,value:"still"},swipArr:Array,frontIconName:{type:String,value:""},frontIconSize:{type:Number,value:28},frontIconColor:{type:String,value:"#3683D6"},endIconName:{type:String,value:""},endIconSize:{type:Number,value:28},endIconColor:{type:String,value:"#3683D6"},backgroundcolor:{type:String,value:"#DFEDFF"},color:{type:String,value:"#3683D6"},speed:{type:Number,value:1500},show:{type:Boolean,value:!0},close:{type:Boolean,value:!1}},data:{wrapWidth:0,width:0,duration:0,animation:null,timer:null},detached(){this.destroyTimer()},ready(){"roll"===this.properties.type&&this.properties.show&&this.initAnimation()},methods:{initAnimation(){wx.createSelectorQuery().in(this).select(".l-noticebar-content-wrap").boundingClientRect(t=>{wx.createSelectorQuery().in(this).select(".l-noticebar-content").boundingClientRect(i=>{const e=i.width/40*this.data.speed,a=wx.createAnimation({duration:e,timingFunction:"linear"});this.setData({wrapWidth:t.width,width:i.width,duration:e,animation:a},()=>{this.startAnimation()})}).exec()}).exec()},startAnimation(){if(0!==this.data.animation.option.transition.duration){this.data.animation.option.transition.duration=0;const t=this.data.animation.translateX(this.data.wrapWidth).step();this.setData({animationData:t.export()})}this.data.animation.option.transition.duration=this.data.duration;const t=this.data.animation.translateX(-this.data.width).step();setTimeout(()=>{this.setData({animationData:t.export()})},100);const i=setTimeout(()=>{this.startAnimation()},this.data.duration);this.setData({timer:i})},destroyTimer(){this.data.timer&&clearTimeout(this.data.timer)},handleTap(){this.triggerEvent("lintap",{},{bubbles:!0,composed:!0}),this.setData({timer:null})},onSwip(t){this.triggerEvent("lintap",{...t.currentTarget.dataset},{bubbles:!0,composed:!0})},onIconTap(){this.triggerEvent("linicontap",{},{bubbles:!0,composed:!0}),this.setData({timer:null})},onClose(){this.setData({timer:null,show:!1})}}}); \ No newline at end of file +Component({externalClasses:["l-class","l-icon-class"],properties:{type:{type:String,value:"still"},swipArr:Array,frontIconName:{type:String,value:""},frontIconSize:{type:Number,value:28},frontIconColor:{type:String,value:"#3683D6"},endIconName:{type:String,value:""},endIconSize:{type:Number,value:28},endIconColor:{type:String,value:"#3683D6"},backgroundcolor:{type:String,value:"#DFEDFF"},color:{type:String,value:"#3683D6"},speed:{type:Number,value:1500},show:{type:Boolean,value:!0},close:{type:Boolean,value:!1}},data:{wrapWidth:0,width:0,duration:0,animation:null,timer:null},detached(){this.destroyTimer()},ready(){"roll"===this.properties.type&&this.properties.show&&this.initAnimation()},methods:{initAnimation(){wx.createSelectorQuery().in(this).select(".l-noticebar-content-wrap").boundingClientRect(t=>{wx.createSelectorQuery().in(this).select(".l-noticebar-content").boundingClientRect(i=>{const e=i.width/40*this.data.speed,a=wx.createAnimation({duration:e,timingFunction:"linear"});this.setData({wrapWidth:t.width,width:i.width,duration:e,animation:a},()=>{this.startAnimation()})}).exec()}).exec()},startAnimation(){if(0!==this.data.animation.option.transition.duration){this.data.animation.option.transition.duration=0;const t=this.data.animation.translateX(this.data.wrapWidth).step();this.setData({animationData:t.export()})}this.data.animation.option.transition.duration=this.data.duration;const t=this.data.animation.translateX(-this.data.width).step();setTimeout(()=>{this.setData({animationData:t.export()})},100);const i=setTimeout(()=>{this.startAnimation()},this.data.duration);this.setData({timer:i})},destroyTimer(){this.data.timer&&clearTimeout(this.data.timer)},handleTap(){this.triggerEvent("lintap",{},{bubbles:!0,composed:!0}),this.setData({timer:null})},onSwip(t){this.triggerEvent("lintap",{...t.currentTarget.dataset},{bubbles:!0,composed:!0})},onIconTap(){this.triggerEvent("linicontap",{},{bubbles:!0,composed:!0}),this.setData({timer:null})},onClose(){this.setData({timer:null,show:!1})}}}); \ No newline at end of file diff --git a/dist/notice-bar/index.wxml b/dist/notice-bar/index.wxml index 9b909338..2276bd05 100644 --- a/dist/notice-bar/index.wxml +++ b/dist/notice-bar/index.wxml @@ -1,5 +1,5 @@ - + diff --git a/examples/dist/notice-bar/index.js b/examples/dist/notice-bar/index.js index 6e47b9e8..5b323603 100644 --- a/examples/dist/notice-bar/index.js +++ b/examples/dist/notice-bar/index.js @@ -1,5 +1,5 @@ Component({ - externalClasses: ['l-class'], + externalClasses: ['l-class','l-icon-class'], properties: { type: { diff --git a/examples/dist/notice-bar/index.wxml b/examples/dist/notice-bar/index.wxml index b6106be2..667a2a28 100644 --- a/examples/dist/notice-bar/index.wxml +++ b/examples/dist/notice-bar/index.wxml @@ -1,5 +1,5 @@ - + diff --git a/src/notice-bar/index.js b/src/notice-bar/index.js index 6e47b9e8..5b323603 100644 --- a/src/notice-bar/index.js +++ b/src/notice-bar/index.js @@ -1,5 +1,5 @@ Component({ - externalClasses: ['l-class'], + externalClasses: ['l-class','l-icon-class'], properties: { type: { diff --git a/src/notice-bar/index.wxml b/src/notice-bar/index.wxml index b6106be2..667a2a28 100644 --- a/src/notice-bar/index.wxml +++ b/src/notice-bar/index.wxml @@ -1,5 +1,5 @@ - + From 9def5ecaf304c7447613431a5ced9885375a4407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Tue, 26 May 2020 11:07:36 +0800 Subject: [PATCH 15/28] =?UTF-8?q?feat(WaterFlow):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=20linitemtap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit linitemtap 为点击瀑布流子项的回调事件 使用场景:需要在页面中监听瀑布流子项的点击事件 close #839 --- dist/water-flow/index.js | 2 +- dist/water-flow/index.wxml | 6 +++--- examples/dist/water-flow/index.js | 20 +++++++++++++++----- examples/dist/water-flow/index.wxml | 6 +++--- src/water-flow/index.js | 20 +++++++++++++++----- src/water-flow/index.wxml | 6 +++--- 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/dist/water-flow/index.js b/dist/water-flow/index.js index f4d02464..6ddc3d1f 100644 --- a/dist/water-flow/index.js +++ b/dist/water-flow/index.js @@ -1 +1 @@ -Component({properties:{columnGap:{type:String,value:"20rpx"}},data:{data:[],leftData:[],rightData:[]},attached(){this._init()},pageLifetimes:{show(){this._init()}},methods:{_init(){wx.lin=wx.lin||{},wx.lin.renderWaterFlow=(t=[],e=!1,a)=>{if("[object Array]"!==Object.prototype.toString.call(t))return console.error("[data]参数类型错误,渲染失败"),!1;e&&(this.data.leftData=[],this.data.rightData=[]),this._select(t,e).then(()=>{a&&a()})}},_select(t,e){const a=wx.createSelectorQuery().in(this);return this.columnNodes=a.selectAll("#left, #right"),new Promise(a=>{this._render(t,0,e,()=>{a()})})},_render(t,e,a,i){t.length>e?this.columnNodes.boundingClientRect().exec(h=>{const r=h[0];this.data.leftHeight=r[0].height,this.data.rightHeight=r[1].height,this.data.leftHeight<=this.data.rightHeight||a?this.data.leftData.push(t[e]):this.data.rightData.push(t[e]),this.setData({leftData:this.data.leftData,rightData:this.data.rightData},()=>{this._render(t,++e,!1,i)})}):i&&i()}}}); \ No newline at end of file +import eventUtil from"../core/utils/event-util";Component({properties:{columnGap:{type:String,value:"20rpx"}},data:{data:[],leftData:[],rightData:[]},attached(){this._init()},pageLifetimes:{show(){this._init()}},methods:{_init(){wx.lin=wx.lin||{},wx.lin.renderWaterFlow=(t=[],e=!1,i)=>{if("[object Array]"!==Object.prototype.toString.call(t))return console.error("[data]参数类型错误,渲染失败"),!1;e&&(this.data.leftData=[],this.data.rightData=[]),this._select(t,e).then(()=>{i&&i()})}},_select(t,e){const i=wx.createSelectorQuery().in(this);return this.columnNodes=i.selectAll("#left, #right"),new Promise(i=>{this._render(t,0,e,()=>{i()})})},_render(t,e,i,a){t.length>e?this.columnNodes.boundingClientRect().exec(h=>{const r=h[0];this.data.leftHeight=r[0].height,this.data.rightHeight=r[1].height,this.data.leftHeight<=this.data.rightHeight||i?this.data.leftData.push(t[e]):this.data.rightData.push(t[e]),this.setData({leftData:this.data.leftData,rightData:this.data.rightData},()=>{this._render(t,++e,!1,a)})}):a&&a()},onTapItem(t){eventUtil.emit(this,"linitemtap",t.detail)}}}); \ No newline at end of file diff --git a/dist/water-flow/index.wxml b/dist/water-flow/index.wxml index 02d3592a..64cf7b58 100644 --- a/dist/water-flow/index.wxml +++ b/dist/water-flow/index.wxml @@ -2,15 +2,15 @@ - + - + - \ No newline at end of file + diff --git a/examples/dist/water-flow/index.js b/examples/dist/water-flow/index.js index 767db22a..6eab065c 100644 --- a/examples/dist/water-flow/index.js +++ b/examples/dist/water-flow/index.js @@ -1,7 +1,9 @@ +import eventUtil from '../core/utils/event-util' + Component({ /** - * 组件的属性列表 - */ + * 组件的属性列表 + */ properties: { columnGap: { type: String, @@ -10,8 +12,8 @@ Component({ }, /** - * 组件的初始数据 - */ + * 组件的初始数据 + */ data: { data: [], leftData: [], @@ -79,6 +81,14 @@ Component({ } else { success && success(); } + }, + + /** + * 监听:点击 water-flow-item + * @param e 事件对象 + */ + onTapItem(e) { + eventUtil.emit(this, 'linitemtap', e.detail) } } -}); \ No newline at end of file +}); diff --git a/examples/dist/water-flow/index.wxml b/examples/dist/water-flow/index.wxml index 19ba14d3..50a496bb 100644 --- a/examples/dist/water-flow/index.wxml +++ b/examples/dist/water-flow/index.wxml @@ -2,15 +2,15 @@ - + - + - \ No newline at end of file + diff --git a/src/water-flow/index.js b/src/water-flow/index.js index 767db22a..6eab065c 100644 --- a/src/water-flow/index.js +++ b/src/water-flow/index.js @@ -1,7 +1,9 @@ +import eventUtil from '../core/utils/event-util' + Component({ /** - * 组件的属性列表 - */ + * 组件的属性列表 + */ properties: { columnGap: { type: String, @@ -10,8 +12,8 @@ Component({ }, /** - * 组件的初始数据 - */ + * 组件的初始数据 + */ data: { data: [], leftData: [], @@ -79,6 +81,14 @@ Component({ } else { success && success(); } + }, + + /** + * 监听:点击 water-flow-item + * @param e 事件对象 + */ + onTapItem(e) { + eventUtil.emit(this, 'linitemtap', e.detail) } } -}); \ No newline at end of file +}); diff --git a/src/water-flow/index.wxml b/src/water-flow/index.wxml index 19ba14d3..50a496bb 100644 --- a/src/water-flow/index.wxml +++ b/src/water-flow/index.wxml @@ -2,15 +2,15 @@ - + - + - \ No newline at end of file + From d72ae9bc39916050f8c2748bd199ad65e5563b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sun, 31 May 2020 17:28:41 +0800 Subject: [PATCH 16/28] =?UTF-8?q?refactor(Behavior):=20=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=20Validator=20=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commitlint.config.js | 3 ++- dist/behaviors/validator.js | 2 +- examples/dist/behaviors/validator.js | 2 +- src/behaviors/validator.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/commitlint.config.js b/commitlint.config.js index a3bb25ce..b4a4c8f0 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -61,7 +61,8 @@ module.exports = { 'Price', 'Counter', 'SearchBar', - 'IndexList' + 'IndexList', + 'Behavior' ] ] } diff --git a/dist/behaviors/validator.js b/dist/behaviors/validator.js index 9b43b561..ae390caf 100644 --- a/dist/behaviors/validator.js +++ b/dist/behaviors/validator.js @@ -1 +1 @@ -export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){t.includes(o)||console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file +export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){!t.includes(o)&&o&&console.error(`${e}: ${o} must be in the [${t}]`)})})}}); \ No newline at end of file diff --git a/examples/dist/behaviors/validator.js b/examples/dist/behaviors/validator.js index 92ff671f..e2a5f950 100644 --- a/examples/dist/behaviors/validator.js +++ b/examples/dist/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue)) { + if (!options.includes(newValue) && newValue) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; diff --git a/src/behaviors/validator.js b/src/behaviors/validator.js index 92ff671f..e2a5f950 100644 --- a/src/behaviors/validator.js +++ b/src/behaviors/validator.js @@ -11,7 +11,7 @@ export default Behavior({ } = properties[name]; if (options) { properties[name].observer = function (newValue) { - if (!options.includes(newValue)) { + if (!options.includes(newValue) && newValue) { console.error(`${name}: ${newValue} must be in the [${options}]`); } }; From b37a0571b13e3162734493f841233448b375bd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sun, 31 May 2020 17:26:29 +0800 Subject: [PATCH 17/28] =?UTF-8?q?fix(Button):=20=E4=BF=AE=E5=A4=8D=20bg-co?= =?UTF-8?q?lor=20=E5=9C=A8=20disable=3Dtrue=20=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: hover 和 disable 样式变动 close #817 --- config/styles/_base.less | 79 +++++++++++++++++---------------- config/styles/_mixins.less | 15 +++++++ dist/button/index.wxml | 2 +- dist/button/index.wxss | 2 +- examples/dist/button/index.wxml | 2 +- examples/dist/button/index.wxss | 2 +- src/button/index.less | 6 +-- src/button/index.wxml | 2 +- 8 files changed, 63 insertions(+), 47 deletions(-) diff --git a/config/styles/_base.less b/config/styles/_base.less index 41e47305..3eb499da 100644 --- a/config/styles/_base.less +++ b/config/styles/_base.less @@ -1,37 +1,38 @@ @import "_theme"; // Color -@default-color : @theme-color; -@success-color : #34BFA3; -@warning-color : #FFE57F; -@error-color : #F4516C; -@disabled-color : #DEE2E6; -@selected-color : fade(@default-color, 90%); -@tooltip-color : #fff; -@subsidiary-color : #80848f; -@rate-star-color : #f5a623; +@default-color : @theme-color; +@success-color : #34BFA3; +@warning-color : #FFE57F; +@error-color : #F4516C; +@disabled-color : #DEE2E6; +@selected-color : fade(@default-color, 90%); +@tooltip-color : #fff; +@subsidiary-color : #80848f; +@rate-star-color : #f5a623; +@active-color : #333; // steps -@step-color : #C4C9D2; -@step-active-color : @theme-color; +@step-color : #C4C9D2; +@step-active-color : @theme-color; // Text -@title-color : #333; -@text-color : #888; +@title-color : #333; +@text-color : #888; // Background Color -@background-color-base : #f8f8f8; // base +@background-color-base : #f8f8f8; // base // Border color -@border-color-base : #dddee1; // outside -@border-color-split : #e9eaec; // inside +@border-color-base : #dddee1; // outside +@border-color-split : #e9eaec; // inside // Size -@size-grid-icon : 28rpx; -@size-font-base : 28rpx; -@size-font-mini : 24rpx; -@size-font-large : 32rpx; +@size-grid-icon : 28rpx; +@size-font-base : 28rpx; +@size-font-mini : 24rpx; +@size-font-large : 32rpx; // Button @btn-font-weight : normal; @@ -57,8 +58,8 @@ @btn-width : 180rpx; @btn-height-large : 88rpx; @btn-width-large : 710rpx; -@btn-height-mini : 60rpx; -@btn-width-mini : 140rpx; +@btn-height-mini : 60rpx; +@btn-width-mini : 140rpx; @btn-loading-color : #fff; @btn-circle-size : 40rpx; @btn-circle-size-mini : 30rpx; @@ -66,28 +67,28 @@ // icon -@icon-font-size : 32px; // 图标字体大小 默认 -@icon-font-size-large : 42px; // 图标字体大小 大号 -@icon-font-size-small : 22px; // 图标字体大小 小号 -@icon-font-color : #80848f; +@icon-font-size : 32px; // 图标字体大小 默认 +@icon-font-size-large : 42px; // 图标字体大小 大号 +@icon-font-size-small : 22px; // 图标字体大小 小号 +@icon-font-color : #80848f; // Avatar -@avatar-bg : #ccc; -@avatar-color : #fff; -@avatar-size-base : 32px; -@avatar-size-lg : 40px; -@avatar-size-sm : 24px; -@avatar-font-size-base : 18px; -@avatar-font-size-lg : 24px; -@avatar-font-size-sm : 14px; -@avatar-border-radius : @border-radius-small; -@border-radius-small : 4px; +@avatar-bg : #ccc; +@avatar-color : #fff; +@avatar-size-base : 32px; +@avatar-size-lg : 40px; +@avatar-size-sm : 24px; +@avatar-font-size-base : 18px; +@avatar-font-size-lg : 24px; +@avatar-font-size-sm : 14px; +@avatar-border-radius : @border-radius-small; +@border-radius-small : 4px; // Animation -@animation-time : .3s; -@transition-time : .2s; -@ease-in-out : ease-in-out; +@animation-time : .3s; +@transition-time : .2s; +@ease-in-out : ease-in-out; // Progress @progress-active-color : @theme-color; \ No newline at end of file diff --git a/config/styles/_mixins.less b/config/styles/_mixins.less index bac2dde9..796d15bc 100644 --- a/config/styles/_mixins.less +++ b/config/styles/_mixins.less @@ -12,4 +12,19 @@ pointer-events: none; box-sizing: border-box; border: 0 solid @border-color-split; +} + +.active() { + opacity: 0.15; + position: absolute; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + border: inherit; + border-radius: inherit; /* inherit parent's border radius */ + transform: translate(-50%, -50%); + content: ' '; + background-color: @active-color; + border-color: @active-color; } \ No newline at end of file diff --git a/dist/button/index.wxml b/dist/button/index.wxml index 81fba9c5..82159c9c 100644 --- a/dist/button/index.wxml +++ b/dist/button/index.wxml @@ -5,7 +5,7 @@ - + diff --git a/dist/button/index.wxss b/dist/button/index.wxss index da04df64..2597fc32 100644 --- a/dist/button/index.wxss +++ b/dist/button/index.wxss @@ -1 +1 @@ -.btn-hover{opacity:.8}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8;background-color:#dee2e6}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file +.btn-hover::before{opacity:.15;position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;transform:translate(-50%,-50%);content:' ';background-color:#333;border-color:#333}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/examples/dist/button/index.wxml b/examples/dist/button/index.wxml index 38b071a8..3738cc7c 100644 --- a/examples/dist/button/index.wxml +++ b/examples/dist/button/index.wxml @@ -6,7 +6,7 @@ Date: Mon, 1 Jun 2020 03:00:44 +0800 Subject: [PATCH 18/28] =?UTF-8?q?chore(TravisCI):=20=E6=96=B0=E5=A2=9E=20T?= =?UTF-8?q?ravisCI=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..6e58887f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +# 指定运行环境 +language: node_js +node_js: + - lts/* + +# 仅监控 master 分支 +branches: + except: + - master + +jobs: + include: + - name: "推送编译" + if: type = push AND branch = develop + install: yarn install + script: + - yarn build + - git config --global user.name "Juzi" + - git config --global user.email "juzi214032@qq.com" + - git add -A + - "git commit -m 'build: Travis CI automatic compilation.'" + - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" + - name: "检测编译" + if: type = pull_request + install: yarn install + script: yarn build From c5676f5358e72707a823c647dd23e81ee723f82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Mon, 1 Jun 2020 03:09:40 +0800 Subject: [PATCH 19/28] =?UTF-8?q?refactor(TravisCI):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20TravisCI=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e58887f..e2ee8af8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,17 +10,18 @@ branches: jobs: include: - - name: "推送编译" + - name: "Push Compile" if: type = push AND branch = develop install: yarn install script: - yarn build + - yarn dev - git config --global user.name "Juzi" - git config --global user.email "juzi214032@qq.com" - git add -A - "git commit -m 'build: Travis CI automatic compilation.'" - - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" - - name: "检测编译" + - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" develop + - name: "Check Compile" if: type = pull_request install: yarn install script: yarn build From 37ff8c749a055ab0258e16a83158bbd64f6ae998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Mon, 1 Jun 2020 17:39:58 +0800 Subject: [PATCH 20/28] =?UTF-8?q?fix(Form):=20=E4=BF=AE=E5=A4=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E8=A7=84=E5=88=99=20required=20=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在同时使用 type 和 required 校验时,required会无效 原因:使用的第三方库 async-validator 仅在值为 undefined 时才不会进行类型(type)校验 空字符串也会进行类型(type)校验,所以会校验不通过 close #856 --- src/behaviors/rules.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/behaviors/rules.js b/src/behaviors/rules.js index e64244f0..ef36085b 100644 --- a/src/behaviors/rules.js +++ b/src/behaviors/rules.js @@ -1,5 +1,6 @@ import Schema from '../common/async-validator/index'; import validator from '../behaviors/validator'; + /** * @param tipType String [toast , message , text] */ @@ -40,16 +41,16 @@ export default Behavior({ } = this.data; if (!rules) return; // 如果rule 是单个object - if(Object.prototype.toString.call(rules) === '[object Object]') { + if (Object.prototype.toString.call(rules) === '[object Object]') { this.data.rules = [rules]; } this.data.rules.forEach(item => { - if(!item.trigger) { + if (!item.trigger) { item.trigger = []; return; } - if(typeof item.trigger === 'string') { + if (typeof item.trigger === 'string') { item.trigger = [item.trigger]; return; } @@ -69,7 +70,7 @@ export default Behavior({ const list = type ? rules.filter(item => { return item.trigger.indexOf(type) > -1; - }): rules; + }) : rules; const schema = new Schema({ [rulesName]: list, }); @@ -88,6 +89,14 @@ export default Behavior({ if (!rules) return; + // 把空字符串设置为 undefined ,见 issue 856 + // async-validator 对空字符串会进行类型检查,与required会冲突 + Object.getOwnPropertyNames(value).forEach((key) => { + if (value[key] === '') { + value[key] = undefined + } + }) + this.data.schema.validate(value, (errors) => { this.setData({ errors: errors || [] From a6531e3d7ad14fec8cdbc3ace4d3da4af2c5f71a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Mon, 1 Jun 2020 18:19:19 +0800 Subject: [PATCH 21/28] =?UTF-8?q?refactor(TravisCI):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20TravisCI=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2ee8af8..b6bb17f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,14 +14,17 @@ jobs: if: type = push AND branch = develop install: yarn install script: - - yarn build - yarn dev - - git config --global user.name "Juzi" - - git config --global user.email "juzi214032@qq.com" + - yarn build + after_success: + - git config --global user.name "Deployment Bot" + - git config --global user.email "deploy@travis-ci.org" - git add -A - "git commit -m 'build: Travis CI automatic compilation.'" - - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" develop + - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" HEAD:develop - name: "Check Compile" if: type = pull_request install: yarn install - script: yarn build + script: + - yarn dev + - yarn build From dde4636f1775ee46aad1297dc9bf290daba8943a Mon Sep 17 00:00:00 2001 From: Deployment Bot Date: Mon, 1 Jun 2020 10:21:25 +0000 Subject: [PATCH 22/28] build: Travis CI automatic compilation. --- dist/behaviors/rules.js | 2 +- dist/checkbox-group/index.js | 2 +- dist/progress/index.js | 2 +- dist/utils/data-util.js | 1 - dist/utils/event-util.js | 1 - dist/utils/eventBus.js | 1 - dist/utils/node-util.js | 1 - dist/utils/pixel-util.js | 1 - dist/utils/wxml-util.js | 1 - examples/dist/behaviors/rules.js | 17 +++++-- examples/dist/utils/data-util.js | 25 ---------- examples/dist/utils/event-util.js | 12 ----- examples/dist/utils/eventBus.js | 78 ------------------------------- examples/dist/utils/node-util.js | 38 --------------- examples/dist/utils/pixel-util.js | 33 ------------- examples/dist/utils/wxml-util.js | 38 --------------- 16 files changed, 16 insertions(+), 237 deletions(-) delete mode 100644 dist/utils/data-util.js delete mode 100644 dist/utils/event-util.js delete mode 100644 dist/utils/eventBus.js delete mode 100644 dist/utils/node-util.js delete mode 100644 dist/utils/pixel-util.js delete mode 100644 dist/utils/wxml-util.js delete mode 100644 examples/dist/utils/data-util.js delete mode 100644 examples/dist/utils/event-util.js delete mode 100644 examples/dist/utils/eventBus.js delete mode 100644 examples/dist/utils/node-util.js delete mode 100644 examples/dist/utils/pixel-util.js delete mode 100644 examples/dist/utils/wxml-util.js diff --git a/dist/behaviors/rules.js b/dist/behaviors/rules.js index e13efe04..200caf39 100644 --- a/dist/behaviors/rules.js +++ b/dist/behaviors/rules.js @@ -1 +1 @@ -import Schema from"../common/async-validator/index";import validator from"../behaviors/validator";export default Behavior({behaviors:[validator],properties:{rules:{type:[Object,Array],value:[]},tipType:{type:String,value:"toast",options:["toast","message","text"]}},data:{schema:"",tipFun:{message:"showMessage",toast:"showToast"},tipContent:{message:"content",toast:"title"},errorText:"",errors:[]},methods:{initRules(){const{rules:t}=this.data;t&&("[object Object]"===Object.prototype.toString.call(t)&&(this.data.rules=[t]),this.data.rules.forEach(t=>{t.trigger?"string"!=typeof t.trigger||(t.trigger=[t.trigger]):t.trigger=[]}))},getNeedValidateRule(t){const e=this.data.name,{rules:a}=this.data;if(!a)return;const r=t?a.filter(e=>e.trigger.indexOf(t)>-1):a,s=new Schema({[e]:r});return this.setData({schema:s}),r},validatorData(t,e){const{tipType:a,tipFun:r,tipContent:s}=this.data;this.getNeedValidateRule(e)&&this.data.schema.validate(t,t=>{if(this.setData({errors:t||[]}),this.triggerEvent("linvalidate",{errors:t,isError:!!t}),t&&a){const e=r[a],i=s[a];return"text"===a?(this.setData({errorText:t[0].message}),t):wx.lin&&wx.lin[e]?(wx.lin[e]&&wx.lin[e]({[i]:t[0].message,duration:1500,mask:!1}),t):(wx.showToast({icon:"none",title:`请在页面内引入${a}组件`}),t)}!t&&a&&this.setData({errorText:""})})}}}); \ No newline at end of file +import Schema from"../common/async-validator/index";import validator from"../behaviors/validator";export default Behavior({behaviors:[validator],properties:{rules:{type:[Object,Array],value:[]},tipType:{type:String,value:"toast",options:["toast","message","text"]}},data:{schema:"",tipFun:{message:"showMessage",toast:"showToast"},tipContent:{message:"content",toast:"title"},errorText:"",errors:[]},methods:{initRules(){const{rules:t}=this.data;t&&("[object Object]"===Object.prototype.toString.call(t)&&(this.data.rules=[t]),this.data.rules.forEach(t=>{t.trigger?"string"!=typeof t.trigger||(t.trigger=[t.trigger]):t.trigger=[]}))},getNeedValidateRule(t){const e=this.data.name,{rules:a}=this.data;if(!a)return;const r=t?a.filter(e=>e.trigger.indexOf(t)>-1):a,s=new Schema({[e]:r});return this.setData({schema:s}),r},validatorData(t,e){const{tipType:a,tipFun:r,tipContent:s}=this.data;this.getNeedValidateRule(e)&&(Object.getOwnPropertyNames(t).forEach(e=>{""===t[e]&&(t[e]=void 0)}),this.data.schema.validate(t,t=>{if(this.setData({errors:t||[]}),this.triggerEvent("linvalidate",{errors:t,isError:!!t}),t&&a){const e=r[a],i=s[a];return"text"===a?(this.setData({errorText:t[0].message}),t):wx.lin&&wx.lin[e]?(wx.lin[e]&&wx.lin[e]({[i]:t[0].message,duration:1500,mask:!1}),t):(wx.showToast({icon:"none",title:`请在页面内引入${a}组件`}),t)}!t&&a&&this.setData({errorText:""})}))}}}); \ No newline at end of file diff --git a/dist/checkbox-group/index.js b/dist/checkbox-group/index.js index ece05a24..65474516 100644 --- a/dist/checkbox-group/index.js +++ b/dist/checkbox-group/index.js @@ -1 +1 @@ -import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){return this._selected={},this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file +import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){this._selected={};return this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}}); \ No newline at end of file diff --git a/dist/progress/index.js b/dist/progress/index.js index dd94aad2..3894e649 100644 --- a/dist/progress/index.js +++ b/dist/progress/index.js @@ -1 +1 @@ -import{px2rpx}from"../utils/util.js";import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-text-class","l-active-class","l-background-class"],behaviors:[validator],properties:{percent:{type:Number,value:0},strokeWidth:{type:Number,value:12},borderRadius:{type:Number,value:6},activeColor:{type:String},backgroundColor:{type:String,value:"#EBEBEB"},showInfo:{type:Boolean,value:!1},textPosition:{type:String,value:"right",options:["left","right"]},textColor:{type:String},interval:{type:Number,value:20},active:{type:Boolean,value:!1},duration:{type:Number,value:30}},options:{multipleSlots:!0,pureDataPattern:/^_/},data:{_slotWidth:0,_slotHeight:0,_progressWidth:0,_progressHeight:0,_marginBottom:0,marginLeft:0,marginTop:0,_useSlot:!1},observers:{"_slotWidth, _slotHeight, _progressWidth, _progressHeight, percent,_useSlot":function(t,e,r,i,s,a){if(a){const a=-(e-i)/2,o=(r-t)*s/100;this.setData({marginTop:a,marginLeft:o})}}},lifetimes:{attached(){this.data.percent>100&&this.setData({percent:100}),wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec(),wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{e100&&this.setData({percent:100});wx.createSelectorQuery().in(this).select(".slot").boundingClientRect(t=>{let e=this.data._useSlot;t.width&&(e=!0),this.setData({_useSlot:e,_slotWidth:px2rpx(t.width),_slotHeight:px2rpx(t.height)})}).exec();wx.createSelectorQuery().in(this).select(".progress").boundingClientRect(t=>{this.setData({_progressHeight:px2rpx(t.height),_progressWidth:px2rpx(t.width)})}).exec();const t=this.data.percent;let e=0;this.data.active&&setInterval(()=>{e{t.data[s]!==a[s]&&(e[s]=a[s])}),Object.keys(e).length&&t.setData(e)}}const dataUtil=new DataUtil;export default dataUtil; \ No newline at end of file diff --git a/dist/utils/event-util.js b/dist/utils/event-util.js deleted file mode 100644 index 65d6890e..00000000 --- a/dist/utils/event-util.js +++ /dev/null @@ -1 +0,0 @@ -class EventUtil{emit(e,t,l){e.triggerEvent(t,l,{bubbles:!0,composed:!0,capturePhase:!0})}}const eventUtil=new EventUtil;export default eventUtil; \ No newline at end of file diff --git a/dist/utils/eventBus.js b/dist/utils/eventBus.js deleted file mode 100644 index 5307356a..00000000 --- a/dist/utils/eventBus.js +++ /dev/null @@ -1 +0,0 @@ -let EventBus=function(){};var objBus=[],arrBus=[];EventBus.prototype={obj:{set:function(r,u){if(r&&u){var n={};n.k=r,n.v=u;for(var t=0,s=objBus.length;t{r()})},on:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},arr:{push:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},pop:function(r){if(r)for(var u=0,n=arrBus.length;u{e.createSelectorQuery().select(t).boundingClientRect(e=>{n(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(n=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil; \ No newline at end of file diff --git a/dist/utils/pixel-util.js b/dist/utils/pixel-util.js deleted file mode 100644 index 7b6e2707..00000000 --- a/dist/utils/pixel-util.js +++ /dev/null @@ -1 +0,0 @@ -class PixelUtil{constructor(t){this.systemInfo=t}px2rpx(t){return 750/this.systemInfo.screenWidth*t}rpx2px(t){return t/750*this.systemInfo.screenWidth}}const pixelUtil=new PixelUtil(wx.getSystemInfoSync());export default pixelUtil; \ No newline at end of file diff --git a/dist/utils/wxml-util.js b/dist/utils/wxml-util.js deleted file mode 100644 index 0f474645..00000000 --- a/dist/utils/wxml-util.js +++ /dev/null @@ -1 +0,0 @@ -class WxmlUtil{async getNodeRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{l(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(l=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{l(e)}).exec()})}}const wxmlUtil=new WxmlUtil;export default wxmlUtil; \ No newline at end of file diff --git a/examples/dist/behaviors/rules.js b/examples/dist/behaviors/rules.js index e64244f0..ef36085b 100644 --- a/examples/dist/behaviors/rules.js +++ b/examples/dist/behaviors/rules.js @@ -1,5 +1,6 @@ import Schema from '../common/async-validator/index'; import validator from '../behaviors/validator'; + /** * @param tipType String [toast , message , text] */ @@ -40,16 +41,16 @@ export default Behavior({ } = this.data; if (!rules) return; // 如果rule 是单个object - if(Object.prototype.toString.call(rules) === '[object Object]') { + if (Object.prototype.toString.call(rules) === '[object Object]') { this.data.rules = [rules]; } this.data.rules.forEach(item => { - if(!item.trigger) { + if (!item.trigger) { item.trigger = []; return; } - if(typeof item.trigger === 'string') { + if (typeof item.trigger === 'string') { item.trigger = [item.trigger]; return; } @@ -69,7 +70,7 @@ export default Behavior({ const list = type ? rules.filter(item => { return item.trigger.indexOf(type) > -1; - }): rules; + }) : rules; const schema = new Schema({ [rulesName]: list, }); @@ -88,6 +89,14 @@ export default Behavior({ if (!rules) return; + // 把空字符串设置为 undefined ,见 issue 856 + // async-validator 对空字符串会进行类型检查,与required会冲突 + Object.getOwnPropertyNames(value).forEach((key) => { + if (value[key] === '') { + value[key] = undefined + } + }) + this.data.schema.validate(value, (errors) => { this.setData({ errors: errors || [] diff --git a/examples/dist/utils/data-util.js b/examples/dist/utils/data-util.js deleted file mode 100644 index 853b7067..00000000 --- a/examples/dist/utils/data-util.js +++ /dev/null @@ -1,25 +0,0 @@ -class DataUtil { - /** - * 设置差异数据 - * @param component - * @param data - */ - setDiffData(component, data) { - const diffData = {} - - // 遍历获取到有差异的数据 - Object.keys(data).forEach(key => { - if (component.data[key] !== data[key]) { - diffData[key] = data[key] - } - }) - - // 设置数据 - if (Object.keys(diffData).length) { - component.setData(diffData) - } - } -} - -const dataUtil = new DataUtil -export default dataUtil diff --git a/examples/dist/utils/event-util.js b/examples/dist/utils/event-util.js deleted file mode 100644 index 44caea7e..00000000 --- a/examples/dist/utils/event-util.js +++ /dev/null @@ -1,12 +0,0 @@ -class EventUtil { - emit(component, eventName, detail) { - component.triggerEvent(eventName, detail, { - bubbles: true, - composed: true, - capturePhase: true - }) - } -} - -const eventUtil = new EventUtil() -export default eventUtil diff --git a/examples/dist/utils/eventBus.js b/examples/dist/utils/eventBus.js deleted file mode 100644 index 53e483df..00000000 --- a/examples/dist/utils/eventBus.js +++ /dev/null @@ -1,78 +0,0 @@ -//创建EventBus对象 -let EventBus = function () {}; -//准备数组容器 -var objBus = [], arrBus = []; -//添加方法 -EventBus.prototype = { - obj: { - set: function (key, action) { - if (key && action) { - var map = {}; - map.k = key; - map.v = action; - //如果存在,则删除之前添加的事件 - for (var i = 0, busLength = objBus.length; i < busLength; i++) { - var tempMap = objBus[i]; - if (tempMap.k === key) { - objBus.splice(i, 1); - } - } - objBus.push(map); - } - }, - get: function (key) { - if (key) { - for (var i = 0, busLength = objBus.length; i < busLength; i++) { - var map = objBus[i]; - if (map.k === key) { - return map.v(); - } - } - } - } - }, - emit: function (key, data) { - if (key) { - for (var i = 0, busLength = arrBus.length; i < busLength; i++) { - var map = arrBus[i]; - if (map.k === key) { - return map.v(data); - } - } - } - return new Promise((resolve) => { resolve();}); - }, - on: function (key, action) { - if (key && action) { - var map = {}; - map.k = key; - map.v = action; - arrBus.push(map); - } - }, - arr: { - push: function (key, action) { - if (key && action) { - var map = {}; - map.k = key; - map.v = action; - arrBus.push(map); - } - }, - pop: function (key) { - if (key) { - for (var i = 0, busLength = arrBus.length; i < busLength; i++) { - var map = arrBus[i]; - if (map.k === key) { - map.v(); - } - } - } - } - } -}; -var eventBus = new EventBus(); -export default eventBus; -// module.exports = { -// eventBus: eventBus -// } diff --git a/examples/dist/utils/node-util.js b/examples/dist/utils/node-util.js deleted file mode 100644 index a90415c0..00000000 --- a/examples/dist/utils/node-util.js +++ /dev/null @@ -1,38 +0,0 @@ -class NodeUtil { - /** - * 获取组件内部节点位置信息(单个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodeRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .select(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } - - /** - * 获取组件内部节点位置信息(多个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodesRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .selectAll(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } -} - -const nodeUtil = new NodeUtil() -export default nodeUtil diff --git a/examples/dist/utils/pixel-util.js b/examples/dist/utils/pixel-util.js deleted file mode 100644 index 51b55ceb..00000000 --- a/examples/dist/utils/pixel-util.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 像素工具 - */ -class PixelUtil { - /** - * 构造函数 - * @param systemInfo 设备信息 - */ - constructor(systemInfo) { - this.systemInfo = systemInfo - } - - /** - * px 转 rpx - * @param pxNumber px数值 - * @returns {number} rpx数值 - */ - px2rpx(pxNumber) { - return (750 / this.systemInfo.screenWidth) * pxNumber - } - - /** - * rpx 转 px - * @param rpxNumber rpx数值 - * @returns {number} px数值 - */ - rpx2px(rpxNumber){ - return (rpxNumber / 750) * this.systemInfo.screenWidth - } -} - -const pixelUtil = new PixelUtil(wx.getSystemInfoSync()) -export default pixelUtil diff --git a/examples/dist/utils/wxml-util.js b/examples/dist/utils/wxml-util.js deleted file mode 100644 index bca64b23..00000000 --- a/examples/dist/utils/wxml-util.js +++ /dev/null @@ -1,38 +0,0 @@ -class WxmlUtil { - /** - * 获取组件内部节点位置信息(单个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodeRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .select(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } - - /** - * 获取组件内部节点位置信息(多个) - * @param component 组件实例 - * @param selector {String} css选择器 - * @returns boundingClientRect() 回调函数的值 - */ - async getNodesRectFromComponent(component, selector) { - return await new Promise((resolve) => { - component - .createSelectorQuery() - .selectAll(selector) - .boundingClientRect((res) => { - resolve(res) - }).exec() - }) - } -} - -const wxmlUtil = new WxmlUtil() -export default wxmlUtil From 661c328b322230a18795dfcbf2f703e944cccfce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Mon, 1 Jun 2020 18:32:59 +0800 Subject: [PATCH 23/28] =?UTF-8?q?refactor(TravisCI):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20TravisCI=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b6bb17f0..1e8a8ae3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,9 @@ jobs: - name: "Push Compile" if: type = push AND branch = develop install: yarn install + before_script: + - rm -rf dist + - rm -rf examples/dist script: - yarn dev - yarn build @@ -20,7 +23,7 @@ jobs: - git config --global user.name "Deployment Bot" - git config --global user.email "deploy@travis-ci.org" - git add -A - - "git commit -m 'build: Travis CI automatic compilation.'" + - "git commit -m 'build: Travis CI automatic compilation'" - git push "https://juzi214032:${GITHUB_TOKEN}@github.com/TaleLin/lin-ui" HEAD:develop - name: "Check Compile" if: type = pull_request From 9a5f152601caef54e67ed6e2ccf089aaae112d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Sat, 30 May 2020 20:09:39 +0800 Subject: [PATCH 24/28] =?UTF-8?q?refactor(IndexList):=20=E6=89=A9=E5=A4=A7?= =?UTF-8?q?=20Sidebar=20=E8=A7=A6=E6=8E=A7=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除 Sidebar 样式 width,扩大 Sidebar 触控区域 --- dist/index-list/index.wxss | 2 +- examples/dist/index-list/index.wxss | 2 +- src/index-list/index.less | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dist/index-list/index.wxss b/dist/index-list/index.wxss index 9b5ddd9a..aaecbd06 100644 --- a/dist/index-list/index.wxss +++ b/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/examples/dist/index-list/index.wxss b/examples/dist/index-list/index.wxss index 9b5ddd9a..aaecbd06 100644 --- a/examples/dist/index-list/index.wxss +++ b/examples/dist/index-list/index.wxss @@ -1 +1 @@ -.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;width:20rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file +.index-list .sidebar{font-size:24rpx;position:fixed;right:30rpx;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center}.index-list .sidebar-item{width:40rpx;height:40rpx;border-radius:50%;display:flex;justify-content:center;align-items:center;margin-top:8rpx}.index-list .sidebar-item-active{color:#fff;background-color:#3963bc}.index-list .tip{width:90rpx;height:90rpx;background-color:#d8d8d8;border-radius:90px 90px 0;display:flex;justify-content:center;align-items:center;position:absolute;left:-160rpx;transform:rotate(-45deg) translateY(-35%)}.index-list .tip-text{font-size:30rpx;transform:rotate(45deg)} \ No newline at end of file diff --git a/src/index-list/index.less b/src/index-list/index.less index 3dd68028..f841edc6 100644 --- a/src/index-list/index.less +++ b/src/index-list/index.less @@ -6,7 +6,6 @@ font-size: 24rpx; position: fixed; right: 30rpx; - width: 20rpx; top: 50%; transform: translateY(-50%); display: flex; From 358e687ada49fef1da5b2bc435f14587ac156c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Wed, 3 Jun 2020 12:20:42 +0800 Subject: [PATCH 25/28] =?UTF-8?q?fix(Input):=20=E4=BF=AE=E5=A4=8D=20width?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于width属性名写错,导致width不生效 由于属性设置为 750rpx,导致 Input 样式在很多情况下不正确 close #860,#744 --- src/input/index.js | 4 ++-- src/input/index.less | 2 -- src/input/index.wxml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/input/index.js b/src/input/index.js index c263721c..82a1e8b6 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -48,8 +48,8 @@ Component({ }, // 表单项的宽度,单位rpx width: { - type: Number, - value: 750 + type: String, + value: 'auto' }, // 表单项标题部分的宽度,单位rpx labelWidth: { diff --git a/src/input/index.less b/src/input/index.less index c36ae74e..4d2a7883 100644 --- a/src/input/index.less +++ b/src/input/index.less @@ -4,9 +4,7 @@ position: relative; font-size: 28rpx; color: #333; - width: 750rpx; height: 88rpx; - // background: #f6f6f6; display: flex; flex-direction: row; align-items: center; diff --git a/src/input/index.wxml b/src/input/index.wxml index b5ec78a4..989f4e5b 100644 --- a/src/input/index.wxml +++ b/src/input/index.wxml @@ -1,7 +1,7 @@ diff --git a/examples/pages/components/layout/pages/index-list/util.wxs b/examples/pages/components/layout/pages/index-list/util.wxs deleted file mode 100644 index b5eea5cc..00000000 --- a/examples/pages/components/layout/pages/index-list/util.wxs +++ /dev/null @@ -1,57 +0,0 @@ -var nameData = [ - '顾拍', '于第', '黄害等', '彭付', '戚转', '屈见', '酆经', '殷乡杰', '苗清', '郝育号', '姜算', '卜非', '舒经屋', '平止', '茅农词', - '伏伦语', '杨级', '卞舞', '孔再肯', '孟游副', '鲁击', '钱皇', '屈平', '严水', '于挥归', '范娘具', '沈承', '贝景华', '王吃暗', '花妻', - '岑应假', '陈编', '韩除找', '平言待', '葛官烈', '章春木', '董参', '茅玩真', '于吧合', '郑门板', '唐够买', '柳得', '秦感母', '何劳调', - '禹岁台', '史未', '卫维气', '屈让', '周歌', '堪贝', '孙中管', '谢劳亲', '雷问授', '施臓托', '奚金', '韦场考', '汪武不', '王流', '伏精', - '庞乾', '沈众转', '孟仍', '明视', '唐骨', '吴汉', '彭牙收', '邵块贝', '乐拥', '臧干', '纪合还', '萧呼', '王降孤', '黄席', '堪派', - '陈更封', '祁喜宣', '屈吃', '邹几己', '陶几又', '费管', '柳贝', '罗罗', '明帝', '乐盖', '许遍胡', '杨报', '项进', '尤失靠', '谈苏', - '计记', '伍反', '顾革', '严顿越', '姚布去', '郎七', '狄何正', '茅规', '金校付', '华友', '苗心模', '臧志印', '鲍练遍', '倪方品', '魏反友', - '汪脚', '熊帝毕', '蒋球', '蒋绝', '祝往', '禹管里', '章任勒', '窦喊街', '倪王室', '臧智含', '时房九', '倪佛乱', '鲁划真', '云无系', - '董创', '皮反秘', '俞因婚', '纪雨动', '窦系困', '窦朋密', '袁常供', '沈拥', '屈小', '邹护坦', '褚暗', '潘量吗', '褚优五', '陶船', '孔更', - '潘某', '皮最恋', '伏任广', '周短尽', '鲍终', '彭声农', '谢适银', '毛屋印', '屈吉职', '何微', '贝余获', '卜门男', '韩贝钟', '平自毕', - '花热阳', '孟越', '萧四', '滕朋', '卜句', '云可', '喻剧', '汤雷', '陶棋式', '戴至备', '冯程四', '蒋河', '茅车', '熊临', '狄遍品', - '沈汽没', '邬激历', '郎简都', '赵罪况', '计运', '凤钟', '周只多', '康饭', '曹阵快', '史示其', '苗句', '汪上', '任加呀', '傅很', '花还', - '茅医', '苏一', '王纳', '姜吗', '禹七', '乐按林', '倪呀岁', '郎最更', '祁终', '昌脸势', '禹土', '纪将', '屈然', '杨泪', '赵总', - '和忘毛', '廉于熟', '奚村四', '周得', '邹谁', '伏准景', '卞善师', '史那艺', '吕什用', '马那', '尤送冷', '郝然听', '平道', '贝诉', '马玩', - '窦翻自', '云话助', '韩痛', '毕登', '韩怕半', '喻渐', '鲍快', '柳九许', '云释', '葛每党', '成乡', '卜阵力', '祝换请', '花九木', '章吃', - '倪诺', '鲍程朋', '柏思退', '卞书接', '史阳', '邵已没', '米说', '董意', '罗列曾', '明雄', '施寻', '纪境', '葛通', '陈伊', '柏迷谁', - '赵坚', '傅算', '云这', '薛笑', '顾鸟', '贺战', '奚第', '成在基', '柳玩由', '凤諣', '和叫', '戚哪', '潘字', '毛诉声', '何两展', - '朱最', '韦律拥', '卞套黑', '赵万', '王卡', '伏神条', '宋罪', '唐至', '韦紧', '姚天', '傅合', '张伊供', '张激见', '史武', '贝留身', - '金离', '潘旧娘', '屈越', '褚类', '倪确', '堪定', '常验大', '韩招陈', '傅雄', '许费算', '元对', '尹到', '卞富又', '齐么越', '伍害查', - '韦否', '韩胡', '云习', '时值带', '孔应收', '顾派点', '魏叫旧', '韩斗', '袁佛', '钱笔', '任眼余', '雷普皇', '柏美我', '祝存', '罗时层', - '沈吃妙', '史鲁', '郑叶冰', '舒睛欢', '尤越', '祁准', '毕写得', '严行', '孙城', '水妈', '何复', '奚边', '奚奥除', '戚刻', '尹亚', - '尹救', '岑示显', '蒋进', '岑迹菜', '康又', '滕遍', '方降坤', '李座岛', '沈简区', '水料准', '伏以', '安黑东', '韦节', '元低', '水群够', - '于击谢', '鲁稜', '沈哪的', '史向色', '狄只', '常官论', '喻研慢', '何座收', '伍费次', '康却脸', '宋超', '傅雷', '毛想高', '庞奖', - '贺佛使', '项下战', '奚起精', '章朝跟', '柳公', '尤际病', '周象林', '许圣', '周早专', '时节题', '姜到妙', '彭杰建', '齐走技', '常响处', - '庞派领', '庞玛是', '酆外劳', '陈放', '褚东随', '邵统', '朱也束', '秦会甚', '贝争听', '廉民满', '酆建', '韩保诉', '项森', '戚片巴', - '华海州', '鲁叶够', '项条', '时鸟', '凤鱼众', '项字', '梁见', '计冲', '秦趣', '贺统', '和向', '陈集', '陶察总', '潘松旧', '方当', - '葛待近', '姜数', '云史变', '褚雪室', '皮易', '苗动回', '薛黄阿', '毕火阳', '鲁余采', '朱手托', '平健', '施曾抱', '时容巨', '臧引', - '萧姆', '伍足', '梁致', '倪仍', '孔山日', '唐摇', '茅演', '祁大', '梁困脚', '常起放', '邵康', '吕世', '凤节', '岑百试', '苏收既', - '昌担纸', '纪则', '柳考', '郎群招', '毕费', '任夏', '康超', '毛干雨', '酆哪典', '雷然朋', '成站报', '伏生', '戴公', '苏授', '宋懂越', - '戴枪', '李看姆', '吴须', '朱指', '堪影责', '水烧广', '奚员山', '贺那', '朱五', '赵少莱', '殷给些', '庞莱规', '顾说务', '钱社', '凤编', - '倪台长', '余村负', '华数', '项量', '庞剧万', '邹毕古', '章雪约', '穆商美', '祁骨', '杨么', '伏住赛', '鲁居坤', '马枪', '凤养产', - '邵白地', '钱许', '喻到坐', '褚纳压', '汤亮', '喻维', '舒书', '褚看', '张主博', '邬论近', '余馆领', '张将休', '米赶', '成周', '黄激士', - '倪生男', '元第价', '何黑', '张草程', '狄刘灵', '苗演', '朱双或', '邵顶', '施馆究', '郝除市', '邹种', '卜临', '钱听因', '伏依托', '于祖', - '倪财国', '穆香', '许份并', '蒋几', '常社', '施朋', '赵东', '宋验玛', '钱急忘', '邹产' -]; - -var apiArray = [ - 'https://api.66mz8.com/api/rand.portrait.php?type=%E5%8A%A8%E6%BC%AB', - 'https://api.uomg.com/api/rand.avatar?', - 'https://api.sunweihu.com/api/sjtx/api.php?' -] - -// 获取昵称 -var assignName = function (index) { - return nameData[index]; -} - -// 获取头像api -var getApi = function(index){ - return apiArray[index]; -} - -module.exports = { - assignName: assignName, - getApi:getApi -} From 976ff7bd29fb51f7d2cd5db8e0604e69255423e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Thu, 4 Jun 2020 22:12:45 +0800 Subject: [PATCH 28/28] =?UTF-8?q?chore(package.json):=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E5=88=B0=200.8.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96c2208f..073914ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lin-ui", - "version": "0.8.1", + "version": "0.8.2", "description": "A high quality UI components library with MiniProgram", "main": "app.js", "directories": {