@xtdev/xt-miniprogram-ui 1.2.60 → 1.2.61

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.
Files changed (87) hide show
  1. package/libs/package.json +1 -0
  2. package/libs/xt-button/README.md +60 -0
  3. package/libs/xt-button/index.js +116 -0
  4. package/libs/xt-button/index.json +7 -0
  5. package/libs/xt-button/index.wxml +31 -0
  6. package/libs/xt-button/index.wxss +70 -0
  7. package/libs/xt-card-cell/README.md +67 -0
  8. package/libs/xt-card-cell/index.js +43 -0
  9. package/libs/xt-card-cell/index.json +6 -0
  10. package/libs/xt-card-cell/index.wxml +34 -0
  11. package/libs/xt-card-cell/index.wxss +89 -0
  12. package/libs/xt-cell/README.md +41 -0
  13. package/libs/xt-cell/index.js +42 -0
  14. package/libs/xt-cell/index.json +7 -0
  15. package/libs/xt-cell/index.wxml +12 -0
  16. package/libs/xt-cell/index.wxss +50 -0
  17. package/libs/xt-date-picker/README.md +77 -0
  18. package/libs/xt-date-picker/index.js +443 -0
  19. package/libs/xt-date-picker/index.json +7 -0
  20. package/libs/xt-date-picker/index.wxml +58 -0
  21. package/libs/xt-date-picker/index.wxss +118 -0
  22. package/libs/xt-date-picker-loop/README.md +77 -0
  23. package/libs/xt-date-picker-loop/index.js +684 -0
  24. package/libs/xt-date-picker-loop/index.json +8 -0
  25. package/libs/xt-date-picker-loop/index.wxml +61 -0
  26. package/libs/xt-date-picker-loop/index.wxss +117 -0
  27. package/libs/xt-dialog/README.md +157 -0
  28. package/libs/xt-dialog/index.js +142 -0
  29. package/libs/xt-dialog/index.json +5 -0
  30. package/libs/xt-dialog/index.wxml +64 -0
  31. package/libs/xt-dialog/index.wxss +129 -0
  32. package/libs/xt-form/index.js +83 -0
  33. package/libs/xt-form/index.json +5 -0
  34. package/libs/xt-form/index.wxml +67 -0
  35. package/libs/xt-form/index.wxss +141 -0
  36. package/libs/xt-icon/README.md +39 -0
  37. package/libs/xt-icon/index.js +25 -0
  38. package/libs/xt-icon/index.json +5 -0
  39. package/libs/xt-icon/index.wxml +2 -0
  40. package/libs/xt-icon/index.wxss +159 -0
  41. package/libs/xt-popover/README.md +71 -0
  42. package/libs/xt-popover/index.js +209 -0
  43. package/libs/xt-popover/index.json +7 -0
  44. package/libs/xt-popover/index.wxml +43 -0
  45. package/libs/xt-popover/index.wxss +135 -0
  46. package/libs/xt-preview-image/README.md +46 -0
  47. package/libs/xt-preview-image/index.js +111 -0
  48. package/libs/xt-preview-image/index.json +4 -0
  49. package/libs/xt-preview-image/index.wxml +25 -0
  50. package/libs/xt-preview-image/index.wxss +82 -0
  51. package/libs/xt-search/README.md +55 -0
  52. package/libs/xt-search/index.js +88 -0
  53. package/libs/xt-search/index.json +7 -0
  54. package/libs/xt-search/index.wxml +17 -0
  55. package/libs/xt-search/index.wxss +82 -0
  56. package/libs/xt-stepper/README.md +52 -0
  57. package/libs/xt-stepper/index.js +158 -0
  58. package/libs/xt-stepper/index.json +5 -0
  59. package/libs/xt-stepper/index.wxml +11 -0
  60. package/libs/xt-stepper/index.wxss +77 -0
  61. package/libs/xt-steps/README.md +79 -0
  62. package/libs/xt-steps/index.js +37 -0
  63. package/libs/xt-steps/index.json +7 -0
  64. package/libs/xt-steps/index.wxml +34 -0
  65. package/libs/xt-steps/index.wxss +186 -0
  66. package/libs/xt-tabs/README.md +98 -0
  67. package/libs/xt-tabs/index.js +35 -0
  68. package/libs/xt-tabs/index.json +6 -0
  69. package/libs/xt-tabs/index.wxml +10 -0
  70. package/libs/xt-tabs/index.wxss +76 -0
  71. package/libs/xt-tag/README.md +65 -0
  72. package/libs/xt-tag/index.js +38 -0
  73. package/libs/xt-tag/index.json +7 -0
  74. package/libs/xt-tag/index.wxml +5 -0
  75. package/libs/xt-tag/index.wxss +36 -0
  76. package/libs/xt-toast/README.md +65 -0
  77. package/libs/xt-toast/index.js +85 -0
  78. package/libs/xt-toast/index.json +7 -0
  79. package/libs/xt-toast/index.wxml +6 -0
  80. package/libs/xt-toast/index.wxss +27 -0
  81. package/libs/xt-uploader/README.md +46 -0
  82. package/libs/xt-uploader/index.js +233 -0
  83. package/libs/xt-uploader/index.json +7 -0
  84. package/libs/xt-uploader/index.wxml +15 -0
  85. package/libs/xt-uploader/index.wxss +68 -0
  86. package/libs/xt-uploader/utils.js +69 -0
  87. package/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ // src/xt-toast/index.js
