index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Component({
  2. data: {
  3. userInfoTop: 0,
  4. cardBackground: '',
  5. time: 0
  6. },
  7. props: {
  8. cardInfo: {},
  9. componentData: {},
  10. onNextPage: () => null
  11. },
  12. didMount() {
  13. this.setUserInfoTop();
  14. this.setCardBackground();
  15. },
  16. didUpdate() {},
  17. didUnmount() {},
  18. methods: {
  19. /*
  20. * 设置背景图
  21. * */
  22. setCardBackground() {
  23. const {
  24. componentData
  25. } = this.props;
  26. const {
  27. componentExtInfo
  28. } = componentData;
  29. const {
  30. cardBackground = ''
  31. } = componentExtInfo || {};
  32. this.setData({
  33. cardBackground
  34. });
  35. },
  36. /*
  37. * 设置位置
  38. * */
  39. setUserInfoTop() {
  40. const {
  41. componentData
  42. } = this.props;
  43. const {
  44. componentExtInfo
  45. } = componentData;
  46. const {
  47. userInfoPositionTop = 0
  48. } = componentExtInfo || {};
  49. this.setData({
  50. userInfoPositionTop: +userInfoPositionTop
  51. });
  52. },
  53. toDetail() {
  54. this.props.onNextPage(2);
  55. },
  56. refreshCard() {
  57. const {
  58. healthCardId
  59. } = this.props.cardInfo;
  60. if (this.data.time !== 0) {
  61. return;
  62. }
  63. this.setData({
  64. time: 60
  65. });
  66. this.timer = setInterval(() => {
  67. this.setData({
  68. time: this.data.time - 1
  69. });
  70. this.data.time === 0 && clearInterval(this.timer);
  71. }, 1000);
  72. this.props.onRefreshCard(healthCardId);
  73. }
  74. }
  75. });