Component({ data: { userInfoTop: 0, cardBackground: '', time: 0 }, props: { cardInfo: {}, componentData: {}, onNextPage: () => null }, didMount() { this.setUserInfoTop(); this.setCardBackground(); }, didUpdate() {}, didUnmount() {}, methods: { /* * 设置背景图 * */ setCardBackground() { const { componentData } = this.props; const { componentExtInfo } = componentData; const { cardBackground = '' } = componentExtInfo || {}; this.setData({ cardBackground }); }, /* * 设置位置 * */ setUserInfoTop() { const { componentData } = this.props; const { componentExtInfo } = componentData; const { userInfoPositionTop = 0 } = componentExtInfo || {}; this.setData({ userInfoPositionTop: +userInfoPositionTop }); }, toDetail() { this.props.onNextPage(2); }, refreshCard() { const { healthCardId } = this.props.cardInfo; if (this.data.time !== 0) { return; } this.setData({ time: 60 }); this.timer = setInterval(() => { this.setData({ time: this.data.time - 1 }); this.data.time === 0 && clearInterval(this.timer); }, 1000); this.props.onRefreshCard(healthCardId); } } });