仿互站小程序
This commit is contained in:
54
vant/dialog/dialog.js
Normal file
54
vant/dialog/dialog.js
Normal file
@@ -0,0 +1,54 @@
|
||||
function e() {
|
||||
var e = getCurrentPages();
|
||||
return e[e.length - 1];
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: !0
|
||||
});
|
||||
|
||||
var t = [], n = function n(o) {
|
||||
return o = Object.assign({}, n.currentOptions, o), o.html = -1 != o.message.indexOf("<"),
|
||||
new Promise(function(n, s) {
|
||||
var c = (o.context || e()).selectComponent(o.selector);
|
||||
delete o.selector, c ? (c.set(Object.assign({
|
||||
onCancel: s,
|
||||
onConfirm: n
|
||||
}, o)), t.push(c)) : console.warn("未找到 van-dialog 节点,请确认 selector 及 context 是否正确");
|
||||
});
|
||||
};
|
||||
|
||||
n.defaultOptions = {
|
||||
show: !0,
|
||||
title: "",
|
||||
message: "",
|
||||
zIndex: 2e4,
|
||||
overlay: !0,
|
||||
className: "",
|
||||
asyncClose: !1,
|
||||
messageAlign: "",
|
||||
transition: "scale",
|
||||
selector: "#van-dialog",
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
showConfirmButton: !0,
|
||||
showCancelButton: !1,
|
||||
closeOnClickOverlay: !1,
|
||||
confirmButtonOpenType: ""
|
||||
}, n.alert = n, n.confirm = function(e) {
|
||||
return n(Object.assign({
|
||||
showCancelButton: !0
|
||||
}, e));
|
||||
}, n.close = function() {
|
||||
t.forEach(function(e) {
|
||||
e.close();
|
||||
}), t = [];
|
||||
}, n.stopLoading = function() {
|
||||
t.forEach(function(e) {
|
||||
e.stopLoading();
|
||||
});
|
||||
}, n.setDefaultOptions = function(e) {
|
||||
Object.assign(n.currentOptions, e);
|
||||
}, n.resetDefaultOptions = function() {
|
||||
n.currentOptions = Object.assign({}, n.defaultOptions);
|
||||
}, n.resetDefaultOptions(), exports.default = n;
|
99
vant/dialog/index.js
Normal file
99
vant/dialog/index.js
Normal file
@@ -0,0 +1,99 @@
|
||||
function n(n, e, o) {
|
||||
return e in n ? Object.defineProperty(n, e, {
|
||||
value: o,
|
||||
enumerable: !0,
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
}) : n[e] = o, n;
|
||||
}
|
||||
|
||||
var e = require("../common/component"), o = require("../mixins/button"), t = require("../mixins/open-type");
|
||||
|
||||
(0, e.VantComponent)({
|
||||
mixins: [ o.button, t.openType ],
|
||||
props: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
message: String,
|
||||
useSlot: Boolean,
|
||||
className: String,
|
||||
asyncClose: Boolean,
|
||||
messageAlign: String,
|
||||
showCancelButton: Boolean,
|
||||
closeOnClickOverlay: Boolean,
|
||||
confirmButtonOpenType: String,
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 2e4
|
||||
},
|
||||
confirmButtonText: {
|
||||
type: String,
|
||||
value: "确认"
|
||||
},
|
||||
cancelButtonText: {
|
||||
type: String,
|
||||
value: "取消"
|
||||
},
|
||||
showConfirmButton: {
|
||||
type: Boolean,
|
||||
value: !0
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
value: !0
|
||||
},
|
||||
transition: {
|
||||
type: String,
|
||||
value: "scale"
|
||||
},
|
||||
closable: {
|
||||
type: Boolean,
|
||||
value: !1
|
||||
}
|
||||
},
|
||||
data: {
|
||||
loading: {
|
||||
confirm: !1,
|
||||
cancel: !1
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show: function(n) {
|
||||
!n && this.stopLoading();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onConfirm: function() {
|
||||
this.handleAction("confirm");
|
||||
},
|
||||
onCancel: function() {
|
||||
this.handleAction("cancel");
|
||||
},
|
||||
onClickOverlay: function() {
|
||||
this.onClose("overlay");
|
||||
},
|
||||
handleAction: function(e) {
|
||||
this.data.asyncClose && this.set(n({}, "loading." + e, !0)), this.onClose(e);
|
||||
},
|
||||
close: function() {
|
||||
this.set({
|
||||
show: !1
|
||||
});
|
||||
},
|
||||
stopLoading: function() {
|
||||
this.set({
|
||||
loading: {
|
||||
confirm: !1,
|
||||
cancel: !1
|
||||
}
|
||||
});
|
||||
},
|
||||
onClose: function(n) {
|
||||
this.data.asyncClose || this.close(), this.$emit("close", n), this.$emit(n, {
|
||||
dialog: this
|
||||
});
|
||||
var e = this.data["confirm" === n ? "onConfirm" : "onCancel"];
|
||||
e && e(this);
|
||||
}
|
||||
}
|
||||
});
|
13
vant/dialog/index.json
Normal file
13
vant/dialog/index.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-popup": "../popup/index",
|
||||
"van-button": "../button/index",
|
||||
"forview": "/utils/forview/index",
|
||||
"van-loading": "/vant/loading/index",
|
||||
"van-dialog": "/vant/dialog/index",
|
||||
"van-icon": "/vant/icon/index",
|
||||
"van-tab": "/vant/tab/index",
|
||||
"van-tabs": "/vant/tabs/index"
|
||||
}
|
||||
}
|
18
vant/dialog/index.wxml
Normal file
18
vant/dialog/index.wxml
Normal file
@@ -0,0 +1,18 @@
|
||||
<van-popup bind:close="onClickOverlay" closable="{{closable}}" closeOnClickOverlay="{{closeOnClickOverlay}}" customClass="van-dialog {{className}}" overlay="{{overlay}}" show="{{show}}" transition="{{transition}}" zIndex="{{zIndex}}">
|
||||
<view class="van-dialog__header {{message||useSlot?'':'van-dialog--isolated'}}" wx:if="{{title}}">
|
||||
{{title}}
|
||||
</view>
|
||||
<slot wx:if="{{useSlot}}"></slot>
|
||||
<view class="van-dialog__message {{title?'van-dialog__message--has-title':''}} {{messageAlign?'van-dialog__message--'+messageAlign:''}}" wx:elif="{{message}}">
|
||||
<rich-text nodes="{{message}}" wx:if="{{html}}"></rich-text>
|
||||
<text wx:else>{{message}}</text>
|
||||
</view>
|
||||
<view class="van-hairline--top van-dialog__footer">
|
||||
<van-button bind:click="onCancel" class="van-dialog__button van-hairline--right" customClass="van-dialog__cancel" loading="{{loading.cancel}}" size="large" wx:if="{{showCancelButton}}">
|
||||
{{cancelButtonText}}
|
||||
</van-button>
|
||||
<van-button appParameter="{{appParameter}}" bind:click="onConfirm" bindcontact="bindContact" binderror="bindError" bindgetphonenumber="bindGetPhoneNumber" bindgetuserinfo="bindGetUserInfo" bindlaunchapp="bindLaunchApp" bindopensetting="bindOpenSetting" businessId="{{businessId}}" class="van-dialog__button" customClass="van-dialog__confirm" lang="{{lang}}" loading="{{loading.confirm}}" openType="{{confirmButtonOpenType}}" sendMessageImg="{{sendMessageImg}}" sendMessagePath="{{sendMessagePath}}" sendMessageTitle="{{sendMessageTitle}}" sessionFrom="{{sessionFrom}}" showMessageCard="{{showMessageCard}}" size="large" wx:if="{{showConfirmButton}}">
|
||||
{{confirmButtonText}}
|
||||
</van-button>
|
||||
</view>
|
||||
</van-popup>
|
68
vant/dialog/index.wxss
Normal file
68
vant/dialog/index.wxss
Normal file
@@ -0,0 +1,68 @@
|
||||
@import "../area/index.wxss";
|
||||
|
||||
.van-dialog {
|
||||
width: 85%;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.van-dialog__header {
|
||||
padding-top: 21px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.van-dialog__header--isolated {
|
||||
padding: 25px 0;
|
||||
}
|
||||
|
||||
.van-dialog__message {
|
||||
max-height: 60vh;
|
||||
padding: 10px 15px;
|
||||
overflow-y: auto;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.van-dialog__message--has-title {
|
||||
padding-top: 12px;
|
||||
color: #7d7e80;
|
||||
}
|
||||
|
||||
.van-dialog__message--left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.van-dialog__message--right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.van-dialog__footer {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.van-dialog__button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.van-dialog__cancel,.van-dialog__confirm {
|
||||
border: 0!important;
|
||||
}
|
||||
|
||||
.van-dialog__confirm {
|
||||
color: #1989fa!important;
|
||||
}
|
||||
|
||||
.van-dialog-bounce-enter {
|
||||
opacity: 0;
|
||||
transform: translate3d(-50%,-50%,0) scale(.7);
|
||||
}
|
||||
|
||||
.van-dialog-bounce-leave-active {
|
||||
opacity: 0;
|
||||
transform: translate3d(-50%,-50%,0) scale(.9);
|
||||
}
|
Reference in New Issue
Block a user