//index.js //获取应用实例 const app = getApp() import { hotInit } from '../../component/hot/hot'; import { myInit } from '../../component/my/my'; import { followInit } from '../../component/follow/follow'; // import httpRequestApi from '../../utils/APIRequest'; // import httputil from '../../utils/httputil'; Page({ data: { tab:[ { name: '热门', templates: 'hot', }, { name: '关注', templates: 'follow', }, { name: '我的', templates: 'my', } ], myIndex: 0, templates: 'hot', title:'index中的title', jurisdictionFlag: true, hotInput:'12345', mineSettingInfo:'528' }, //tab点击 switcher: function({currentTarget}) { this.updateData(currentTarget.dataset.index); }, // 根据index 更新template updateData:function(index){ let myIndex = index; let templates = this.data.tab[myIndex].templates; this.setData({ myIndex, templates }); if (myIndex == 0) { hotInit(this); } if (myIndex == 1) { followInit(this); } if (myIndex == 2) { myInit(this); } }, onLoad: function (options) { if(options.index) { this.updateData(options.index) } hotInit(this) this.init(); }, //初始化数据 init: function () { // httputil.getOpenidSessionKey((res) => { // console.log('微信的用户信息', res); // this.setData({ // jurisdictionFlag: true // }) // lookInit(this); // },(error) => { // console.log(error); // this.setData({ // jurisdictionFlag: false // }) // }); } })