|
@@ -189,9 +189,11 @@ Page({
|
|
|
// let myMd5 = _this.getImgMd5(binData)
|
|
|
// let my2Md5 = _this.getImg2Md5(binData)
|
|
|
// let my3Md5 = _this.getImg3Md5(binData)
|
|
|
+ // todo 测试用
|
|
|
wx.setClipboardData({
|
|
|
data: res2.digest,
|
|
|
})
|
|
|
+
|
|
|
_this.sliceDataIntoChunks(binData, 64);
|
|
|
|
|
|
console.log("加载文件成功2:", binData.byteLength, binData.length)
|
|
@@ -265,6 +267,7 @@ Page({
|
|
|
// 用户已授权访问相册
|
|
|
console.log('用户已授权访问相册2');
|
|
|
// 可以在这里执行访问相册的操作
|
|
|
+ _this.upload()
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -321,6 +324,12 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 切分高位和低位
|
|
|
+ splitHighLowBytes(value) {
|
|
|
+ let highByte = (value >> 8) & 0xFF;
|
|
|
+ let lowByte = value & 0xFF;
|
|
|
+ return { highByte, lowByte };
|
|
|
+ },
|
|
|
async sendImage(index) {
|
|
|
let _this = this
|
|
|
|
|
@@ -332,6 +341,14 @@ Page({
|
|
|
// let i = 0;
|
|
|
// _this.data._timer = setInterval(async () => {
|
|
|
if (index > chunks.length - 1) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '壁纸上传完成md5:' + _this.data._imgMD5,
|
|
|
+ content: '最终发送数据大小:' + _this.data._imgNext + ',总大小:' + total + '',
|
|
|
+ showCancel: false,
|
|
|
+ success(res) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
_this.endImage(0)
|
|
|
return;
|
|
|
}
|
|
@@ -339,7 +356,7 @@ Page({
|
|
|
const chunk = chunks[index];
|
|
|
_this.data._imgNext += (chunk.byteLength ?? chunk.length);
|
|
|
|
|
|
- // console.log("发送壁纸数据1:", index, ":", _this.data._imgNext, ":", chunk.length, ":", chunk.byteLength, ":", total, chunks.length)
|
|
|
+ console.log("发送壁纸数据1:", index, ":", _this.data._imgNext, ":", chunk.length, ":", chunk.byteLength, ":", total, chunks.length)
|
|
|
|
|
|
let res = await btHelper.wallPaperSyncData(chunk);
|
|
|
// let res = true;
|
|
@@ -397,6 +414,29 @@ Page({
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ successSend() {
|
|
|
+ wx.showModal({
|
|
|
+ title: '上传壁纸成功',
|
|
|
+ showCancel: false,
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const pages = getCurrentPages();
|
|
|
+ // 获取上一级页面实例
|
|
|
+ const prevPage = pages[pages.length - 2];
|
|
|
+ // 传递参数
|
|
|
+ prevPage.setData({
|
|
|
+ topImg: {
|
|
|
+ "pic": _this.data._imgUrl,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
failSend(showToast) {
|
|
|
let _this = this
|
|
|
_this.data._chunks = null
|
|
@@ -405,9 +445,14 @@ Page({
|
|
|
_this.data._imgNext = 0
|
|
|
wx.hideLoading()
|
|
|
if (showToast) {
|
|
|
- wx.showModal({
|
|
|
- title: '壁纸上传失败了',
|
|
|
- showCancel: false
|
|
|
+ // todo 测试注释的
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '壁纸上传失败了',
|
|
|
+ // showCancel: false
|
|
|
+ // })
|
|
|
+ wx.showToast({
|
|
|
+ title: '发送失败',
|
|
|
+ icon: 'failure'
|
|
|
})
|
|
|
}
|
|
|
_this.setData({
|
|
@@ -432,9 +477,9 @@ Page({
|
|
|
this.cropper = this.selectComponent("#image-cropper");
|
|
|
this.cropper.imgReset();
|
|
|
let image = options.param
|
|
|
+ let json = JSON.parse(image)
|
|
|
console.log("裁剪页:", image)
|
|
|
- if (image.pic) {
|
|
|
- let json = JSON.parse(image)
|
|
|
+ if (json.pic) {
|
|
|
this.hasImage(json)
|
|
|
} else {
|
|
|
console.log("没有图片")
|
|
@@ -477,27 +522,7 @@ Page({
|
|
|
_this.failSend(true)
|
|
|
} else if (value === 0 && kind == 1) {
|
|
|
// 发送完成
|
|
|
- _this.failSend(false)
|
|
|
- wx.showModal({
|
|
|
- title: '上传壁纸成功',
|
|
|
- showCancel: false,
|
|
|
- success(res) {
|
|
|
- if (res.confirm) {
|
|
|
- const pages = getCurrentPages();
|
|
|
- // 获取上一级页面实例
|
|
|
- const prevPage = pages[pages.length - 2];
|
|
|
- // 传递参数
|
|
|
- prevPage.setData({
|
|
|
- topImg: {
|
|
|
- "pic": _this.data._imgUrl,
|
|
|
- }
|
|
|
- });
|
|
|
- wx.navigateBack({
|
|
|
- delta: 1,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ _this.successSend()
|
|
|
} else {
|
|
|
// 发送失败
|
|
|
_this.failSend(true)
|