2025-04-22 14:39:59 +08:00

102 lines
1.7 KiB
JavaScript

// packages/WaterPurifier/pages/Addfriend/Addfriend.js
Page({
/**
* 页面的初始数据
*/
data: {
},
save(){
wx.downloadFile({
url: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/water_filter/customer.jpg',
success(res) {
if (res.statusCode === 200) {
const tempFilePath = res.tempFilePath; // 获取临时文件路径
// 保存图片到相册
wx.saveImageToPhotosAlbum({
filePath: tempFilePath,
success() {
wx.showToast({
title: '保存成功',
icon: 'success',
});
},
fail(err) {
console.error('保存失败', err);
wx.showToast({
title: '保存失败,请重试',
icon: 'none',
});
},
});
}
},
fail(err) {
console.error('下载失败', err);
wx.showToast({
title: '下载失败,请重试',
icon: 'none',
});
},
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})