1
|
-import {isArray} from 'lodash';
|
1
|
+import { isArray } from 'lodash';
|
2
|
|
2
|
|
3
|
export default {
|
3
|
export default {
|
4
|
install(Vue) {
|
4
|
install(Vue) {
|
|
@@ -6,57 +6,57 @@ export default { |
|
@@ -6,57 +6,57 @@ export default { |
6
|
let promptEle = null;
|
6
|
let promptEle = null;
|
7
|
let timer = null;
|
7
|
let timer = null;
|
8
|
|
8
|
|
9
|
- function creatPromptVM(self) {
|
9
|
+ function createPromptVM(self) {
|
10
|
let tpl = Vue.extend({
|
10
|
let tpl = Vue.extend({
|
11
|
- data: function () {
|
|
|
12
|
- return {
|
|
|
13
|
- type: '',
|
|
|
14
|
- img: '',
|
|
|
15
|
- title: '',
|
|
|
16
|
- desc: '',
|
|
|
17
|
- onClick: null,
|
|
|
18
|
- classNames: []
|
|
|
19
|
- }
|
|
|
20
|
- },
|
|
|
21
|
- render: function(h) {
|
|
|
22
|
- let classNames = ['yoho-grass-prompt-wrap', ...this.classNames];
|
11
|
+ data: function() {
|
|
|
12
|
+ return {
|
|
|
13
|
+ type: '',
|
|
|
14
|
+ img: '',
|
|
|
15
|
+ title: '',
|
|
|
16
|
+ desc: '',
|
|
|
17
|
+ onClick: null,
|
|
|
18
|
+ classNames: []
|
|
|
19
|
+ };
|
|
|
20
|
+ },
|
|
|
21
|
+ render: function(h) {
|
|
|
22
|
+ let classNames = ['yoho-grass-prompt-wrap', ...this.classNames];
|
23
|
|
23
|
|
24
|
- return h('div', {class: ['yoho-grass-prompt', `yoho-grass-prompt-${this.type}`]}, [
|
|
|
25
|
- h(this.url ? 'router-link' : 'div', {
|
|
|
26
|
- class: classNames,
|
|
|
27
|
- on: {
|
|
|
28
|
- click: () => {
|
|
|
29
|
- this.onClick && this.onClick();
|
|
|
30
|
- }
|
24
|
+ return h('div', { class: ['yoho-grass-prompt', `yoho-grass-prompt-${this.type}`] }, [
|
|
|
25
|
+ h(this.url ? 'router-link' : 'div', {
|
|
|
26
|
+ class: classNames,
|
|
|
27
|
+ on: {
|
|
|
28
|
+ click: () => {
|
|
|
29
|
+ this.onClick && this.onClick();
|
31
|
}
|
30
|
}
|
32
|
- }, [
|
|
|
33
|
- h('ImageFormat', {
|
|
|
34
|
- class: ['prompt-thumb'],
|
|
|
35
|
- props: {
|
|
|
36
|
- src: this.img,
|
|
|
37
|
- lazy: false,
|
|
|
38
|
- width: 100,
|
|
|
39
|
- height: 100
|
31
|
+ }
|
|
|
32
|
+ }, [
|
|
|
33
|
+ h('ImageFormat', {
|
|
|
34
|
+ class: ['prompt-thumb'],
|
|
|
35
|
+ props: {
|
|
|
36
|
+ src: this.img,
|
|
|
37
|
+ lazy: false,
|
|
|
38
|
+ width: 100,
|
|
|
39
|
+ height: 100
|
|
|
40
|
+ }
|
|
|
41
|
+ }),
|
|
|
42
|
+ h('div', { class: ['prompt-info'] }, [
|
|
|
43
|
+ h('p', {
|
|
|
44
|
+ class: ['prompt-info-title'],
|
|
|
45
|
+ domProps: {
|
|
|
46
|
+ innerHTML: this.title
|
40
|
}
|
47
|
}
|
41
|
}),
|
48
|
}),
|
42
|
- h('div', {class: ['prompt-info']}, [
|
|
|
43
|
- h('p', {
|
|
|
44
|
- class: ['prompt-info-title'],
|
|
|
45
|
- domProps: {
|
|
|
46
|
- innerHTML: this.title
|
|
|
47
|
- }
|
|
|
48
|
- }),
|
|
|
49
|
- h('p', {
|
|
|
50
|
- class: ['prompt-info-desc'],
|
|
|
51
|
- domProps: {
|
|
|
52
|
- innerHTML: this.desc
|
|
|
53
|
- }
|
|
|
54
|
- })
|
|
|
55
|
- ]),
|
|
|
56
|
- h('span', {class: ['iconfont', 'icon-right', 'prompt-icon']})
|
|
|
57
|
- ])
|
49
|
+ h('p', {
|
|
|
50
|
+ class: ['prompt-info-desc'],
|
|
|
51
|
+ domProps: {
|
|
|
52
|
+ innerHTML: this.desc
|
|
|
53
|
+ }
|
|
|
54
|
+ })
|
|
|
55
|
+ ]),
|
|
|
56
|
+ h('span', { class: ['iconfont', 'icon-right', 'prompt-icon'] })
|
58
|
])
|
57
|
])
|
59
|
- }
|
58
|
+ ]);
|
|
|
59
|
+ }
|
60
|
});
|
60
|
});
|
61
|
|
61
|
|
62
|
promptVM = new tpl();
|
62
|
promptVM = new tpl();
|
|
@@ -65,13 +65,13 @@ export default { |
|
@@ -65,13 +65,13 @@ export default { |
65
|
}
|
65
|
}
|
66
|
|
66
|
|
67
|
Vue.prototype.$grassPrompt = function(data = {}, time) {
|
67
|
Vue.prototype.$grassPrompt = function(data = {}, time) {
|
68
|
- let {img, title, desc, type, className, onClick} = data;
|
68
|
+ let { img, title, desc, type, className, onClick } = data;
|
69
|
|
69
|
|
70
|
if (!promptVM) {
|
70
|
if (!promptVM) {
|
71
|
- creatPromptVM(this);
|
71
|
+ createPromptVM(this);
|
72
|
}
|
72
|
}
|
73
|
|
73
|
|
74
|
- promptVM.img = img || '';
|
74
|
+ promptVM.img = img || '';
|
75
|
promptVM.title = title;
|
75
|
promptVM.title = title;
|
76
|
promptVM.desc = desc;
|
76
|
promptVM.desc = desc;
|
77
|
promptVM.type = type || 'bottom';
|
77
|
promptVM.type = type || 'bottom';
|