12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //index.js
- //获取应用实例
- const app = getApp()
- import { hotInit } from '../../component/hot/hot';
- // import { myInit } from '../../component/my/my';
- // import { searchInit } 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',
- }
- ],
- ind: 0,
- templates: 'hot',
- jurisdictionFlag: true
- },
- //tab点击
- switcher: function({currentTarget}) {
- let index = currentTarget.dataset.index;
- let templates = this.data.tab[index].templates;
- //console.log(this.data[ind])
- this.setData({
- index,
- templates
- })
- if (index == 1) {
- searchInit(this);
- }
- if (index == 2) {
- myInit(this);
- }
- },
- jurisdiction: function () {
- setTimeout(()=>{
- this.init();
- },1000)
- },
- onLoad: function (options) {
- if(options.index) {
- let index = options.index;
- let templates = this.data.tab[index].templates;
- this.setData({
- templates,
- index,
- })
- if (index == 1) {
- searchInit(this);
- }
- if (index == 2) {
- myInit(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
- // })
- // });
- }
- })
|