// nova-werun/components/circle/index.js Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { //屏幕高度 statusBarHeight: 0, // 状态栏高度 screenHeight: 0, // 屏幕高度 customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮) bottomNavHeight: 0, // 底部导航栏高度 contentHeight: 0, // 可用内容高度 contentHeight2: 0, contentpadding: 0, //顶部padding高度 //图片 images: [ 'http://img2.baidu.com/it/u=2324169262,1340424811&fm=253&app=138&f=JPEG?w=800&h=1422', 'https://img2.baidu.com/it/u=2814429148,2262424695&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422', 'https://img2.baidu.com/it/u=2814429148,2262424695&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://img2.baidu.com/it/u=2814429148,2262424695&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422', 'https://img2.baidu.com/it/u=2814429148,2262424695&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', 'https://inews.gtimg.com/om_bt/OE8piEBa-tbqn-wNvWZl8coi4AlzoUD43upEkoAnIkYL8AA/641', ], imageclass:'', //是否展示点赞评论按钮 isgood:false, isclick:false, }, lifetimes: { detached: function () { // 在组件实例被从页面节点树移除时执行 }, attached: async function () { // 在组件实例进入页面节点树时执行 // 计算 const systemInfo = wx.getSystemInfoSync(); const statusBarHeight = systemInfo.statusBarHeight || 0; const screenHeight = systemInfo.screenHeight || 0; const custom = wx.getMenuButtonBoundingClientRect(); const customHeight = custom.height + 10 + 2 || 0; const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0; const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth; const contentHeight = (screenHeight - bottomNavHeight - 50) * 750 / systemInfo.windowWidth; const contentHeight2 = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth; this.setData({ statusBarHeight, screenHeight, customHeight, bottomNavHeight, contentHeight, contentpadding, contentHeight2 }); console.log('123', contentHeight, contentHeight2); }, }, /** * 组件的方法列表 */ methods: { onImageLoad: function (e) { const { width, height } = e.detail; // 获取图片的宽高 console.log('11', e.detail); const imageClass = width > height ? 'image-landscape' : 'image-portrait'; // 判断横竖屏 this.setData({ imageclass: imageClass // 动态设置图片的类名 }); }, previewImage: function(e) { const index = e.currentTarget.dataset.index; // 获取当前点击图片的索引 const images = this.data.images; // 获取所有图片的链接 wx.previewImage({ current: images[index], // 当前显示图片的链接 urls: images // 需要预览的图片链接列表 }); }, gourl(e){ const url = e.currentTarget.dataset.url wx.navigateTo({ url: url // 目标页面的路径 }); }, showgood(){ this.setData({ isgood:!this.data.isgood }) console.log(this.data.isgood); }, isclick(){ this.setData({ isclick:!this.data.isclick }) setTimeout(()=>{ this.showgood() },400) console.log(this.data.isclick); } } })