Browse Source

feat(api): 添加发送站内信功能并优化聊天页面

- 在 api/common.js 中新增 sendMessage 方法,用于发送站内信
- 更新 im_chat_info.vue 页面,实现消息发送功能
- 优化消息输入框和发送按钮,支持实时显示已输入内容
- 发送消息后清空输入框,并将新消息添加到聊天列表中
master
liutong 12 months ago
parent
commit
d3e72316b2
  1. 8
      api/common.js
  2. 43
      pages/common/im_chat_info.vue

8
api/common.js

@ -33,6 +33,14 @@ export default {
})
},
//发送站内信
sendMessage(data) {
let url = `/member/send_message`
return http.get(url,data).then(res => {
return res;
})
},
}

43
pages/common/im_chat_info.vue

@ -33,10 +33,10 @@
</view>
<view class="input_section">
<view class="left_box">
<input class="input" type="text" placeholder="请输入">
<input class="input" v-model="formData.content" type="text" placeholder="请输入">
</view>
<view class="right_box">
<image class="send_img" src="@/static/images/common/fa_song.png"></image>
<image @click="submitForm()" class="send_img" src="@/static/images/common/fa_song.png"></image>
</view>
</view>
</view>
@ -70,10 +70,7 @@ export default {
tableList:[],//
formData: {
images_arr: [],
images: '',
content: '',
mailbox: '',
},
}
},
@ -166,32 +163,44 @@ export default {
// console.log('AQxxx2',this.formData.member_store_certification_arr)
},
//
async submitForm() {
let data = {...this.formData}
data.images = data.images_arr.join(',')
let data = {
hair_staff_id: this.filteredData.hair_staff_id,
content: this.formData.content,
}
if (!data.content) {
//
uni.showToast({
title: '反馈内容为必填项',
title: '请输入内容',
icon: 'none'
})
return
}
let res = await memberApi.setFeedback(data)
let res = await commonApi.sendMessage(data)
if (res.code != 1) {
uni.showToast({
title: res.msg,
icon: 'none'
})
} else {
uni.showToast({
title: '提交成功',
icon: 'none'
})
//1s
setTimeout(() => {
this.$util.openHomeView();
}, 1000);
let content = this.formData.content
this.formData.content = ''//
let msgData = {
"id": '',
"hair_staff_id": this.filteredData.hair_staff_id,
"closed_staff_id": '',
"content": content,
"status": 1,
"type": 2,
"create_time": "",
"redirect": null,
"title": null,
"direction": "right",
"show_time": ""
}
//
this.tableList = this.tableList.concat(msgData);
}
},

Loading…
Cancel
Save