订阅码保存更新

This commit is contained in:
GaoHao
2024-11-04 16:01:35 +08:00
parent 3cc4b53ddd
commit e460b5b7be
2 changed files with 1 additions and 68 deletions

View File

@@ -39,10 +39,7 @@ onShow(() => {
}) })
const saveImage = () => { const saveImage = () => {
// #ifdef APP-PLUS
saveQrcodeImg()
uni.downloadFile({ uni.downloadFile({
url: vdata.QrcodeUrl, url: vdata.QrcodeUrl,
success: (res) => { success: (res) => {
@@ -66,73 +63,9 @@ const saveImage = () => {
infoBox.showErrorToast('保存失败') infoBox.showErrorToast('保存失败')
} }
}) })
// #endif
//#ifdef MP-WEIXIN
downloadQR()
//#endif
}
//#ifdef MP-WEIXIN
function downloadQR() {
wx.getSetting({
//获取权限
success(res) {
console.log(res)
if (res.authSetting['scope.writePhotosAlbum']) {
saveWxQrcodeImg(vdata.QrcodeUrl)
} else {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() {
saveWxQrcodeImg(vdata.QrcodeUrl)
},
})
}
},
})
}
//#endif
const saveQrcodeImg = () => {
saveHeadImgFile(vdata.QrcodeUrl, 80)
.then((success) => {
infoBox.showSuccessToast('保存成功')
})
.catch((err) => {
console.log(err)
infoBox.showErrorToast('保存失败')
})
} }
const saveWxQrcodeImg = (data) => {
const fileManager = wx.getFileSystemManager()
console.log( )
const filePath = wx.env.USER_DATA_PATH + '/qrCode'+new Date().getTime()+'.png'
//这块是定义图片的名称,可自定义其他
fileManager.writeFile({
filePath: filePath,
data: data.slice(22),
encoding: 'base64',
success: (res) => {
wx.saveImageToPhotosAlbum({
filePath: filePath,
success: function (res) {
//保存成功
infoBox.showSuccessToast('保存成功')
},
fail: function (err) {
console.log(err)
//保存失败
infoBox.showErrorToast('保存失败')
},
})
},
fail: (err) => {
infoBox.showErrorToast('保存失败')
},
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -46,7 +46,7 @@
<view class="right"> <view class="right">
<view> <view>
<up-checkbox-group><up-checkbox label="免桌位费" v-model:checked="vdata.isTableFee" activeColor="#0FC161" shape="circle" @change="isTableFeeChange"> </up-checkbox></up-checkbox-group> <up-checkbox-group><up-checkbox label="免桌位费" v-model:checked="vdata.isTableFee" activeColor="#0FC161" shape="circle" @change="isTableFeeChange"> </up-checkbox></up-checkbox-group>
</view></up-icon> </view>
</view> </view>
</view> </view>
<view class="page-cell m"> <view class="page-cell m">