index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. followInit(this);
  58. }
  59. if (myIndex == 3) {
  60. myInit(this);
  61. }
  62. },
  63. onLoad: function (options) {
  64. if(options.index) {
  65. this.updateData(options.index)
  66. }
  67. hotInit(this)
  68. this.init();
  69. },
  70. //初始化数据
  71. init: function () {
  72. // httputil.getOpenidSessionKey((res) => {
  73. // console.log('微信的用户信息', res);
  74. // this.setData({
  75. // jurisdictionFlag: true
  76. // })
  77. // lookInit(this);
  78. // },(error) => {
  79. // console.log(error);
  80. // this.setData({
  81. // jurisdictionFlag: false
  82. // })
  83. // });
  84. }
  85. })