1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| <template>
| <uni-shadow-root class="vant-dialog-index"><van-popup :show="show" :z-index="zIndex" :overlay="overlay" :transition="transition" :custom-class="'van-dialog van-dialog--'+(theme)+' '+(className)" :custom-style="'width: '+(utils.addUnit(width))+';'+(customStyle)" :overlay-style="overlayStyle" :close-on-click-overlay="closeOnClickOverlay" @close="onClickOverlay">
| <view v-if="title || useTitleSlot" :class="utils.bem('dialog__header', { isolated: !(message || useSlot) })">
| <slot v-if="useTitleSlot" name="title"></slot>
| <block v-else-if="title">{{ title }}</block>
| </view>
|
| <slot v-if="useSlot"></slot>
| <view v-else-if="message" :class="utils.bem('dialog__message', [theme, messageAlign, { hasTitle: title }])">
| <text class="van-dialog__message-text">{{ message }}</text>
| </view>
|
| <van-goods-action v-if="theme === 'round-button'" custom-class="van-dialog__footer--round-button">
| <van-goods-action-button v-if="showCancelButton" size="large" :loading="loading.cancel" class="van-dialog__button van-hairline--right" custom-class="van-dialog__cancel" :custom-style="'color: '+(cancelButtonColor)" @click="onCancel">
| {{ cancelButtonText }}
| </van-goods-action-button>
| <van-goods-action-button v-if="showConfirmButton" size="large" class="van-dialog__button" :loading="loading.confirm" custom-class="van-dialog__confirm" :custom-style="'color: '+(confirmButtonColor)" :open-type="confirmButtonOpenType" :lang="lang" :business-id="businessId" :session-from="sessionFrom" :send-message-title="sendMessageTitle" :send-message-path="sendMessagePath" :send-message-img="sendMessageImg" :show-message-card="showMessageCard" :app-parameter="appParameter" @click="onConfirm" @getuserinfo="bindGetUserInfo" @contact="bindContact" @getphonenumber="bindGetPhoneNumber" @error="bindError" @launchapp="bindLaunchApp" @opensetting="bindOpenSetting">
| {{ confirmButtonText }}
| </van-goods-action-button>
| </van-goods-action>
|
| <view v-else class="van-hairline--top van-dialog__footer">
| <van-button v-if="showCancelButton" size="large" :loading="loading.cancel" class="van-dialog__button van-hairline--right" custom-class="van-dialog__cancel" :custom-style="'color: '+(cancelButtonColor)" @click="onCancel">
| {{ cancelButtonText }}
| </van-button>
| <van-button v-if="showConfirmButton" size="large" class="van-dialog__button" :loading="loading.confirm" custom-class="van-dialog__confirm" :custom-style="'color: '+(confirmButtonColor)" :open-type="confirmButtonOpenType" :lang="lang" :business-id="businessId" :session-from="sessionFrom" :send-message-title="sendMessageTitle" :send-message-path="sendMessagePath" :send-message-img="sendMessageImg" :show-message-card="showMessageCard" :app-parameter="appParameter" @click="onConfirm" @getuserinfo="bindGetUserInfo" @contact="bindContact" @getphonenumber="bindGetPhoneNumber" @error="bindError" @launchapp="bindLaunchApp" @opensetting="bindOpenSetting">
| {{ confirmButtonText }}
| </van-button>
| </view>
| </van-popup></uni-shadow-root>
| </template>
| <wxs src="../wxs/utils.wxs" module="utils"></wxs>
| <script>
| import VanPopup from '../popup/index.vue'
| import VanButton from '../button/index.vue'
| import VanGoodsAction from '../goods-action//index.vue'
| import VanGoodsActionButton from '../goods-action-button/index.vue'
| global['__wxVueOptions'] = {components:{'van-popup': VanPopup,'van-button': VanButton,'van-goods-action': VanGoodsAction,'van-goods-action-button': VanGoodsActionButton}}
|
| global['__wxRoute'] = 'vant/dialog/index'
| import { VantComponent } from '../common/component';
| import { button } from '../mixins/button';
| import { openType } from '../mixins/open-type';
| import { GRAY, RED } from '../common/color';
| VantComponent({
| mixins: [button, openType],
| props: {
| show: {
| type: Boolean,
| observer(show) {
| !show && this.stopLoading();
| },
| },
| title: String,
| message: String,
| theme: {
| type: String,
| value: 'default',
| },
| useSlot: Boolean,
| className: String,
| customStyle: String,
| asyncClose: Boolean,
| messageAlign: String,
| overlayStyle: String,
| useTitleSlot: Boolean,
| showCancelButton: Boolean,
| closeOnClickOverlay: Boolean,
| confirmButtonOpenType: String,
| width: null,
| zIndex: {
| type: Number,
| value: 2000,
| },
| confirmButtonText: {
| type: String,
| value: '确认',
| },
| cancelButtonText: {
| type: String,
| value: '取消',
| },
| confirmButtonColor: {
| type: String,
| value: RED,
| },
| cancelButtonColor: {
| type: String,
| value: GRAY,
| },
| showConfirmButton: {
| type: Boolean,
| value: true,
| },
| overlay: {
| type: Boolean,
| value: true,
| },
| transition: {
| type: String,
| value: 'scale',
| },
| },
| data: {
| loading: {
| confirm: false,
| cancel: false,
| },
| },
| methods: {
| onConfirm() {
| this.handleAction('confirm');
| },
| onCancel() {
| this.handleAction('cancel');
| },
| onClickOverlay() {
| this.onClose('overlay');
| },
| handleAction(action) {
| if (this.data.asyncClose) {
| this.setData({
| [`loading.${action}`]: true,
| });
| }
| this.onClose(action);
| },
| close() {
| this.setData({
| show: false,
| });
| },
| stopLoading() {
| this.setData({
| loading: {
| confirm: false,
| cancel: false,
| },
| });
| },
| onClose(action) {
| if (!this.data.asyncClose) {
| this.close();
| }
| this.$emit('close', action);
| // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading
| this.$emit(action, { dialog: this });
| const callback = this.data[
| action === 'confirm' ? 'onConfirm' : 'onCancel'
| ];
| if (callback) {
| callback(this);
| }
| },
| },
| });
| export default global['__wxComponents']['vant/dialog/index']
| </script>
| <style platform="mp-weixin">
| @import '../common/index.css';.van-dialog{top:45%!important;overflow:hidden;width:320px;width:var(--dialog-width,320px);font-size:16px;font-size:var(--dialog-font-size,16px);border-radius:16px;border-radius:var(--dialog-border-radius,16px);background-color:#fff;background-color:var(--dialog-background-color,#fff)}@media (max-width:321px){.van-dialog{width:90%;width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{text-align:center;padding-top:24px;padding-top:var(--dialog-header-padding-top,24px);font-weight:500;font-weight:var(--dialog-header-font-weight,500);line-height:24px;line-height:var(--dialog-header-line-height,24px)}.van-dialog__header--isolated{padding:24px 0;padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{overflow-y:auto;text-align:center;-webkit-overflow-scrolling:touch;font-size:14px;font-size:var(--dialog-message-font-size,14px);line-height:20px;line-height:var(--dialog-message-line-height,20px);max-height:60vh;max-height:var(--dialog-message-max-height,60vh);padding:24px;padding:var(--dialog-message-padding,24px)}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{padding-top:8px;padding-top:var(--dialog-has-title-message-padding-top,8px);color:#646566;color:var(--dialog-has-title-message-text-color,#646566)}.van-dialog__message--round-button{padding-bottom:16px;color:#323233}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__footer--round-button{position:relative!important;padding:8px 24px 16px!important}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9);opacity:0}
| </style>
|
|