Skip to content

Commit

Permalink
fix(view): noticebar完善
Browse files Browse the repository at this point in the history
  • Loading branch information
cos2004 committed Aug 14, 2018
1 parent 7f8106c commit f6806b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
18 changes: 6 additions & 12 deletions src/components/noticebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ export default class AtNoticebar extends Taro.Component {
}

onGotoMore () {
if (Taro.getEnv() === 'WEAPP') {
Taro.navigateTo({
url: this.props.moreUrl,
})
} else {
alert('该环境尚未实现此API')
}
this.props.onGotoMore && this.props.onGotoMore(...arguments)
}

componentDidMount () {
Expand All @@ -52,7 +46,7 @@ export default class AtNoticebar extends Taro.Component {

render () {
const {
moreUrl,
showMore,
single,
icon,
marquee,
Expand All @@ -74,7 +68,7 @@ export default class AtNoticebar extends Taro.Component {
style['animation-duration'] = `${dura}s`
innerClassName.push(this.state.animElemId)
} else {
if (moreUrl) rootClassName.push('at-noticebar--more')
if (showMore) rootClassName.push('at-noticebar--more')
if (single) rootClassName.push('at-noticebar--single')
}

Expand All @@ -88,7 +82,7 @@ export default class AtNoticebar extends Taro.Component {
<Text className={innerClassName} style={style}>{this.props.children}</Text>
</View>
</View>
{moreUrl && <View className='at-noticebar__more' onClick={this.onGotoMore.bind(this)}><Text className='text'>{_moreText}</Text><View className='at-noticebar__more-icon'><AtIcon value='chevron-right' size='16'></AtIcon></View></View>}
{showMore && <View className='at-noticebar__more' onClick={this.onGotoMore.bind(this)}><Text className='text'>{_moreText}</Text><View className='at-noticebar__more-icon'><AtIcon value='chevron-right' size='16'></AtIcon></View></View>}
</View>
)
}
Expand All @@ -100,7 +94,7 @@ AtNoticebar.defaultProps = {
marquee: false,
speed: 100,
moreText: '查看详情',
moreUrl: '',
showMore: false,
icon: '',
}

Expand All @@ -110,6 +104,6 @@ AtNoticebar.propTypes = {
marquee: PropTypes.bool,
speed: PropTypes.number,
moreText: PropTypes.string,
moreUrl: PropTypes.string,
showMore: PropTypes.bool,
icon: PropTypes.string,
}
13 changes: 9 additions & 4 deletions src/pages/view/noticebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export default class NoticebarPage extends Taro.Component {
}
}

onGotoMore () {
if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) Taro.showModal({ content: '点击了更多!' })
else if (Taro.getEnv() === Taro.ENV_TYPE.WEB) alert('您点击了更多!')
}

render () {
return (
<View className='page'>
Expand Down Expand Up @@ -74,16 +79,16 @@ export default class NoticebarPage extends Taro.Component {
<View className='panel__title'>查看更多</View>
<View className='panel__content'>
<View className='bar-item'>
<AtNoticebar moreUrl='https://taro.aotu.io/' single>[单行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
<AtNoticebar showMore single onGotoMore={this.onGotoMore.bind(this)}>[单行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
</View>
<View className='bar-item'>
<AtNoticebar icon='volume-plus' moreUrl='https://taro.aotu.io/' single>[单行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
<AtNoticebar showMore icon='volume-plus' single onGotoMore={this.onGotoMore.bind(this)}>[单行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
</View>
<View className='bar-item'>
<AtNoticebar moreUrl='https://taro.aotu.io/'>[多行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
<AtNoticebar showMore moreText='更多' onGotoMore={this.onGotoMore.bind(this)}>[多行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
</View>
<View className='bar-item'>
<AtNoticebar icon='volume-plus' moreUrl='https://taro.aotu.io/'>[多行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
<AtNoticebar showMore moreText='更多' icon='volume-plus' onGotoMore={this.onGotoMore.bind(this)}>[多行] 这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏,这是 NoticeBar 通告栏</AtNoticebar>
</View>
</View>
</View>
Expand Down

0 comments on commit f6806b9

Please sign in to comment.