From 28dfee7429d2938d97bc3beddd31eea7d51dee8a Mon Sep 17 00:00:00 2001 From: niunai Date: Sun, 26 Mar 2017 15:22:11 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=AD=A3quantit?= =?UTF-8?q?y=E5=80=BC=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/quantity/src/quantity.vue | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/quantity/src/quantity.vue b/packages/quantity/src/quantity.vue index 469f75ed1..0f16ef49e 100644 --- a/packages/quantity/src/quantity.vue +++ b/packages/quantity/src/quantity.vue @@ -44,8 +44,14 @@ export default { }, data() { + let value = this.value ? +this.value : +this.defaultValue; + const correctedValue = this.correctValue(value); + if (value !== correctedValue) { + value = correctedValue; + this.$emit('input', value); + } return { - currentValue: this.value ? +this.value : +this.defaultValue + currentValue: value }; }, @@ -66,38 +72,37 @@ export default { watch: { currentValue(val) { - this.$emit('input', +val); + this.$emit('input', val); + this.$emit('change', val); }, value(val) { if (val) { - this.currentValue = +val; + this.currentValue = this.correctValue(+val); } } }, methods: { + // 纠正value值 + correctValue(value) { + value = Math.max(this.min, value); + value = Math.min(this.max, value); + return value; + }, handleInputChange(event) { - let val = +event.target.value; - const max = +this.max; - const min = +this.min; + const val = +event.target.value; - if (val > max) { - val = max; - } else if (val < min) { - val = min; - } - - this.currentValue = val; + this.currentValue = this.correctValue(val); }, handleChange(type) { if ((this.isMinusDisabled && type === 'minus') || (this.isPlusDisabled && type === 'plus')) { + this.$emit('overlimit', type); return; } const step = +this.step; const currentValue = +this.currentValue; this.currentValue = type === 'minus' ? (currentValue - step) : (currentValue + step); - this.$emit('change', this.currentValue); } } }; From da41d9c1fe65ef097b2b8423210c1d604162ef8c Mon Sep 17 00:00:00 2001 From: niunai Date: Sun, 26 Mar 2017 15:29:51 +0800 Subject: [PATCH 2/7] [build] 0.0.44 --- packages/zanui-css/package.json | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zanui-css/package.json b/packages/zanui-css/package.json index 8169d9ef5..4aad840f4 100644 --- a/packages/zanui-css/package.json +++ b/packages/zanui-css/package.json @@ -1,6 +1,6 @@ { "name": "@youzan/zanui-css", - "version": "0.0.43", + "version": "0.0.44", "description": "zanui css.", "main": "lib/index.css", "style": "lib/index.css", diff --git a/src/index.js b/src/index.js index 429f5fe83..755f16254 100644 --- a/src/index.js +++ b/src/index.js @@ -80,7 +80,7 @@ if (typeof window !== 'undefined' && window.Vue) { module.exports = { install, - version: '0.0.43', + version: '0.0.44', Button, Switch, Field, From db438160cda275fbc3b267d3d294595f38009a94 Mon Sep 17 00:00:00 2001 From: niunai Date: Sun, 26 Mar 2017 15:29:52 +0800 Subject: [PATCH 3/7] [release] 0.0.44 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0b1fb9b2..bfa3e107c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@youzan/zanui-vue", - "version": "0.0.43", + "version": "0.0.44", "description": "有赞vue wap组件库", "main": "lib/zanui.js", "style": "lib/zanui-css/index.css", From 03af3b3eba3bff09fb9da1eca238de1ce0cbcc87 Mon Sep 17 00:00:00 2001 From: cookfront Date: Mon, 27 Mar 2017 17:06:30 +0800 Subject: [PATCH 4/7] swipe add indicator --- docs/examples-dist/button.vue | 7 ---- docs/examples-docs/swipe.md | 25 ++++++++++++- packages/swipe/src/swipe-item.vue | 7 +++- packages/swipe/src/swipe.vue | 33 +++++++++++++---- packages/zanui-css/src/swipe.css | 61 ++++++++++++++++++++++--------- 5 files changed, 99 insertions(+), 34 deletions(-) diff --git a/docs/examples-dist/button.vue b/docs/examples-dist/button.vue index ecbc26d0f..3295b1f38 100644 --- a/docs/examples-dist/button.vue +++ b/docs/examples-dist/button.vue @@ -53,13 +53,6 @@ - -
- 确认付款 - 确认收货 - 取消订单 -
-
+ + ## Swipe 轮播 ### 基础用法 @@ -33,7 +43,7 @@ :::demo 自动轮播 ```html - + @@ -43,3 +53,16 @@ ``` ::: + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| autoPlay | 是否自动轮播 | `boolean` | `false` | `true`, `false` | +| showIndicators | 是否显示指示器 | `boolean` | `true` | `true`, `false` | + +### 事件 + +| 事件名 | 说明 | 参数 | +|-----------|-----------|-----------| +| `pagechange:end` | 每一页轮播结束后触发 | `(elem, currIndex)`:`elem`为触发页当前的DOM节点 | diff --git a/packages/swipe/src/swipe-item.vue b/packages/swipe/src/swipe-item.vue index 0a7ea92b5..2d8575839 100644 --- a/packages/swipe/src/swipe-item.vue +++ b/packages/swipe/src/swipe-item.vue @@ -6,6 +6,11 @@ diff --git a/packages/swipe/src/swipe.vue b/packages/swipe/src/swipe.vue index 83e641a6a..0d7c5b229 100644 --- a/packages/swipe/src/swipe.vue +++ b/packages/swipe/src/swipe.vue @@ -1,6 +1,14 @@ @@ -13,13 +21,17 @@ export default { name: 'zan-swipe', props: { - autoPlay: { + autoPlay: Boolean, + showIndicators: { type: Boolean, - default: false - }, - onPageChangeEnd: { - type: Function, - default: () => {} + default: true + } + }, + + data() { + return { + currIndex: 0, + swipes: [] } }, @@ -53,6 +65,13 @@ export default { updated() { this.scroll.update(); + }, + + methods: { + onPageChangeEnd(page, currIndex) { + this.currIndex = +currIndex; + this.$emit('pagechange:end', page, currIndex); + } } }; diff --git a/packages/zanui-css/src/swipe.css b/packages/zanui-css/src/swipe.css index e5af9411f..2c092278e 100644 --- a/packages/zanui-css/src/swipe.css +++ b/packages/zanui-css/src/swipe.css @@ -1,24 +1,49 @@ +@import './common/var.css'; + @component-namespace zan { - @b swipe { - position: relative; - overflow: hidden; - width: 100%; + @b swipe { + position: relative; + overflow: hidden; + width: 100%; + + @e indicators { + position: absolute; + bottom: 10px; + left: 50%; + transform: translateX(-50%); } - @b swipe-item { - display: none; - width: 100%; - height: 100%; - overflow: hidden; - text-align: center; + @e indicator { + width: 5px; + height: 5px; + display: inline-block; + border-radius: 100%; + background: #000; + opacity: .2; + margin: 0 3px; + z-index: 1; - img { - width: 100%; - height: auto; - } - - &:first-child { - display: block; - } + @m active { + background: $c-orange; + opacity: 1; + } } + } + + @b swipe-item { + display: none; + width: 100%; + height: 100%; + overflow: hidden; + text-align: center; + + img { + width: 100%; + height: auto; + } + + &:first-child { + display: block; + } + } } From e2995f1d365feee0588e3badba724e0e3dfafe0d Mon Sep 17 00:00:00 2001 From: cookfront Date: Mon, 27 Mar 2017 17:07:24 +0800 Subject: [PATCH 5/7] fix lint --- packages/swipe/src/swipe-item.vue | 1 - packages/swipe/src/swipe.vue | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/swipe/src/swipe-item.vue b/packages/swipe/src/swipe-item.vue index 2d8575839..be2dd955a 100644 --- a/packages/swipe/src/swipe-item.vue +++ b/packages/swipe/src/swipe-item.vue @@ -8,7 +8,6 @@ export default { name: 'zan-swipe-item', - beforeCreate() { this.$parent.swipes.push(this); } diff --git a/packages/swipe/src/swipe.vue b/packages/swipe/src/swipe.vue index 0d7c5b229..0c335da0e 100644 --- a/packages/swipe/src/swipe.vue +++ b/packages/swipe/src/swipe.vue @@ -32,7 +32,7 @@ export default { return { currIndex: 0, swipes: [] - } + }; }, mounted() { From 1501d6858b9081f9c601db21d7136dee667d653c Mon Sep 17 00:00:00 2001 From: cookfront Date: Mon, 27 Mar 2017 17:24:56 +0800 Subject: [PATCH 6/7] fix swipe css --- packages/zanui-css/src/swipe.css | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/zanui-css/src/swipe.css b/packages/zanui-css/src/swipe.css index 2c092278e..57fbdb57d 100644 --- a/packages/zanui-css/src/swipe.css +++ b/packages/zanui-css/src/swipe.css @@ -5,6 +5,7 @@ position: relative; overflow: hidden; width: 100%; + height: 100%; @e indicators { position: absolute; @@ -28,13 +29,19 @@ opacity: 1; } } + + @e items { + position: relative; + overflow: hidden; + position: relative; + height: 100%; + } } @b swipe-item { display: none; - width: 100%; height: 100%; - overflow: hidden; + width: 100%; text-align: center; img { From 10b75dcbc1511509eaf0d89a3ade7c580a607b5c Mon Sep 17 00:00:00 2001 From: cookfront Date: Mon, 27 Mar 2017 18:35:00 +0800 Subject: [PATCH 7/7] fix swipe css --- packages/zanui-css/src/swipe.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zanui-css/src/swipe.css b/packages/zanui-css/src/swipe.css index 57fbdb57d..518ded439 100644 --- a/packages/zanui-css/src/swipe.css +++ b/packages/zanui-css/src/swipe.css @@ -19,8 +19,8 @@ height: 5px; display: inline-block; border-radius: 100%; - background: #000; - opacity: .2; + background: #999; + opacity: .8; margin: 0 3px; z-index: 1;