index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {miniProgramConfig} from '../../api/other';
  2. const app = getApp();
  3. Page({
  4. data: {
  5. banners: [],
  6. introduction:'',
  7. start_time:'',
  8. end_time:''
  9. },
  10. async onLoad(){
  11. const res = await miniProgramConfig();
  12. app.globalData.programConfig = res.data;
  13. this.setData({
  14. banners:res.data.carousels,
  15. introduction:res.data.marathon_event.introduction,
  16. start_time:res.data.marathon_event.start_time,
  17. end_time:res.data.marathon_event.end_time
  18. })
  19. },
  20. onShow() {
  21. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  22. this.getTabBar().setData({
  23. selected: 0
  24. })
  25. }
  26. },
  27. goPage(e){
  28. const index = e.currentTarget.dataset.index;
  29. if(index == 0){
  30. wx.navigateTo({
  31. url: `/pages/rules/rules?type=${index}`
  32. })
  33. }else if(index == 1){
  34. wx.navigateTo({
  35. url: `/pages/rules/rules?type=${index}`
  36. })
  37. }
  38. },
  39. goRegister() {
  40. wx.navigateTo({
  41. url: '/pages/register/register'
  42. })
  43. },
  44. // 打开分享弹框
  45. onShowShare() {
  46. const tabbar = this.getTabBar && this.getTabBar()
  47. if (tabbar && tabbar.openShare) {
  48. tabbar.openShare()
  49. } else {
  50. console.log("没找到 tabbar 组件")
  51. }
  52. },
  53. onShareAppMessage() {
  54. return {
  55. path: '/pages/index/index',
  56. imageUrl: app.globalData.programConfig.share_img
  57. }
  58. },
  59. })