index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {
  2. getActivityInfo
  3. } from '~/api/activity'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. state: true,
  10. tens: 2,
  11. bits: 0,
  12. configure: {}
  13. },
  14. async onLoad(options) {
  15. let configure = await getActivityInfo(options.id)
  16. console.log(configure);
  17. this.setData({
  18. configure
  19. })
  20. },
  21. play() {
  22. let dsq
  23. if (!this.data.state) {
  24. this.setData({
  25. state: true
  26. })
  27. let countDown = 20
  28. // 一分钟倒计时
  29. dsq = setInterval(item => {
  30. if (countDown == 1) {
  31. clearInterval(dsq)
  32. }
  33. if (countDown % 10 == 0) {
  34. this.setData({
  35. tens: --this.data.tens,
  36. bits: 9
  37. })
  38. } else {
  39. this.setData({
  40. bits: --this.data.bits
  41. })
  42. }
  43. --countDown
  44. }, 1000)
  45. } else {
  46. clearInterval(dsq)
  47. this.setData({
  48. state: false,
  49. tens: 2,
  50. bits: 0
  51. })
  52. }
  53. }
  54. })