|
@@ -81,6 +81,7 @@ class MsgComponent extends React.Component {
|
|
|
thumbMediaId:"",
|
|
|
selectKeysProps:"",
|
|
|
imgInitialization:false,
|
|
|
+ _ID:""
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -342,7 +343,7 @@ class MsgComponent extends React.Component {
|
|
|
};
|
|
|
componentDidMount() {
|
|
|
let self = this;
|
|
|
- self.setState({ chooseKey:self.props.chooseKey, mediaId:self.props.mediaId }, () => { self.loadImgs()});
|
|
|
+ self.setState({ chooseKey:self.props.chooseKey, _ID:self.props.mediaId }, () => { self.loadImgs()});
|
|
|
//隐藏表情弹框
|
|
|
document.addEventListener('click', () => {
|
|
|
self.setState({
|
|
@@ -355,21 +356,24 @@ class MsgComponent extends React.Component {
|
|
|
|
|
|
//生命周期
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
- this.setState({ chooseKey:nextProps.chooseKey })
|
|
|
- // console.log(nextProps.chooseKey,'chooseKey');
|
|
|
+ if(!nextProps.type){
|
|
|
+ this.setState({ chooseKey:nextProps.chooseKey , _ID : nextProps.mediaId ? nextProps.mediaId : null})
|
|
|
+ }
|
|
|
+ if(nextProps.mediaId){
|
|
|
+ this.loadImgs();
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ imgUrlText:"",
|
|
|
+ imgUrlNews:"",
|
|
|
+ imgUrlMini:"",
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
// let self = this;
|
|
|
// if (!util.object.equal(nextProps.msgId, this.state.msgId)) {
|
|
|
// self.setState({ msgId: nextProps.msgId }, () => { self.loadImgs()});
|
|
|
// }
|
|
|
|
|
|
- if(nextProps.msgType == "text" || nextProps.msgType == "news" && nextProps.cutextKey == nextProps.msgType){
|
|
|
- this.setState({ chooseKey:nextProps.chooseKey,mediaId: nextProps.mediaId,selectKeysProps:nextProps.cutextKey }, () => { this.loadImgs()});
|
|
|
- }
|
|
|
- if(nextProps.msgType == "miniprogrampage" && nextProps.cutextKey == "miniprogrampage"){
|
|
|
- this.setState({ chooseKey:nextProps.chooseKey,mediaId: nextProps.thumbMediaId,selectKeysProps:nextProps.cutextKey }, () => { this.loadImgs()});
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
onFinish = e => {
|
|
|
e.preventDefault();
|
|
@@ -384,14 +388,16 @@ class MsgComponent extends React.Component {
|
|
|
};
|
|
|
loadImgs(){
|
|
|
let self = this;
|
|
|
- let mediaId = '';
|
|
|
- if (self.state.chooseKey == 'text') {
|
|
|
- mediaId = self.state.mediaId;
|
|
|
- } else if (self.state.chooseKey == 'news') {
|
|
|
- mediaId = self.state.mediaId;
|
|
|
- } else if (self.state.chooseKey == 'miniprogrampage') {
|
|
|
- mediaId = self.state.thumbMediaId;
|
|
|
- }
|
|
|
+ // let mediaId = '';
|
|
|
+ // if (self.state.chooseKey == 'text') {
|
|
|
+ // mediaId = self.state.mediaId;
|
|
|
+ // } else if (self.state.chooseKey == 'news') {
|
|
|
+ // mediaId = self.state.mediaId;
|
|
|
+ // } else if (self.state.chooseKey == 'miniprogrampage') {
|
|
|
+ // mediaId = self.state.thumbMediaId;
|
|
|
+ // }
|
|
|
+ let mediaId = ''
|
|
|
+ mediaId = self.state._ID
|
|
|
if (mediaId && mediaId != '') {
|
|
|
//设置图片显示
|
|
|
if (mediaId != '') {
|
|
@@ -407,7 +413,7 @@ class MsgComponent extends React.Component {
|
|
|
} else if (self.state.chooseKey == 'miniprogrampage') {
|
|
|
self.setState({ imgUrlMini: res.result.localUrl }) //imgUrlMini = res.result.localUrl;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
};
|
|
|
}
|
|
@@ -594,13 +600,12 @@ class MsgComponent extends React.Component {
|
|
|
}
|
|
|
|
|
|
let imgUrlMini = self.state.imgUrlMini;
|
|
|
- // if (imgUrlMini) {
|
|
|
- // let imgSeperator = "?";
|
|
|
- // if(imgUrlNews.indexOf("?") !== -1 ) imgSeperator = "&";
|
|
|
- // if(imgUrlNews.indexOf("&") !== -1 ) imgSeperator = "&";
|
|
|
-
|
|
|
- // imgUrlMini = imgUrlMini + imgSeperator + 'Sso-Token=' + SsoToken ;
|
|
|
- // }
|
|
|
+ if (imgUrlMini) {
|
|
|
+ let imgSeperator = "?";
|
|
|
+ if(imgUrlMini.indexOf("?") !== -1 ) imgSeperator = "&";
|
|
|
+ if(imgUrlMini.indexOf("&") !== -1 ) imgSeperator = "&";
|
|
|
+ imgUrlMini = imgUrlMini.indexOf('Sso-Token') > -1 ? imgUrlMini: imgUrlMini + imgSeperator + 'Sso-Token=' + SsoToken ;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
return (
|