// pages/item/item.js Page({ /** * 页面的初始数据 */ data: { title: '', loading: true, movie: {}, currentIndex: 0, }, /** * 生命周期函数--监听页面加载 */ pagechange: function (e) { // 通过touch判断,改变tab的下标值 if ("touch" === e.detail.source) { let currentPageIndex = this.data.currentIndex; currentPageIndex = (currentPageIndex + 1) % 2; // 拿到当前索引并动态改变 this.setData({ currentIndex: currentPageIndex, }) } }, //点击tab时触发 titleClick: function (e) { this.setData({ //拿到当前索引并动态改变 currentIndex: e.currentTarget.dataset.idx }) }, onLoad: function (options) { const _this = this; // 拼接请求url // const url = 'https://api.douban.com/v2/movie/subject/' + options.id; // // 请求数据 // wx.request({ // url: url, // data: {}, // header: { // 'content-type': 'json' // 默认值 // }, // success:function(res) { // // 赋值 // _this.setData({ // movie: res.data, // loading: false // 隐藏等待框 // }) // } // }) _this.setData({ movie: {title:'日本7.2级地震',images:'111',year:'2022年7月7日',average:'17:00:00日本发生7.2级地震,张家港桥跨中位移超限,其余桥梁无异',directors:'111',name:'111',casts:'111',directors:'111',summary:'1111'}, loading: false // 隐藏等待框 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { // 修改导航栏标题 wx.setNavigationBarTitle({ // title: this.data.title + '<<预警信息<<详情' title: this.data.title+ '详情' }) } })