//index.js //获取应用实例 var imageUtil = require('../../utils/window.js'); const app = getApp() Page({ data: { url:'../../images/timg.jpg', motto: '', userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo'), imagewidth: 0,//缩放后的宽 imageheight: 0,//缩放后的高 aa:[ { id:'0', from:"Investing.com 中文", nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手", reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....", time:"6天前" }, { id:'1', from:"chinese.aljazeera.net", nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来", reward: "波音公司当地时间27日宣布,将在美国裁减超1...", time:"6天前" }, { id:'2', from:"Investing.com 中文", nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%", reward: "Reuters.美股异动|波音(BA.US)737MAX客...", time:"5天前" }, { id:'3', from:"Investing.com 中文", nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手", reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....", time:"6天前" }, { id:'4', from:"chinese.aljazeera.net", nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来", reward: "波音公司当地时间27日宣布,将在美国裁减超1...", time:"6天前" }, { id:'5', from:"Investing.com 中文", nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%", reward: "Reuters.美股异动|波音(BA.US)737MAX客...", time:"5天前" }, { id:'6', from:"Investing.com 中文", nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手", reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....", time:"6天前" }, { id:'7', from:"chinese.aljazeera.net", nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来", reward: "波音公司当地时间27日宣布,将在美国裁减超1...", time:"6天前" }, { id:'8', from:"Investing.com 中文", nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%", reward: "Reuters.美股异动|波音(BA.US)737MAX客...", time:"5天前" }, { id:'9', from:"Investing.com 中文", nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手", reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....", time:"6天前" }, { id:'10', from:"chinese.aljazeera.net", nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来", reward: "波音公司当地时间27日宣布,将在美国裁减超1...", time:"6天前" }, { id:'11', from:"Investing.com 中文", nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%", reward: "Reuters.美股异动|波音(BA.US)737MAX客...", time:"5天前" }, { id:'12', from:"Investing.com 中文", nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手", reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....", time:"6天前" }, { id:'13', from:"chinese.aljazeera.net", nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来", reward: "波音公司当地时间27日宣布,将在美国裁减超1...", time:"6天前" }, { id:'14', from:"Investing.com 中文", nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%", reward: "Reuters.美股异动|波音(BA.US)737MAX客...", time:"5天前" }, ], }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onReady: function (e) { // this.computeScrollViewHeight(); // var query = wx.createSelectorQuery() // query.select('#test').boundingClientRect(function (res) { // console.log(res.top); // }).exec(); }, onLoad: function () { // this.computeScrollViewHeight(); // if (app.globalData.userInfo) { // this.setData({ // userInfo: app.globalData.userInfo, // hasUserInfo: true // }) // } else if (this.data.canIUse){ // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // // 所以此处加入 callback 以防止这种情况 // app.userInfoReadyCallback = res => { // this.setData({ // userInfo: res.userInfo, // hasUserInfo: true // }) // } // } else { // // 在没有 open-type=getUserInfo 版本的兼容处理 // wx.getUserInfo({ // success: res => { // app.globalData.userInfo = res.userInfo // this.setData({ // userInfo: res.userInfo, // hasUserInfo: true // }) // } // }) // } }, computeScrollViewHeight() { var that = this let query = wx.createSelectorQuery().in(that) query.select('.userinfo').boundingClientRect() query.select('.search').boundingClientRect() query.select('.news').boundingClientRect() query.exec(res => { let topHeight = res[0].height let searchHeight = res[1].height let titleHeight = res[2].height let windowHeight = wx.getSystemInfoSync().windowHeight let windowWidth = wx.getSystemInfoSync().windowWidth let height = windowHeight - topHeight - searchHeight - titleHeight let ratio = 750 / windowWidth let scrollHeight = height * ratio + 20 that.setData({ scrollHeight: scrollHeight}) }) }, imageLoad: function (e) { var imageSize = imageUtil.imageUtil(e) this.setData({ imagewidth: imageSize.imageWidth, imageheight: imageSize.imageHeight }) this.computeScrollViewHeight(); }, onFold:function(e){ console.log( e.currentTarget.dataset.id); wx.navigateTo({ url:"../news/news" }); }, getUserInfo: function(e) { console.log(e) app.globalData.userInfo = e.detail.userInfo this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) } })