123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //index.js
- //获取应用实例
- const app = getApp()
- import { lookInit } from '../../component/look/look';
- import { myInit } from '../../component/mys/mys';
- import { searchInit } from '../../component/search/search';
- import httpRequestApi from '../../utils/APIRequest';
- import httputil from '../../utils/httputil';
- Page({
- data: {
- tab:[
- {
- name: '看',
- templates: 'look',
- img: '../../static/image/look1.png',
- selectimg: '../../static/image/look2.png'
- },
- {
- name: '搜',
- templates: 'search',
- img: '../../static/image/sou1.png',
- selectimg: '../../static/image/sou2.png'
- }, {
- name: '我的',
- templates: 'mys',
- img: '../../static/image/my1.png',
- selectimg: '../../static/image/my2.png'
- }
- ],
- ind: 0,
- templates: 'look',
- jurisdictionFlag: true
- },
- //tab点击
- switcher: function({currentTarget}) {
- let ind = currentTarget.dataset.ind;
- let templates = this.data.tab[ind].templates;
- //console.log(this.data[ind])
- this.setData({
- ind,
- templates
- })
- if (ind == 1) {
- searchInit(this);
- }
- if (ind == 2) {
- myInit(this);
- }
- },
- jurisdiction: function () {
- setTimeout(()=>{
- this.init();
- },1000)
- },
- onLoad: function (options) {
- if(options.ind) {
- let ind = options.ind;
- let templates = this.data.tab[ind].templates;
- this.setData({
- templates,
- ind,
- })
- if (ind == 1) {
- searchInit(this);
- }
- if (ind == 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
- })
- });
- }
- })
|