const app = getApp(); var utils = require("../../../utils/http"); const util = require("../../../utils/util"); let page = 1; Page({ /** * 页面的初始数据 */ data: { orderBuildType: 'new', unlogin: false,//默认未登录状态,false未登录,true登录成功,并是公司成员 imgUrl: app.globalData.imgUrl, mattertype: '热装楼盘', list: [], datashow: false, buildinglist: [], page: 1, nowtype: '', nowid: '', downflag: false, downloaded: false, downlen: 0, num: 0, nowtitle: '', nowimg: '', wshareshow: false, listshare: false, poster: '', qrcode: '', islist: false, otherarr:[ {id:1,name:'最新',type:'time'}, {id:2,name:'最热',type:'hot'} ], type:1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; wx.hideShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] }) wx.showLoading({ title: '加载中...', }) if (options.type) { this.setData({ type: options.type }) } this.getBuildingProgress(); }, setBuildFilter(e) { page = 1; this.setData({ orderBuildType: e.currentTarget.dataset.type }) this.getBuildingProgress(); }, dothis: function () { }, getBuildingProgress() { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/building/index', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { order: that.data.orderBuildType, page: page, limit: "10", }, success: function (res) { wx.hideLoading() if (res.data.code == 0) { res.data.data.forEach(v => { v.areastr = v.area_list.map(v => `${v}㎡`).join('/'); v.update_time = v.update_time ? v.update_time.split(' ')[0] : ''; v.duetime = v.duetime ? v.duetime.split(' ')[0] : ''; }) that.setData({ buildinglist: res.data.data, datashow:true }) } } }) }, toPageDetail(e) { let id = e.currentTarget.dataset.id; wx.navigateTo({ url: '/index/pages/progressdetail/progressdetail?cid=' + id+'&type='+this.data.type, }) }, progressShare(e) { this.setData({ nowtype: 'building', nowid: e.currentTarget.dataset.cid, nowtitle: e.currentTarget.dataset.title, nowimg: e.currentTarget.dataset.img, wshareshow: true, islist: false, }) }, shareurltap: function () { let that = this; switch (that.data.nowtype) { case 'building': wx.showLoading({ title: '加载中...', }) util.schemefun('/share/pages/buildprogress/buildprogress', 'uid=' + app.globalData.personMsg.id + '&cid=' + that.data.nowid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id, that.data.nowid, 'building', ''); this.sharelogtap(); break; default: console.log('1') } }, setpostertap: function () { let that = this; let type = that.data.nowtype, usrl = ""; if (this.data.mattertype == '热装楼盘') { type = "building"; } wx.navigateTo({ url: '/index/pages/setposter/setposter?type=' + type + '&aid=' + this.data.nowid + "&listshare=" + (that.data.listshare ? '123' : '') + usrl, }) }, sendfriendtap: function () { this.sharelogtap(); }, sharelogtap: function (e) { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.nowid, type: that.data.nowtype }, success: function (r) { } }) }, handleCollect(e) { let collect = e.currentTarget.dataset.collect; let id = e.currentTarget.dataset.id; let index = e.currentTarget.dataset.index; let urllink = !collect ? app.globalData.webUrl + 'api/building/collect' : app.globalData.webUrl + 'api/building/collectCancel'; utils.$post({ url: urllink, header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: id, }, success: (res) => { if (res.data.code == 0) { this.data.buildinglist[index].collected = !collect; this.setData({ buildinglist: this.data.buildinglist }) wx.showToast({ title: res.data.msg, icon: 'none', duration: 1000 }) } } }) }, arrfun: function (str) { var that = this; let arr = str.split(','); return arr; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { page = 1; }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { page = 1; }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { page = 1; }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { var that = this; if (that.data.mattertype == '热装楼盘') { page = 1; this.getBuildingProgress(); wx.stopPullDownRefresh(); } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var that = this; if (that.data.mattertype == '热装楼盘') { var that = this; page = page * 1 + 1; utils.$post({ url: app.globalData.webUrl + 'api/building/index', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { order: that.data.orderBuildType, page: page, limit: "10", }, success: function (res) { wx.hideLoading() if (res.data.code == 0) { let list = that.data.buildinglist; res.data.data.forEach(v => { v.areastr = v.area_list.map(v => `${v}㎡`).join('/'); v.update_time = v.update_time ? v.update_time.split(' ')[0] : ''; v.duetime = v.duetime ? v.duetime.split(' ')[0] : ''; }) list = list.concat(res.data.data); that.setData({ buildinglist: list }) } } }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { let that = this; this.setData({ wshareshow: false }) that.setData({ wshareshow: false }) var img = that.data.nowimg; img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/'); if (that.data.nowtype == 'building') { this.sharelogtap(); return { title: that.data.nowtitle, imageUrl: that.data.nowimg, path: '/share/pages/buildprogress/buildprogress?cid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id } } } })