[improvement] Dialog: optimize template (#729)

This commit is contained in:
neverland 2018-10-10 15:12:33 +08:00 committed by GitHub
parent 3c4e07093d
commit 43bf3a014a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 91 additions and 62 deletions

View File

@ -1,14 +1,39 @@
<demo-block title="消息提示" padding>
<van-button type="primary" plain bind:click="onClickAlert" custom-class="demo-margin-right">消息提示</van-button>
<van-button type="primary" plain bind:click="onClickAlert2">无标题提示</van-button>
<van-button
plain
type="primary"
custom-class="demo-margin-right"
bind:click="onClickAlert"
>
消息提示
</van-button>
<van-button
plain
type="primary"
bind:click="onClickAlert2"
>
无标题提示
</van-button>
</demo-block>
<demo-block title="消息确认" padding>
<van-button type="primary" plain bind:click="onClickConfirm">消息确认</van-button>
<van-button
plain
type="primary"
bind:click="onClickConfirm"
>
消息确认
</van-button>
</demo-block>
<demo-block title="组件调用" padding>
<van-button type="danger" plain bind:click="showCustomDialog">组件调用</van-button>
<van-button
plain
type="danger"
bind:click="showCustomDialog"
>
组件调用
</van-button>
<van-dialog
use-slot
async-close
@ -27,7 +52,7 @@
value="{{ password }}"
type="password"
label="密码"
:border="false"
border="{{ false }}"
placeholder="请输入密码"
/>
</van-dialog>

View File

@ -1,23 +1,23 @@
<button
class="custom-class van-button {{ classes }}"
id="{{ id }}"
lang="{{ lang }}"
class="custom-class van-button {{ classes }}"
open-type="{{ openType }}"
app-parameter="{{ appParameter }}"
hover-stop-propagation="{{ hoverStopPropagation }}"
hover-start-time="{{ hoverStartTime }}"
hover-stay-time="{{ hoverStayTime }}"
lang="{{ lang }}"
hover-start-time="{{ hoverStartTime }}"
hover-stop-propagation="{{ hoverStopPropagation }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"
send-message-path="{{ sendMessagePath }}"
send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}"
bind:tap="onClick"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindopensetting="bindOpenSetting"
>
<van-loading
wx:if="{{ loading }}"
@ -25,5 +25,5 @@
custom-class="loading-class"
color="{{ type === 'default' ? '#c9c9c9' : '#fff' }}"
/>
<slot wx:else></slot>
<slot wx:else />
</button>

View File

@ -1,6 +1,11 @@
<view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}">
<view class="van-card__thumb" bind:tap="onClickThumb">
<image wx:if="{{ thumb }}" lazy-load="{{ lazyLoad }}" src="{{ thumb }}" class="van-card__img thumb-class" />
<image
wx:if="{{ thumb }}"
src="{{ thumb }}"
lazy-load="{{ lazyLoad }}"
class="van-card__img thumb-class"
/>
<slot wx:else name="thumb" />
<van-tag
wx:if="{{ tag }}"
@ -11,19 +16,23 @@
{{ tag }}
</van-tag>
</view>
<view class="van-card__content">
<view wx:if="{{ title || price || price === 0 }}" class="van-card__row">
<view wx:if="{{ title }}" class="van-card__title van-multi-ellipsis--l2 title-class">{{ title }}</view>
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
</view>
<slot wx:else name="title" />
<view wx:if="{{ desc || num }}" class="van-card__row">
<view wx:if="{{ desc }}" class="van-card__desc van-ellipsis desc-class">{{ desc }}</view>
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
</view>
<slot wx:else name="desc" />
<slot name="tags" />
</view>
<view class="van-card__footer">
<slot name="footer" />
</view>

View File

@ -22,7 +22,7 @@
</view>
<view class="van-cell__value value-class">
<view wx:if="{{ value }}">{{ value }}</view>
<block wx:if="{{ value }}">{{ value }}</block>
<slot wx:else />
</view>

View File

@ -30,8 +30,6 @@
&__footer {
display: flex;
overflow: hidden;
user-select: none;
}
&__button {

View File

@ -11,6 +11,7 @@ VantComponent({
useSlot: Boolean,
asyncClose: Boolean,
showCancelButton: Boolean,
closeOnClickOverlay: Boolean,
confirmButtonOpenType: String,
zIndex: {
type: Number,
@ -31,10 +32,6 @@ VantComponent({
overlay: {
type: Boolean,
value: true
},
closeOnClickOverlay: {
type: Boolean,
value: false
}
},

View File

@ -3,48 +3,51 @@
transition="scale"
z-index="{{ zIndex }}"
overlay="{{ overlay }}"
close-on-click-overlay="{{ closeOnClickOverlay }}"
custom-class="van-dialog"
close-on-click-overlay="{{ closeOnClickOverlay }}"
bind:close="onClickOverlay"
>
<view wx:if="{{ title }}" class="van-dialog__header {{ !message && !useSlot ? 'van-dialog--isolated' : '' }}">
<view
wx:if="{{ title }}"
class="van-dialog__header {{ message || useSlot ? '' : 'van-dialog--isolated' }}"
>
{{ title }}
</view>
<view class="van-dialog__content" wx:if="{{ message || useSlot }}">
<slot wx:if="{{ useSlot }}" />
<view wx:elif="{{ message }}" class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }}">
<text>{{ message }}</text>
</view>
<slot wx:if="{{ useSlot }}" />
<view
wx:elif="{{ message }}"
class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }}"
>
<text>{{ message }}</text>
</view>
<view class="van-hairline--top van-dialog__footer {{ showCancelButton && showConfirmButton ? 'van-dialog__footer--buttons' : '' }}">
<view wx:if="{{ showCancelButton }}" class="van-dialog__button">
<van-button
loading="{{ loading.cancel }}"
size="large"
custom-class="van-dialog__cancel"
bind:click="onCancel"
>
{{ cancelButtonText }}
</van-button>
</view>
<view
wx:if="{{ showConfirmButton }}"
class="van-dialog__button {{ showCancelButton ? 'van-hairline--left' : '' }}"
<view class="van-hairline--top van-dialog__footer">
<van-button
wx:if="{{ showCancelButton }}"
size="large"
loading="{{ loading.cancel }}"
class="van-dialog__button van-hairline--right"
custom-class="van-dialog__cancel"
bind:click="onCancel"
>
<van-button
size="large"
loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm"
open-type="{{ confirmButtonOpenType }}"
bind:click="onConfirm"
bindcontact="bindContact"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindopensetting="bindOpenSetting"
>
{{ confirmButtonText }}
</van-button>
</view>
{{ cancelButtonText }}
</van-button>
<van-button
wx:if="{{ showConfirmButton }}"
size="large"
class="van-dialog__button"
loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm"
open-type="{{ confirmButtonOpenType }}"
bind:click="onConfirm"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
>
{{ confirmButtonText }}
</van-button>
</view>
</van-popup>

View File

@ -1,11 +1,12 @@
export const button = Behavior({
properties: {
id: String,
sessionFrom: String,
appParameter: String,
sendMessageTitle: String,
sendMessagePath: String,
sendMessageImg: String,
sendMessagePath: String,
showMessageCard: String,
sendMessageTitle: String,
hoverStopPropagation: Boolean,
hoverStartTime: {
type: Number,
@ -19,9 +20,5 @@ export const button = Behavior({
type: String,
value: 'en'
},
sessionFrom: {
type: String,
value: ''
}
}
});