|
|
import {isArray} from 'lodash';
|
|
|
import { isArray } from 'lodash';
|
|
|
|
|
|
export default {
|
|
|
install(Vue) {
|
...
|
...
|
@@ -6,57 +6,57 @@ export default { |
|
|
let promptEle = null;
|
|
|
let timer = null;
|
|
|
|
|
|
function creatPromptVM(self) {
|
|
|
function createPromptVM(self) {
|
|
|
let tpl = Vue.extend({
|
|
|
data: function () {
|
|
|
return {
|
|
|
type: '',
|
|
|
img: '',
|
|
|
title: '',
|
|
|
desc: '',
|
|
|
onClick: null,
|
|
|
classNames: []
|
|
|
}
|
|
|
},
|
|
|
render: function(h) {
|
|
|
let classNames = ['yoho-grass-prompt-wrap', ...this.classNames];
|
|
|
data: function() {
|
|
|
return {
|
|
|
type: '',
|
|
|
img: '',
|
|
|
title: '',
|
|
|
desc: '',
|
|
|
onClick: null,
|
|
|
classNames: []
|
|
|
};
|
|
|
},
|
|
|
render: function(h) {
|
|
|
let classNames = ['yoho-grass-prompt-wrap', ...this.classNames];
|
|
|
|
|
|
return h('div', {class: ['yoho-grass-prompt', `yoho-grass-prompt-${this.type}`]}, [
|
|
|
h(this.url ? 'router-link' : 'div', {
|
|
|
class: classNames,
|
|
|
on: {
|
|
|
click: () => {
|
|
|
this.onClick && this.onClick();
|
|
|
}
|
|
|
return h('div', { class: ['yoho-grass-prompt', `yoho-grass-prompt-${this.type}`] }, [
|
|
|
h(this.url ? 'router-link' : 'div', {
|
|
|
class: classNames,
|
|
|
on: {
|
|
|
click: () => {
|
|
|
this.onClick && this.onClick();
|
|
|
}
|
|
|
}, [
|
|
|
h('ImageFormat', {
|
|
|
class: ['prompt-thumb'],
|
|
|
props: {
|
|
|
src: this.img,
|
|
|
lazy: false,
|
|
|
width: 100,
|
|
|
height: 100
|
|
|
}
|
|
|
}, [
|
|
|
h('ImageFormat', {
|
|
|
class: ['prompt-thumb'],
|
|
|
props: {
|
|
|
src: this.img,
|
|
|
lazy: false,
|
|
|
width: 100,
|
|
|
height: 100
|
|
|
}
|
|
|
}),
|
|
|
h('div', { class: ['prompt-info'] }, [
|
|
|
h('p', {
|
|
|
class: ['prompt-info-title'],
|
|
|
domProps: {
|
|
|
innerHTML: this.title
|
|
|
}
|
|
|
}),
|
|
|
h('div', {class: ['prompt-info']}, [
|
|
|
h('p', {
|
|
|
class: ['prompt-info-title'],
|
|
|
domProps: {
|
|
|
innerHTML: this.title
|
|
|
}
|
|
|
}),
|
|
|
h('p', {
|
|
|
class: ['prompt-info-desc'],
|
|
|
domProps: {
|
|
|
innerHTML: this.desc
|
|
|
}
|
|
|
})
|
|
|
]),
|
|
|
h('span', {class: ['iconfont', 'icon-right', 'prompt-icon']})
|
|
|
])
|
|
|
h('p', {
|
|
|
class: ['prompt-info-desc'],
|
|
|
domProps: {
|
|
|
innerHTML: this.desc
|
|
|
}
|
|
|
})
|
|
|
]),
|
|
|
h('span', { class: ['iconfont', 'icon-right', 'prompt-icon'] })
|
|
|
])
|
|
|
}
|
|
|
]);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
promptVM = new tpl();
|
...
|
...
|
@@ -65,13 +65,13 @@ export default { |
|
|
}
|
|
|
|
|
|
Vue.prototype.$grassPrompt = function(data = {}, time) {
|
|
|
let {img, title, desc, type, className, onClick} = data;
|
|
|
let { img, title, desc, type, className, onClick } = data;
|
|
|
|
|
|
if (!promptVM) {
|
|
|
creatPromptVM(this);
|
|
|
createPromptVM(this);
|
|
|
}
|
|
|
|
|
|
promptVM.img = img || '';
|
|
|
promptVM.img = img || '';
|
|
|
promptVM.title = title;
|
|
|
promptVM.desc = desc;
|
|
|
promptVM.type = type || 'bottom';
|
...
|
...
|
|