index.js 1.7 KB

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