12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //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}) {
- if (!this.data.jurisdictionFlag) {
- return false;
- }
- 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.id) {
- wx.setStorageSync('uid', options.uid);
- }
- 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 (uid) {
- httputil.getOpenidSessionKey((res) => {
- console.log('微信的用户信息', res);
- wx.setStorageSync('userInfo', res)
- this.setData({
- jurisdictionFlag: true
- })
- lookInit(this);
- },(error) => {
- console.log(error);
- this.setData({
- jurisdictionFlag: false
- })
- });
- }
- })
|