2
+ Component({
3
+ /**
4
+ * 组件的属性列表
5
+ */
6
+ properties: {
7
+ show:{
8
+ type:Boolean,
9
+ value:false
10
+ },
11
+ type:{
12
+ type:String,
13
+ value:'nomal'
14
+ },
15
+ duration:{
16
+ type:Number,
17
+ value:5000
18
+ },
19
+ message:{
20
+ type:String,
21
+ value:''
22
+ },
23
+ navDuration:{
24
+ type:Number,
25
+ value:null
26
+ },
27
+ navUrl:{
28
+ type:String,
29
+ value:null
30
+ }
31
+ },
32
+
33
+ /**
34
+ * 组件的初始数据
35
+ */
36
+ data: {
37
+ // 带跳转的toast是否允许自动消失
38
+ dispear: false
39
+ },
40
+ observers:{
41
+ show(val){
42
+ if(val){
43
+ this.showToast();
44
+ }
45
+ }
46
+ },
47
+ lifetimes:{
48
+ attached(){
49
+ // if(this.properties.type == 'nomal') this.showToast();
50
+ if(this.properties.type == 'navToast') this.showNavToast();
51
+ }
52
+ },
53
+ /**
54
+ * 组件的方法列表
55
+ */
56
+ methods: {
57
+ // 常规toast
58
+ showToast(){
59
+ console.log('查看变量',this.properties.show);
60
+ wx.showToast({
61
+ title: this.properties.message,
62
+ duration: this.properties.duration,
63
+ icon:'none'
64
+ })
65
+ },
66
+ // 带跳转的提示
67
+ showNavToast(){
68
+ if(this.properties.navDuration){
69
+ setTimeout(()=>{
70
+ this.setData({
71
+ dispear: true
72
+ })
73
+ },this.properties.navDuration)
74
+ }
75
+ },
76
+ // 点击提示框跳转至目标页面
77
+ navTo(){
78
+ if(this.properties.navUrl){
79
+ wx.navigateTo({
80
+ url: this.properties.navUrl,
81
+ })
82
+ }
83
+ }
84
+ }
85
+ })
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared",
4
+ "usingComponents": {
5
+ "xt-icon": "../xt-icon"
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ <!--src/xt-toast/index.wxml-->
2
+ <!-- 带跳转的提示 -->
3
+ <view class="nav_toast_box" wx:if="{{type === 'navToast'}}" style="{{dispear?'opacity: 0;':''}}" catchtap="navTo">
4
+ <view class="nav_toast_text">{{message}}</view>
5
+ <xt-icon class="nav_icon" slot="right-icon" icon="arrow" size="32"></xt-icon>
6
+ </view>
@@ -0,0 +1,27 @@
1
+ /* src/xt-toast/index.wxss */
2
+ .nav_toast_box{
3
+ /* position: absolute; */
4
+ /* left: 50%; */
5
+ /* margin-left: -351rpx; */
6
+ width: 100%;
7
+ display: flex;
8
+ align-items: center;
9
+ justify-content: space-between;
10
+ background-color: #FCE1D4;
11
+ border-radius: 8rpx;
12
+ padding: 20rpx 24rpx;
13
+ box-sizing: border-box;
14
+ transition:all 0.3s linear;
15
+ }
16
+ .nav_toast_text{
17
+ width: 598rpx;
18
+ box-sizing: border-box;
19
+ line-height: 40rpx;
20
+ font-size: 28rpx;
21
+ font-family: PingFang SC-Semibold, PingFang SC;
22
+ color: #F26B27;
23
+ }
24
+ .nav_icon{
25
+ color: #F26B27;
26
+ margin-left: 24rpx;
27
+ }
@@ -0,0 +1,46 @@
1
+ # Icon图标
2
+
3
+ ### 介绍
4
+ 用于表单列表上传图片
5
+
6
+ ###效果图
7
+ ![效果图](https://img.tanjiu.cn/home/p4fiMjw3F7ssMNhQxafHCnsn8ZZ8m67Q.png "列表uploader效果图")
8
+
9
+ ### 引入
10
+ 在app.json或页面配置json中引入
11
+ ```
12
+ "usingComponents": {
13
+ "xt-uploader": "@xtdev/xt-miniprogram-ui/xt-uploader",
14
+ }
15
+ ```
16
+
17
+ ## 代码演示
18
+
19
+ ### 基础用法
20
+
21
+ ```
22
+ <xt-uploader title="标题标题"></xt-uploader>
23
+ ```
24
+
25
+ ##API
26
+
27
+ ####xt-uploader props
28
+
29
+ | 参数 | 说明 | 类型 | 默认值
30
+ | ----------- | ----------- | ---------- | -------- |
31
+ | fileList | 图片列表,必传,受控组件 | Array<String> | `[]`
32
+ | title | 表单标题 | string |
33
+ | max | 上传最大值,每次可选照片数,默认为9 | number | 9
34
+ | upload-desc | 上传文案说明 | `String` |
35
+ | custom-upload | 是否自定义上传,true 点击盒子触发upload | boolean | `false`
36
+ | disabled | 是否禁用,禁用时不能删除和上传,可预览 | boolean | `false`
37
+ | sourceType | 照片来源 | `Array<String>` | ["album", "camera"]
38
+ | upload-api | 组件库放公网,上传接口api,必传 | {url: 'https://...',fileDir: 'microComponents'} |
39
+
40
+ ####Events
41
+
42
+ | 事件名 | 说明 | 回调参数 |
43
+ | ---------------- | ------------- | ---------------------- |
44
+ | bind:upload | 上传成功后触发,如果customUpload为true则点击上传及触发 | fileList:图片列表, url:当前上传图片地址 |
45
+ | bind:delete | 删除成功后触发 | fileList:图片列表, url:当前删除图片地址,index:当前删除图片索引 |
46
+ | bind:error | 上传失败后触发 | errMsg: 失败原因 |
@@ -0,0 +1,233 @@
1
+ // src/xt-uploader/index.js
2
+ const utils = require("./utils");
3
+ // 节流函数
4
+ function _throttle(fn, wait = 500, isImmediate = false){
5
+ var flag = true;
6
+ return function(){
7
+ if(flag == true){
8
+ var context = this
9
+ var args = arguments
10
+ flag = false
11
+ isImmediate && fn.apply(context,args)
12
+ setTimeout(() => {
13
+ !isImmediate && fn.apply(context,args)
14
+ flag = true
15
+ },wait)
16
+ }
17
+ }
18
+ }
19
+
20
+ Component({
21
+ /**
22
+ * 组件的属性列表
23
+ */
24
+ properties: {
25
+ title: {
26
+ type: String,
27
+ value: "",
28
+ },
29
+ fileList: {
30
+ type: Array,
31
+ value: [],
32
+ },
33
+ max: {
34
+ type: Number,
35
+ value: 9,
36
+ },
37
+ uploadDesc: {
38
+ type: String,
39
+ value: "",
40
+ },
41
+ // ["album", "camera"]
42
+ sourceType: {
43
+ type: Array,
44
+ value: ["album", "camera"],
45
+ },
46
+ customUpload: {
47
+ type: Boolean,
48
+ value: false,
49
+ },
50
+ disabled: {
51
+ type: Boolean,
52
+ value: false,
53
+ },
54
+ uploadApi: {
55
+ type: Object,
56
+ value: {},
57
+ },
58
+ },
59
+
60
+ /**
61
+ * 组件的初始数据
62
+ */
63
+ data: {},
64
+
65
+ /**
66
+ * 组件的方法列表
67
+ */
68
+ methods: {
69
+ // 预览
70
+ onPreviewImage(e) {
71
+ const url = e.target.dataset.url;
72
+ // const index = e.target.dataset.index;
73
+ wx.previewImage({
74
+ urls: this.properties.fileList,
75
+ current: url,
76
+ });
77
+ },
78
+ // 删除
79
+ onDelete(e) {
80
+ const url = e.currentTarget.dataset.url;
81
+ const index = e.currentTarget.dataset.index;
82
+ this.properties.fileList.splice(index, 1);
83
+ this.triggerEvent("delete", {
84
+ fileList: this.properties.fileList,
85
+ url,
86
+ index,
87
+ });
88
+ },
89
+ // 上传成功
90
+ onUploadSuccess(files, url) {
91
+ this.triggerEvent("upload", { fileList: files, url });
92
+ },
93
+ // 上传失败
94
+ onUploadError(errMsg) {
95
+ this.triggerEvent("error", { errMsg });
96
+ },
97
+ // 点击上传
98
+ startTakePhoto: _throttle(function (e) {
99
+ console.log("onStartTakePhoto", e);
100
+ const _this = this;
101
+ const {
102
+ customUpload,
103
+ uploadApi,
104
+ max,
105
+ sourceType,
106
+ fileList,
107
+ } = this.properties;
108
+ if (customUpload) {
109
+ this.triggerEvent("upload", {});
110
+ return;
111
+ }
112
+ if (!uploadApi || !uploadApi.url) {
113
+ wx.showToast({
114
+ title: "请传入上传接口",
115
+ icon: "error",
116
+ });
117
+ return;
118
+ }
119
+ // ios企微环境下不支持该API
120
+ const { platform, environment } = this.getSystemInfo();
121
+ console.log(platform, environment);
122
+ let chooseImgApi = (environment !== "wxwork" || platform !== "ios") ? wx.chooseMedia : wx.chooseImage;
123
+ chooseImgApi({
124
+ count: max - fileList.length,
125
+ mediaType: ["image"],
126
+ sizeType: ["compressed"],
127
+ sourceType,
128
+ success(res) {
129
+ console.log(res, "0000");
130
+ // tempFilePath可以作为img标签的src属性显示图片
131
+ const tempFilePaths = res.tempFiles;
132
+ if (Array.isArray(tempFilePaths) && tempFilePaths.length) {
133
+ Promise.allSettled(
134
+ tempFilePaths.map((temp) =>
135
+ _this.uploadImage_v(temp.tempFilePath || temp.path)
136
+ )
137
+ ).then((uploadRes) => {
138
+ wx.hideLoading();
139
+ console.log("----uploadRes", uploadRes);
140
+ // 上传成功
141
+ const successUrls = uploadRes
142
+ .filter((result) => result.status == "fulfilled")
143
+ .map((result) => result.value);
144
+ if (successUrls.length) {
145
+ const files = fileList.concat(successUrls);
146
+ _this.onUploadSuccess(files, successUrls);
147
+ }
148
+ // 上传失败
149
+ const errorList = uploadRes.filter(
150
+ (result) => result.status == "rejected"
151
+ );
152
+ if (errorList.length) {
153
+ _this.onUploadError(errorList[0].value);
154
+ }
155
+ });
156
+ }
157
+ },
158
+ fail(error) {
159
+ _this.onUploadError(error && error.errMsg);
160
+ console.log("-----选取失败", error && error.errMsg);
161
+ },
162
+ });
163
+ }, 1500, true),
164
+ getSystemInfo() {
165
+ const environment = wx.getSystemInfoSync().environment || "wechat";
166
+ const platform = wx.getSystemInfoSync().platform;
167
+ return {
168
+ environment,
169
+ platform,
170
+ };
171
+ },
172
+ // 上传文件
173
+ uploadImage_v(filePaths) {
174
+ return new Promise((resolve, reject) => {
175
+ const { url, fileDir, ...header } = this.properties.uploadApi;
176
+ wx.showLoading({title: "上传中", mask: true});
177
+ utils.newHttp(
178
+ url,
179
+ "GET",
180
+ {
181
+ dir: fileDir || "microComponents",
182
+ },
183
+ header,
184
+ (res) => {
185
+ const { host, signature, accessKeyId, policy, dir } = res.data;
186
+ if (host) {
187
+ let path = filePaths;
188
+ let name = utils.random_string(32) + utils.get_suffix(path);
189
+ wx.uploadFile({
190
+ url: host,
191
+ filePath: filePaths,
192
+ name: "file",
193
+ formData: {
194
+ key: dir + "/" + name,
195
+ policy,
196
+ success_action_status: "200",
197
+ OSSAccessKeyId: accessKeyId,
198
+ signature,
199
+ },
200
+ header: {
201
+ // "Content-Type": "multipart/form-data",
202
+ },
203
+ success: (res) => {
204
+ if (res.statusCode == 200) {
205
+ let url = host + dir + "/" + name;
206
+ resolve(url);
207
+ // fileList.push(url);
208
+ // _this.onUploadSuccess(url);
209
+ // wx.showToast({
210
+ // icon: "success",
211
+ // title: "上传成功",
212
+ // });
213
+ }
214
+ },
215
+ fail: (err) => {
216
+ reject(err.errMsg || "网络错误,请重试");
217
+ // _this.onUploadError(err.errMsg || "网络错误,请重试");
218
+ // wx.showToast({
219
+ // icon: "error",
220
+ // title: err.errMsg || "网络错误,请重试",
221
+ // });
222
+ },
223
+ });
224
+ } else {
225
+ reject(res.message);
226
+ // _this.onUploadError(res.message);
227
+ }
228
+ }
229
+ );
230
+ });
231
+ },
232
+ },
233
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared",
4
+ "usingComponents": {
5
+ "xt-icon": "../xt-icon/index"
6
+ }
7
+ }
@@ -0,0 +1,15 @@
1
+ <!-- src/xt-uploader/index.wxml -->
2
+ <view class="xt-uploader">
3
+ <view class="title_text" wx:if="{{title}}">{{title}}</view>
4
+ <view class="file_box">
5
+ <view wx:for="{{fileList}}" wx:key="index" class="file_item">
6
+ <image class="file_img" src="{{item}}" mode="aspectFit" bindtap="onPreviewImage" data-url="{{item}}" data-index="{{index}}" />
7
+ <!-- 删除 -->
8
+ <xt-icon icon="shanchu" size="48" class="close_box" bindtap="onDelete" data-url="{{item}}" data-index="{{index}}" wx:if="{{!disabled}}"></xt-icon>
9
+ </view>
10
+ <view class="file_item" wx:if="{{!disabled && fileList.length<max}}" bindtap="startTakePhoto">
11
+ <image src="https://img.tanjiu.cn/home/DDDsrH7PpNhneQsXGFmGGPcSM3QYXG8N.png" class="camera_icon" />
12
+ <view wx:if="{{uploadDesc}}" class="upload_desc">{{uploadDesc}}</view>
13
+ </view>
14
+ </view>
15
+ </view>
@@ -0,0 +1,68 @@
1
+ /* src/xt-uploader/index.wxss */
2
+ .xt-uploader {
3
+ background-color : #fff;
4
+ /* padding : 32rpx;
5
+ padding-bottom : 0; */
6
+ }
7
+
8
+ .title_text {
9
+ line-height: 48rpx;
10
+ font-size : 34rpx;
11
+ font-family: PingFang SC-Semibold,
12
+ PingFang SC;
13
+ font-weight : 800;
14
+ color : #000000;
15
+ margin-bottom: 16rpx;
16
+ }
17
+
18
+ .file_box {
19
+ display : flex;
20
+ flex-wrap: wrap;
21
+ }
22
+
23
+ .file_item {
24
+ width : 196rpx;
25
+ height : 196rpx;
26
+ border-radius : 8rpx;
27
+ overflow : hidden;
28
+ position : relative;
29
+ display : flex;
30
+ flex-direction : column;
31
+ justify-content : center;
32
+ align-items : center;
33
+ background-color: #F5F5F5;
34
+ margin-bottom : 16rpx;
35
+ flex-shrink: 0;
36
+ }
37
+
38
+ .file_item:not(:last-child) {
39
+ margin-right: 16rpx;
40
+ }
41
+
42
+ .camera_icon {
43
+ width : 80rpx;
44
+ height: 80rpx;
45
+ }
46
+
47
+ .file_img {
48
+ width : 196rpx;
49
+ height: 196rpx;
50
+ }
51
+
52
+ .close_box {
53
+ position : absolute;
54
+ line-height: 48rpx;
55
+ top : 0;
56
+ right : 0;
57
+ color : rgba(0, 0, 0, 0.5);
58
+ }
59
+
60
+ .upload_desc {
61
+ line-height: 40rpx;
62
+ font-size : 28rpx;
63
+ font-family: PingFang SC-Regular,
64
+ PingFang SC;
65
+ font-weight: 400;
66
+ color : #727272;
67
+ margin-top : 8rpx;
68
+ }
@@ -0,0 +1,69 @@
1
+ // import md5 from "md5";
2
+
3
+ function newhttpRequest(url, method, params, header, callBack) {
4
+ wx.request({
5
+ url,
6
+ method: method,
7
+ header: {
8
+ "content-type": "application/json",
9
+ // Authorization: md5(pass),
10
+ token: "openApi",
11
+ ...header,
12
+ },
13
+ data: params,
14
+ success(res) {
15
+ if (res.data) {
16
+ var result = {
17
+ data: res.data.data || res.data.retdata || res,
18
+ message: res.data.message || res.data.errMsg,
19
+ code:
20
+ res.data.code ||
21
+ res.data.errCode ||
22
+ (res.data.code == 0 || res.data.errCode == 0 ? 0 : null),
23
+ };
24
+ callBack(result);
25
+ }
26
+ },
27
+ fail(err) {
28
+ var result = {
29
+ success: false,
30
+ data: {},
31
+ message: err.errMsg || err.msg,
32
+ };
33
+ wx.showToast({
34
+ title: result.message || "请检查网络是否通畅,稍后重试!",
35
+ icon: "none",
36
+ });
37
+ console.log("err = ", err);
38
+ callBack(result);
39
+ },
40
+ });
41
+ }
42
+
43
+ function random_string(len) {
44
+ len = len || 32;
45
+ let chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
46
+ let maxPos = chars.length;
47
+ let pwd = "";
48
+ for (let i = 0; i < len; i++) {
49
+ pwd += chars.charAt(Math.floor(Math.random() * maxPos));
50
+ }
51
+ return pwd;
52
+ }
53
+
54
+ // 解密
55
+ function get_suffix(filename) {
56
+ console.log(filename, "filename");
57
+ let pos = filename.lastIndexOf(".");
58
+ let suffix = "";
59
+ if (pos != -1) {
60
+ suffix = filename.substring(pos);
61
+ }
62
+ return suffix;
63
+ }
64
+
65
+ module.exports = {
66
+ newHttp: newhttpRequest,
67
+ random_string,
68
+ get_suffix,
69
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtdev/xt-miniprogram-ui",
3
- "version": "1.2.60",
3
+ "version": "1.2.61",
4
4
  "description": "",
5
5
  "miniprogram": "libs",
6
6
  "publishConfig": {