diff --git a/README.md b/README.md index bbd16fb9..b7fbd7fc 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@
![](https://img.shields.io/badge/build-passing-00d508.svg) -![](https://img.shields.io/badge/version-0.5.12-3963bc.svg) +![](https://img.shields.io/badge/version-0.5.13-3963bc.svg) ![](https://img.shields.io/badge/license-MIT-3963bc.svg)
@@ -39,7 +39,7 @@ Lin UI 是基于 **微信小程序原生语法** 实现的组件库。遵循简 ## 最新版本 -核心库:0.5.12 +核心库:0.5.13 示例工程:0.0.1-alpha.2 diff --git a/build/build-prod.js b/build/build-prod.js index 596f555e..e8613165 100644 --- a/build/build-prod.js +++ b/build/build-prod.js @@ -13,7 +13,6 @@ gulp.task('dispose-js', () => { .pipe(gulp.dest('../dist/')); }); - gulp.task('dispose-wxss', () => { const path = isCustom ? `../src/${result}/*.less` : '../src/**/*.less', remainPath = isCustom ? `!../src/${result}/_*.less` : '!../src/**/_*.less'; diff --git a/config/component.json b/config/component.json index 03c93db7..026b5e89 100644 --- a/config/component.json +++ b/config/component.json @@ -1,5 +1,3 @@ { - "components": [ - - ] + "components": [] } diff --git a/dist/action-sheet/index.js b/dist/action-sheet/index.js index 7ab61bcf..74f969e0 100644 --- a/dist/action-sheet/index.js +++ b/dist/action-sheet/index.js @@ -87,7 +87,7 @@ Component({ success } = this.data; success && success({ ...e.currentTarget.dataset }); - this.triggerEvent('linitemtap', { ...e.currentTarget.dataset }); + this.triggerEvent('linitemtap', { ...e.currentTarget.dataset },{ bubbles: true, composed: true }); this._hideActionSheet(); }, @@ -112,7 +112,7 @@ Component({ }); this.triggerEvent('lincancel', { errMsg: 'showactionsheet:fail cancel' - }); + },{ bubbles: true, composed: true }); this._hideActionSheet(); }, diff --git a/dist/badge/index.js b/dist/badge/index.js index a1275d86..09721a18 100644 --- a/dist/badge/index.js +++ b/dist/badge/index.js @@ -1,5 +1,5 @@ Component({ - externalClasses: ['l-class','l-class-self'], + externalClasses: ['l-class', 'l-class-self'], properties: { // 红点模式 dot: { @@ -32,32 +32,34 @@ Component({ // 最终数字 finalCount() { switch (this.data.countType) { - case 'overflow': - this.setData({ - finalCount: parseInt(this.data.count) >= parseInt(this.data.maxCount) ? `${this.data.maxCount}+` : this.data.count - }); - break; - case 'ellipsis': - this.setData({ - finalCount: parseInt(this.data.count) >= parseInt(this.data.maxCount) ? `...` : this.data.count - }); - break; - case 'limit': - this.setData({ - finalCount: parseInt(this.data.count) >= 999 ? (parseInt(this.data.count) >= 9999 ? Math.floor(this.data.count / 10000 * 100) / 100 + `w` : Math.floor(this.data.count / 1000 * 100) / 100 + `k`) : this.data.count - }) - break; - default: - this.setData({ - finalCount: parseInt(this.data.count) - }) - break; + case 'overflow': + this.setData({ + finalCount: parseInt(this.data.count) >= parseInt(this.data.maxCount) ? `${this.data.maxCount}+` : this.data.count + }); + break; + case 'ellipsis': + this.setData({ + finalCount: parseInt(this.data.count) >= parseInt(this.data.maxCount) ? `...` : this.data.count + }); + break; + case 'limit': + this.setData({ + finalCount: parseInt(this.data.count) >= 999 ? (parseInt(this.data.count) >= 9999 ? Math.floor(this.data.count / 10000 * 100) / 100 + `w` : Math.floor(this.data.count / 1000 * 100) / 100 + `k`) : this.data.count + }); + break; + default: + this.setData({ + finalCount: parseInt(this.data.count) + }); + break; } }, // 点击事件 handleTap() { - this.triggerEvent('lintap'); - this.triggerEvent('lintapcatch', {}, { bubbles: true }); + this.triggerEvent('lintap', {}, { + bubbles: true, + composed: true + }); }, } }); \ No newline at end of file diff --git a/dist/button/index.js b/dist/button/index.js index dfb4f0e2..5ed9c3a4 100644 --- a/dist/button/index.js +++ b/dist/button/index.js @@ -32,10 +32,11 @@ Component({ value: false, }, // 微信原生接口 - width:Number, - height:Number, + width: Number, + height: Number, icon: String, image: String, + bgColor: String, iconStyle: { type: String, value: 'size:20;color:#3683D6' @@ -68,8 +69,10 @@ Component({ // button点击事件 handleTap() { if (this.data.disabled) return false; - this.triggerEvent('lintap'); - this.triggerEvent('lintapcatch',{},{ bubbles: true }); + this.triggerEvent('lintap', {}, { + bubbles: true, + composed: true + }); }, // 开放能力事件回调 openTypeEvent(data) { diff --git a/dist/button/index.wxml b/dist/button/index.wxml index 2a915345..7bfb7c5a 100644 --- a/dist/button/index.wxml +++ b/dist/button/index.wxml @@ -10,7 +10,7 @@ hover-stop-propagation="{{hoverStopPropagation}}" hover-start-time="{{hoverStartTime}}" hover-stay-time="{{hoverStayTime}}" - style="{{width?'min-width:'+width+'rpx;':''}} {{height?'height:'+height+'rpx;'+'line-height:'+height+'rpx;':''}} {{size=='long'?'border-radius:0':''}}"> + style="{{width?'min-width:'+width+'rpx;':''}} {{height?'height:'+height+'rpx;'+'line-height:'+height+'rpx;':''}} {{size=='long'?'border-radius:0;':''}} {{'background-color:'+bgColor}}"> diff --git a/dist/card/index.js b/dist/card/index.js index 0f4226fe..b3d16fbe 100644 --- a/dist/card/index.js +++ b/dist/card/index.js @@ -35,4 +35,4 @@ Component({ methods: { } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/dist/count-selector/index.js b/dist/count-selector/index.js index f7dfe4ac..4a5e110e 100644 --- a/dist/count-selector/index.js +++ b/dist/count-selector/index.js @@ -1,7 +1,7 @@ Component({ externalClasses: [ - 'l-class', - 'l-symbol-class', + 'l-class', + 'l-symbol-class', 'l-count-class', 'l-disabled-class' ], @@ -41,67 +41,76 @@ Component({ onBlur(e) { let { value - } = e.detail + } = e.detail; setTimeout(() => { - this.blurCount(value) - }, 50) + this.blurCount(value); + }, 50); }, blurCount(value) { if (value) { if (value > this.properties.max) this.setData({ count: this.properties.max - }) + }); else if (value < this.properties.min) this.setData({ count: this.properties.min - }) + }); else this.setData({ count: value - }) + }); } else { this.setData({ count: this.properties.count - }) + }); } let detail = { count: this.data.count, type: 'blur' - } - this.triggerEvent('lintap', detail) + }; + this.triggerEvent('lintap', detail, { + bubbles: true, + composed: true + }); }, reduceTap() { - let distance = this.data.count - this.properties.step + let distance = this.data.count - this.properties.step; if (distance <= this.properties.min) { - this.data.count = this.properties.min + this.data.count = this.properties.min; } else { - this.data.count -= this.properties.step + this.data.count -= this.properties.step; } this.setData({ count: this.data.count - }) + }); let detail = { count: this.data.count, type: 'reduce' - } - this.triggerEvent('lintap', detail) + }; + this.triggerEvent('lintap', detail, { + bubbles: true, + composed: true + }); }, addTap() { let distance = this.data.count + this.properties.step; if (distance >= this.properties.max) { - this.data.count = this.properties.max + this.data.count = this.properties.max; } else { this.data.count += this.properties.step; } this.setData({ count: this.data.count - }) + }); let detail = { count: this.data.count, type: 'add' - } - this.triggerEvent('lintap', detail) + }; + this.triggerEvent('lintap', detail, { + bubbles: true, + composed: true + }); }, } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/dist/custom-tab-bar/index.js b/dist/custom-tab-bar/index.js index a3309a04..c4dd6580 100644 --- a/dist/custom-tab-bar/index.js +++ b/dist/custom-tab-bar/index.js @@ -90,7 +90,7 @@ Component({ idx, path:this.route }; - let option = {}; + let option = { bubbles: true, composed: true }; this.triggerEvent('lintap', detail, option); }, showRedDot(idx) { diff --git a/dist/dialog/index.js b/dist/dialog/index.js index a87905c4..9cad9271 100644 --- a/dist/dialog/index.js +++ b/dist/dialog/index.js @@ -155,7 +155,7 @@ Component({ onCancelTap(e) { let detail = 'cancel'; - let option = {}; + let option = { bubbles: true, composed: true }; const { success @@ -175,7 +175,7 @@ Component({ // 背景点击事件 onDialogTap(e) { let detail = true; - let option = {}; + let option = { bubbles: true, composed: true }; if (this.data.locked !== true) { this.setData({ diff --git a/dist/grid-item/index.js b/dist/grid-item/index.js index ff43aec6..cb1e500d 100644 --- a/dist/grid-item/index.js +++ b/dist/grid-item/index.js @@ -22,9 +22,7 @@ Component({ tapGridItem(e) { this.triggerEvent('lintap', { ...e - }, { - composed: true - }) + }, { bubbles: true, composed: true }) }, } }); \ No newline at end of file diff --git a/dist/grid/index.js b/dist/grid/index.js index 7dd1f849..a303962f 100644 --- a/dist/grid/index.js +++ b/dist/grid/index.js @@ -70,7 +70,7 @@ Component({ tapGrid(e) { this.triggerEvent('lintap', { index:this.data.currentIndex - }) + },{ bubbles: true, composed: true }) } } }); \ No newline at end of file diff --git a/dist/list/index.js b/dist/list/index.js index 75728a45..e9e2ab42 100644 --- a/dist/list/index.js +++ b/dist/list/index.js @@ -77,7 +77,7 @@ Component({ } this.triggerEvent('lintap', { e - }, {}) + }, { bubbles: true, composed: true }) } } }); \ No newline at end of file diff --git a/dist/loading/index.js b/dist/loading/index.js index bd75066a..5deaf671 100644 --- a/dist/loading/index.js +++ b/dist/loading/index.js @@ -1,5 +1,5 @@ Component({ - externalClasses: ['l-container-class','l-class'], + externalClasses: ['l-container-class', 'l-class'], properties: { // 显示与隐藏 show: { @@ -32,9 +32,39 @@ Component({ value: false, } }, + + attached() { + this._init(); + }, + methods: { + _init() { + wx.lin = wx.lin || {}; + wx.lin.showLoading = (options) => { + const { + custom = false, + fullScreen = false, + color = '', + type = 'rotate', + size = 'default' + } = { ...options }; + this.setData({ + custom, + fullScreen, + color, + type, + size, + show: true + }); + }; + wx.lin.hideLoading = () => { + this.setData({ + show: false + }); + }; + }, // 阻止滑动 - doNothingMove(e) { + doNothingMove() { // do nothing…… }, } diff --git a/dist/loadmore/index.js b/dist/loadmore/index.js index 5a0c482e..d5163fd4 100644 --- a/dist/loadmore/index.js +++ b/dist/loadmore/index.js @@ -4,21 +4,21 @@ Component({ multipleSlots: true // 在组件定义时的选项中启用多slot支持 }, properties: { - show:Boolean, - custom:Boolean, - line:Boolean, - color:String, - type:{ - type:String, - value:'loading' + show: Boolean, + custom: Boolean, + line: Boolean, + color: String, + type: { + type: String, + value: 'loading' }, - endText:{ - type:String, - value:'我是有底线的~' + endText: { + type: String, + value: '我是有底线的~' }, - loadingText:{ - type:String, - value:'加载中...' + loadingText: { + type: String, + value: '加载中...' } }, @@ -26,13 +26,43 @@ Component({ }, - ready: function () { - + attached() { + this._init(); }, + methods: { - onLoadmore(){ - this.triggerEvent('lintap'); - this.triggerEvent('lintapcatch',{},{ bubbles: true }); + _init() { + wx.lin = wx.lin || {}; + wx.lin.showLoadmore = (options) => { + const { + custom = false, + line = false, + color = '', + type = 'loading', + endText = '我是有底线的', + loadingText = '加载中...' + } = { ...options }; + this.setData({ + custom, + line, + color, + type, + endText, + loadingText, + show: true + }); + }; + wx.lin.hideLoadmore = () => { + this.setData({ + show: false + }); + }; + }, + onLoadmore() { + this.triggerEvent('lintap', {}, { + bubbles: true, + composed: true + }); } } }); diff --git a/dist/mask/index.js b/dist/mask/index.js index c8040846..17637022 100644 --- a/dist/mask/index.js +++ b/dist/mask/index.js @@ -64,7 +64,7 @@ Component({ onMaskTap(e) { let detail = true; - let option = {}; + let option = { bubbles: true, composed: true }; if (this.data.locked !== true) { this.setData({ diff --git a/dist/message/index.js b/dist/message/index.js index 37467673..460dd7a7 100644 --- a/dist/message/index.js +++ b/dist/message/index.js @@ -35,7 +35,7 @@ Component({ observers: { 'show': function (show) { - show && this.changeStatus() + show && this.changeStatus(); } }, @@ -51,7 +51,7 @@ Component({ duration = 1500, success = null } = options; - this.data.success = success + this.data.success = success; this.setData({ content, icon, @@ -59,7 +59,7 @@ Component({ duration, type }); - this.changeStatus() + this.changeStatus(); return this; }; }, @@ -67,15 +67,15 @@ Component({ changeStatus() { this.setData({ status: true - }) - if (this.data.timer) clearTimeout(this.data.timer) + }); + if (this.data.timer) clearTimeout(this.data.timer); this.data.timer = setTimeout(() => { this.setData({ status: false - }) - if (this.data.success) this.data.success() - this.data.timer = null - }, this.properties.duration) + }); + if (this.data.success) this.data.success(); + this.data.timer = null; + }, this.properties.duration); } } }); \ No newline at end of file diff --git a/dist/notice-bar/index.js b/dist/notice-bar/index.js index 46953681..f6f5d2a0 100644 --- a/dist/notice-bar/index.js +++ b/dist/notice-bar/index.js @@ -17,9 +17,9 @@ Component({ type: Number, value: 28 }, - frontIconColor:{ - type:String, - value:'#3683D6' + frontIconColor: { + type: String, + value: '#3683D6' }, endIconName: { type: String, @@ -29,9 +29,9 @@ Component({ type: Number, value: 28 }, - endIconColor:{ - type:String, - value:'#3683D6' + endIconColor: { + type: String, + value: '#3683D6' }, // 背景颜色 backgroundcolor: { @@ -83,7 +83,7 @@ Component({ const duration = rect.width / 40 * this.data.speed; const animation = wx.createAnimation({ duration: duration, - timingFunction: "linear", + timingFunction: 'linear', }); this.setData({ wrapWidth: wrapRect.width, @@ -126,20 +126,18 @@ Component({ } }, handleTap() { - this.triggerEvent('lintap'); - this.triggerEvent('lincatchtap', {}, { bubbles: true }); + this.triggerEvent('lintap',{},{ bubbles: true, composed: true }); this.setData({ timer: null }); }, - onSwip(e){ + onSwip(e) { this.triggerEvent('lintap', { ...e.currentTarget.dataset - }); + },{ bubbles: true, composed: true }); }, onIconTap(){ - this.triggerEvent('linicontap'); - this.triggerEvent('liniconcatchtap', {}, { bubbles: true }); + this.triggerEvent('linicontap',{},{ bubbles: true, composed: true }); this.setData({ timer: null }); diff --git a/dist/popup/index.js b/dist/popup/index.js index 112a8b76..5fbfd543 100644 --- a/dist/popup/index.js +++ b/dist/popup/index.js @@ -54,7 +54,7 @@ Component({ // 点击事件 onPupopTap(e) { let detail = true; - let option = {}; + let option = { bubbles: true, composed: true }; if (this.data.locked !== true) { this.setData({ show: !this.data.show diff --git a/dist/price/index.js b/dist/price/index.js index ab4bb540..cce91dec 100644 --- a/dist/price/index.js +++ b/dist/price/index.js @@ -2,7 +2,7 @@ Component({ /** * 组件的属性列表 */ - externalClasses: ['l-class', 'l-unit-class', 'l-count-class'], + externalClasses: ['l-deleted-class', 'l-unit-class', 'l-count-class', 'l-class'], options: { multipleSlots: true // 在组件定义时的选项中启用多slot支持 }, @@ -11,40 +11,31 @@ Component({ type: String, value: '¥' }, - unitColor: { + size: { type: String, - value: '#333' + value: '28' }, - unitSize: { - type: [String, Number], - value: 28 - }, - unitBold: { - type: String, - value: 'normal' - }, - count: { - type: Number, - value: 0.00, - observer: 'reserveNumber' - }, - countColor: { + color: { type: String, - value: '#333' - }, - countSize: { - type: [String, Number], - value: 28 + value: '#3963BC' }, - countBold: { + bold: { type: String, - value: 'normal' + value: '500' }, - delete: Boolean, - delColor: { + unitColor: String, + unitSize: String, + unitBold: String, + count: { type: String, - value: '#777' + value: '0.00', + observer: 'reserveNumber' }, + countColor: String, + countSize: String, + countBold: String, + deleted: Boolean, + delColor: String, reserveDigit: { type: Number, value: 2 @@ -63,21 +54,29 @@ Component({ * 组件的方法列表 */ methods: { - reserveNumber(value) { - const strValue = value.toString(); + reserveNumber() { + const strValue = this.data.count.toString(); + const isNumber = !isNaN(Number(this.data.count)); const dotIndex = strValue.indexOf('.'); if (strValue.length - dotIndex - 1 > this.data.reserveDigit && dotIndex !== -1) { this.setData({ - result: strValue.substring(0, dotIndex + this.data.reserveDigit) + result: isNumber ? strValue.substring(0, dotIndex + 1 + this.data.reserveDigit) : strValue }); } else { - this.addZero(strValue); + if (isNumber) { + this.addZero(strValue); + } else { + this.setData({ + result: strValue + }); + } } }, addZero(value) { - const realLen = value.indexOf('.') + 1 + this.data.reserveDigit; + const dotIndex = value.indexOf('.') == -1 ? value.length - 1 : value.indexOf('.'); + const realLen = dotIndex + 1 + this.data.reserveDigit; if (value.length < realLen && this.data.autofix) { - const result = value + '0'.repeat(realLen - value.length); + const result = dotIndex == value.indexOf('.') ? value + '0'.repeat(realLen - value.length) : value + '.' + '0'.repeat(realLen - value.length); this.setData({ result }); diff --git a/dist/price/index.wxml b/dist/price/index.wxml index e35de0c8..4506ccfb 100644 --- a/dist/price/index.wxml +++ b/dist/price/index.wxml @@ -1,8 +1,8 @@ - + - {{unit}} - - {{result}} + {{unit}} + + {{result}} \ No newline at end of file diff --git a/dist/price/index.wxss b/dist/price/index.wxss index 9aeaeb87..892dfbdd 100644 --- a/dist/price/index.wxss +++ b/dist/price/index.wxss @@ -1 +1 @@ -.price-del{text-decoration:line-through!important}.price-container{display:inline-block;text-align:center} \ No newline at end of file +.price-del{text-decoration:line-through!important}.price-container{display:inline-block;text-align:center;color:#3963bc;font-size:28rpx} \ No newline at end of file diff --git a/dist/search-bar/index.js b/dist/search-bar/index.js index 09c635ac..84199415 100644 --- a/dist/search-bar/index.js +++ b/dist/search-bar/index.js @@ -19,10 +19,6 @@ Component({ value: 'search' }, placeholder: String, - confirmType: { - type: String, - value: 'search' - }, cancelText: { type: String, value: '取消' @@ -92,7 +88,10 @@ Component({ */ methods: { onCancel() { - this.triggerEvent('lincancel') + this.triggerEvent('lincancel', {}, { + bubbles: true, + composed: true + }); }, // input属性列表 handleInputChange(event) { @@ -137,7 +136,10 @@ Component({ this.setData({ value: '' }); - this.triggerEvent('linclear', event.detail); + this.triggerEvent('linclear', event.detail, { + bubbles: true, + composed: true + }); } } }); \ No newline at end of file diff --git a/dist/segment/index.wxml b/dist/segment/index.wxml index 93ea85b5..e2ae10e3 100644 --- a/dist/segment/index.wxml +++ b/dist/segment/index.wxml @@ -9,7 +9,7 @@