dpzvc-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/build-style.js +42 -0
- package/dist/dpzvc.js +17605 -0
- package/dist/styles/dpzvc.css +1 -0
- package/dist-prod/index.html +26 -0
- package/dist-prod/main.js +1 -0
- package/dist-prod/vendor.bundle.js +1 -0
- package/package.json +88 -0
- package/src/components/Indicator/Indicator.vue +77 -0
- package/src/components/Indicator/index.js +153 -0
- package/src/components/Text/Number.vue +201 -0
- package/src/components/Text/index.js +7 -0
- package/src/components/Text/textBar.vue +142 -0
- package/src/components/action-sheet/actionSheet.vue +91 -0
- package/src/components/action-sheet/index.js +5 -0
- package/src/components/app.vue +66 -0
- package/src/components/badge/badge.vue +77 -0
- package/src/components/badge/index.js +5 -0
- package/src/components/button/button.vue +122 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/card.vue +59 -0
- package/src/components/card/index.js +5 -0
- package/src/components/cell/cell.vue +103 -0
- package/src/components/cell/index.js +5 -0
- package/src/components/cell-swipe/cell-swipe.vue +148 -0
- package/src/components/cell-swipe/index.js +5 -0
- package/src/components/checkBox/checkbox-group.vue +76 -0
- package/src/components/checkBox/checkbox.vue +107 -0
- package/src/components/checkBox/index.js +8 -0
- package/src/components/header/header.vue +82 -0
- package/src/components/header/index.js +5 -0
- package/src/components/loadMore/index.js +5 -0
- package/src/components/loadMore/loadmore.vue +293 -0
- package/src/components/message/confirm.js +52 -0
- package/src/components/message/index.js +132 -0
- package/src/components/message/message.vue +135 -0
- package/src/components/message/messageGroup.vue +74 -0
- package/src/components/modal/confirm.js +161 -0
- package/src/components/modal/index.js +63 -0
- package/src/components/modal/modal.vue +144 -0
- package/src/components/picker/area-picker/area-picker.vue +223 -0
- package/src/components/picker/area-picker/props.js +17 -0
- package/src/components/picker/date-picker/date-picker.vue +291 -0
- package/src/components/picker/date-picker/props.js +24 -0
- package/src/components/picker/index.js +5 -0
- package/src/components/picker/normal-picker/normal-picker.vue +107 -0
- package/src/components/picker/normal-picker/props.js +20 -0
- package/src/components/picker/picker-slot.vue +206 -0
- package/src/components/picker/picker.vue +111 -0
- package/src/components/popup/index.js +5 -0
- package/src/components/popup/popup.vue +117 -0
- package/src/components/progress/index.js +5 -0
- package/src/components/progress/progress.vue +77 -0
- package/src/components/prompt/confirm.js +174 -0
- package/src/components/prompt/index.js +50 -0
- package/src/components/prompt/prompt.vue +166 -0
- package/src/components/radioBox/index.js +8 -0
- package/src/components/radioBox/radiobox-group.vue +74 -0
- package/src/components/radioBox/radiobox.vue +117 -0
- package/src/components/rater/index.js +5 -0
- package/src/components/rater/rater.vue +164 -0
- package/src/components/slideBar/index.js +6 -0
- package/src/components/slideBar/slideBar.vue +269 -0
- package/src/components/spinner/behavior/blade.vue +22 -0
- package/src/components/spinner/behavior/double-bounce.vue +22 -0
- package/src/components/spinner/behavior/fading-circle.vue +37 -0
- package/src/components/spinner/behavior/snake.vue +32 -0
- package/src/components/spinner/behavior/triple-bounce.vue +41 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/spinner/props.js +25 -0
- package/src/components/spinner/spinner.vue +74 -0
- package/src/components/swipe/index.js +5 -0
- package/src/components/swipe/swipe.vue +399 -0
- package/src/components/switchbar/index.js +5 -0
- package/src/components/switchbar/switchbar.vue +83 -0
- package/src/components/tab/index.js +6 -0
- package/src/components/tab/tab.vue +95 -0
- package/src/components/toTop/index.js +5 -0
- package/src/components/toTop/topTop.vue +76 -0
- package/src/components/upload/index.js +5 -0
- package/src/components/upload/upload.vue +200 -0
- package/src/config/config.js +17 -0
- package/src/directives/clickoutside.js +32 -0
- package/src/directives/tranferDom.js +65 -0
- package/src/index.js +83 -0
- package/src/lib/MegaPixImage.js +253 -0
- package/src/lib/exif.js +808 -0
- package/src/main.js +76 -0
- package/src/mixin/emitter.js +41 -0
- package/src/mixin/input.js +41 -0
- package/src/router.js +229 -0
- package/src/styles/base/font.less +99 -0
- package/src/styles/base/reset.less +69 -0
- package/src/styles/base/variable.less +108 -0
- package/src/styles/components/actionSheet.less +43 -0
- package/src/styles/components/badge.less +79 -0
- package/src/styles/components/button.less +123 -0
- package/src/styles/components/card.less +31 -0
- package/src/styles/components/cell-swipe.less +20 -0
- package/src/styles/components/cell.less +71 -0
- package/src/styles/components/checkBox.less +111 -0
- package/src/styles/components/editor.less +3 -0
- package/src/styles/components/header.less +70 -0
- package/src/styles/components/indicator.less +37 -0
- package/src/styles/components/loadmore.less +48 -0
- package/src/styles/components/message.less +57 -0
- package/src/styles/components/modal.less +82 -0
- package/src/styles/components/number.less +58 -0
- package/src/styles/components/picker.less +150 -0
- package/src/styles/components/popup.less +46 -0
- package/src/styles/components/progress.less +50 -0
- package/src/styles/components/prompt.less +37 -0
- package/src/styles/components/radioBox.less +136 -0
- package/src/styles/components/slide-Bar.less +147 -0
- package/src/styles/components/spinner.less +328 -0
- package/src/styles/components/swipe.less +125 -0
- package/src/styles/components/switchBar.less +88 -0
- package/src/styles/components/tab.less +69 -0
- package/src/styles/components/text.less +80 -0
- package/src/styles/components/toTop.less +26 -0
- package/src/styles/components/upload.less +23 -0
- package/src/styles/index.less +38 -0
- package/src/styles/utils/1px.less +204 -0
- package/src/styles/utils/animation.less +131 -0
- package/src/styles/utils/nowrap.less +19 -0
- package/src/template/index.ejs +26 -0
- package/src/utils/util.js +203 -0
- package/src/vconsole-resources.min.js +6 -0
- package/src/vconsole-sources.min.js +6 -0
- package/src/vconsole.min.js +7 -0
- package/src/views/ActionSheet.vue +33 -0
- package/src/views/Badge.vue +40 -0
- package/src/views/Button.vue +40 -0
- package/src/views/Card.vue +52 -0
- package/src/views/Cell.vue +21 -0
- package/src/views/CellSwipe.vue +85 -0
- package/src/views/CheckBox.vue +53 -0
- package/src/views/Header.vue +47 -0
- package/src/views/Indicator.vue +69 -0
- package/src/views/LoadMore.vue +54 -0
- package/src/views/Message.vue +42 -0
- package/src/views/Modal.vue +32 -0
- package/src/views/Picker.vue +50 -0
- package/src/views/Popup.vue +87 -0
- package/src/views/Progress.vue +32 -0
- package/src/views/Prompt.vue +31 -0
- package/src/views/RadioBox.vue +55 -0
- package/src/views/Rater.vue +39 -0
- package/src/views/SlideBar.vue +47 -0
- package/src/views/Spinner.vue +15 -0
- package/src/views/Swipe.vue +34 -0
- package/src/views/SwitchBar.vue +36 -0
- package/src/views/Tab.vue +41 -0
- package/src/views/Text.vue +64 -0
- package/src/views/ToTop.vue +17 -0
- package/src/views/Upload.vue +44 -0
- package/src/views/guide.vue +159 -0
- package/src/views/index.vue +435 -0
- package/webpack.base.config.js +74 -0
- package/webpack.dev.config.js +67 -0
- package/webpack.dist.dev.config.js +44 -0
- package/webpack.dist.prod.config.js +50 -0
- package/webpack.prod.config.js +72 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<label :class="classes">
|
|
4
|
+
<span :class="wrapperClasses">
|
|
5
|
+
<span :class="innerClasses"></span>
|
|
6
|
+
<input type="checkbox" v-if="!isGroup" :disabled="disable" :checked="currentValue" @change="change"
|
|
7
|
+
class="dpzvc-checkbox-input noselect "/>
|
|
8
|
+
<input type="checkbox" v-else :disabled="disable" :value="label" v-model="model" @change="change"
|
|
9
|
+
class="dpzvc-checkbox-input noselect "/>
|
|
10
|
+
</span>
|
|
11
|
+
<slot v-if="show"><span ref="slot">{{label}}</span></slot>
|
|
12
|
+
</label>
|
|
13
|
+
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import {findComponentUpward} from '../../utils/util'
|
|
19
|
+
import Emitter from '../../mixin/emitter'
|
|
20
|
+
const prefixCls = 'dpzvc-checkbox';
|
|
21
|
+
export default {
|
|
22
|
+
name: 'checkBox',
|
|
23
|
+
data(){
|
|
24
|
+
return {
|
|
25
|
+
model: [],
|
|
26
|
+
isGroup: false,
|
|
27
|
+
show: true,
|
|
28
|
+
currentValue: this.value,
|
|
29
|
+
parent: findComponentUpward(this, 'checkBoxGroup'),
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
mixins: [Emitter],
|
|
34
|
+
mounted(){
|
|
35
|
+
this.parent = findComponentUpward(this, 'checkBoxGroup');
|
|
36
|
+
if (this.parent) {
|
|
37
|
+
this.isGroup = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!this.isGroup) {
|
|
41
|
+
this.currentValue = this.value;
|
|
42
|
+
if (this.$refs.slot && this.$refs.slot.innerHtml == '') {
|
|
43
|
+
this.show = false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
computed: {
|
|
48
|
+
classes(){
|
|
49
|
+
return [
|
|
50
|
+
`${prefixCls}`
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
wrapperClasses(){
|
|
54
|
+
return [
|
|
55
|
+
`${prefixCls}-wrapper`,
|
|
56
|
+
{
|
|
57
|
+
[`${prefixCls}-checked`]: this.currentValue,
|
|
58
|
+
[`${prefixCls}-disable`]: this.disable
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
innerClasses(){
|
|
63
|
+
return [
|
|
64
|
+
`${prefixCls}-inner`
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
props: {
|
|
69
|
+
|
|
70
|
+
disable: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
74
|
+
value: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
label: {
|
|
79
|
+
type: [String, Number, Boolean],
|
|
80
|
+
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
},
|
|
84
|
+
methods: {
|
|
85
|
+
change(e){
|
|
86
|
+
if (this.disable) return;
|
|
87
|
+
const checked = e.target.checked;
|
|
88
|
+
this.currentValue = checked;
|
|
89
|
+
this.$emit('input', checked);
|
|
90
|
+
if (this.isGroup) {
|
|
91
|
+
|
|
92
|
+
this.parent.change(this.model)
|
|
93
|
+
} else {
|
|
94
|
+
this.$emit('on-change', checked);
|
|
95
|
+
this.dispatch('on-form-change', checked)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
watch: {
|
|
101
|
+
|
|
102
|
+
value(val){
|
|
103
|
+
this.currentValue = val
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes" v-if="visible">
|
|
3
|
+
<header>
|
|
4
|
+
<div class="left" @click="back">
|
|
5
|
+
<slot name="left"><span class="arrow"></span><span class="text">返回</span></slot>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="title dpzvc-nowrap">{{title}}</div>
|
|
8
|
+
<div class="right">
|
|
9
|
+
<slot name="right"><div></div></slot>
|
|
10
|
+
</div>
|
|
11
|
+
</header>
|
|
12
|
+
<div class="header-place" v-if="fixed"></div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
const prefixCls = 'dpzvc-header';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'header',
|
|
21
|
+
props: {
|
|
22
|
+
value:{
|
|
23
|
+
type:Boolean,
|
|
24
|
+
default:true
|
|
25
|
+
},
|
|
26
|
+
fixed: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true
|
|
29
|
+
},
|
|
30
|
+
title: String,
|
|
31
|
+
wechat:{
|
|
32
|
+
type:Boolean,
|
|
33
|
+
default:false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data(){
|
|
37
|
+
return {
|
|
38
|
+
visible:this.value,
|
|
39
|
+
isWechat:this.wechat
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
classes() {
|
|
44
|
+
return [
|
|
45
|
+
`${prefixCls}`,
|
|
46
|
+
{
|
|
47
|
+
[`${prefixCls}-fixed`]: !!this.fixed
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
isWeixin(){
|
|
52
|
+
|
|
53
|
+
return "micromessenger" == window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i)
|
|
54
|
+
},
|
|
55
|
+
isPcWeixin(){
|
|
56
|
+
return "windowswechat" == window.navigator.userAgent.toLowerCase().match(/WindowsWechat/i)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
mounted(){
|
|
60
|
+
if ((this.isWeixin || this.isPcWeixin) && !this.isWechat) this.visible = false
|
|
61
|
+
},
|
|
62
|
+
methods: {
|
|
63
|
+
back() {
|
|
64
|
+
this.$router ? this.$router.back() : window.history.back();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
watch:{
|
|
68
|
+
value(val){
|
|
69
|
+
this.visible = val
|
|
70
|
+
},
|
|
71
|
+
visible(val){
|
|
72
|
+
this.$emit('input',val)
|
|
73
|
+
},
|
|
74
|
+
wechat(val){
|
|
75
|
+
this.isWechat = val
|
|
76
|
+
},
|
|
77
|
+
isWechat(val){
|
|
78
|
+
this.$emit('input',val);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="containerClasses" @scroll="onScroll" :style="{height:height}">
|
|
3
|
+
<div :class="topClasses" v-if="refresh" :style="{height:translateY+'px'}">
|
|
4
|
+
<div :class="statusClass">
|
|
5
|
+
<slot name="top">
|
|
6
|
+
<span class="spinner"><spinner v-if="upStatus == 'loading'" size="15" type="snake"></spinner></span><span
|
|
7
|
+
class="dpzvc-loadmore-text">{{upText}}</span>
|
|
8
|
+
</slot>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
<div :class="contentClasses">
|
|
12
|
+
<slot></slot>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div :class="bottomClasses" v-if="loadMore">
|
|
16
|
+
<div :class="statusClass">
|
|
17
|
+
<slot name="bottom">
|
|
18
|
+
<span class="spinner"><spinner v-if="downStatus == 'loading'" size="15"
|
|
19
|
+
type="snake"></spinner></span><span class="dpzvc-loadmore-text">{{downText}}</span>
|
|
20
|
+
</slot>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import Spinner from '../spinner'
|
|
28
|
+
const prefixCls = 'dpzvc-loadmore';
|
|
29
|
+
export default {
|
|
30
|
+
name: 'loadmore',
|
|
31
|
+
components: {
|
|
32
|
+
Spinner
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
height: {
|
|
36
|
+
type: [Number, String],
|
|
37
|
+
default: '100%'
|
|
38
|
+
},
|
|
39
|
+
refresh: Function,
|
|
40
|
+
upLoadingText: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '加载中...'
|
|
43
|
+
},
|
|
44
|
+
upDistance: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 70
|
|
47
|
+
},
|
|
48
|
+
upPullText: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: '↓ 下拉刷新'
|
|
51
|
+
},
|
|
52
|
+
upDropText: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '↑ 释放更新'
|
|
55
|
+
},
|
|
56
|
+
maxDistance: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default: 0
|
|
59
|
+
},
|
|
60
|
+
speed: {
|
|
61
|
+
type: Number,
|
|
62
|
+
default: 3
|
|
63
|
+
},
|
|
64
|
+
downEndText: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: '没有更多了'
|
|
67
|
+
},
|
|
68
|
+
downDropText: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: '↑ 上拉加载数据'
|
|
71
|
+
},
|
|
72
|
+
downLoadingText: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: '加载中...'
|
|
75
|
+
},
|
|
76
|
+
downDistance: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 50
|
|
79
|
+
},
|
|
80
|
+
loadMore: Function,
|
|
81
|
+
hasMore: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true
|
|
84
|
+
},
|
|
85
|
+
styles: {
|
|
86
|
+
type: Object,
|
|
87
|
+
default(){
|
|
88
|
+
return {}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
auto: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: true
|
|
94
|
+
},
|
|
95
|
+
autoFill: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
data(){
|
|
101
|
+
return {
|
|
102
|
+
translateY: 0,
|
|
103
|
+
startTranslateY: 0,
|
|
104
|
+
currentY: 0,
|
|
105
|
+
startY: 0,
|
|
106
|
+
upStatus: '',
|
|
107
|
+
downStatus: '',
|
|
108
|
+
direction: '',
|
|
109
|
+
upText: '',
|
|
110
|
+
downText: '',
|
|
111
|
+
down: false,
|
|
112
|
+
drag: false,
|
|
113
|
+
more: this.hasMore,
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
computed: {
|
|
117
|
+
containerClasses(){
|
|
118
|
+
return [
|
|
119
|
+
`${prefixCls}`
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
topClasses(){
|
|
123
|
+
return [
|
|
124
|
+
`${prefixCls}-top`,
|
|
125
|
+
{
|
|
126
|
+
[`${prefixCls}-drag`]: !this.drag
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
bottomClasses(){
|
|
131
|
+
return [
|
|
132
|
+
`${prefixCls}-bottom`
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
contentClasses(){
|
|
136
|
+
return [
|
|
137
|
+
`${prefixCls}-content`,
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
statusClass(){
|
|
141
|
+
return [
|
|
142
|
+
`${prefixCls}-status`
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
mounted(){
|
|
147
|
+
if (this.auto && this.refresh && typeof this.refresh == 'function') {
|
|
148
|
+
this.translateY = 40;
|
|
149
|
+
this.drag = false;
|
|
150
|
+
this.direction = 'down';
|
|
151
|
+
this.upStatus = 'loading';
|
|
152
|
+
this.refresh()
|
|
153
|
+
}
|
|
154
|
+
this.bindEvents();
|
|
155
|
+
},
|
|
156
|
+
methods: {
|
|
157
|
+
onLoadOff(){
|
|
158
|
+
this.translateY = 0;
|
|
159
|
+
this.upStatus = '';
|
|
160
|
+
this.downStatus = '';
|
|
161
|
+
if (!this.more) this.downStatus = 'end';
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
if (this.more && this.isBottom()) {
|
|
164
|
+
this.direction = 'up';
|
|
165
|
+
this.downStatus = 'loading';
|
|
166
|
+
this.loadMore();
|
|
167
|
+
}
|
|
168
|
+
}, 1000)
|
|
169
|
+
},
|
|
170
|
+
isBottom(){
|
|
171
|
+
if (this.$el.scrollHeight > this.$el.offsetHeight) return false;
|
|
172
|
+
return true;
|
|
173
|
+
},
|
|
174
|
+
onScroll(e){
|
|
175
|
+
e.preventDefault()
|
|
176
|
+
if (this.downStatus == 'loading') return;
|
|
177
|
+
let scrollTop = this.$el.scrollTop;
|
|
178
|
+
if (this.loadMore && typeof this.loadMore == 'function') {
|
|
179
|
+
let absY = this.$el.scrollHeight - (this.$el.offsetHeight + scrollTop);
|
|
180
|
+
if (absY > this.downDistance && this.downStatus === 'drop') {
|
|
181
|
+
this.downStatus = '';
|
|
182
|
+
} else if (absY <= this.downDistance && absY > this.downDistance && this.more) {
|
|
183
|
+
this.downStatus = 'drop';
|
|
184
|
+
} else if (absY <= this.downDistance) {
|
|
185
|
+
this.downStatus = 'loading';
|
|
186
|
+
if (this.more) {
|
|
187
|
+
this.downStatus = 'loading';
|
|
188
|
+
this.loadMore();
|
|
189
|
+
} else {
|
|
190
|
+
this.downStatus = 'end';
|
|
191
|
+
let that = this;
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
that.onLoadOff();
|
|
194
|
+
}, 1000);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onTouchStart(e){
|
|
200
|
+
if (this.upStatus === 'loading') return;
|
|
201
|
+
this.startY = e.touches[0].clientY;
|
|
202
|
+
this.startTranslateY = this.translateY;
|
|
203
|
+
this.down = false;
|
|
204
|
+
},
|
|
205
|
+
onTouchMove(e){
|
|
206
|
+
let pos = this.$el.getBoundingClientRect();
|
|
207
|
+
if (this.upStatus === 'loading' || this.startY < pos.top && this.startY > pos.down) return;
|
|
208
|
+
this.currentY = e.touches[0].clientY;
|
|
209
|
+
let distance = (this.currentY - this.startY) / this.speed;
|
|
210
|
+
let scrollTop = this.$el.scrollTop;
|
|
211
|
+
this.direction = distance > 0 ? 'down' : 'up';
|
|
212
|
+
if (this.currentY >= this.startY && typeof this.refresh === 'function' && scrollTop === 0 && this.direction === 'down') {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
event.stopPropagation();
|
|
215
|
+
if (this.maxDistance > 0) {
|
|
216
|
+
this.translateY = distance <= this.maxDistance ? distance - scrollTop : this.translateY;
|
|
217
|
+
} else {
|
|
218
|
+
this.translateY = distance - scrollTop;
|
|
219
|
+
}
|
|
220
|
+
if (this.translateY < 0) {
|
|
221
|
+
this.translateY = 0;
|
|
222
|
+
}
|
|
223
|
+
this.upStatus = this.translateY >= this.upDistance ? 'drop' : 'pull';
|
|
224
|
+
this.drag = true;
|
|
225
|
+
this.down = this.down || this.isBottom();
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
onTouchEnd(e){
|
|
229
|
+
if (this.upStatus === 'loading') return;
|
|
230
|
+
if (this.direction === 'down' && this.$el.scrollTop <= 0 && this.translateY >= 0) {
|
|
231
|
+
if (this.upStatus == 'drop') {
|
|
232
|
+
this.translateY = 40;
|
|
233
|
+
this.upStatus = 'loading';
|
|
234
|
+
this.refresh();
|
|
235
|
+
} else {
|
|
236
|
+
this.translateY = 0;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
this.direction = '';
|
|
240
|
+
this.drag = false;
|
|
241
|
+
},
|
|
242
|
+
bindEvents(){
|
|
243
|
+
this.$el.addEventListener('touchstart', this.onTouchStart, false);
|
|
244
|
+
this.$el.addEventListener('touchmove', this.onTouchMove, false);
|
|
245
|
+
this.$el.addEventListener('touchend', this.onTouchEnd, false);
|
|
246
|
+
},
|
|
247
|
+
unbindEvents(){
|
|
248
|
+
this.$el.removeEventListener('touchstart', this.onTouchStart, false);
|
|
249
|
+
this.$el.removeEventListener('touchmove', this.onTouchMove, false);
|
|
250
|
+
this.$el.removeEventListener('touchend', this.onTouchEnd, false);
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
watch: {
|
|
254
|
+
upStatus(val){
|
|
255
|
+
switch (val) {
|
|
256
|
+
case 'pull':
|
|
257
|
+
this.upText = this.upPullText;
|
|
258
|
+
break;
|
|
259
|
+
case 'drop':
|
|
260
|
+
this.upText = this.upDropText;
|
|
261
|
+
break;
|
|
262
|
+
case 'loading':
|
|
263
|
+
this.upText = this.upLoadingText;
|
|
264
|
+
}
|
|
265
|
+
this.$emit('on-change-up-status', val)
|
|
266
|
+
},
|
|
267
|
+
downStatus(val){
|
|
268
|
+
switch (val) {
|
|
269
|
+
case 'end':
|
|
270
|
+
this.downText = this.downEndText;
|
|
271
|
+
break;
|
|
272
|
+
case 'drop':
|
|
273
|
+
this.downText = this.downDropText;
|
|
274
|
+
break;
|
|
275
|
+
case 'loading':
|
|
276
|
+
this.downText = this.downLoadingText;
|
|
277
|
+
break;
|
|
278
|
+
default:
|
|
279
|
+
this.downText = '';
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
this.$emit('on-change-down-status', val)
|
|
283
|
+
},
|
|
284
|
+
hasMore(val){
|
|
285
|
+
this.more = val
|
|
286
|
+
if (!val) this.downStatus = 'end'
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
beforeDestroy(){
|
|
290
|
+
this.unbindEvents();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/8.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import MessageGroup from './messageGroup.vue'
|
|
6
|
+
import Vue from 'vue';
|
|
7
|
+
import {camelcaseToHyphen} from '../../utils/util'
|
|
8
|
+
|
|
9
|
+
MessageGroup.newInstance = function (props) {
|
|
10
|
+
|
|
11
|
+
let _props = props || {};
|
|
12
|
+
|
|
13
|
+
let _prop = '';
|
|
14
|
+
Object.keys(_props).forEach((prop) => {
|
|
15
|
+
|
|
16
|
+
_prop += ' :' + camelcaseToHyphen(prop) + '=' + prop
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
let div = document.createElement('div');
|
|
20
|
+
|
|
21
|
+
document.body.appendChild(div);
|
|
22
|
+
|
|
23
|
+
let message = new Vue({
|
|
24
|
+
el: div,
|
|
25
|
+
data: _props,
|
|
26
|
+
template:`<Message-group ${_prop} ></Message-group>`,
|
|
27
|
+
components: {MessageGroup},
|
|
28
|
+
}).$children[0];
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
|
|
33
|
+
add(props){
|
|
34
|
+
message.add(props)
|
|
35
|
+
},
|
|
36
|
+
remove(props) {
|
|
37
|
+
|
|
38
|
+
message.remove(props)
|
|
39
|
+
},
|
|
40
|
+
component: message,
|
|
41
|
+
destroy(){
|
|
42
|
+
message.closeAll();
|
|
43
|
+
|
|
44
|
+
setTimeout(()=>{
|
|
45
|
+
document.body.removeChild(document.getElementsByClassName('dpzvc-message')[0].parentElement)
|
|
46
|
+
},500)
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default MessageGroup;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/8.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import MessageGroup from './confirm'
|
|
6
|
+
import {random_str} from '../../utils/util'
|
|
7
|
+
let defualtDuration = 1;
|
|
8
|
+
let key = 1;
|
|
9
|
+
let top = '0';
|
|
10
|
+
|
|
11
|
+
let MG_instance;
|
|
12
|
+
|
|
13
|
+
let seed = 1;
|
|
14
|
+
|
|
15
|
+
let time = Date.now();
|
|
16
|
+
|
|
17
|
+
function getName(){
|
|
18
|
+
return 'dpzvc-message-group_'+time+'_'+(seed++)+'_'+random_str();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let getNewInstance = function () {
|
|
22
|
+
MG_instance = MG_instance || MessageGroup.newInstance({
|
|
23
|
+
|
|
24
|
+
styles: {
|
|
25
|
+
top: top,
|
|
26
|
+
right: '0'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return MG_instance;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function message(props) {
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
let [
|
|
38
|
+
text,
|
|
39
|
+
name,
|
|
40
|
+
duration,
|
|
41
|
+
showLeft,
|
|
42
|
+
rightHide,
|
|
43
|
+
loading,
|
|
44
|
+
onClose,
|
|
45
|
+
styles,
|
|
46
|
+
type,
|
|
47
|
+
position]
|
|
48
|
+
|
|
49
|
+
=
|
|
50
|
+
|
|
51
|
+
[
|
|
52
|
+
props.text || '',
|
|
53
|
+
props.name || getName(),
|
|
54
|
+
(props.duration == 0) ? 0 : props.duration || defualtDuration,
|
|
55
|
+
props.showLeft || false,
|
|
56
|
+
props.rightHide || true,
|
|
57
|
+
props.loading || false,
|
|
58
|
+
props.onClose || function () {},
|
|
59
|
+
props.styles || {},
|
|
60
|
+
props.type || 'normal',
|
|
61
|
+
props.position || 'center'];
|
|
62
|
+
|
|
63
|
+
let instance = getNewInstance();
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
instance.add({
|
|
68
|
+
name: name,
|
|
69
|
+
text: text,
|
|
70
|
+
duration: duration,
|
|
71
|
+
showLeft: showLeft,
|
|
72
|
+
rightHide: rightHide,
|
|
73
|
+
loading: loading,
|
|
74
|
+
onClose: onClose,
|
|
75
|
+
styles: styles,
|
|
76
|
+
type: type,
|
|
77
|
+
position:position
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return (function () {
|
|
81
|
+
let target = name;
|
|
82
|
+
|
|
83
|
+
return function () {
|
|
84
|
+
instance.remove(`${target}`);
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
|
|
92
|
+
show(options){
|
|
93
|
+
return message(options)
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
error(options){
|
|
97
|
+
options.type = 'error';
|
|
98
|
+
return message(options)
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
success(options){
|
|
102
|
+
|
|
103
|
+
options.type = 'success';
|
|
104
|
+
return message(options)
|
|
105
|
+
},
|
|
106
|
+
loading(options){
|
|
107
|
+
options.type = 'loading';
|
|
108
|
+
options.duration = 0;
|
|
109
|
+
options.showLeft = true;
|
|
110
|
+
return message(options)
|
|
111
|
+
},
|
|
112
|
+
config(options){
|
|
113
|
+
|
|
114
|
+
if (options.top) {
|
|
115
|
+
|
|
116
|
+
top = options.top
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (options.duration) {
|
|
120
|
+
|
|
121
|
+
defualtDuration = options.duration
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
destroy(){
|
|
125
|
+
if (!MG_instance) return false;
|
|
126
|
+
MG_instance = getNewInstance();
|
|
127
|
+
MG_instance.destroy()
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|