Merge branch 'dev' into hotfix/fix-sku-err-toast

This commit is contained in:
niunai 2018-01-23 20:28:25 +08:00
commit 1199e3c088
31 changed files with 987 additions and 344 deletions

View File

@ -69,6 +69,7 @@ Use `tag` prop to custom button tag
|-----------|-----------|-----------|-------------|-------------|
| type | Type | `String` | `default` | `primary` `danger` |
| size | Size | `String` | `normal` | `large` `small` `mini` |
| text | Text | `String` | - | - |
| tag | Tag | `String` | `button` | - |
| native-type | Native Type Attribute | `String` | `''` | - |
| disabled | Whether disable button | `Boolean` | `false` | - |

View File

@ -1,5 +1,35 @@
## Changelog
### [0.12.5](https://github.com/youzan/vant/tree/v0.12.5)
`2018-01-23`
**Improvements**
* Button: add text prop [\#563](https://github.com/youzan/vant/pull/563) [@chenjiahan](https://github.com/chenjiahan)
* CouponList: support v-model、exchangeButtonLoading、exchangeMinLength [\#556](https://github.com/youzan/vant/pull/556) [\#566](https://github.com/youzan/vant/pull/566) [@chenjiahan](https://github.com/chenjiahan)
* Icon: update share icon [\#562](https://github.com/youzan/vant/pull/562) [@chenjiahan](https://github.com/chenjiahan)
* Sku: improve render performance [\#550](https://github.com/youzan/vant/pull/550) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* Area: should not display city & county list when not select province [\#560](https://github.com/youzan/vant/pull/560) [@chenjiahan](https://github.com/chenjiahan)
* Cell: fix required style [\#553](https://github.com/youzan/vant/pull/553) [@qianzhaoy](https://github.com/qianzhaoy)
### [0.12.4](https://github.com/youzan/vant/tree/v0.12.4)
`2018-01-18`
**Improvements**
* Picker: add props to custom button text [\#548](https://github.com/youzan/vant/pull/548) [@chenjiahan](https://github.com/chenjiahan)
* Toast: add setDefaultOptions method [\#541](https://github.com/youzan/vant/pull/541) [@chenjiahan](https://github.com/chenjiahan)
* Dialog: add setDefaultOptions method [\#539](https://github.com/youzan/vant/pull/539) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* Stepper: not fire event on changing the value prop [\#546](https://github.com/youzan/vant/pull/546) [@chuangbo](https://github.com/chuangbo)
* Picker: fix misspelling of visibleItemCount prop [\#549](https://github.com/youzan/vant/pull/549) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.3](https://github.com/youzan/vant/tree/v0.12.3)
`2018-01-12`

View File

@ -79,11 +79,14 @@ export default {
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| v-model | Current exchange code | `String` | - | - |
| chosen-coupon | Index of chosen coupon | `Number` | `-1` | - |
| coupons | Coupon list | `Array` | `[]` | - |
| disabled-coupons | Disabled voupon list | `Array` | `[]` | - |
| exchange-button-text | Exchange button text | `String` | `Exchange` | - |
| exchange-button-loading | Whether to show loading in exchange button | `Boolean` | `false` | - |
| exchange-button-disabled | Whether to disable exchange button | `Boolean` | `false` | - |
| exchange-min-length | Min length to enable exchange button | `Number` | `1` | - |
| displayed-coupon-index | Index of displayed coupon | `Number` | - | - |
| close-button-text | Close button text | `String` | `Close` | - |
| disabled-list-title | Disabled list title | `String` | `Unavailable` | - |

View File

@ -73,8 +73,9 @@ Vue.use(Button);
|-----------|-----------|-----------|-------------|-------------|
| type | 按钮类型 | `String` | `default` | `primary` `danger` |
| size | 按钮尺寸 | `String` | `normal` | `large` `small` `mini` |
| text | 按钮文字 | `String` | - | - |
| tag | 按钮标签 | `String` | `button` | 任意`HTML`标签 |
| native-type | 按钮类型(原生) | `String` | `''` | - |
| native-type | 按钮类型(原生) | `String` | - | - |
| disabled | 是否禁用 | `Boolean` | `false` | - |
| loading | 是否显示为加载状态 | `Boolean` | `false` | - |
| block | 是否为块级元素 | `Boolean` | `false` | - |

View File

@ -1,5 +1,55 @@
## 更新日志
## [v0.12.5](https://github.com/youzan/vant/tree/v0.12.5) (2018-01-23)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.4...v0.12.5)
**Issue**
- ssr项目使用时css加载错误 [\#561](https://github.com/youzan/vant/issues/561)
- css加载报错 [\#559](https://github.com/youzan/vant/issues/559)
- tabbar的active手动设置不生效 [\#558](https://github.com/youzan/vant/issues/558)
- 页面手动刷新 tabbar 会 回到起始路由页面对应的 active icon [\#557](https://github.com/youzan/vant/issues/557)
- 轮播图van-swipe 懒加载图片v-lazy 使用报错Failed to resolve directive: lazy [\#554](https://github.com/youzan/vant/issues/554)
- ssr 使用 babel-plugin-import报错 [\#552](https://github.com/youzan/vant/issues/552)
- stepper如何放到cell里面 [\#551](https://github.com/youzan/vant/issues/551)
- DatetimePicker设置每一列可见元素个数visibile-column-count失效 [\#547](https://github.com/youzan/vant/issues/547)
- Toast 和 Dialog 增加全局参数配置 [\#538](https://github.com/youzan/vant/issues/538)
- picker 组件文档 [\#537](https://github.com/youzan/vant/issues/537)
**Improvements**
- \[Improvement\] CouponList: support v-model & exchangeButtonLoading [\#566](https://github.com/youzan/vant/pull/566) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] update dependencies [\#565](https://github.com/youzan/vant/pull/565) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Button: add text prop [\#563](https://github.com/youzan/vant/pull/563) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Icon: update share icon [\#562](https://github.com/youzan/vant/pull/562) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Area: should not display city & county list when not select province [\#560](https://github.com/youzan/vant/pull/560) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] CouponList: add exchangeMinLength prop [\#556](https://github.com/youzan/vant/pull/556) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Cell: fix required style [\#553](https://github.com/youzan/vant/pull/553) ([qianzhaoy](https://github.com/qianzhaoy))
- \[Improvement\] Sku: improve render performance [\#550](https://github.com/youzan/vant/pull/550) ([chenjiahan](https://github.com/chenjiahan))
## [v0.12.4](https://github.com/youzan/vant/tree/v0.12.4) (2018-01-18)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.3...v0.12.4)
**Issue**
- \[Stepper\]: should not fire the events on changing the value prop [\#545](https://github.com/youzan/vant/issues/545)
- 有关vant导入所有组件用法示例异常 [\#543](https://github.com/youzan/vant/issues/543)
- 密码输入框组件与数字键盘组件报错 [\#542](https://github.com/youzan/vant/issues/542)
- ImagePreview 组件文档 [\#540](https://github.com/youzan/vant/issues/540)
- 官网文档 Button组件API "disabled" 拼写错误 [\#536](https://github.com/youzan/vant/issues/536)
- TabBar切换颜色没有加深 [\#535](https://github.com/youzan/vant/issues/535)
- 问一个swipe的问题为什么写了img 写上了v-lazy 没效果 [\#534](https://github.com/youzan/vant/issues/534)
- checkbox的全选取消的问题 [\#533](https://github.com/youzan/vant/issues/533)
**Improvements**
- \[bugfix\] Picker: misspelling of visibleItemCount [\#549](https://github.com/youzan/vant/pull/549) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Picker: add props to custom button text [\#548](https://github.com/youzan/vant/pull/548) ([chenjiahan](https://github.com/chenjiahan))
- \[bug fix\] Stepper: not fire event on changing the value prop [\#546](https://github.com/youzan/vant/pull/546) ([chuangbo](https://github.com/chuangbo))
- \[Doc\] fix misspelling of NumberKeyboard [\#544](https://github.com/youzan/vant/pull/544) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Toast: add setDefaultOptions method [\#541](https://github.com/youzan/vant/pull/541) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Dialog: add setDefaultOptions method [\#539](https://github.com/youzan/vant/pull/539) ([chenjiahan](https://github.com/chenjiahan))
## [v0.12.3](https://github.com/youzan/vant/tree/v0.12.3) (2018-01-12)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.2...v0.12.3)

View File

@ -1,5 +1,34 @@
## 更新日志
### [0.12.5](https://github.com/youzan/vant/tree/v0.12.5)
`2018-01-23`
**Improvements**
* Button: 新增 text 属性 [\#563](https://github.com/youzan/vant/pull/563) [@chenjiahan](https://github.com/chenjiahan)
* CouponList: 支持 v-model、exchangeButtonLoading、exchangeMinLength [\#556](https://github.com/youzan/vant/pull/556) [\#566](https://github.com/youzan/vant/pull/566) [@chenjiahan](https://github.com/chenjiahan)
* Icon: 更新 share 图标 [\#562](https://github.com/youzan/vant/pull/562) [@chenjiahan](https://github.com/chenjiahan)
* Sku: 优化渲染性能 [\#550](https://github.com/youzan/vant/pull/550) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* Area: 修复未选中省份时市区展示错误的问题 [\#560](https://github.com/youzan/vant/pull/560) [@chenjiahan](https://github.com/chenjiahan)
* Cell: 修复 required 样式错误的问题 [\#553](https://github.com/youzan/vant/pull/553) [@qianzhaoy](https://github.com/qianzhaoy)
### [0.12.4](https://github.com/youzan/vant/tree/v0.12.4)
`2018-01-18`
**Improvements**
* Picker: 新增 confirmButtonText、cancelButtonText 属性 [\#548](https://github.com/youzan/vant/pull/548) [@chenjiahan](https://github.com/chenjiahan)
* Toast: 新增 setDefaultOptions 方法 [\#541](https://github.com/youzan/vant/pull/541) [@chenjiahan](https://github.com/chenjiahan)
* Dialog: 新增 setDefaultOptions 方法 [\#539](https://github.com/youzan/vant/pull/539) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* Stepper: 修改 value 值时不触发 change 事件 [\#546](https://github.com/youzan/vant/pull/546) [@chuangbo](https://github.com/chuangbo)
* Picker: 修复 visibleItemCount 属性拼写错误 [\#549](https://github.com/youzan/vant/pull/549) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.3](https://github.com/youzan/vant/tree/v0.12.3)
`2018-01-12`

View File

@ -69,7 +69,7 @@ export default {
### CouponCell API
| 参数 | 说明 | 类型 | 默认值 | 必须 |
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| title | 单元格标题 | `String` | `优惠券码` | - |
| chosen-coupon | 当前选中优惠券的索引 | `Number` | `-1` | - |
@ -78,13 +78,16 @@ export default {
### CouponList API
| 参数 | 说明 | 类型 | 默认值 | 必须 |
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| v-model | 当前输入的兑换码 | `String` | - | - |
| chosen-coupon | 当前选中优惠券的索引 | `Number` | `-1` | - |
| coupons | 可用优惠券列表 | `Array` | `[]` | - |
| disabled-doupons | 不可用优惠券列表 | `Array` | `[]` | - |
| exchange-button-text | 兑换按钮文字 | `String` | `兑换` | - |
| exchange-button-loading | 是否在兑换按钮上显示加载动画 | `Boolean` | `false` | - |
| exchange-button-disabled | 是否禁用兑换按钮 | `Boolean` | `false` | - |
| exchange-min-length | 兑换码最小长度 | `Number` | `1` | - |
| displayed-coupon-index | 滚动至特定优惠券位置 | `Number` | - | - |
| show-close-button | 是否显示列表底部按钮 | `Boolean` | `true` | - |
| close-button-text | 列表底部按钮文字 | `String` | `不使用优惠` | - |

View File

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="shortcut icon" href="https://img.yzcdn.cn/zanui/vant/vant-2017-12-18.ico">
<title>Vant - 有赞移动端 Vue 组件库</title>
<script>window.Promise || document.write('<script src="//b.yzcdn.cn/huiyi/build/h5/js/pinkie.min.js"><\/script>');</script>
</head>
<body ontouchstart>

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "0.12.4",
"version": "0.12.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "0.12.4",
"version": "0.12.5",
"description": "A Vue.js 2.0 Mobile UI at YouZan",
"main": "lib/vant.js",
"style": "lib/vant-css/index.css",
@ -50,7 +50,7 @@
"vue": ">= 2.5.0"
},
"devDependencies": {
"autoprefixer": "^7.2.4",
"autoprefixer": "^7.2.5",
"avoriaz": "2.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
@ -63,10 +63,10 @@
"chai": "^4.1.2",
"codecov": "^3.0.0",
"cross-env": "^5.1.3",
"css-loader": "^0.28.8",
"dependency-tree": "^5.12.0",
"eslint": "^4.15.0",
"eslint-plugin-vue": "^4.1.0",
"css-loader": "^0.28.9",
"dependency-tree": "^6.0.0",
"eslint": "^4.16.0",
"eslint-plugin-vue": "^4.2.0",
"extract-text-webpack-plugin": "3.0.2",
"fast-vue-md-loader": "^1.0.3",
"friendly-errors-webpack-plugin": "^1.6.1",
@ -89,23 +89,23 @@
"precss": "2.0.0",
"progress-bar-webpack-plugin": "^1.10.0",
"rimraf": "^2.5.4",
"shelljs": "^0.7.8",
"shelljs": "^0.8.1",
"sinon": "^2.4.1",
"sinon-chai": "^2.12.0",
"style-loader": "^0.19.1",
"uppercamelcase": "^3.0.0",
"url-loader": "^0.6.2",
"vant-doc": "1.0.1",
"vant-doc": "1.0.2",
"vue": "^2.5.13",
"vue-loader": "^13.6.2",
"vue-loader": "^13.7.0",
"vue-router": "^3.0.1",
"vue-sfc-compiler": "^0.0.7",
"vue-sfc-compiler": "^0.0.8",
"vue-style-loader": "^3.0.0",
"vue-template-compiler": "^2.5.13",
"vue-template-es2015-compiler": "^1.6.0",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.1",
"webpack-dev-server": "2.9.7",
"webpack-bundle-analyzer": "^2.9.2",
"webpack-dev-server": "2.11.1",
"webpack-merge": "^4.1.1"
}
}

View File

@ -94,23 +94,23 @@ export default create({
// `code`
getList(type, code) {
if (!this.listValid) {
return [];
}
let result = [];
const { areaList } = this;
const list =
type === 'province'
? areaList.province_list
: type === 'city' ? areaList.city_list : areaList.county_list;
if (this.listValid && (type === 'province' || code)) {
const { areaList } = this;
const list =
type === 'province'
? areaList.province_list
: type === 'city' ? areaList.city_list : areaList.county_list;
let result = Object.keys(list).map(code => ({
code,
name: list[code]
}));
result = Object.keys(list).map(code => ({
code,
name: list[code]
}));
if (type !== 'province' && code) {
result = result.filter(item => item.code.indexOf(code) === 0);
if (type !== 'province' && code) {
result = result.filter(item => item.code.indexOf(code) === 0);
}
}
result.unshift({

View File

@ -23,7 +23,7 @@
:color="type === 'default' ? 'black' : 'white'"
/>
<span class="van-button__text">
<slot />
<slot>{{ text }}</slot>
</span>
</component>
</template>
@ -35,6 +35,7 @@ export default create({
name: 'van-button',
props: {
text: String,
block: Boolean,
loading: Boolean,
disabled: Boolean,

View File

@ -3,7 +3,7 @@
<cell-group class="van-coupon-list__top" v-if="showExchangeBar">
<field
class="van-coupon-list__filed van-hairline--surround"
v-model="exchangeCode"
v-model="currentCode"
:placeholder="inputPlaceholder || $t('placeholder')"
:maxlength="20"
/>
@ -11,11 +11,11 @@
size="small"
type="danger"
class="van-coupon-list__exchange"
:disabled="exchangeButtonDisabled || !exchangeCode.length"
:text="exchangeButtonText || $t('exchange')"
:loading="exchangeButtonLoading"
:disabled="buttonDisabled"
@click="onClickExchangeButton"
>
{{ exchangeButtonText || $t('exchange') }}
</van-button>
/>
</cell-group>
<div class="van-coupon-list__list" :class="{ 'van-coupon-list--with-exchange': showExchangeBar }" ref="list">
<coupon-item
@ -24,7 +24,7 @@
:key="item.id || item.name"
:data="item"
:chosen="index === chosenCoupon"
@click.native="onClickCoupon(index)"
@click.native="$emit('change', index)"
/>
<h3 v-if="disabledCoupons.length">{{ disabledListTitle || $t('disabled') }}</h3>
<coupon-item
@ -40,11 +40,10 @@
</div>
<div
v-show="showCloseButton"
v-text="closeButtonText || $t('close')"
class="van-coupon-list__close van-hairline--top"
@click="onClickNotUse"
>
{{ closeButtonText || $t('close') }}
</div>
@click="$emit('change', -1)"
/>
</div>
</template>
@ -69,11 +68,22 @@ export default create({
CouponItem
},
model: {
prop: 'code'
},
props: {
code: String,
closeButtonText: String,
inputPlaceholder: String,
disabledListTitle: String,
exchangeButtonText: String,
exchangeButtonLoading: Boolean,
exchangeButtonDisabled: Boolean,
exchangeMinLength: {
type: Number,
default: 1
},
chosenCoupon: {
type: Number,
default: -1
@ -86,10 +96,6 @@ export default create({
type: Array,
default: () => []
},
exchangeButtonDisabled: {
type: Boolean,
default: false
},
displayedCouponIndex: {
type: Number,
default: -1
@ -104,16 +110,34 @@ export default create({
}
},
watch: {
displayedCouponIndex(val) {
this.scrollToShowCoupon(val);
data() {
return {
currentCode: this.code || ''
};
},
computed: {
buttonDisabled() {
return (
!this.exchangeButtonLoading &&
(this.exchangeButtonDisabled ||
this.currentCode.length < this.exchangeMinLength)
);
}
},
data() {
return {
exchangeCode: ''
};
watch: {
code(code) {
this.currentCode = code;
},
currentCode(code) {
this.$emit('input', code);
},
displayedCouponIndex(val) {
this.scrollToShowCoupon(val);
}
},
mounted() {
@ -121,17 +145,16 @@ export default create({
},
methods: {
onClickNotUse() {
this.$emit('change', -1);
},
onClickCoupon(index) {
this.$emit('change', index);
},
onClickExchangeButton() {
this.$emit('exchange', this.exchangeCode);
this.exchangeCode = '';
this.$emit('exchange', this.currentCode);
// auto clear currentCode when not use v-model
if (!this.code) {
this.currentCode = '';
}
},
//
// scroll to show specific coupon
scrollToShowCoupon(index) {
if (index === -1) {
return;

View File

@ -50,14 +50,11 @@ export default create({
callback: Function,
confirmButtonText: String,
cancelButtonText: String,
showCancelButton: Boolean,
showConfirmButton: {
type: Boolean,
default: true
},
showCancelButton: {
type: Boolean,
default: false
},
overlay: {
type: Boolean,
default: true

View File

@ -62,7 +62,7 @@ import TreeSelect from './tree-select';
import Uploader from './uploader';
import Waterfall from './waterfall';
const version = '0.12.4';
const version = '0.12.5';
const components = [
Actionsheet,
AddressEdit,

View File

@ -3,7 +3,12 @@
<div class="van-sku-container">
<div class="van-sku-layout">
<!-- sku-header -->
<slot name="sku-header" :skuEventBus="skuEventBus" :selectedSku="selectedSku" :selectedSkuComb="selectedSkuComb">
<slot
name="sku-header"
:sku-event-bus="skuEventBus"
:selected-sku="selectedSku"
:selected-sku-comb="selectedSkuComb"
>
<sku-header
:sku-event-bus="skuEventBus"
:selected-sku="selectedSku"
@ -14,9 +19,9 @@
</slot>
<div class="van-sku-body" :style="bodyStyle">
<!-- sku-body-top -->
<slot name="sku-body-top" :selectedSku="selectedSku" :skuEventBus="skuEventBus" />
<slot name="sku-body-top" :selected-sku="selectedSku" :sku-event-bus="skuEventBus" />
<!-- sku-group -->
<slot name="sku-group" :selectedSku="selectedSku" :skuEventBus="skuEventBus">
<slot name="sku-group" :selected-sku="selectedSku" :sku-event-bus="skuEventBus">
<div v-if="hasSku" class="van-sku-group-container van-hairline--bottom">
<div
v-for="(skuTreeItem, index) in skuTree"
@ -40,9 +45,15 @@
</div>
</slot>
<!-- extra-sku-group -->
<slot name="extra-sku-group" :skuEventBus="skuEventBus"/>
<slot name="extra-sku-group" :sku-event-bus="skuEventBus"/>
<!-- sku-stepper -->
<slot name="sku-stepper" :skuEventBus="skuEventBus" :selectedSku="selectedSku" :selectedSkuComb="selectedSkuComb" :selectedNum="selectedNum">
<slot
name="sku-stepper"
:sku-event-bus="skuEventBus"
:selected-sku="selectedSku"
:selected-sku-comb="selectedSkuComb"
:selected-num="selectedNum"
>
<sku-stepper
ref="skuStepper"
:sku-event-bus="skuEventBus"
@ -68,7 +79,7 @@
</slot>
</div>
<!-- sku-actions -->
<slot name="sku-actions" :skuEventBus="skuEventBus">
<slot name="sku-actions" :sku-event-bus="skuEventBus">
<sku-actions
:sku-event-bus="skuEventBus"
:buy-text="buyText"
@ -83,21 +94,21 @@
<script>
/* eslint-disable camelcase */
import Vue from 'vue';
import Popup from '../../popup';
import Toast from '../../toast';
import SkuHeader from '../components/SkuHeader';
import SkuRow from '../components/SkuRow';
import SkuRowItem from '../components/SkuRowItem';
import SkuStepper from '../components/SkuStepper';
import SkuMessages from '../components/SkuMessages';
import SkuActions from '../components/SkuActions';
import Popup from '../popup';
import Toast from '../toast';
import SkuHeader from './components/SkuHeader';
import SkuRow from './components/SkuRow';
import SkuRowItem from './components/SkuRowItem';
import SkuStepper from './components/SkuStepper';
import SkuMessages from './components/SkuMessages';
import SkuActions from './components/SkuActions';
import {
isAllSelected,
getSkuComb,
getSelectedSkuValues
} from '../utils/skuHelper';
import { LIMIT_TYPE } from '../constants';
import { create } from '../../utils';
} from './utils/skuHelper';
import { LIMIT_TYPE } from './constants';
import { create } from '../utils';
const { QUOTA_LIMIT } = LIMIT_TYPE;
@ -115,13 +126,20 @@ export default create({
},
props: {
sku: Object,
goods: Object,
value: Boolean,
buyText: String,
goodsId: [Number, String],
stepperTitle: String,
hideStock: Boolean,
resetStepperOnHide: Boolean,
resetSelectedSkuOnHide: Boolean,
disableStepperInput: Boolean,
initialSku: {
type: Object,
default: () => ({})
},
sku: Object,
quota: {
type: Number,
default: 0
@ -130,25 +148,18 @@ export default create({
type: Number,
default: 0
},
hideStock: Boolean,
showAddCartBtn: {
type: Boolean,
default: true
},
buyText: String,
stepperTitle: String,
bodyOffsetTop: {
type: Number,
default: 200
},
resetStepperOnHide: Boolean,
resetSelectedSkuOnHide: Boolean,
disableStepperInput: Boolean,
messagePlaceholderMap: {
type: Object,
default: () => ({})
},
value: Boolean
}
},
data() {
@ -205,19 +216,19 @@ export default create({
maxHeight: maxHeight + 'px'
};
},
isSkuCombSelected() {
return isAllSelected(this.sku.tree, this.selectedSku);
},
// sku
isSkuEmpty() {
for (var key in this.sku) {
if (Object.prototype.hasOwnProperty.call(this.sku, key)) return false;
}
return true;
return Object.keys(this.sku).length === 0;
},
hasSku() {
return !this.sku.none_sku;
},
selectedSkuComb() {
if (!this.hasSku) {
return {
@ -230,13 +241,14 @@ export default create({
}
return null;
},
skuTree() {
return this.sku.tree || [];
}
},
created() {
var skuEventBus = new Vue();
const skuEventBus = new Vue();
this.skuEventBus = skuEventBus;
skuEventBus.$on('sku:close', this.handleCloseClicked);
@ -263,19 +275,23 @@ export default create({
}
});
},
getSkuMessages() {
return this.$refs.skuMessages ? this.$refs.skuMessages.getMessages() : {};
},
getSkuCartMessages() {
return this.$refs.skuMessages
? this.$refs.skuMessages.getCartMessages()
: {};
},
validateSkuMessages() {
return this.$refs.skuMessages
? this.$refs.skuMessages.validateMessages()
: '';
},
validateSku() {
if (this.selectedNum === 0) {
return this.$t('unavailable');
@ -289,9 +305,11 @@ export default create({
return this.$t('spec');
}
},
handleCloseClicked() {
this.show = false;
},
handleSkuSelected(skuValue) {
// sku
this.selectedSku =
@ -305,9 +323,11 @@ export default create({
selectedSkuComb: this.selectedSkuComb
});
},
handleNumChange(num) {
this.selectedNum = num;
},
handleOverLimit({ action, limitType, quota, quotaUsed }) {
if (action === 'minus') {
Toast(this.$t('least'));
@ -321,12 +341,15 @@ export default create({
}
}
},
handleAddCartClicked() {
this.handleBuyOrAddCart('add-cart');
},
handleBuyClicked() {
this.handleBuyOrAddCart('buy-clicked');
},
handleBuyOrAddCart(type) {
const error = this.validateSku();
if (error) {

View File

@ -1,7 +1,17 @@
<template>
<div class="van-sku-actions">
<van-button v-if="showAddCartBtn" bottom-action @click="onAddCartClicked">{{ $t('cart') }}</van-button>
<van-button type="primary" bottom-action @click="onBuyClicked">{{ buyText || $t('buy') }}</van-button>
<van-button
v-if="showAddCartBtn"
bottom-action
:text="$t('cart')"
@click="skuEventBus.$emit('sku:addCart')"
/>
<van-button
type="primary"
bottom-action
:text="buyText || $t('buy')"
@click="skuEventBus.$emit('sku:buy')"
/>
</div>
</template>
@ -20,15 +30,6 @@ export default create({
buyText: String,
skuEventBus: Object,
showAddCartBtn: Boolean
},
methods: {
onAddCartClicked() {
this.skuEventBus.$emit('sku:addCart');
},
onBuyClicked() {
this.skuEventBus.$emit('sku:buy');
}
}
});
</script>

View File

@ -1,12 +1,12 @@
<template>
<div class="van-sku-header van-hairline--bottom">
<div class="van-sku-header__img-wrap">
<img class="van-sku__goods-img" :src="goodsImg">
<img class="van-sku__goods-img" :src="goodsImg" >
</div>
<div class="van-sku-header__goods-info">
<div class="van-sku__goods-name">{{ goods.title }}</div>
<div class="van-sku__goods-price"><span class="van-sku__price-symbol"></span><span class="van-sku__price-num">{{ price }}</span></div>
<span class="van-sku__close-icon" @click="onCloseClicked" />
<span class="van-sku__close-icon" @click="skuEventBus.$emit('sku:close')" />
</div>
</div>
</template>
@ -26,9 +26,6 @@ export default create({
},
computed: {
skuTree() {
return this.sku.tree;
},
goodsImg() {
const s1Id = this.selectedSku.s1;
const skuImg = this.getSkuImg(s1Id);
@ -45,14 +42,11 @@ export default create({
},
methods: {
onCloseClicked() {
this.skuEventBus.$emit('sku:close');
},
getSkuImg(id) {
if (!id) return;
// skuImgskuTrees1sku
const treeItem = this.skuTree.filter(treeItem => treeItem.k_s === 's1')[0] || {};
const treeItem = this.sku.tree.filter(treeItem => treeItem.k_s === 's1')[0] || {};
if (!treeItem.v) {
return;

View File

@ -1,26 +1,14 @@
<template>
<cell-group class="van-sku-messages">
<template v-for="(message, index) in internalMessages">
<template v-if="message.type === 'image'" />
<field
v-else-if="message.multiple == '1'"
:key="`${goodsId}-${index}`"
:required="message.required == '1'"
:label="message.name"
:placeholder="getPlaceholder('textarea')"
type="textarea"
v-model="messageValues[index]"
/>
<field
v-else
:key="`${goodsId}-${index}`"
:required="message.required == '1'"
:label="message.name"
:placeholder="getPlaceholder(message.type)"
:type="getType(message)"
v-model="messageValues[index]"
/>
</template>
<field
v-for="(message, index) in internalMessages"
v-model="messageValues[index]"
:key="`${goodsId}-${index}`"
:required="message.required == '1'"
:label="message.name"
:placeholder="getPlaceholder(message)"
:type="getType(message)"
/>
</cell-group>
</template>
@ -47,26 +35,23 @@ export default create({
computed: {
internalMessages() {
if (Object.prototype.toString.call(this.messages) === '[object Array]') {
return this.messages;
}
return [];
return Array.isArray(this.messages) ? this.messages.filter(message => message.type !== 'image') : [];
},
messageValues() {
const messageValues = [];
this.internalMessages.forEach((message, index) => {
messageValues[index] = '';
});
return messageValues;
return this.internalMessages.map(() => '');
}
},
methods: {
getType({ type, datetime }) {
if (type === 'id_no') return 'text';
return datetime > 0 ? 'datetime-local' : type;
getType(message) {
if (+message.multiple === 1) {
return 'textarea';
}
if (message.type === 'id_no') {
return 'text';
}
return message.datetime > 0 ? 'datetime-local' : message.type;
},
getMessages() {
@ -96,8 +81,9 @@ export default create({
return messages;
},
getPlaceholder(key) {
return this.messagePlaceholderMap[key] || this.$t(`placeholder.${key}`);
getPlaceholder(message) {
const type = +message.multiple === 1 ? 'textarea' : message.type;
return this.messagePlaceholderMap[type] || this.$t(`placeholder.${type}`);
},
validateMessages() {

View File

@ -1,12 +1,14 @@
<template>
<span
v-if="isChoosable"
@click="onSkuSelected"
class="van-sku-row__item"
:class="{ 'van-sku-row__item--active': isChoosed }">
:class="{
'van-sku-row__item--active': isChoosed,
'van-sku-row__item--disabled': !isChoosable
}"
@click="onSkuSelected"
>
{{ skuValue.name }}
</span>
<span v-else class="van-sku-row__item van-sku-row__item--disabled">{{ skuValue.name }}</span>
</template>
<script>
@ -25,6 +27,7 @@ export default {
isChoosed() {
return this.skuValue.id === this.selectedSku[this.skuKeyStr];
},
isChoosable() {
const matchedSku = Object.assign({}, this.selectedSku, {
[this.skuKeyStr]: this.skuValue.id
@ -44,7 +47,12 @@ export default {
methods: {
onSkuSelected() {
this.skuEventBus.$emit('sku:select', Object.assign({}, this.skuValue, { skuKeyStr: this.skuKeyStr }));
if (this.isChoosable) {
this.skuEventBus.$emit('sku:select', {
...this.skuValue,
skuKeyStr: this.skuKeyStr
});
}
}
}
};

View File

@ -8,7 +8,7 @@
:min="1"
:max="stepperLimit"
:disable-input="disableStepperInput"
@overlimit="handleOverLimit"
@overlimit="onOverLimit"
/>
</div>
<div v-if="!hideStock" class="van-sku__stock">{{ $t('remain', stock) }}</div>
@ -39,14 +39,8 @@ export default create({
stepperTitle: String,
quota: Number,
quotaUsed: Number,
hideStock: {
type: Boolean,
default: false
},
disableStepperInput: {
type: Boolean,
default: false
}
hideStock: Boolean,
disableStepperInput: Boolean
},
data() {
@ -97,7 +91,8 @@ export default create({
setCurrentNum(num) {
this.currentNum = num;
},
handleOverLimit(action) {
onOverLimit(action) {
this.skuEventBus.$emit('sku:overLimit', {
action,
limitType: this.limitType,

View File

@ -1,3 +1,4 @@
import Sku from './Sku';
import SkuActions from './components/SkuActions';
import SkuHeader from './components/SkuHeader';
import SkuMessages from './components/SkuMessages';
@ -5,14 +6,13 @@ import SkuStepper from './components/SkuStepper';
import SkuRow from './components/SkuRow';
import SkuRowItem from './components/SkuRowItem';
import skuHelper from './utils/skuHelper';
import SkuContainer from './containers/SkuContainer';
SkuContainer.SkuActions = SkuActions;
SkuContainer.SkuHeader = SkuHeader;
SkuContainer.SkuMessages = SkuMessages;
SkuContainer.SkuStepper = SkuStepper;
SkuContainer.SkuRow = SkuRow;
SkuContainer.SkuRowItem = SkuRowItem;
SkuContainer.skuHelper = skuHelper;
Sku.SkuActions = SkuActions;
Sku.SkuHeader = SkuHeader;
Sku.SkuMessages = SkuMessages;
Sku.SkuStepper = SkuStepper;
Sku.SkuRow = SkuRow;
Sku.SkuRowItem = SkuRowItem;
Sku.skuHelper = skuHelper;
export default SkuContainer;
export default Sku;

View File

@ -1,6 +1,6 @@
{
"name": "vant-css",
"version": "0.12.4",
"version": "0.12.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "vant-css",
"version": "0.12.4",
"version": "0.12.5",
"description": "vant css.",
"main": "lib/index.css",
"style": "lib/index.css",

View File

@ -72,7 +72,7 @@
&::before {
content: '*';
position: absolute;
left: -7px;
left: 7px;
font-size: 14px;
color: $red;
}

View File

@ -2,5 +2,5 @@
font-style: normal;
font-weight: normal;
font-family: 'vant-icon';
src: url('./vant-icon-120564.ttf') format('truetype');
src: url('./vant-icon-dc7d92.ttf') format('truetype');
}

View File

@ -4,7 +4,7 @@
font-style: normal;
font-weight: normal;
font-family: 'vant-icon';
src: url('https://b.yzcdn.cn/zanui/icon/vant-icon-120564.ttf') format('truetype');
src: url('https://b.yzcdn.cn/zanui/icon/vant-icon-dc7d92.ttf') format('truetype');
}
.van-icon {

View File

@ -10,6 +10,7 @@
font-size: 12px;
line-height: 1.2;
border-radius: 5px;
word-break: break-all;
align-items: center;
justify-content: center;
flex-direction: column;

818
yarn.lock

File diff suppressed because it is too large Load Diff