index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const app = getApp()
  2. import {
  3. throttle,
  4. getWaterDrop
  5. } from '../../utils/index/index'
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. isHomePage: {
  12. type: Boolean,
  13. value: false
  14. },
  15. },
  16. props: {
  17. onSure: {
  18. type: Function,
  19. value: () => {}
  20. },
  21. onBack: {
  22. type: Function,
  23. value: () => {}
  24. },
  25. suerName: '确定',
  26. logoutName: '退出',
  27. showBtn: true,
  28. logOut: '/pages/home/index',
  29. isCustomBack: false
  30. },
  31. /**
  32. * 组件的初始数据
  33. */
  34. data: {
  35. intervalId: null,
  36. },
  37. didMount() {
  38. this.interval()
  39. },
  40. /**
  41. * 组件的方法列表
  42. */
  43. methods: {
  44. interval() {
  45. var that = this;
  46. if (app.globalData.sn) {
  47. that.setData({
  48. appVersion: app.globalData.appVersion,
  49. sn: app.globalData.sn,
  50. })
  51. } else {
  52. that.data.intervalId = setInterval(function () {
  53. if (app.globalData.sn) {
  54. that.setData({
  55. appVersion: app.globalData.appVersion,
  56. sn: app.globalData.sn,
  57. })
  58. clearInterval(that.data.intervalId);
  59. }
  60. }, 1000);
  61. }
  62. },
  63. logOut() {
  64. clearInterval(this.data.intervalId);
  65. app.data.isOkBrushingCard = false
  66. app.data.isOkQrCodeSignIn = false
  67. if (!this.props.isHomePage) {
  68. console.log(this.props.isCustomBack)
  69. if (this.props.isCustomBack) {
  70. this.props.onBack('back');
  71. }else {
  72. my.reLaunch({
  73. url: this.props.logOut,
  74. })
  75. }
  76. }
  77. },
  78. clickSure: throttle( function () {
  79. clearInterval(this.data.intervalId);
  80. this.props.onSure('sure');
  81. }, 5000),
  82. },
  83. observers: {}
  84. })