xyvcard-wechat-auth 0.0.29 → 0.0.31
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/dist/components/common/auth-form/form-upload-file/index.d.ts +1 -0
- package/dist/components/common/auth-form/form-upload-file/index.js +127 -0
- package/dist/components/common/auth-form/form-upload-file/index.json +7 -0
- package/dist/components/common/auth-form/form-upload-file/index.wxml +8 -0
- package/dist/components/common/auth-form/form-upload-file/index.wxss +1 -0
- package/dist/components/common/auth-top-navigation/index.js +52 -1
- package/dist/components/common/auth-top-navigation/index.json +3 -1
- package/dist/components/common/auth-top-navigation/index.wxml +3 -3
- package/dist/components/common/auth-top-navigation/index.wxss +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { config } from "../../../../utils/config.js";
|
|
2
|
+
import { fileApi } from "../../../../api/files/index.js";
|
|
3
|
+
Component({
|
|
4
|
+
/**
|
|
5
|
+
* 组件的属性列表
|
|
6
|
+
*/
|
|
7
|
+
properties: {
|
|
8
|
+
// 按钮样式
|
|
9
|
+
fileStyle: {
|
|
10
|
+
type: String,
|
|
11
|
+
value: "background-color: #2563EB"
|
|
12
|
+
},
|
|
13
|
+
// 租户
|
|
14
|
+
tenant: {
|
|
15
|
+
type: String,
|
|
16
|
+
value: config.tenant
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* 组件的初始数据
|
|
21
|
+
*/
|
|
22
|
+
data: {
|
|
23
|
+
closeModel: false,
|
|
24
|
+
percentage: 100
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* 组件的方法列表
|
|
28
|
+
*/
|
|
29
|
+
methods: {
|
|
30
|
+
// 文件选择
|
|
31
|
+
chooseFileModel() {
|
|
32
|
+
this.setData({
|
|
33
|
+
closeModel: true
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
// 从相册中选择
|
|
37
|
+
handleAlbumImg() {
|
|
38
|
+
const that = this;
|
|
39
|
+
that.setData({
|
|
40
|
+
closeModel: !that.data.closeModel
|
|
41
|
+
});
|
|
42
|
+
wx.chooseMedia({
|
|
43
|
+
count: 20,
|
|
44
|
+
mediaType: ["image"],
|
|
45
|
+
sourceType: ["album"],
|
|
46
|
+
success(response) {
|
|
47
|
+
console.log(response);
|
|
48
|
+
if (response.errMsg === "chooseMedia:ok") {
|
|
49
|
+
console.log(response);
|
|
50
|
+
const tempFilePaths = response.tempFiles;
|
|
51
|
+
console.log(tempFilePaths);
|
|
52
|
+
tempFilePaths.forEach((item) => {
|
|
53
|
+
console.log(item);
|
|
54
|
+
item.name = Math.random() + ".jpg";
|
|
55
|
+
const fs = wx.getFileSystemManager();
|
|
56
|
+
const bodySize = 3670016;
|
|
57
|
+
let part = 1;
|
|
58
|
+
const total = Math.ceil(item.size / bodySize);
|
|
59
|
+
that.updateWebFilePart(fs, item, Math.random() + "123", bodySize, part, total);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
// 上传附件
|
|
66
|
+
handleUploadFile() {
|
|
67
|
+
const that = this;
|
|
68
|
+
that.setData({
|
|
69
|
+
closeModel: !that.data.closeModel
|
|
70
|
+
});
|
|
71
|
+
wx.chooseMessageFile({
|
|
72
|
+
count: 100,
|
|
73
|
+
type: "all",
|
|
74
|
+
// extension: extension,
|
|
75
|
+
success(response) {
|
|
76
|
+
if (response.errMsg === "chooseMessageFile:ok") {
|
|
77
|
+
console.log(response);
|
|
78
|
+
const tempFilePaths = response.tempFiles;
|
|
79
|
+
console.log(tempFilePaths);
|
|
80
|
+
tempFilePaths.forEach((item) => {
|
|
81
|
+
console.log(item);
|
|
82
|
+
const fs = wx.getFileSystemManager();
|
|
83
|
+
const bodySize = 3670016;
|
|
84
|
+
let part = 1;
|
|
85
|
+
const total = Math.ceil(item.size / bodySize);
|
|
86
|
+
that.updateWebFilePart(fs, item, Math.random() + "123", bodySize, part, total);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
updateWebFilePart(fs, item, requestId, bodySize, part, total) {
|
|
93
|
+
console.log(bodySize, part, total);
|
|
94
|
+
let that = this;
|
|
95
|
+
const position = (part - 1) * bodySize;
|
|
96
|
+
const remainingBytes = item.size - position;
|
|
97
|
+
const currentChunkSize = Math.min(bodySize, remainingBytes);
|
|
98
|
+
fs.readFile({
|
|
99
|
+
filePath: item.tempFilePath || item.path,
|
|
100
|
+
encoding: "base64",
|
|
101
|
+
// 注意这里使用 'binary' 模式读取文件
|
|
102
|
+
position,
|
|
103
|
+
length: currentChunkSize,
|
|
104
|
+
success: (res) => {
|
|
105
|
+
console.log(res);
|
|
106
|
+
const buffer = res.data;
|
|
107
|
+
let fileReq = { tenant: this.properties.tenant, body: buffer, fileName: item.name, fileDir: "bigfile", fileSize: item.size, requestId, filePart: part };
|
|
108
|
+
fileApi.uploadWebFile(fileReq).then((res2) => {
|
|
109
|
+
console.log(res2);
|
|
110
|
+
this.setData({
|
|
111
|
+
percentage: Math.ceil(part * 100 / total)
|
|
112
|
+
});
|
|
113
|
+
if (Math.ceil(part * 100 / total) == 100) {
|
|
114
|
+
that.triggerEvent("getFileResponse", { fileResponse: res2.data, item });
|
|
115
|
+
}
|
|
116
|
+
if (part * bodySize < item.size) {
|
|
117
|
+
this.updateWebFilePart(fs, item, requestId, bodySize, ++part, total);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
fail: (err) => {
|
|
122
|
+
console.error("Failed to read file:", err);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<button class="file-btn" bindtap="chooseFileModel" style="{{ fileStyle }}">上传附件</button>
|
|
2
|
+
|
|
3
|
+
<van-progress wx:if="{{ percentage < 100 }}" percentage="{{ percentage }}" />
|
|
4
|
+
|
|
5
|
+
<auth-popup show="{{ closeModel }}" titleShow="{{ false }}">
|
|
6
|
+
<view class="item" bind:tap="handleUploadFile">微信</view>
|
|
7
|
+
<view class="item" bind:tap="handleAlbumImg">相册</view>
|
|
8
|
+
</auth-popup>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.file-btn{color:#fff;font-size:24rpx;width:100px !important;margin-bottom:16rpx}.item{font-size:28rpx;text-align:center;padding:12px 0;border-bottom:1px solid #ebebeb;font-size:16px}.item:nth-child(2){border-bottom:0;margin-bottom:40rpx}
|
|
@@ -5,6 +5,11 @@ Component({
|
|
|
5
5
|
* 组件的属性列表
|
|
6
6
|
*/
|
|
7
7
|
properties: {
|
|
8
|
+
// 是否开启字体渐变 白-黑
|
|
9
|
+
isGradient: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
value: false
|
|
12
|
+
},
|
|
8
13
|
// 标题
|
|
9
14
|
title: {
|
|
10
15
|
type: String,
|
|
@@ -14,6 +19,11 @@ Component({
|
|
|
14
19
|
isLeftIcon: {
|
|
15
20
|
type: Boolean,
|
|
16
21
|
value: true
|
|
22
|
+
},
|
|
23
|
+
// 字体的颜色
|
|
24
|
+
titleColor: {
|
|
25
|
+
type: String,
|
|
26
|
+
value: "#333"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
/**
|
|
@@ -33,7 +43,7 @@ Component({
|
|
|
33
43
|
pageScrollTop: 0,
|
|
34
44
|
// 胶囊球的宽度
|
|
35
45
|
buttonWidth: getHeight().MenuButtonWidth,
|
|
36
|
-
//
|
|
46
|
+
// 背景透明色
|
|
37
47
|
color: ""
|
|
38
48
|
}
|
|
39
49
|
},
|
|
@@ -44,6 +54,47 @@ Component({
|
|
|
44
54
|
// 返回
|
|
45
55
|
handleBack() {
|
|
46
56
|
this.triggerEvent("eventBackTo");
|
|
57
|
+
},
|
|
58
|
+
// 计算导航栏透明度(供父组件调用)
|
|
59
|
+
calculateOpacity(scrollTop) {
|
|
60
|
+
let defaultTitleColorwhite = "#fff";
|
|
61
|
+
let defaultTitleColorBlack = "#333";
|
|
62
|
+
let color, titleColor;
|
|
63
|
+
if (scrollTop == 0) {
|
|
64
|
+
color = "rgba(255, 255, 255, 0)";
|
|
65
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
66
|
+
} else if (scrollTop > 0 && scrollTop <= 10) {
|
|
67
|
+
color = "rgba(255, 255, 255, 0.1)";
|
|
68
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
69
|
+
} else if (scrollTop >= 10 && scrollTop < 20) {
|
|
70
|
+
color = "rgba(255, 255, 255, 0.2)";
|
|
71
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
72
|
+
} else if (scrollTop >= 20 && scrollTop < 30) {
|
|
73
|
+
color = "rgba(255, 255, 255, 0.3)";
|
|
74
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
75
|
+
} else if (scrollTop >= 30 && scrollTop < 40) {
|
|
76
|
+
color = "rgba(255, 255, 255, 0.4)";
|
|
77
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
78
|
+
} else if (scrollTop >= 40 && scrollTop < 50) {
|
|
79
|
+
color = "rgba(255, 255, 255, 0.5)";
|
|
80
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
81
|
+
} else if (scrollTop >= 50 && scrollTop < 60) {
|
|
82
|
+
color = "rgba(255, 255, 255, 0.6)";
|
|
83
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
84
|
+
} else if (scrollTop >= 60 && scrollTop < 70) {
|
|
85
|
+
color = "rgba(255, 255, 255, 0.7)";
|
|
86
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
87
|
+
} else if (scrollTop >= 70 && scrollTop < 80) {
|
|
88
|
+
color = "rgba(255, 255, 255, 0.8)";
|
|
89
|
+
titleColor = this.properties.isGradient ? defaultTitleColorwhite : defaultTitleColorBlack;
|
|
90
|
+
} else {
|
|
91
|
+
color = "rgba(255, 255, 255, 1)";
|
|
92
|
+
titleColor = defaultTitleColorBlack;
|
|
93
|
+
}
|
|
94
|
+
this.setData({
|
|
95
|
+
"style.color": color,
|
|
96
|
+
titleColor
|
|
97
|
+
});
|
|
47
98
|
}
|
|
48
99
|
}
|
|
49
100
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<view style="background-color: {{ style.color }};">
|
|
2
|
-
<view class="auth-top-navigation" style="padding-top: {{ style.paddingTop }}px; height: {{ style.height }}px;">
|
|
3
|
-
<
|
|
1
|
+
<view class="auth-top" style="background-color: {{ style.color }};">
|
|
2
|
+
<view class="auth-top-navigation" style="padding-top: {{ style.paddingTop }}px; height: {{ style.height }}px;color: {{ titleColor }}">
|
|
3
|
+
<van-icon name="arrow-left" size="22px" wx:if="{{ isLeftIcon }}" color="{{ titleColor }}" bind:tap="handleBack" />
|
|
4
4
|
<text class="title">{{ title }}</text>
|
|
5
5
|
</view>
|
|
6
6
|
</view>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.auth-top
|
|
1
|
+
.auth-top{position:fixed;left:0;top:0;right:0;z-index:99999;transition:opacity .2s ease}.auth-top-navigation{display:flex;align-items:center;padding:0 10px}.auth-top-navigation .title{flex:1;text-align:center;font-size:28rpx}
|