Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

Commit b902321

Browse files
author
pengshanglong
committed
fix: Avatar LoadMore Button
1 parent f67b50e commit b902321

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

src/components/avatar/index.jsx

+11-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
},
2929
openData: {
3030
type: Object,
31-
default: () => {},
31+
default: () => ({}),
3232
},
3333
customStyle: {
3434
type: [Object, String],
@@ -40,7 +40,7 @@ export default {
4040
},
4141
},
4242

43-
render() {
43+
render(h) {
4444
const { size, circle, image, text, openData, customStyle, className } = this
4545
const rootClassName = ['at-avatar']
4646
const iconSize = SIZE_CLASS[size || 'normal']
@@ -52,19 +52,17 @@ export default {
5252
let letter = ''
5353
if (text) letter = text[0]
5454

55-
let elem
56-
if (openData && openData.type === 'userAvatarUrl' && this.$isWEAPP()) {
57-
// TODO OpenData Component
58-
elem = <OpenData type={openData.type}></OpenData>
59-
} else if (image) {
60-
elem = <image class="at-avatar__img" src={image} />
61-
} else {
62-
elem = <text class="at-avatar__text">{letter}</text>
63-
}
64-
55+
const isOpenData = openData && openData.type === 'userAvatarUrl' && this.$isWEAPP()
56+
const isImage = !isOpenData && image !== ''
57+
const isText = !isOpenData && !image
58+
console.log('isOpenData', isOpenData)
59+
console.log('isImage', isImage)
60+
console.log('isText', isText)
6561
return (
6662
<view class={classNames(rootClassName, classObject, className)} style={customStyle}>
67-
{elem}
63+
{isOpenData && <OpenData type={openData.type}></OpenData>}
64+
{isImage && <image class="at-avatar__img" src={image} />}
65+
{isText && <view class="at-avatar__text">{letter}</view>}
6866
</view>
6967
)
7068
},

src/components/button/index.jsx

-7
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,7 @@ export default {
196196
const loadingColor = type === 'primary' ? '#fff' : ''
197197
const loadingSize = size === 'small' ? '30' : 0
198198

199-
let loadingComponent = null
200199
if (loading) {
201-
loadingComponent = (
202-
<view className="at-button__icon">
203-
<Loading color={loadingColor} size={loadingSize} />
204-
</view>
205-
)
206200
rootClassName.push('at-button--icon')
207201
}
208202

@@ -248,7 +242,6 @@ export default {
248242
<Loading color={loadingColor} size={loadingSize} />
249243
</view>
250244
)}
251-
{loadingComponent}
252245
<view class="at-button__text">{this.$slots.default}</view>
253246
</view>
254247
)

src/components/load-more/index.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import classNames from 'classnames'
2+
import Button from '../button/index'
23
import AtActivityIndicator from '../activity-indicator/index'
34

45
export default {
@@ -61,9 +62,9 @@ export default {
6162
} else if (status === 'more') {
6263
component = (
6364
<view class="at-load-more__cnt">
64-
<AtButton full onClick={this.onClick} customStyle={moreBtnStyle}>
65+
<Button full onTap={this.onClick} customStyle={moreBtnStyle}>
6566
{moreText}
66-
</AtButton>
67+
</Button>
6768
</view>
6869
)
6970
} else {

src/pages/index/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
color="#F00"
1919
/>
2020
</Badge>
21-
<Button
21+
<!-- <Button
2222
loading
2323
type="primary"
2424
:on-click="onClick"
2525
>
2626
hello
27-
</Button>
27+
</Button> -->
2828
<Fab>fab</Fab>
2929
<Avatar text="111" />
3030
<Curtain

0 commit comments

Comments
 (0)