消息处理
This commit is contained in:
parent
e51d0938ac
commit
5fc7573af2
@ -169,10 +169,13 @@ Page({
|
||||
// 解析消息内容
|
||||
if (typeof item.content === 'string') {
|
||||
try {
|
||||
item.content = JSON.parse(item.content);
|
||||
const text = JSON.parse(item.content)
|
||||
item.content = {
|
||||
message: text.message || text.messages
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn('消息内容解析失败:', item.content);
|
||||
item.content = { messages: item.content };
|
||||
item.content = { message: item.content };
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +409,7 @@ Page({
|
||||
const msg = {
|
||||
id,
|
||||
content: {
|
||||
messages: welcomeText
|
||||
message: welcomeText
|
||||
},
|
||||
"msg_type": 1,
|
||||
receiver_id: '',
|
||||
@ -433,7 +436,7 @@ Page({
|
||||
request('app/send_message', 'POST', {
|
||||
"app_id": accountInfo.miniProgram.appId,
|
||||
"content": JSON.stringify({
|
||||
messages: welcomeText
|
||||
message: welcomeText
|
||||
}),
|
||||
"from_user_id": userInfo.openid,
|
||||
"from_user_name": userInfo.user_name,
|
||||
@ -470,7 +473,7 @@ Page({
|
||||
const msg = {
|
||||
id,
|
||||
content: {
|
||||
messages: text
|
||||
message: text
|
||||
},
|
||||
"msg_type": 1,
|
||||
receiver_id: '',
|
||||
@ -492,7 +495,7 @@ Page({
|
||||
request('app/send_message', 'POST', {
|
||||
"app_id": accountInfo.miniProgram.appId,
|
||||
"content": JSON.stringify({
|
||||
messages: text
|
||||
message: text
|
||||
}),
|
||||
"from_user_id": userInfo.openid,
|
||||
"from_user_name": userInfo.user_name,
|
||||
@ -550,7 +553,7 @@ Page({
|
||||
msg_type: '2',
|
||||
receiver_id: '',
|
||||
content: {
|
||||
messages: tempFilePaths[0]
|
||||
message: tempFilePaths[0]
|
||||
},
|
||||
sender_id: userInfo.openid,
|
||||
sender_name: userInfo.user_name,
|
||||
@ -574,7 +577,7 @@ Page({
|
||||
request('app/send_message', 'POST', {
|
||||
"app_id": accountInfo.miniProgram.appId,
|
||||
"content": JSON.stringify({
|
||||
messages: res
|
||||
message: res
|
||||
}),
|
||||
"from_user_id": userInfo.openid,
|
||||
"from_user_name": userInfo.user_name,
|
||||
@ -617,7 +620,7 @@ Page({
|
||||
// _ts: replyNow
|
||||
// };
|
||||
// that.setData({
|
||||
// messages: that.data.messages.concat(reply)
|
||||
// message: that.data.messages.concat(reply)
|
||||
// });
|
||||
// setTimeout(() => {
|
||||
// that.setData({
|
||||
|
||||
@ -20,10 +20,10 @@
|
||||
<view class="bubble-wrap">
|
||||
<view class="bubble">
|
||||
<block wx:if="{{item.msg_type == 1}}">
|
||||
<text class="msg-text">{{item.content.messages}}</text>
|
||||
<text class="msg-text">{{item.content.message}}</text>
|
||||
</block>
|
||||
<block wx:elif="{{item.msg_type == 2}}">
|
||||
<image src="{{item.content.messages}}" bindtap="previewImage" data-src="{{item.content.messages}}" class="msg-image" mode="aspectFill" />
|
||||
<image src="{{item.content.message}}" bindtap="previewImage" data-src="{{item.content.message}}" class="msg-image" mode="aspectFill" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"useSummer": true
|
||||
},
|
||||
"appid": "wx26ad074017e1e63f",
|
||||
"libVersion": "3.9.2",
|
||||
"libVersion": "3.10.3",
|
||||
"setting": {
|
||||
"es6": true,
|
||||
"postcss": false,
|
||||
|
||||
@ -28,13 +28,6 @@
|
||||
"query": "url=1",
|
||||
"scene": null,
|
||||
"launchMode": "default"
|
||||
},
|
||||
{
|
||||
"name": "pages/index/detail",
|
||||
"pathName": "pages/index/detail",
|
||||
"query": "url=1",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user