width: 200px;
margin: 0px auto;
padding: 20px 30px;
- background-color: #fff;
+ background-color: #1bc1b0;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
.modal-header {
margin-top: 0;
- color: #1bc1b0;
}
.modal-body {
margin: 20px 0;
- color: #1bc1b0;
}
.modal-default-button {
<template>
<transition name="modal">
- <div class="modal-mask">
+ <div class="modal-mask" v-if="show">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
- default header
+ {{ header }}
</slot>
</div>
<div class="modal-body">
<slot name="body">
- default body
+ {{ body }}
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
- <button class="modal-default-button" @click="$emit('close')">
- OK
- </button>
+ <a class="btn btn-primary" @click="closeDialog()">
+ {{ confirm }}
+ </a>
</slot>
</div>
</div>
<script>
export default {
name: 'Dialog',
+ data() {
+ return {
+ show: false,
+ };
+ },
+ props: {
+ header: {
+ type: String
+ },
+ body: {
+ type: String
+ },
+ confirm: {
+ type: String,
+ default: "OK"
+ }
+ },
+ methods: {
+ showDialog: function() {
+ this.show = true;
+ },
+ closeDialog: function() {
+ this.show = false;
+ this.$emit('on-close');
+ }
+ }
}
</script>
--- /dev/null
+import dialog from "./component"
+import Vue from 'vue';
+
+let instance;
+const dialogInstance = {
+ install: function (Vue, options) {
+ Vue.component('v-dialog', dialog);
+ Vue.prototype.$dialog = dialogInstance;
+ },
+ close: function() {
+ if(instance) {
+ instance.$children[0].closeDialog();
+ instance.onClose();
+ }
+ },
+ show: function(op) {
+ let data = {
+ header: op.header,
+ body: op.body,
+ };
+ if (op.confirm) {
+ data.confirm = op.confirm;
+ }
+ instance = new Vue({
+ data: data,
+ methods: {
+ onClose: function() {
+ this.$destroy();
+ document.getElementById("app").removeChild(this.$el);
+ },
+ },
+ render (h) {
+ return h(dialog, {
+ props: {
+ header: this.header,
+ body: this.body,
+ confirm: this.confirm,
+ },
+ on: {
+ onClose: this.onClose,
+ }
+ });
+ }
+ });
+ const component = instance.$mount();
+ document.getElementById("app").appendChild(component.$el);
+ instance.$children[0].showDialog();
+ }
+};
+
+export default dialogInstance;
\ No newline at end of file
.catch(err => {
console.log(err);
loader.hide();
- alert(err);
+ this.$dialog.show({
+ header: "提示",
+ body: err.message,
+ });
// this.tips = err.message;
});
}
console.log(res);
})
.catch(error => {
- alert(error);
+ this.$dialog.show({
+ header: "提示",
+ body: error,
+ });
});
}
}
},
confirmTransfer: function() {
if (this.confirmPasssword != this.transaction.passwd) {
- alert("密码不一致");
+ this.$dialog.show({
+ header: "提示",
+ body: "密码不一致",
+ });
return;
}
let loader = this.$loading.show({
this.confirmClose();
this.transaction.passwd = "";
this.confirmPasssword = "";
- alert(error);
+ this.$dialog.show({
+ header: "提示",
+ body: err.message,
+ });
});
}
}
<Menu ref="menu" @on-current-account="accountLoader" @accounts-clear="accountClear"></Menu>
<Transfer ref="transfer" @on-success="refreshTransactions"></Transfer>
<TxInfo ref="trxInfo" @on-success="refreshTransactions"></TxInfo>
- <v-dialog v-if="showModal" @close="showModal = false">
- <h3 slot="header">提示</h3>
- <h5 slot="body">{{this.dialogMsg}}</h5>
- </v-dialog>
</div>
</template>
},
data() {
return {
- dialogMsg: "",
- showModal: false,
network: "testnet",
clipboard: new ClipboardJS(".address-text"),
addressTitle: "点击复制地址",
this.refreshTransactions();
this.clipboard.on("success", (e) => {
- this.dialogMsg = "coby success";
- this.showModal = true;
+ this.$dialog.show({
+ header: "提示",
+ body: "coby success",
+ });
});
this.clipboard.on("error", (e) => {
- this.dialogMsg = "coby error";
- this.showModal = true;
+ this.$dialog.show({
+ header: "提示",
+ body: "coby error",
+ });
});
},
beforeDestroy() {
import 'vuescroll/dist/vuescroll.css';
import "../assets/style.css";
import 'vue-loading-overlay/dist/vue-loading.css';
-import dialog from "./dialog/component"
+import Dialog from "./dialog/index"
Vue.use(Loading);
Vue.use(vuescroll);
-Vue.component('v-dialog', dialog);
+Vue.use(Dialog);
Vue.prototype.$vuescrollConfig = {
bar: {
mode: 'pure-native',
})
.catch(err => {
loader.hide();
- alert(err);
+ this.$dialog.show({
+ header: "提示",
+ body: err.message,
+ });
});
},
recover: function() {
localStorage.login = true;
})
.catch(error => {
- alert(error);
+ this.$dialog.show({
+ header: "提示",
+ body: err.message,
+ });
});
},
back: function() {