@xtdev/xt-miniprogram-ui 1.0.10 → 1.0.13

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 (45) hide show
  1. package/libs/xt-button/README.md +60 -0
  2. package/libs/xt-button/index.js +116 -0
  3. package/libs/xt-button/index.json +6 -0
  4. package/libs/xt-button/index.wxml +31 -0
  5. package/libs/xt-button/index.wxss +70 -0
  6. package/libs/xt-card-cell/README.md +65 -0
  7. package/libs/xt-card-cell/index.wxss +1 -0
  8. package/libs/xt-dialog/README.md +152 -0
  9. package/libs/xt-dialog/index.js +126 -0
  10. package/libs/xt-dialog/index.json +4 -0
  11. package/libs/xt-dialog/index.wxml +51 -0
  12. package/libs/xt-dialog/index.wxss +121 -0
  13. package/libs/xt-icon/README.md +39 -0
  14. package/libs/xt-icon/index.wxss +25 -46
  15. package/libs/xt-search/README.md +55 -0
  16. package/libs/xt-search/index.js +0 -37
  17. package/libs/xt-search/index.wxml +7 -7
  18. package/libs/xt-search/index.wxss +3 -3
  19. package/libs/xt-stepper/README.md +52 -0
  20. package/libs/xt-stepper/index.js +158 -0
  21. package/libs/xt-stepper/index.json +4 -0
  22. package/libs/xt-stepper/index.wxml +11 -0
  23. package/libs/xt-stepper/index.wxss +83 -0
  24. package/libs/xt-steps/README.md +61 -0
  25. package/libs/xt-steps/index.js +37 -0
  26. package/libs/xt-steps/index.json +7 -0
  27. package/libs/xt-steps/index.wxml +32 -0
  28. package/libs/xt-steps/index.wxss +180 -0
  29. package/libs/xt-tag/README.md +65 -0
  30. package/libs/xt-tag/index.js +38 -0
  31. package/libs/xt-tag/index.json +6 -0
  32. package/libs/xt-tag/index.wxml +5 -0
  33. package/libs/xt-tag/index.wxss +36 -0
  34. package/libs/xt-toast/README.md +65 -0
  35. package/libs/xt-toast/index.js +85 -0
  36. package/libs/xt-toast/index.json +6 -0
  37. package/libs/xt-toast/index.wxml +6 -0
  38. package/libs/xt-toast/index.wxss +27 -0
  39. package/libs/xt-uploader/README.md +44 -0
  40. package/libs/xt-uploader/index.js +150 -0
  41. package/libs/xt-uploader/index.json +7 -0
  42. package/libs/xt-uploader/index.wxml +15 -0
  43. package/libs/xt-uploader/index.wxss +67 -0
  44. package/libs/xt-uploader/utils.js +73 -0
  45. 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,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "xt-icon": "../xt-icon"
