index.js 826 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //index.js
  2. import api from '../../utils/api'
  3. //获取应用实例
  4. const app = getApp()
  5. Page({
  6. data: {
  7. splash: '',
  8. miniAppId: '',
  9. miniAppPath: '',
  10. second: 3
  11. },
  12. //事件处理函数
  13. onLoad: function() {
  14. api.getStartup().then(res => {
  15. this.setData({
  16. splash: res.data.splash_image,
  17. miniAppId: res.data.mini_app_id || ''
  18. })
  19. this.bindload(res.data.splash_image ? 3000 : 0)
  20. setInterval(() => {
  21. this.setData({
  22. second: --this.data.second
  23. })
  24. }, 1000)
  25. }, err => {
  26. console.log(err)
  27. this.bindload(0)
  28. })
  29. },
  30. bindload (time) {
  31. setTimeout(() => {
  32. wx.switchTab({
  33. url: '/pages/game/game'
  34. })
  35. }, time)
  36. },
  37. routeTo (e) {
  38. wx.switchTab({
  39. url: e.currentTarget.dataset.to
  40. })
  41. }
  42. })