123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //index.js
- //获取应用实例
- import {
- getOpenidSessionKey
- } from '../../utils/httpUtil';
- const app = getApp()
- import {
- hotInit
- } from '../../component/hot/hot';
- import {
- groupInit
- } from '../../component/group/group';
- 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',
- hide: true
- },
- jurisdiction: function () {
- console.log(1)
- //隐藏弹框
- this.setData({
- hide: !this.data.hide
- })
- //登录页信息
- this.onShow();
- },
- //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();
- },
- onShow: function () {
- // this.init();
- getOpenidSessionKey((res) => {
- console.log(res);
- }, (error) => {
- // console.log(error)
- this.setData({
- hide: !this.data.hide
- })
- });
- },
- //初始化数据
- init: function () {
- httputil.getOpenidSessionKey((res) => {
- console.log('微信的用户信息', res);
- // this.setData({
- // jurisdictionFlag: true
- // })
- // lookInit(this);
- }, (error) => {
- console.log(error);
- this.jurisdiction()
- // this.setData({
- // jurisdictionFlag: false
- // })
- });
- }
- })
|