mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
Coupon: not contain popup by default
This commit is contained in:
parent
c4510aa8e0
commit
fd36e37dc0
@ -1,5 +1,3 @@
|
|||||||
## Coupon 优惠券选择器
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Toast } from 'packages';
|
import { Toast } from 'packages';
|
||||||
|
|
||||||
@ -49,6 +47,7 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChange(index) {
|
onChange(index) {
|
||||||
|
this.showList = false;
|
||||||
this.chosenCoupon = index;
|
this.chosenCoupon = index;
|
||||||
},
|
},
|
||||||
onExchange(code) {
|
onExchange(code) {
|
||||||
@ -59,6 +58,16 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.demo-coupon {
|
||||||
|
.van-popup {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
## Coupon 优惠券选择器
|
||||||
|
|
||||||
### 使用指南
|
### 使用指南
|
||||||
``` javascript
|
``` javascript
|
||||||
import { CouponCell, CouponList } from 'vant';
|
import { CouponCell, CouponList } from 'vant';
|
||||||
@ -81,14 +90,15 @@ Vue.component(CouponList.name, CouponList);
|
|||||||
></van-coupon-cell>
|
></van-coupon-cell>
|
||||||
|
|
||||||
<!-- 优惠券列表 -->
|
<!-- 优惠券列表 -->
|
||||||
<van-coupon-list
|
<van-popup v-model="showList" position="bottom">
|
||||||
v-model="showList"
|
<van-coupon-list
|
||||||
:coupons="coupons"
|
:coupons="coupons"
|
||||||
:chosen-coupon="chosenCoupon"
|
:chosen-coupon="chosenCoupon"
|
||||||
:disabled-coupons="disabledCoupons"
|
:disabled-coupons="disabledCoupons"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
@exchange="onExchange"
|
@exchange="onExchange"
|
||||||
></van-coupon-list>
|
></van-coupon-list>
|
||||||
|
</van-popup>
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -116,6 +126,7 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChange(index) {
|
onChange(index) {
|
||||||
|
this.showList = false;
|
||||||
this.chosenCoupon = index;
|
this.chosenCoupon = index;
|
||||||
},
|
},
|
||||||
onExchange(code) {
|
onExchange(code) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<van-popup v-model="showPopup" position="bottom" class="van-coupon-list">
|
<div class="van-coupon-list">
|
||||||
<van-cell-group class="van-coupon-list__top">
|
<van-cell-group class="van-coupon-list__top">
|
||||||
<van-field v-model="exchangeCode" :placeholder="inputPlaceholder" :maxlength="20" />
|
<van-field v-model="exchangeCode" :placeholder="inputPlaceholder" :maxlength="20" />
|
||||||
<van-button size="small" type="danger" class="van-coupon-list__exchange" :disabled="exchangeButtonDisabled || !exchangeCode.length" @click="onClickExchangeButton">{{ exchangeButtonText }}</van-button>
|
<van-button size="small" type="danger" class="van-coupon-list__exchange" :disabled="exchangeButtonDisabled || !exchangeCode.length" @click="onClickExchangeButton">{{ exchangeButtonText }}</van-button>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-coupon-list__close van-hairline--top" @click="onClickNotUse">{{ closeButtonText }}</div>
|
<div class="van-coupon-list__close van-hairline--top" @click="onClickNotUse">{{ closeButtonText }}</div>
|
||||||
</van-popup>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -45,15 +45,7 @@ export default {
|
|||||||
[Item.name]: Item
|
[Item.name]: Item
|
||||||
},
|
},
|
||||||
|
|
||||||
model: {
|
|
||||||
prop: 'show'
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
show: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
chosenCoupon: {
|
chosenCoupon: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: -1
|
default: -1
|
||||||
@ -93,13 +85,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
show(val) {
|
|
||||||
this.showPopup = val;
|
|
||||||
},
|
|
||||||
showPopup(val) {
|
|
||||||
this.$emit('input', val);
|
|
||||||
this.scrollToTop();
|
|
||||||
},
|
|
||||||
displayedCouponIndex(val) {
|
displayedCouponIndex(val) {
|
||||||
this.scrollToShowCoupon(val);
|
this.scrollToShowCoupon(val);
|
||||||
}
|
}
|
||||||
@ -107,8 +92,7 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
exchangeCode: '',
|
exchangeCode: ''
|
||||||
showPopup: this.show
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -118,11 +102,9 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClickNotUse() {
|
onClickNotUse() {
|
||||||
this.showPopup = false;
|
|
||||||
this.$emit('change', -1);
|
this.$emit('change', -1);
|
||||||
},
|
},
|
||||||
onClickCoupon(index) {
|
onClickCoupon(index) {
|
||||||
this.showPopup = false;
|
|
||||||
this.$emit('change', index);
|
this.$emit('change', index);
|
||||||
},
|
},
|
||||||
onClickExchangeButton() {
|
onClickExchangeButton() {
|
||||||
@ -142,11 +124,6 @@ export default {
|
|||||||
list.scrollTop = card[index].$el.offsetTop - 100;
|
list.scrollTop = card[index].$el.offsetTop - 100;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
scrollToTop() {
|
|
||||||
const { list } = this.$refs;
|
|
||||||
|
|
||||||
list.scrollTop = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
.van-coupon {
|
.van-coupon {
|
||||||
&-list {
|
&-list {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
background-color: $background-color;
|
background-color: $background-color;
|
||||||
|
|
||||||
&__top {
|
&__top {
|
||||||
@ -33,6 +34,7 @@
|
|||||||
color: $gray-dark;
|
color: $gray-dark;
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
font-weight: normal;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@ -105,7 +107,8 @@
|
|||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
margin-bottom: 10px;
|
font-weight: normal;
|
||||||
|
margin: 0 0 10px;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@ -113,6 +116,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
|
margin: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
@mixin multi-ellipsis 1;
|
@mixin multi-ellipsis 1;
|
||||||
@ -132,8 +136,10 @@
|
|||||||
border-radius: 0 4px 4px 0;
|
border-radius: 0 4px 4px 0;
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
margin: 0;
|
||||||
opacity: .8;
|
opacity: .8;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
p,
|
p,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user