index.js 2.1 KB

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