import { getHouseInfo } from '../../utils/api.js' Page({ /** * 页面的初始数据 */ data: { familyInfo:null, showQr: true, memberList:[], roomCode:null, selectedTabBar:"resiNew", loadMoreVisible:false, keyWord:'',//房屋搜索字段 houseInfo:[], houseFlag:'1' }, /** * 生命周期函数--监听页面加载 */ 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, }) } }, // 跳转新增页面 handleTo(){ if(this.data.selectedTabBar=='resiNew'){ wx.navigateTo({ url: '/subpages/family/pages/familyInfo/familyInfo?pageType=add&id='+ this.data.familyInfo.id }) }else if(this.data.selectedTabBar=='housePrice'){ wx.navigateTo({ url: '/subpages/family/pages/addHouse/addHouse?name=卖房', }) }else if(this.data.selectedTabBar=='groupPrice'){ wx.navigateTo({ url: '/subpages/family/pages/addGroupBuyPublish/addGroupBuyPublish', }) }else{ } }, chooseTabBar(e) { this.data.pageNo = 1 this.data.pageSize = 10 if (e.currentTarget.dataset.type === 'resiNew') { // this.getresiNewList() } else if (e.currentTarget.dataset.type === 'housePrice') { this.data.pageNo = 1 this.data.pageSize = 10 // this.getHousesalerentinfo() } else if (e.currentTarget.dataset.type === 'groupPrice') { }else if (e.currentTarget.dataset.type === 'integral'){ // this.getgroupPriceList() wx.showLoading({ title: "加载中", mask: true, }); this.navigateToIntegralCentre() } this.setData({ selectedTabBar: e.currentTarget.dataset.type, }) console.log(this.data.selectedTabBar); }, handleActiveHouse(e){ this.setData({ houseFlag:e.currentTarget.dataset.status, loadMoreVisible: false }) this.getHousesalerentinfo() }, handelKeyword(e){ this.setData({ keyWord:e.detail.value }) this.getHousesalerentinfo() }, navigateToIntegralCentre() { wx.navigateTo({ url:'/subpages/pointManagement/pages/pointList/pointList' }) wx.hideLoading() }, getHousesalerentinfo(){ let parmas = { pageNum:this.data.pageNo, pageSize:this.data.pageSize, houseStatus:this.data.houseFlag, search:this.data.keyWord } wx.showLoading({ title: '加载中', }) api .getHousesalerentinfo(parmas) .then((res) => { console.log('房屋列表', res) for(let i in res.data.list){ res.data.list[i].createdData = res.data.list[i].createdData.substr(0,10) } this.setData({ houseInfo:res.data.list, }) }) .catch((err) => { console.log(err) }) wx.hideLoading() }, // 跳转查看页面 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() { wx.navigateTo({ url: `/subpages/family/pages/editHouseInfo/editHouseInfo?roomCode=`+this.data.roomCode }) }, })