index.js 1.5 KB

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