@xtdev/xt-miniprogram-ui 1.2.63 → 1.2.73
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/libs/xt-preview-image/README.md +46 -0
- package/libs/xt-preview-image/index.js +111 -0
- package/libs/xt-preview-image/index.json +4 -0
- package/libs/xt-preview-image/index.wxml +25 -0
- package/libs/xt-preview-image/index.wxss +82 -0
- package/libs/xt-stepper/index.js +10 -11
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# PreviewImage 图片预览
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
自定义图片预览
|
|
5
|
+
|
|
6
|
+
###效果图
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
### 引入
|
|
10
|
+
在app.json或页面配置json中引入
|
|
11
|
+
```
|
|
12
|
+
"usingComponents": {
|
|
13
|
+
"xt-preview-image": "@xtdev/xt-miniprogram-ui/xt-preview-image",
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 代码演示
|
|
18
|
+
|
|
19
|
+
### 基础用法
|
|
20
|
+
|
|
21
|
+
#### 操作样式
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
<image-preview id="imagePreview" show="{{showPreviewPop}}" images="{{previewImages}}" current-index="0" bind:close="onPreviewClose" />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
#### xt-popover props
|
|
30
|
+
|
|
31
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
32
|
+
| ----------- | ----------- | ---------- | ------------ |
|
|
33
|
+
| show | 是否显示预览,可选值为 `true` `false` | boolean | `false`
|
|
34
|
+
| images | 图片列表 | array | `[]`
|
|
35
|
+
| currentIndex | 当前显示的图片索引 | number | `0`
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
####Events
|
|
40
|
+
|
|
41
|
+
| 事件名 | 说明 | 回调参数 |
|
|
42
|
+
| ---------------- | ------------- | ---------------------- |
|
|
43
|
+
| bind:imageload | 图片加载完成 | event.detail
|
|
44
|
+
| bind:imagetap | 点击图片 | event
|
|
45
|
+
| bind:change | 切换图片 | currentIndex 当前示的图片索引
|
|
46
|
+
| bind:close | 关闭预览 | event
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
// 是否显示预览
|
|
4
|
+
show: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
value: false,
|
|
7
|
+
},
|
|
8
|
+
// 图片列表
|
|
9
|
+
images: {
|
|
10
|
+
type: Array,
|
|
11
|
+
value: [],
|
|
12
|
+
},
|
|
13
|
+
// 当前显示的图片索引
|
|
14
|
+
currentIndex: {
|
|
15
|
+
type: Number,
|
|
16
|
+
value: 0,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
data: {
|
|
21
|
+
current: 0, // 当前显示图片索引
|
|
22
|
+
startX: 0, // 手势开始X坐标
|
|
23
|
+
isSwiping: false, // 是否正在滑动
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
observers: {
|
|
27
|
+
images: function (newVal) {
|
|
28
|
+
this.setData({
|
|
29
|
+
current: 0,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
currentIndex: function (newVal) {
|
|
33
|
+
this.setData({
|
|
34
|
+
current: newVal,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
methods: {
|
|
40
|
+
// 图片加载完成
|
|
41
|
+
onImageLoad(e) {
|
|
42
|
+
this.triggerEvent('imageload', e.detail);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// 点击图片
|
|
46
|
+
onImageTap() {
|
|
47
|
+
this.triggerEvent('imagetap');
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// 切换上一张
|
|
51
|
+
onPrev(e) {
|
|
52
|
+
if (this.data.current > 0) {
|
|
53
|
+
const newIndex = this.data.current - 1;
|
|
54
|
+
this.setData({
|
|
55
|
+
current: newIndex,
|
|
56
|
+
});
|
|
57
|
+
console.log('hadel prev', newIndex);
|
|
58
|
+
this.triggerEvent('change', { current: newIndex });
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// 切换下一张
|
|
63
|
+
onNext(e) {
|
|
64
|
+
if (this.data.current < this.data.images.length - 1) {
|
|
65
|
+
const newIndex = this.data.current + 1;
|
|
66
|
+
this.setData({
|
|
67
|
+
current: newIndex,
|
|
68
|
+
});
|
|
69
|
+
console.log('hadel next', newIndex);
|
|
70
|
+
this.triggerEvent('change', { current: newIndex });
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// swiper切换事件
|
|
75
|
+
onSwiperChange(e) {
|
|
76
|
+
const newIndex = e.detail.current;
|
|
77
|
+
this.setData({
|
|
78
|
+
current: newIndex,
|
|
79
|
+
});
|
|
80
|
+
this.triggerEvent('change', { current: newIndex });
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// 动画结束事件
|
|
84
|
+
onAnimationFinish(e) {
|
|
85
|
+
this.setData({
|
|
86
|
+
isSwiping: false,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// 关闭预览
|
|
91
|
+
onClose() {
|
|
92
|
+
this.triggerEvent('close');
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// 外部调用方法:打开预览
|
|
96
|
+
open(images, index = 0) {
|
|
97
|
+
this.setData({
|
|
98
|
+
show: true,
|
|
99
|
+
images: images,
|
|
100
|
+
current: index,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// 外部调用方法:关闭预览
|
|
105
|
+
close() {
|
|
106
|
+
this.setData({
|
|
107
|
+
show: false,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<view wx:if="{{show}}">
|
|
2
|
+
<view class="preview-container" bindtap="onClose">
|
|
3
|
+
<!-- 顶部指示器 -->
|
|
4
|
+
<view class="indicator">{{current + 1}}/{{images.length}}</view>
|
|
5
|
+
<!-- 图片滑动区域 -->
|
|
6
|
+
<swiper class="image-swiper" current="{{current}}" duration="300" bindchange="onSwiperChange" bindanimationfinish="onAnimationFinish">
|
|
7
|
+
<block wx:for="{{images}}" wx:key="*this">
|
|
8
|
+
<swiper-item>
|
|
9
|
+
<view class="image-container">
|
|
10
|
+
<image class="preview-image" src="{{item}}" mode="widthFix" bindload="onImageLoad" bindtap="onImageTap" />
|
|
11
|
+
</view>
|
|
12
|
+
</swiper-item>
|
|
13
|
+
</block>
|
|
14
|
+
</swiper>
|
|
15
|
+
<!-- 左右箭头导航 -->
|
|
16
|
+
<view class="nav-arrow left-arrow" catch:tap="onPrev" wx:if="{{current > 0}}">
|
|
17
|
+
<image class="arrow-icon" src="https://img.tanjiu.cn/home/P2EQ2zaa5izYWX8W7F2TfnnxxX2ByiKD.png" mode="aspectFit" />
|
|
18
|
+
</view>
|
|
19
|
+
<view class="nav-arrow right-arrow" catch:tap="onNext" wx:if="{{current < images.length - 1}}">
|
|
20
|
+
<image class="arrow-icon" src="https://img.tanjiu.cn/home/kNny7B8ymAdta2fWSEkPysZHfRWXSjHA.png" mode="aspectFit" />
|
|
21
|
+
</view>
|
|
22
|
+
<!-- 关闭按钮 -->
|
|
23
|
+
<view class="close-btn" catch:tap="onClose"></view>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.preview-container {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
background-color: rgba(0, 0, 0, 0.9);
|
|
8
|
+
z-index: 99;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.indicator {
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 148rpx;
|
|
14
|
+
left: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
text-align: center;
|
|
17
|
+
color: #fff;
|
|
18
|
+
font-size: 32rpx;
|
|
19
|
+
z-index: 100;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.image-swiper {
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.image-container {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
align-items: center;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.preview-image {
|
|
37
|
+
width: 100%;
|
|
38
|
+
display: block;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.nav-arrow {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 50%;
|
|
44
|
+
transform: translateY(-50%);
|
|
45
|
+
width: 80rpx;
|
|
46
|
+
height: 80rpx;
|
|
47
|
+
z-index: 100;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.left-arrow {
|
|
54
|
+
left: 20rpx;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.right-arrow {
|
|
58
|
+
right: 20rpx;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.arrow-icon {
|
|
62
|
+
width: 56rpx;
|
|
63
|
+
height: 56rpx;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.close-btn {
|
|
67
|
+
position: absolute;
|
|
68
|
+
bottom: 148rpx;
|
|
69
|
+
left: 50%;
|
|
70
|
+
transform: translateX(-50%);
|
|
71
|
+
background-image: url("https://img.tanjiu.cn/home/mZ2k3nw6FMc5besY7yHW3JKibXi7Ehmh.png");
|
|
72
|
+
background-size: cover;
|
|
73
|
+
width: 80rpx;
|
|
74
|
+
height: 80rpx;
|
|
75
|
+
border-radius: 40rpx;
|
|
76
|
+
display: flex;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
align-items: center;
|
|
79
|
+
color: #fff;
|
|
80
|
+
font-size: 32rpx;
|
|
81
|
+
z-index: 100;
|
|
82
|
+
}
|
package/libs/xt-stepper/index.js
CHANGED
|
@@ -30,39 +30,39 @@ Component({
|
|
|
30
30
|
properties: {
|
|
31
31
|
value: {
|
|
32
32
|
type: [Number, String],
|
|
33
|
-
|
|
33
|
+
value: 1
|
|
34
34
|
},
|
|
35
35
|
min: {
|
|
36
36
|
type: Number,
|
|
37
|
-
|
|
37
|
+
value: 0
|
|
38
38
|
},
|
|
39
39
|
max: {
|
|
40
40
|
type: Number,
|
|
41
|
-
|
|
41
|
+
value: 100
|
|
42
42
|
},
|
|
43
43
|
step: {
|
|
44
44
|
type: Number,
|
|
45
|
-
|
|
45
|
+
value: 1
|
|
46
46
|
},
|
|
47
47
|
background: {
|
|
48
48
|
type: String,
|
|
49
|
-
|
|
49
|
+
value: '#fff'
|
|
50
50
|
},
|
|
51
51
|
color: {
|
|
52
52
|
type: String,
|
|
53
|
-
|
|
53
|
+
value: '#000'
|
|
54
54
|
},
|
|
55
55
|
disabled: {
|
|
56
56
|
type: Boolean,
|
|
57
|
-
|
|
57
|
+
value: false
|
|
58
58
|
},
|
|
59
59
|
stepTips: {
|
|
60
60
|
type: String,
|
|
61
|
-
|
|
61
|
+
value: ''
|
|
62
62
|
},
|
|
63
63
|
disableInput: {
|
|
64
64
|
type: Boolean,
|
|
65
|
-
|
|
65
|
+
value: false
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
|
|
@@ -151,8 +151,7 @@ Component({
|
|
|
151
151
|
},
|
|
152
152
|
observers: {
|
|
153
153
|
value(val) {
|
|
154
|
-
|
|
155
|
-
this.setData({inputValue});
|
|
154
|
+
this.setData({inputValue: val});
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
});
|