5
+ }
6
+ }
@@ -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,44 @@
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` |
34
+ | upload-desc | 上传文案说明 | `String` |
35
+ | custom-upload | 是否自定义上传,true 点击盒子触发upload | `Boolean` |
36
+ | disabled | 是否禁用,禁用时不能删除和上传,可预览 | `Boolean` |
37
+ | sourceType | 照片来源 | ["album", "camera"] |
38
+
39
+ ####Events
40
+
41
+ | 事件名 | 说明 | 回调参数 |
42
+ | ---------------- | ------------- | ---------------------- |
43
+ | bind:upload | 上传成功后触发,如果customUpload为true则点击上传及触发 | fileList:图片列表, url:当前上传图片地址 |
44
+ | bind:delete | 删除成功后触发 | fileList:图片列表, url:当前删除图片地址,index:当前删除图片索引 |
@@ -0,0 +1,150 @@
1
+ // src/xt-uploader/index.js
2
+ const utils = require("./utils");
3
+ Component({
4
+ /**
5
+ * 组件的属性列表
6
+ */
7
+ properties: {
8
+ title: {
9
+ type: String,
10
+ value: "",
11
+ },
12
+ fileList: {
13
+ type: Array,
14
+ value: [],
15
+ },
16
+ max: {
17
+ type: Number,
18
+ value: 9,
19
+ },
20
+ uploadDesc: {
21
+ type: String,
22
+ value: "",
23
+ },
24
+ // ["album", "camera"]
25
+ sourceType: {
26
+ type: Array,
27
+ value: ["camera"],
28
+ },
29
+ customUpload: {
30
+ type: Boolean,
31
+ value: false,
32
+ },
33
+ disabled: {
34
+ type: Boolean,
35
+ value: false,
36
+ },
37
+ },
38
+
39
+ /**
40
+ * 组件的初始数据
41
+ */
42
+ data: {},
43
+
44
+ /**
45
+ * 组件的方法列表
46
+ */
47
+ methods: {
48
+ // 预览
49
+ onPreviewImage(e) {
50
+ const url = e.target.dataset.url;
51
+ // const index = e.target.dataset.index;
52
+ wx.previewImage({
53
+ urls: this.properties.fileList,
54
+ current: url,
55
+ });
56
+ },
57
+ // 删除
58
+ onDelete(e) {
59
+ const url = e.currentTarget.dataset.url;
60
+ const index = e.currentTarget.dataset.index;
61
+ this.properties.fileList.splice(index, 1);
62
+ this.triggerEvent("delete", {
63
+ fileList: this.properties.fileList,
64
+ url,
65
+ index,
66
+ });
67
+ },
68
+ // 上传成功
69
+ onUploadSuccess(url) {
70
+ this.triggerEvent("upload", { fileList: this.properties.fileList, url });
71
+ },
72
+ // 点击上传
73
+ startTakePhoto() {
74
+ const _this = this;
75
+ if (this.properties.customUpload) {
76
+ this.triggerEvent("upload", {});
77
+ return;
78
+ }
79
+ wx.chooseMedia({
80
+ count: 1,
81
+ mediaType: ["image"],
82
+ sizeType: ["compressed"],
83
+ sourceType: this.properties.sourceType,
84
+ success(res) {
85
+ console.log(res, "0000");
86
+ // tempFilePath可以作为img标签的src属性显示图片
87
+ const tempFilePaths = res.tempFiles[0].tempFilePath;
88
+ _this.uploadImage_v(tempFilePaths);
89
+ },
90
+ fail(error) {
91
+ wx.showToast({
92
+ title: error && error.errMsg,
93
+ icon: "none",
94
+ });
95
+ },
96
+ });
97
+ },
98
+ // 上传文件
99
+ uploadImage_v(filePaths) {
100
+ let _this = this;
101
+ const { fileList } = _this.properties;
102
+ wx.showLoading("图片上传中");
103
+ utils.newHttp(
104
+ "/core/file/oss/miniProgramPolicy",
105
+ "GET",
106
+ {
107
+ dir: "microComponents",
108
+ },
109
+ (res) => {
110
+ const { host, signature, accessKeyId, policy, dir } = res.data;
111
+ let path = filePaths;
112
+ let name = utils.random_string(32) + utils.get_suffix(path);
113
+ wx.uploadFile({
114
+ url: host,
115
+ filePath: filePaths,
116
+ name: "file",
117
+ formData: {
118
+ key: dir + "/" + name,
119
+ policy,
120
+ success_action_status: "200",
121
+ OSSAccessKeyId: accessKeyId,
122
+ signature,
123
+ },
124
+ header: {
125
+ "Content-Type": "multipart/form-data",
126
+ "wow-token": "c9fbecb5fdeecb78e8745db9225d88e1",
127
+ },
128
+ success: (res) => {
129
+ if (res.statusCode == 200) {
130
+ let url = host + dir + "/" + name;
131
+ fileList.push(url);
132
+ _this.onUploadSuccess(url);
133
+ wx.showToast({
134
+ icon: "success",
135
+ title: "上传成功",
136
+ });
137
+ }
138
+ },
139
+ fail: (err) => {
140
+ wx.showToast({
141
+ icon: "error",
142
+ title: err.errMsg || "网络错误,请重试",
143
+ });
144
+ },
145
+ });
146
+ }
147
+ );
148
+ },
149
+ },
150
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "isolated",
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,67 @@
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 : 32rpx;
35
+ }
36
+
37
+ .file_item:not(:last-child) {
38
+ margin-right: 32rpx;
39
+ }
40
+
41
+ .camera_icon {
42
+ width : 80rpx;
43
+ height: 80rpx;
44
+ }
45
+
46
+ .file_img {
47
+ width : 196rpx;
48
+ height: 196rpx;
49
+ }
50
+
51
+ .close_box {
52
+ position : absolute;
53
+ line-height: 48rpx;
54
+ top : 0;
55
+ right : 0;
56
+ color : rgba(0, 0, 0, 0.5);
57
+ }
58
+
59
+ .upload_desc {
60
+ line-height: 40rpx;
61
+ font-size : 28rpx;
62
+ font-family: PingFang SC-Regular,
63
+ PingFang SC;
64
+ font-weight: 400;
65
+ color : #727272;
66
+ margin-top : 8rpx;
67
+ }
@@ -0,0 +1,73 @@
1
+ // import md5 from "md5";
2
+
3
+ function newhttpRequest(url, method, params, callBack, header) {
4
+ //change - gml 接口url拼接
5
+ var full_url = "https://gateway.tanjiu.cn" + url;
6
+ wx.request({
7
+ url: full_url,
8
+ method: method,
9
+ header: {
10
+ "content-type": "application/json",
11
+ // Authorization: md5(pass),
12
+ "ls-client-id": "TANJIUCLOUD_BUSINESS",
13
+ token: "openApi",
14
+ "x-login-session": JSON.stringify({ userId: "2022199" }),
15
+ ...header,
16
+ },
17
+ data: params,
18
+ success(res) {
19
+ if (res.data) {
20
+ var result = {
21
+ data: res.data.data || res.data.retdata || res,
22
+ message: res.data.message || res.data.errMsg,
23
+ code:
24
+ res.data.code ||
25
+ res.data.errCode ||
26
+ (res.data.code == 0 || res.data.errCode == 0 ? 0 : null),
27
+ };
28
+ callBack(result);
29
+ }
30
+ },
31
+ fail(err) {
32
+ var result = {
33
+ success: false,
34
+ data: {},
35
+ message: err.errMsg || err.msg,
36
+ };
37
+ wx.showToast({
38
+ title: esult.message || "请检查网络是否通畅,稍后重试!",
39
+ icon: "none",
40
+ });
41
+ console.log("err = ", err);
42
+ callBack(result);
43
+ },
44
+ });
45
+ }
46
+
47
+ function random_string(len) {
48
+ len = len || 32;
49
+ let chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
50
+ let maxPos = chars.length;
51
+ let pwd = "";
52
+ for (let i = 0; i < len; i++) {
53
+ pwd += chars.charAt(Math.floor(Math.random() * maxPos));
54
+ }
55
+ return pwd;
56
+ }
57
+
58
+ // 解密
59
+ function get_suffix(filename) {
60
+ console.log(filename, "filename");
61
+ let pos = filename.lastIndexOf(".");
62
+ let suffix = "";
63
+ if (pos != -1) {
64
+ suffix = filename.substring(pos);
65
+ }
66
+ return suffix;
67
+ }
68
+
69
+ module.exports = {
70
+ newHttp: newhttpRequest,
71
+ random_string,
72
+ get_suffix,
73
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtdev/xt-miniprogram-ui",
3
- "version": "1.0.10",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "miniprogram": "libs",
6
6
  "publishConfig": {