|
@@ -154,21 +154,52 @@ const login = () => {
|
|
}
|
|
}
|
|
|
|
|
|
const saveImage = url => {
|
|
const saveImage = url => {
|
|
- uni.downloadFile({
|
|
|
|
- url: url,
|
|
|
|
- success: (res) => {
|
|
|
|
- if (res.statusCode === 200) {
|
|
|
|
- console.log('下载成功');
|
|
|
|
- uni.saveFile({
|
|
|
|
- tempFilePath: res.tempFilePath,
|
|
|
|
- success: function(red) {
|
|
|
|
- console.log('-->data',red)
|
|
|
|
- uni.$u.toast(`保存路径:${red.savedFilePath}`)
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }else{
|
|
|
|
- uni.$u.toast(`保存失败`)
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ uni.downloadFile({
|
|
|
|
+ url: url,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ if (res.statusCode === 200) {
|
|
|
|
+ console.log('下载成功');
|
|
|
|
+ uni.authorize({
|
|
|
|
+ scope: 'scope.writePhotosAlbum',
|
|
|
|
+ success() {
|
|
|
|
+ uni.saveImageToPhotosAlbum({
|
|
|
|
+ filePath: res.tempFilePath,
|
|
|
|
+ success: function(red) {
|
|
|
|
+ uni.$u.toast(`保存成功`)
|
|
|
|
+ //uni.$u.toast(`保存路径:${red.savedFilePath}`)
|
|
|
|
+ resolve()
|
|
|
|
+ },
|
|
|
|
+ fail: function() {
|
|
|
|
+ uni.$u.toast(`保存失败`)
|
|
|
|
+ reject()
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ fail: err => {
|
|
|
|
+ uni.$u.toast(`授权失败`+JSON.stringify(err))
|
|
|
|
+ reject()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }else{
|
|
|
|
+ uni.$u.toast(`保存失败`)
|
|
|
|
+ reject()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: err => {
|
|
|
|
+ uni.$u.toast(`保存失败`+JSON.stringify(err))
|
|
|
|
+ reject()
|
|
}
|
|
}
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const copyText = text => {
|
|
|
|
+ uni.setClipboardData({
|
|
|
|
+ data: text,
|
|
|
|
+ success: function () {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ uni.$u.toast(`复制成功`)
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -193,5 +224,6 @@ export {
|
|
shareMessage,
|
|
shareMessage,
|
|
share,
|
|
share,
|
|
login,
|
|
login,
|
|
- saveImage
|
|
|
|
|
|
+ saveImage,
|
|
|
|
+ copyText
|
|
}
|
|
}
|