Commit e111a694 by pangchong

feat: 优化

parent dfa7f786
......@@ -75,16 +75,8 @@ const afterRead = async (event) => {
})
})
for (let i = 0; i < lists.length; i++) {
const arrayBuffer = new Uint8Array(lists[i].url) //先将本地图片路径转换成array类型
const binary = arrayBufferToBinary(arrayBuffer)
// const binary = uni.getFileSystemManager().readFileSync(lists[i].url, 'binary')
// const imgBlob = await fetch(lists[i].url).then((r) => r.blob())
// const imgFile = new File([imgBlob], lists[i].name, { type: imgBlob.type })
// let form = new FormData()
// form.append('file', imgFile)
try {
const res = await uploadFilePromise(lists[i].url, binary)
const res = await uploadFilePromise(lists[i].url)
if (res.code == 200) {
fileList.value.splice(fileListLen, 1, {
...res.data,
......@@ -103,14 +95,6 @@ const afterRead = async (event) => {
}
}
function arrayBufferToBinary(buffer) {
// 创建一个二进制编码器
const encoder = new TextEncoder()
// 将ArrayBuffer视为UTF-8字符串的字节序列
const view = new Uint8Array(buffer)
// 使用二进制编码器将字节序列转换为字符串
return encoder.encode(new Uint8Array(buffer)).toString()
}
watch(
fileList,
(value) => {
......@@ -130,16 +114,12 @@ watch(
},
{ deep: true }
)
const uploadFilePromise = (url, binary) => {
const uploadFilePromise = (url) => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: ps.url,
name: 'file',
filePath: url,
file: binary,
formData: {
file: binary
},
success: (res) => {
resolve(JSON.parse(res.data))
},
......
......@@ -17,7 +17,9 @@
"delay" : 0
},
/* 模块配置 */
"modules" : {},
"modules" : {
"Camera" : {}
},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
......
......@@ -80,7 +80,7 @@
</card-details>
<card-details type="appeal" title="申诉状态" titleIcon="email">
<view class="appeal-status">{{ useGetDictByValue('appealInfo', details.appealInfo) }}</view>
<image :src="item.fileUrl" v-for="(item, index) in getFileList" :key="item.id" @tap="previewImage(index)" />
<image :src="item.fileUrl" v-for="(item, index) in getFileList" :key="item.id" @tap="previewImage(index)" mode="widthFix" />
</card-details>
</view>
</global-page>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment