import { getHouseInfo } from '../../utils/api.js' Page({ /** * 页面的初始数据 */ data: { familyInfo:null, showQr: true, memberList:[], roomCode:null, }, /** * 生命周期函数--监听页面加载 */ async onLoad(options) { wx.showLoading({ title: "加载中", mask: true, }); this.setData({ roomCode : options.roomCode }) // this.setData({ // roomCode:'3702110100420037200006' // }) wx.setStorage({ key: 'roomCode', data: this.data.roomCode }) await this.getInfo(this.data.roomCode) wx.hideLoading() }, /** * 生命周期函数--监听页面显示 */ async onShow() { wx.showLoading({ title: "加载中", mask: true, }); let roomCode = wx.getStorageSync('roomCode') this.setData({ roomCode : roomCode }) await this.getInfo(this.data.roomCode) wx.hideLoading() }, // 获取房屋信息 async getInfo(code){ const res = await getHouseInfo({roomCode:code}) if(res.msg === 'success' && res.code === 0){ this.setData({ 'familyInfo':res.data, 'roomCode':res.data.members }) } }, // 跳转新增页面 handleTo(){ wx.navigateTo({ url: '/subpages/family/pages/familyInfo/familyInfo?pageType=add&id='+ this.data.familyInfo.id }) }, // 跳转查看页面 toFamilyInfo(e){ wx.navigateTo({ url: '/subpages/family/pages/familyInfo/familyInfo?pageType=look&idCard='+ e.currentTarget.dataset.id }) }, // 取消编辑 cancel() { this.setData({ showQr: true, }); }, // 点击保存二维码 comfirmSave() { wx.downloadFile({ url: this.data.familyInfo.maUrl, success: function (res) { let imageFilePath = res.tempFilePath; wx.saveImageToPhotosAlbum({ filePath: imageFilePath, success: function (data) { wx.showToast({ title: '保存成功', icon: 'none', duration: 1500 }); }, fail: function (res) { wx.showToast({ title: '保存失败', icon: 'none', duration: 1500 }) } }) }, fail: (err) => { wx.showToast({ title: '下载失败', icon: 'none', duration: 1500 }) } }) }, handlePreview() { if (!this.data.familyInfo.maUrl) return; this.setData({ showQr: false, }); }, })