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