|
@@ -15,7 +15,7 @@ Page({
|
|
|
navbarData: {
|
|
|
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
|
|
title: '壁纸设置', //导航栏 中间的标题
|
|
|
-
|
|
|
+ callback: true,
|
|
|
},
|
|
|
src: "",
|
|
|
width: 320,//宽度
|
|
@@ -27,6 +27,7 @@ Page({
|
|
|
_imgUrl: null,
|
|
|
_imgMD5: null,
|
|
|
_imgIndex: null,
|
|
|
+ _imgTopPic: null,
|
|
|
_imgNext: 0,
|
|
|
max_scale: 2,
|
|
|
_hasPermission: false,
|
|
@@ -35,7 +36,7 @@ Page({
|
|
|
cropper: null,
|
|
|
callback() {
|
|
|
let that = this
|
|
|
- if (this.data._chunks.length > 0) {
|
|
|
+ if (this.data.progress > 0) {
|
|
|
wx.showModal({
|
|
|
title: '保存壁纸中,确定要中断退出吗?',
|
|
|
content: '',
|
|
@@ -170,9 +171,9 @@ Page({
|
|
|
})
|
|
|
// app.globalData.imgSrc = obj.url;
|
|
|
console.log("裁剪壁纸:", res);
|
|
|
- _this.data._imgUrl = res.url
|
|
|
+ _this.data._imgUrl = _this.data._imgTopPic ?? res.url
|
|
|
fs.readFile({
|
|
|
- filePath: res.url,
|
|
|
+ filePath: _this.data._imgUrl,
|
|
|
encoding: '', // 不指定编码以获取原始二进制数据
|
|
|
success: (obj) => {
|
|
|
console.log("加载文件成功:", obj.data.byteLength, obj.data.length)
|
|
@@ -190,9 +191,9 @@ Page({
|
|
|
// let my2Md5 = _this.getImg2Md5(binData)
|
|
|
// let my3Md5 = _this.getImg3Md5(binData)
|
|
|
// todo 测试用
|
|
|
- wx.setClipboardData({
|
|
|
- data: res2.digest,
|
|
|
- })
|
|
|
+ // wx.setClipboardData({
|
|
|
+ // data: res2.digest,
|
|
|
+ // })
|
|
|
|
|
|
_this.sliceDataIntoChunks(binData, 64);
|
|
|
|
|
@@ -278,8 +279,8 @@ Page({
|
|
|
if (!res) {
|
|
|
wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
- title: '发送失败',
|
|
|
- icon: 'none'
|
|
|
+ title: '发送图片失败',
|
|
|
+ icon: 'error'
|
|
|
})
|
|
|
}
|
|
|
});
|
|
@@ -318,8 +319,8 @@ Page({
|
|
|
if (!res) {
|
|
|
wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
- title: '发送失败',
|
|
|
- icon: 'none'
|
|
|
+ title: '发送图片失败',
|
|
|
+ icon: 'error'
|
|
|
})
|
|
|
}
|
|
|
});
|
|
@@ -341,14 +342,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) {
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '壁纸上传完成md5:' + _this.data._imgMD5,
|
|
|
+ // content: '最终发送数据大小:' + _this.data._imgNext + ',总大小:' + total + '',
|
|
|
+ // showCancel: false,
|
|
|
+ // success(res) {
|
|
|
|
|
|
- }
|
|
|
- })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
_this.endImage(0)
|
|
|
return;
|
|
|
}
|
|
@@ -379,7 +380,7 @@ Page({
|
|
|
},
|
|
|
endImage(value) {
|
|
|
let _this = this
|
|
|
- // console.log("结束壁纸上传:", value)
|
|
|
+ console.log("结束壁纸上传:", value)
|
|
|
if (_this.data._timer) {
|
|
|
clearInterval(_this.data._timer)
|
|
|
_this.data._timer = null
|
|
@@ -415,6 +416,7 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
successSend() {
|
|
|
+ let _this = this
|
|
|
wx.showModal({
|
|
|
title: '上传壁纸成功',
|
|
|
showCancel: false,
|
|
@@ -424,11 +426,7 @@ Page({
|
|
|
// 获取上一级页面实例
|
|
|
const prevPage = pages[pages.length - 2];
|
|
|
// 传递参数
|
|
|
- prevPage.setData({
|
|
|
- topImg: {
|
|
|
- "pic": _this.data._imgUrl,
|
|
|
- }
|
|
|
- });
|
|
|
+ prevPage.updateTopImg(_this.data._imgUrl)
|
|
|
wx.navigateBack({
|
|
|
delta: 1,
|
|
|
})
|
|
@@ -451,7 +449,7 @@ Page({
|
|
|
// showCancel: false
|
|
|
// })
|
|
|
wx.showToast({
|
|
|
- title: '发送失败',
|
|
|
+ title: '发送图片败',
|
|
|
icon: 'failure'
|
|
|
})
|
|
|
}
|
|
@@ -468,6 +466,7 @@ Page({
|
|
|
src: image.pic,
|
|
|
max_scale: 1,
|
|
|
});
|
|
|
+ that.data._imgTopPic = image.pic
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|