let util = require('../../../../utils/util') let apiArr = require('../../../../api/water_filter') // 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', }); }, }); }, getServerInfo() { let that = this util.postUrl(apiArr.cusGetServerInfo, { device_id:wx.getStorageSync('device_id') }, res => { res.qr_code = res.qr_code.startsWith('http') ? res.qr_code : util.img_url + res.qr_code console.log(res.qr_code); that.setData({ serverInfo: res }) }) }, call(){ let that = this wx.makePhoneCall({ phoneNumber: that.data.serverInfo.customer_phone, }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { wx.showShareMenu({ withShareTicket: true, menus: ['shareAppMessage', 'shareTimeline'] }) this.getServerInfo() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { return { title: '人人爱净水', // 分享卡片标题(必填) path: '/pages/water_filter/water_filter', // 用户点击后跳转的路径(可选,默认当前页) imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义图片(可选,比例建议 5:4) } }, onShareTimeline() { return { title: '人人爱净水', // 自定义标题 query: '', // 自定义页面路径中的参数 imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义分享图片路径 } }, })