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

Loading…
Cancel
Save