提醒页面增加创可贴展示

This commit is contained in:
mx1700 2019-07-15 22:13:53 +08:00
parent da7ff8050a
commit ecac562fc3
4 changed files with 59 additions and 5 deletions

2
package-lock.json generated
View file

@ -10660,7 +10660,7 @@
},
"prop-types": {
"version": "15.7.2",
"resolved": "http://registry.npm.taobao.org/prop-types/download/prop-types-15.7.2.tgz",
"resolved": "https://registry.npm.taobao.org/prop-types/download/prop-types-15.7.2.tgz",
"integrity": "sha1-UsQedbjIfnK52TYOAga5ncv/psU=",
"requires": {
"loose-envify": "^1.4.0",

View file

@ -1,5 +1,5 @@
import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {Image, StyleSheet, Text, View} from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Touchable from '../touchable';
@ -27,6 +27,8 @@ export default class Notification extends Component {
} else if(msg.type == 2) {
return this.renderFollow(msg);
} else if(msg.type == 3) {
return this.renderLike(msg);
}
}
@ -34,6 +36,7 @@ export default class Notification extends Component {
}
renderComment(msg) {
console.log(msg);
const users = unique(msg.list.map(it => it.content.author.name)).join('、');
const body = `${users} 回复了你`;
@ -59,6 +62,26 @@ export default class Notification extends Component {
</Touchable>
)
}
renderLike(msg) {
console.log(msg);
const body = `${msg.content.user.name} 给了你一个创可贴`;
return (
<Touchable key={msg.link_id} onPress={() => this.props.onLikePress(msg)}>
<View style={localStyle.container}>
<Image
source={
require('../../img/ok-beng2.png')
}
style={localStyle.icon2}
/>
<Text style={localStyle.text}>{body}</Text>
</View>
</Touchable>
)
}
}
const localStyle = StyleSheet.create({
@ -76,5 +99,11 @@ const localStyle = StyleSheet.create({
text: {
flex: 1,
lineHeight: 20
}
},
icon2: {
width: 14,
height: 14,
marginRight: 10,
marginTop: 4,
},
});

View file

@ -62,7 +62,7 @@ export default class NotificationList extends Component {
});
}
} else if (v.type == 2) {
} else if (v.type == 2 || v.type == 3) {
ret.push(v);
}
@ -149,6 +149,30 @@ export default class NotificationList extends Component {
}
}
_onLikePress(msg) {
Navigation.push(this.props.componentId, {
component: {
name: 'User',
options: {
bottomTabs: {
visible: false,
// hide bottom tab for android
drawBehind: true,
animate: true
}
},
passProps: {
user: msg.content.user
}
}
});
if(this.props.isSetRead) {
//this._setRead(msg);
}
}
render() {
let hasData = this.state.notifications && this.state.notifications.length > 0;
return hasData ? (
@ -164,6 +188,7 @@ export default class NotificationList extends Component {
<Notification msg={item}
onCommentPress={this._onCommentPress.bind(this)}
onFollowPress={this._onFollowPress.bind(this)}
onLikePress={this._onLikePress.bind(this)}
></Notification>
);
}}

View file

@ -248,7 +248,7 @@ async function addFollow(user_id) {
}
async function getMessages() {
return call('GET', '/tip');
return callV2('GET', '/tips');
}
async function getMessagesHistory() {