sadais-piui 1.2.7-beta123 → 1.2.7-beta125
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/components/pi-img/index.vue +275 -266
- package/components/pi-webview/index.vue +6 -3
- package/package.json +1 -1
|
@@ -1,266 +1,275 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="pi-img" :style="[rectStyle]">
|
|
3
|
-
<view
|
|
4
|
-
class="pi-align-center"
|
|
5
|
-
:style="[rectStyle, imageStyle, customStyle]"
|
|
6
|
-
:class="[customClass]"
|
|
7
|
-
@tap="handleButtonTap"
|
|
8
|
-
>
|
|
9
|
-
<image
|
|
10
|
-
:src="src"
|
|
11
|
-
:mode="mode"
|
|
12
|
-
:lazy-load="lazyLoad"
|
|
13
|
-
:style="[rectStyle, imageStyle]"
|
|
14
|
-
:show-menu-by-longpress="showMenuByLongpress"
|
|
15
|
-
|
|
16
|
-
@
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
:
|
|
28
|
-
:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
type: String,
|
|
85
|
-
// '
|
|
86
|
-
default: img.
|
|
87
|
-
},
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
type:
|
|
91
|
-
// '
|
|
92
|
-
default: img.
|
|
93
|
-
},
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
type: [String, Number],
|
|
97
|
-
// '
|
|
98
|
-
default: img.
|
|
99
|
-
},
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
type:
|
|
103
|
-
//
|
|
104
|
-
default: img.
|
|
105
|
-
},
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
//
|
|
110
|
-
default: img.
|
|
111
|
-
},
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
type: [String, Number],
|
|
115
|
-
//
|
|
116
|
-
default: img.
|
|
117
|
-
},
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
type:
|
|
137
|
-
//
|
|
138
|
-
default: img.
|
|
139
|
-
},
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
type: Boolean,
|
|
143
|
-
// true
|
|
144
|
-
default: img.
|
|
145
|
-
},
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
type: Boolean,
|
|
149
|
-
// true
|
|
150
|
-
default: img.
|
|
151
|
-
},
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
type:
|
|
155
|
-
//
|
|
156
|
-
default: img.
|
|
157
|
-
},
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
type:
|
|
177
|
-
//
|
|
178
|
-
default: img.
|
|
179
|
-
},
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
type: Boolean,
|
|
183
|
-
//
|
|
184
|
-
default: img.
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view class="pi-img" :style="[rectStyle]">
|
|
3
|
+
<view
|
|
4
|
+
class="pi-align-center"
|
|
5
|
+
:style="[rectStyle, imageStyle, customStyle]"
|
|
6
|
+
:class="[customClass]"
|
|
7
|
+
@tap="handleButtonTap"
|
|
8
|
+
>
|
|
9
|
+
<image
|
|
10
|
+
:src="src"
|
|
11
|
+
:mode="mode"
|
|
12
|
+
:lazy-load="lazyLoad"
|
|
13
|
+
:style="[rectStyle, imageStyle]"
|
|
14
|
+
:show-menu-by-longpress="showMenuByLongpress"
|
|
15
|
+
:webp="webp"
|
|
16
|
+
@error="handleError"
|
|
17
|
+
@load="handleLoad"
|
|
18
|
+
/>
|
|
19
|
+
<view class="pi-abso-center">
|
|
20
|
+
<!-- 加载中 -->
|
|
21
|
+
<template v-if="src && loading">
|
|
22
|
+
<!-- 加载中样式 -->
|
|
23
|
+
<slot v-if="$slots.loading" name="loading" />
|
|
24
|
+
<pi-loading
|
|
25
|
+
v-else
|
|
26
|
+
:show="loading"
|
|
27
|
+
:type="loadingType"
|
|
28
|
+
:color="loadingColor"
|
|
29
|
+
:size="loadingSize"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
32
|
+
<!-- 加载失败 -->
|
|
33
|
+
<template v-if="src && error">
|
|
34
|
+
<!-- 加载失败样式 -->
|
|
35
|
+
<slot v-if="$slots.error" name="error" />
|
|
36
|
+
<view v-else class="pi-icon-pic" />
|
|
37
|
+
</template>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
<view
|
|
41
|
+
v-if="badge || dot"
|
|
42
|
+
class="img-badge"
|
|
43
|
+
:class="{ dot }"
|
|
44
|
+
:style="[badgeStyle]"
|
|
45
|
+
>
|
|
46
|
+
{{ badge }}
|
|
47
|
+
</view>
|
|
48
|
+
<view v-if="dot" />
|
|
49
|
+
</view>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
/**
|
|
54
|
+
* 注意,必须指定宽度和高度,否则没办法显示低图和加载错误占位图
|
|
55
|
+
* 如果要自定义loading底图和请求失败图,请使用slot对本组件进行二次封装
|
|
56
|
+
*/
|
|
57
|
+
import { getConfig } from '../../config'
|
|
58
|
+
import { debounce } from '@sadais/piui-tool/tools/common'
|
|
59
|
+
|
|
60
|
+
const TAG = 'PiImg'
|
|
61
|
+
const { img } = getConfig()
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
name: 'PiImg',
|
|
65
|
+
props: {
|
|
66
|
+
// 自定义样式
|
|
67
|
+
customStyle: {
|
|
68
|
+
type: Object,
|
|
69
|
+
default() {
|
|
70
|
+
// {}
|
|
71
|
+
return img.customStyle
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
// 自定义样式类
|
|
75
|
+
customClass: {
|
|
76
|
+
type: String,
|
|
77
|
+
default() {
|
|
78
|
+
// ''
|
|
79
|
+
return img.customClass
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
// 图片地址
|
|
83
|
+
src: {
|
|
84
|
+
type: String,
|
|
85
|
+
// ''
|
|
86
|
+
default: img.src
|
|
87
|
+
},
|
|
88
|
+
// 裁剪模式
|
|
89
|
+
mode: {
|
|
90
|
+
type: String,
|
|
91
|
+
// 'widthFix'
|
|
92
|
+
default: img.mode
|
|
93
|
+
},
|
|
94
|
+
// 宽度
|
|
95
|
+
width: {
|
|
96
|
+
type: [String, Number],
|
|
97
|
+
// '100%'
|
|
98
|
+
default: img.width
|
|
99
|
+
},
|
|
100
|
+
// 高度
|
|
101
|
+
height: {
|
|
102
|
+
type: [String, Number],
|
|
103
|
+
// 'auto'
|
|
104
|
+
default: img.height
|
|
105
|
+
},
|
|
106
|
+
// 是否显示图标右上角小红点
|
|
107
|
+
dot: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
// false
|
|
110
|
+
default: img.dot
|
|
111
|
+
},
|
|
112
|
+
// 小红点的半径
|
|
113
|
+
dotRadius: {
|
|
114
|
+
type: [String, Number],
|
|
115
|
+
// 16
|
|
116
|
+
default: img.dotRadius
|
|
117
|
+
},
|
|
118
|
+
// 图标右上角徽标的内容
|
|
119
|
+
badge: {
|
|
120
|
+
type: [String, Number],
|
|
121
|
+
// ''
|
|
122
|
+
default: img.badge
|
|
123
|
+
},
|
|
124
|
+
// 图片形状
|
|
125
|
+
shape: {
|
|
126
|
+
// `'round'-圆形` `'square'-方形`
|
|
127
|
+
type: String,
|
|
128
|
+
// 'square'
|
|
129
|
+
default: img.shape,
|
|
130
|
+
validator: function(value) {
|
|
131
|
+
return ['square', 'round'].includes(value)
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
// shape为square的时候设置
|
|
135
|
+
borderRadius: {
|
|
136
|
+
type: [String, Number],
|
|
137
|
+
// 0
|
|
138
|
+
default: img.borderRadius
|
|
139
|
+
},
|
|
140
|
+
// 是否懒加载
|
|
141
|
+
lazyLoad: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
// true
|
|
144
|
+
default: img.lazyLoad
|
|
145
|
+
},
|
|
146
|
+
// 开启长按图片显示识别微信小程序码菜单
|
|
147
|
+
showMenuByLongpress: {
|
|
148
|
+
type: Boolean,
|
|
149
|
+
// true
|
|
150
|
+
default: img.showMenuByLongpress
|
|
151
|
+
},
|
|
152
|
+
// 是否显示加载中的图标或者自定义的slot
|
|
153
|
+
showLoading: {
|
|
154
|
+
type: Boolean,
|
|
155
|
+
// true
|
|
156
|
+
default: img.showLoading
|
|
157
|
+
},
|
|
158
|
+
// 加载中颜色
|
|
159
|
+
loadingColor: {
|
|
160
|
+
type: String,
|
|
161
|
+
// '#c1c1c1'
|
|
162
|
+
default: img.loadingColor
|
|
163
|
+
},
|
|
164
|
+
// loading类型
|
|
165
|
+
loadingType: {
|
|
166
|
+
// `'spinner'-菊花` `'round'-圆环`
|
|
167
|
+
type: String,
|
|
168
|
+
// 'spinner'
|
|
169
|
+
default: img.loadingType,
|
|
170
|
+
validator: function(value) {
|
|
171
|
+
return ['spinner', 'round'].includes(value)
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
// 尺寸
|
|
175
|
+
loadingSize: {
|
|
176
|
+
type: [String, Number],
|
|
177
|
+
// 32
|
|
178
|
+
default: img.loadingSize
|
|
179
|
+
},
|
|
180
|
+
// 是否显示加载中的图标或者自定义的slot
|
|
181
|
+
showError: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
// true
|
|
184
|
+
default: img.showError
|
|
185
|
+
},
|
|
186
|
+
// 默认不解析 webP 格式,只支持网络资源
|
|
187
|
+
webp: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
// false
|
|
190
|
+
default: img.webp
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
data() {
|
|
194
|
+
return {
|
|
195
|
+
loading: this.showLoading,
|
|
196
|
+
// 图片是否加载错误,如果是,则显示错误占位图
|
|
197
|
+
error: false
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
computed: {
|
|
201
|
+
getDotRadius() {
|
|
202
|
+
return this.$pi.common.addUnit(this.dotRadius)
|
|
203
|
+
},
|
|
204
|
+
rectStyle() {
|
|
205
|
+
return {
|
|
206
|
+
width: this.$pi.common.addUnit(this.width),
|
|
207
|
+
height: this.$pi.common.addUnit(this.height)
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
badgeStyle() {
|
|
211
|
+
const style = {}
|
|
212
|
+
if (this.dot) {
|
|
213
|
+
style.width = this.getDotRadius
|
|
214
|
+
style.height = this.getDotRadius
|
|
215
|
+
}
|
|
216
|
+
return style
|
|
217
|
+
},
|
|
218
|
+
imageStyle() {
|
|
219
|
+
return {
|
|
220
|
+
overflow: 'hidden',
|
|
221
|
+
borderRadius:
|
|
222
|
+
this.shape === 'round'
|
|
223
|
+
? '50%'
|
|
224
|
+
: this.$pi.common.addUnit(this.borderRadius)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
methods: {
|
|
229
|
+
handleButtonTap: debounce(function(e) {
|
|
230
|
+
this.$emit('click', e)
|
|
231
|
+
}, 200),
|
|
232
|
+
handleError() {
|
|
233
|
+
console.log(TAG, '图片加载失败')
|
|
234
|
+
this.error = true
|
|
235
|
+
this.loading = false
|
|
236
|
+
// 图片加载完成
|
|
237
|
+
this.$emit('load')
|
|
238
|
+
},
|
|
239
|
+
handleLoad() {
|
|
240
|
+
this.error = false
|
|
241
|
+
this.loading = false
|
|
242
|
+
this.$emit('load')
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
</script>
|
|
247
|
+
|
|
248
|
+
<style lang="scss" scoped>
|
|
249
|
+
.pi-img {
|
|
250
|
+
position: relative;
|
|
251
|
+
.img-badge {
|
|
252
|
+
position: absolute;
|
|
253
|
+
top: 0;
|
|
254
|
+
right: 0;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
min-width: 16px;
|
|
257
|
+
padding: 0 3px;
|
|
258
|
+
font-size: 12px;
|
|
259
|
+
font-weight: 500;
|
|
260
|
+
line-height: 1.2;
|
|
261
|
+
color: #ffffff;
|
|
262
|
+
text-align: center;
|
|
263
|
+
background-color: #ee0a24;
|
|
264
|
+
border: 1px solid #ffffff;
|
|
265
|
+
border-radius: 16px;
|
|
266
|
+
transform: translate(50%, -50%);
|
|
267
|
+
transform-origin: 100%;
|
|
268
|
+
&.dot {
|
|
269
|
+
min-width: 0;
|
|
270
|
+
background-color: #ee0a24;
|
|
271
|
+
border-radius: 100%;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
</style>
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
<view class="pi-scroll-container">
|
|
3
3
|
<!-- #ifndef MP -->
|
|
4
4
|
<slot name="title">
|
|
5
|
-
<pi-navbar :show-home="showHome">{{ title }}</pi-navbar>
|
|
5
|
+
<pi-navbar :show-home="showHome" :fixed="false">{{ title }}</pi-navbar>
|
|
6
6
|
</slot>
|
|
7
7
|
<!-- #endif -->
|
|
8
8
|
<!-- #ifndef APP-PLUS -->
|
|
9
|
-
<
|
|
9
|
+
<view class="pi-scroll pi-safearea">
|
|
10
|
+
<web-view v-if="webviewURL" :progress="true" :src="webviewURL" />
|
|
11
|
+
</view>
|
|
10
12
|
<!-- #endif -->
|
|
11
13
|
</view>
|
|
12
14
|
</template>
|
|
@@ -57,7 +59,8 @@ export default {
|
|
|
57
59
|
// H5 url 需要加时间戳,否则会有缓存问题
|
|
58
60
|
this.webviewURL = this.autoAddTimestamp
|
|
59
61
|
? this.urlAddParam(this.url || '', {
|
|
60
|
-
sadaisTimestamp:
|
|
62
|
+
sadaisTimestamp:
|
|
63
|
+
new Date().getTime() + '-' + Math.round(Math.random(1) * 10000)
|
|
61
64
|
})
|
|
62
65
|
: this.url
|
|
63
66
|
console.log('webview页面即将打开以下URL:', this.webviewURL)
|