const app=getApp(); var utils=require("../../../utils/http"); const util=require("../../../utils/util"); Page({ /** * 页面的初始数据 */ data: { cid:'', siteobj:{}, imgUrl:app.globalData.imgUrl, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ cid:options.cid }) this.sitemdg(); }, sitemdg(){ const that=this; utils.$post({ url: app.globalData.webUrl + 'api/construction/view', header: { 'Authorization':'bearer '+app.globalData.token }, data: { id:that.data.cid }, success: function (res) { wx.hideLoading(); if(res.data.code==0){ that.setData({ siteobj:res.data.data }) wx.setNavigationBarTitle({ title: res.data.data.name, }) } } }) }, looktap(e){ wx.previewImage({ current: e.currentTarget.dataset.img, // 当前显示图片的 http 链接 urls: this.data.siteobj.step_list[e.currentTarget.dataset.idx].data.img // 需要预览的图片 http 链接列表 }) }, openVRLink(e) { let type = e.currentTarget.dataset.type; let vrlink = e.currentTarget.dataset.vr; wx.navigateTo({ url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&uid=' + (app.globalData.shareuserid?app.globalData.shareuserid:app.globalData.personMsg.id) + '&cty=construction' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.cid, }) }, collectap(e){ const that=this; let str=""; let siteobj=this.data.siteobj; if(siteobj.collect==0){ str='api/construction/collect' }else{ str='api/construction/collectCancel' } utils.$post({ url: app.globalData.webUrl + str, header: { 'Authorization':'bearer '+app.globalData.token }, data: { id:that.data.cid }, success: function (res) { wx.hideLoading(); if(res.data.code==0){ if(str=='api/construction/collect'){ siteobj.collect=1; }else{ siteobj.collect=0; } that.setData({ siteobj:siteobj }) } } }) }, sharetap:function(){ this.setData({ wshareshow:true }) }, setpostertap: function () { wx.navigateTo({ url: '/index/pages/setposter/setposter?type=Construction&aid='+this.data.cid+"&listshare=", }) }, sendfriendtap(){ this.shareaddlog(); }, shareaddlog:function(){ var that=this; utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization':'bearer '+app.globalData.token }, data: { id:that.data.cid, type:'Construction' }, success: function (r) { } }) }, shareurltap:function(){ wx.showLoading({ title: '加载中...', }) util.schemefun('/share/pages/constructsite/constructsite','cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype,this.data.cid,'Construction',''); this.shareaddlog(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { this.shareaddlog(); console.log('/share/pages/constructsite/constructsite?cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype) return { title: this.data.siteobj.name, imageUrl: this.data.siteobj.cover, path: '/share/pages/constructsite/constructsite?cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype } } })