mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
微信登录版
This commit is contained in:
104
wechat_v2/miniprogram_npm/@vant/weapp/dialog/dialog.js
Normal file
104
wechat_v2/miniprogram_npm/@vant/weapp/dialog/dialog.js
Normal file
@@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
var __assign =
|
||||
(this && this.__assign) ||
|
||||
function () {
|
||||
__assign =
|
||||
Object.assign ||
|
||||
function (t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s)
|
||||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var queue = [];
|
||||
var defaultOptions = {
|
||||
show: false,
|
||||
title: '',
|
||||
width: null,
|
||||
theme: 'default',
|
||||
message: '',
|
||||
zIndex: 100,
|
||||
overlay: true,
|
||||
selector: '#van-dialog',
|
||||
className: '',
|
||||
asyncClose: false,
|
||||
beforeClose: null,
|
||||
transition: 'scale',
|
||||
customStyle: '',
|
||||
messageAlign: '',
|
||||
overlayStyle: '',
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
showConfirmButton: true,
|
||||
showCancelButton: false,
|
||||
closeOnClickOverlay: false,
|
||||
confirmButtonOpenType: '',
|
||||
};
|
||||
var currentOptions = __assign({}, defaultOptions);
|
||||
function getContext() {
|
||||
var pages = getCurrentPages();
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
var Dialog = function (options) {
|
||||
options = __assign(__assign({}, currentOptions), options);
|
||||
return new Promise(function (resolve, reject) {
|
||||
var context = options.context || getContext();
|
||||
var dialog = context.selectComponent(options.selector);
|
||||
delete options.context;
|
||||
delete options.selector;
|
||||
if (dialog) {
|
||||
dialog.setData(
|
||||
__assign(
|
||||
{
|
||||
callback: function (action, instance) {
|
||||
action === 'confirm' ? resolve(instance) : reject(instance);
|
||||
},
|
||||
},
|
||||
options
|
||||
)
|
||||
);
|
||||
wx.nextTick(function () {
|
||||
dialog.setData({ show: true });
|
||||
});
|
||||
queue.push(dialog);
|
||||
} else {
|
||||
console.warn(
|
||||
'未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
Dialog.alert = function (options) {
|
||||
return Dialog(options);
|
||||
};
|
||||
Dialog.confirm = function (options) {
|
||||
return Dialog(__assign({ showCancelButton: true }, options));
|
||||
};
|
||||
Dialog.close = function () {
|
||||
queue.forEach(function (dialog) {
|
||||
dialog.close();
|
||||
});
|
||||
queue = [];
|
||||
};
|
||||
Dialog.stopLoading = function () {
|
||||
queue.forEach(function (dialog) {
|
||||
dialog.stopLoading();
|
||||
});
|
||||
};
|
||||
Dialog.currentOptions = currentOptions;
|
||||
Dialog.defaultOptions = defaultOptions;
|
||||
Dialog.setDefaultOptions = function (options) {
|
||||
currentOptions = __assign(__assign({}, currentOptions), options);
|
||||
Dialog.currentOptions = currentOptions;
|
||||
};
|
||||
Dialog.resetDefaultOptions = function () {
|
||||
currentOptions = __assign({}, defaultOptions);
|
||||
Dialog.currentOptions = currentOptions;
|
||||
};
|
||||
Dialog.resetDefaultOptions();
|
||||
exports.default = Dialog;
|
||||
126
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.js
Normal file
126
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.js
Normal file
@@ -0,0 +1,126 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var button_1 = require('../mixins/button');
|
||||
var color_1 = require('../common/color');
|
||||
var utils_1 = require('../common/utils');
|
||||
component_1.VantComponent({
|
||||
mixins: [button_1.button],
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
observer: function (show) {
|
||||
!show && this.stopLoading();
|
||||
},
|
||||
},
|
||||
title: String,
|
||||
message: String,
|
||||
theme: {
|
||||
type: String,
|
||||
value: 'default',
|
||||
},
|
||||
useSlot: Boolean,
|
||||
className: String,
|
||||
customStyle: String,
|
||||
asyncClose: Boolean,
|
||||
messageAlign: String,
|
||||
beforeClose: null,
|
||||
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: color_1.RED,
|
||||
},
|
||||
cancelButtonColor: {
|
||||
type: String,
|
||||
value: color_1.GRAY,
|
||||
},
|
||||
showConfirmButton: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
transition: {
|
||||
type: String,
|
||||
value: 'scale',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
loading: {
|
||||
confirm: false,
|
||||
cancel: false,
|
||||
},
|
||||
callback: function () {},
|
||||
},
|
||||
methods: {
|
||||
onConfirm: function () {
|
||||
this.handleAction('confirm');
|
||||
},
|
||||
onCancel: function () {
|
||||
this.handleAction('cancel');
|
||||
},
|
||||
onClickOverlay: function () {
|
||||
this.close('overlay');
|
||||
},
|
||||
close: function (action) {
|
||||
var _this = this;
|
||||
this.setData({ show: false });
|
||||
wx.nextTick(function () {
|
||||
_this.$emit('close', action);
|
||||
var callback = _this.data.callback;
|
||||
if (callback) {
|
||||
callback(action, _this);
|
||||
}
|
||||
});
|
||||
},
|
||||
stopLoading: function () {
|
||||
this.setData({
|
||||
loading: {
|
||||
confirm: false,
|
||||
cancel: false,
|
||||
},
|
||||
});
|
||||
},
|
||||
handleAction: function (action) {
|
||||
var _a;
|
||||
var _this = this;
|
||||
this.$emit(action, { dialog: this });
|
||||
var _b = this.data,
|
||||
asyncClose = _b.asyncClose,
|
||||
beforeClose = _b.beforeClose;
|
||||
if (!asyncClose && !beforeClose) {
|
||||
this.close(action);
|
||||
return;
|
||||
}
|
||||
this.setData(((_a = {}), (_a['loading.' + action] = true), _a));
|
||||
if (beforeClose) {
|
||||
utils_1.toPromise(beforeClose(action)).then(function (value) {
|
||||
if (value) {
|
||||
_this.close(action);
|
||||
} else {
|
||||
_this.stopLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
9
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.json
Normal file
9
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-popup": "../popup/index",
|
||||
"van-button": "../button/index",
|
||||
"van-goods-action": "../goods-action/index",
|
||||
"van-goods-action-button": "../goods-action-button/index"
|
||||
}
|
||||
}
|
||||
113
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.wxml
Normal file
113
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.wxml
Normal file
@@ -0,0 +1,113 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<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 }}"
|
||||
bind:close="onClickOverlay"
|
||||
>
|
||||
<view
|
||||
wx:if="{{ title || useTitleSlot }}"
|
||||
class="{{ utils.bem('dialog__header', { isolated: !(message || useSlot) }) }}"
|
||||
>
|
||||
<slot wx:if="{{ useTitleSlot }}" name="title" />
|
||||
<block wx:elif="{{ title }}">{{ title }}</block>
|
||||
</view>
|
||||
|
||||
<slot wx:if="{{ useSlot }}" />
|
||||
<view
|
||||
wx:elif="{{ message }}"
|
||||
class="{{ utils.bem('dialog__message', [theme, messageAlign, { hasTitle: title }]) }}"
|
||||
>
|
||||
<text class="van-dialog__message-text">{{ message }}</text>
|
||||
</view>
|
||||
|
||||
<van-goods-action wx:if="{{ theme === 'round-button' }}" custom-class="van-dialog__footer--round-button">
|
||||
<van-goods-action-button
|
||||
wx:if="{{ showCancelButton }}"
|
||||
size="large"
|
||||
loading="{{ loading.cancel }}"
|
||||
class="van-dialog__button van-hairline--right"
|
||||
custom-class="van-dialog__cancel"
|
||||
custom-style="color: {{ cancelButtonColor }}"
|
||||
bind:click="onCancel"
|
||||
>
|
||||
{{ cancelButtonText }}
|
||||
</van-goods-action-button>
|
||||
<van-goods-action-button
|
||||
wx: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 }}"
|
||||
|
||||
bind:click="onConfirm"
|
||||
bindgetuserinfo="onGetUserInfo"
|
||||
bindcontact="onContact"
|
||||
bindgetphonenumber="onGetPhoneNumber"
|
||||
binderror="onError"
|
||||
bindlaunchapp="onLaunchApp"
|
||||
bindopensetting="onOpenSetting"
|
||||
>
|
||||
{{ confirmButtonText }}
|
||||
</van-goods-action-button>
|
||||
</van-goods-action>
|
||||
|
||||
<view wx:else 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"
|
||||
custom-style="color: {{ cancelButtonColor }}"
|
||||
bind:click="onCancel"
|
||||
>
|
||||
{{ cancelButtonText }}
|
||||
</van-button>
|
||||
<van-button
|
||||
wx: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 }}"
|
||||
|
||||
bind:click="onConfirm"
|
||||
bindgetuserinfo="onGetUserInfo"
|
||||
bindcontact="onContact"
|
||||
bindgetphonenumber="onGetPhoneNumber"
|
||||
binderror="onError"
|
||||
bindlaunchapp="onLaunchApp"
|
||||
bindopensetting="onOpenSetting"
|
||||
>
|
||||
{{ confirmButtonText }}
|
||||
</van-button>
|
||||
</view>
|
||||
</van-popup>
|
||||
1
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.wxss
Normal file
1
wechat_v2/miniprogram_npm/@vant/weapp/dialog/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.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:flex}.van-dialog__footer--round-button{position:relative!important;padding:8px 24px 16px!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{transform:translate3d(-50%,-50%,0) scale(.9);opacity:0}
|
||||
Reference in New Issue
Block a user