Fix:3824 【商城小程序】千县旅居—店铺分享保存按钮点击无反应(体验版)
This commit is contained in:
@@ -380,6 +380,73 @@ export default {
|
||||
this.getFarmerData()
|
||||
},
|
||||
methods: {
|
||||
saveImg() {
|
||||
const _this = this
|
||||
uni.getSetting({
|
||||
success: getRes => {
|
||||
if (getRes.authSetting["scope.writePhotosAlbum"]) {
|
||||
_this.downloadImage()
|
||||
} else {
|
||||
uni.authorize({
|
||||
scope: "scope.writePhotosAlbum",
|
||||
success: () => {
|
||||
_this.downloadImage()
|
||||
},
|
||||
fail: () => {
|
||||
uni.openSetting({
|
||||
success: openRes => {
|
||||
console.log(typeof openRes, openRes)
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: "请在设置中打开对应权限",
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err, 2)
|
||||
}
|
||||
})
|
||||
},
|
||||
downloadImage() {
|
||||
const _this = this
|
||||
const randomID = () => Math.random().toString(36).substring(2)
|
||||
uni.downloadFile({
|
||||
url: this.posterUrl, // 网络图片的地址
|
||||
filePath: wx.env.USER_DATA_PATH + "/share_" + randomID() + ".png", // 指定的本地文件路径
|
||||
success: downRes => {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: downRes.filePath, // 临时文件地址
|
||||
success: function () {
|
||||
uni.showToast({
|
||||
title: "保存成功",
|
||||
icon: "success",
|
||||
success() {
|
||||
_this.showShare = false
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: function (err) {
|
||||
uni.showToast({
|
||||
title: err,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: function (err) {
|
||||
uni.showToast({
|
||||
title: err.errMsg,
|
||||
icon: "error"
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
changeShare() {
|
||||
uni.showLoading()
|
||||
postJiaLouShare(this.id).then(res => {
|
||||
|
||||
Reference in New Issue
Block a user