index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. import { groupInit } from '../../component/group/group';
  5. import { hotInit } from '../../component/hot/hot';
  6. import { myInit } from '../../component/my/my';
  7. import { followInit } from '../../component/follow/follow';
  8. // import '../../utils/hls';
  9. // import httpRequestApi from '../../utils/APIRequest';
  10. // import httputil from '../../utils/httputil';
  11. Page({
  12. data: {
  13. tab:[
  14. {
  15. name: '热团',
  16. templates: 'group',
  17. },
  18. {
  19. name: '推荐',
  20. templates: 'hot',
  21. },
  22. {
  23. name: '关注',
  24. templates: 'follow',
  25. },
  26. {
  27. name: '我的',
  28. templates: 'my',
  29. }
  30. ],
  31. myIndex: 1,
  32. templates: 'hot',
  33. title:'index中的title',
  34. jurisdictionFlag: true,
  35. hotInput:'12345',
  36. mineSettingInfo:'528'
  37. },
  38. //tab点击
  39. switcher: function({currentTarget}) {
  40. this.updateData(currentTarget.dataset.index);
  41. },
  42. // 根据index 更新template
  43. updateData:function(index){
  44. let myIndex = index;
  45. let templates = this.data.tab[myIndex].templates;
  46. this.setData({
  47. myIndex,
  48. templates
  49. });
  50. if (myIndex == 0) {
  51. groupInit(this);
  52. }
  53. if (myIndex == 1) {
  54. hotInit(this);
  55. }
  56. if (myIndex == 2) {
  57. console.log('follow')
  58. followInit(this);
  59. }
  60. if (myIndex == 3) {
  61. myInit(this);
  62. }
  63. },
  64. onLoad: function (options) {
  65. if(options.index) {
  66. this.updateData(options.index)
  67. }
  68. hotInit(this)
  69. this.init();
  70. },
  71. //初始化数据
  72. init: function () {
  73. // httputil.getOpenidSessionKey((res) => {
  74. // console.log('微信的用户信息', res);
  75. // this.setData({
  76. // jurisdictionFlag: true
  77. // })
  78. // lookInit(this);
  79. // },(error) => {
  80. // console.log(error);
  81. // this.setData({
  82. // jurisdictionFlag: false
  83. // })
  84. // });
  85. }
  86. })