//index.js //获取应用实例 const app = getApp() import { groupInit } from '../../component/group/group'; import { hotInit } from '../../component/hot/hot'; import { myInit } from '../../component/my/my'; import { followInit } from '../../component/follow/follow'; // import '../../utils/hls'; // import httpRequestApi from '../../utils/APIRequest'; // import httputil from '../../utils/httputil'; Page({ data: { tab:[ { name: '热团', templates: 'group', }, { name: '推荐', templates: 'hot', }, { name: '关注', templates: 'follow', }, { name: '我的', templates: 'my', } ], myIndex: 1, 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) { groupInit(this); } if (myIndex == 1) { hotInit(this); } if (myIndex == 2) { console.log('follow') followInit(this); } if (myIndex == 3) { 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 // }) // }); } })