|
|
@ -7,12 +7,11 @@ |
|
|
class="section_1" |
|
|
class="section_1" |
|
|
scroll-y="true" |
|
|
scroll-y="true" |
|
|
:lower-threshold="lowerThreshold" |
|
|
:lower-threshold="lowerThreshold" |
|
|
@scrolltolower="loadMoreData" |
|
|
|
|
|
style="height: 80vh;" |
|
|
style="height: 80vh;" |
|
|
> |
|
|
> |
|
|
<view class="ul"> |
|
|
<view class="ul"> |
|
|
<view class="item_box" v-for="(v,k) in tableList" :key="k"> |
|
|
<view class="item_box" v-for="(v,k) in tableList" :key="k" :id="'item_' + v.id"> |
|
|
<view class="time_section" v-if="v.create_time">{{v.create_time}}</view> |
|
|
<view class="time_section" v-if="v.created_at">{{v.created_at}}</view> |
|
|
|
|
|
|
|
|
<view class="li" v-if="v.direction == `left`"> |
|
|
<view class="li" v-if="v.direction == `left`"> |
|
|
<view class="item left_item"> |
|
|
<view class="item left_item"> |
|
|
@ -43,6 +42,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import apiRoute from '@/api/apiRoute.js'; |
|
|
import memberApi from '@/api/member.js'; |
|
|
import memberApi from '@/api/member.js'; |
|
|
import commonApi from '@/api/common.js'; |
|
|
import commonApi from '@/api/common.js'; |
|
|
import AQUplodeImgMulti from '@/components/AQ/AQUplodeImgMulti'; |
|
|
import AQUplodeImgMulti from '@/components/AQ/AQUplodeImgMulti'; |
|
|
@ -65,17 +65,37 @@ export default { |
|
|
page:1,//当前页码 |
|
|
page:1,//当前页码 |
|
|
limit:10,//每页返回数据条数 |
|
|
limit:10,//每页返回数据条数 |
|
|
total:10,//数据总条数 |
|
|
total:10,//数据总条数 |
|
|
hair_staff_id: '',//发信人id |
|
|
friend_id: '',//chat_friends表id |
|
|
}, |
|
|
}, |
|
|
tableList:[],//聊天数据列表 |
|
|
tableList:[],//聊天数据列表 |
|
|
|
|
|
|
|
|
|
|
|
from_id:'',//发送者ID |
|
|
|
|
|
to_id:'',//接收者ID |
|
|
|
|
|
from_type:'',//发送者类型|personnel=员工,customer=学生(客户) |
|
|
|
|
|
|
|
|
|
|
|
//请求参数 |
|
|
|
|
|
chatFriendsInfoParams:{ |
|
|
|
|
|
personnel_id:'', |
|
|
|
|
|
customer_resources_id:'', |
|
|
|
|
|
}, |
|
|
|
|
|
chatFriendsInfo:{},//好友关系详情 |
|
|
|
|
|
|
|
|
|
|
|
//聊天表单信息 |
|
|
formData: { |
|
|
formData: { |
|
|
content: '', |
|
|
from_type:'',//发送者类型|personnel=员工,customer=学生(客户) |
|
|
|
|
|
from_id:'',//发送者ID |
|
|
|
|
|
to_id:'',//接收者ID |
|
|
|
|
|
friend_id:'',//关联chat_friends表id |
|
|
|
|
|
message_type: 'text',//消息类型|text=文本,img=图片 |
|
|
|
|
|
content: '',//文本内容(JSON 格式扩展字段),文本类型=纯文字,图片类型=绝对路径 |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
lastItemId: null, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad(options) { |
|
|
onLoad(options) { |
|
|
this.filteredData.hair_staff_id = options.hair_staff_id//发信人id |
|
|
this.from_id = options.from_id//发送者的id |
|
|
|
|
|
this.to_id = options.to_id//接收者的id |
|
|
}, |
|
|
}, |
|
|
onShow(){ |
|
|
onShow(){ |
|
|
this.init() |
|
|
this.init() |
|
|
@ -89,7 +109,66 @@ export default { |
|
|
|
|
|
|
|
|
//初始化 |
|
|
//初始化 |
|
|
async init(){ |
|
|
async init(){ |
|
|
|
|
|
//获取用户类型 |
|
|
|
|
|
let userType = uni.getStorageSync('userType') |
|
|
|
|
|
//1=教练,2=销售,3=学员 |
|
|
|
|
|
if (['1', '2'].includes(String(userType))) { |
|
|
|
|
|
// |
|
|
|
|
|
this.from_type = 'personnel'//员工 |
|
|
|
|
|
this.chatFriendsInfoParams.personnel_id = this.from_id//员工资源的id |
|
|
|
|
|
this.chatFriendsInfoParams.customer_resources_id = this.to_id//学生资源的id |
|
|
|
|
|
|
|
|
|
|
|
this.formData.from_type = 'personnel'//员工 |
|
|
|
|
|
this.formData.from_id = this.from_id//发送者的id(员工) |
|
|
|
|
|
this.formData.to_id = this.to_id//接收者的id(学生) |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
// |
|
|
|
|
|
this.from_type = 'customer'//学生 |
|
|
|
|
|
this.chatFriendsInfoParams.personnel_id = this.to_id//员工资源的id |
|
|
|
|
|
this.chatFriendsInfoParams.customer_resources_id = this.from_id//学生资源的id |
|
|
|
|
|
|
|
|
|
|
|
this.formData.from_type = 'customer'//学生 |
|
|
|
|
|
this.formData.from_id = this.to_id//发送者的id(学生) |
|
|
|
|
|
this.formData.to_id = this.from_id//接收者的id(员工) |
|
|
|
|
|
} |
|
|
|
|
|
//获取好友关系详情 |
|
|
|
|
|
await this.getChatFriendsInfo() |
|
|
|
|
|
//获取聊天记录列表 |
|
|
await this.getList(); |
|
|
await this.getList(); |
|
|
|
|
|
|
|
|
|
|
|
// 更新最后一个 item 的 ID |
|
|
|
|
|
this.lastItemId = 'item_' + (this.tableList.length - 1); |
|
|
|
|
|
|
|
|
|
|
|
// 滚动到底部 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.$refs.scrollView.scrollTo({ top: this.scrollViewHeight }); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 或者直接使用 scroll-into-view |
|
|
|
|
|
this.scrollIntoView = this.lastItemId; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//获取好友关系详情 |
|
|
|
|
|
async getChatFriendsInfo(){ |
|
|
|
|
|
let params = { |
|
|
|
|
|
personnel_id: this.chatFriendsInfoParams.personnel_id,//员工资源ID |
|
|
|
|
|
customer_resources_id: this.chatFriendsInfoParams.customer_resources_id,//学生资源ID |
|
|
|
|
|
} |
|
|
|
|
|
let res = await apiRoute.xs_chatGetChatFriendsInfo(params) |
|
|
|
|
|
if (res.code != 1){ |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: res.msg, |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.chatFriendsInfo = res.data |
|
|
|
|
|
|
|
|
|
|
|
this.filteredData.friend_id = res.data.id |
|
|
|
|
|
|
|
|
|
|
|
this.formData.friend_id = res.data.id |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//加载更多(下一页) |
|
|
//加载更多(下一页) |
|
|
@ -109,27 +188,27 @@ export default { |
|
|
this.filteredData.total = 10//数据总条数 |
|
|
this.filteredData.total = 10//数据总条数 |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//获取列表 |
|
|
//获取聊天记录列表 |
|
|
async getList(){ |
|
|
async getList(){ |
|
|
this.loading = true |
|
|
this.loading = true |
|
|
|
|
|
|
|
|
let data = {...this.filteredData} |
|
|
let data = {...this.filteredData} |
|
|
|
|
|
|
|
|
//判断是否还有数据 |
|
|
// 判断是否还有数据可加载 |
|
|
if(this.filteredData.page * this.filteredData.limit > this.filteredData.total){ |
|
|
if ((this.filteredData.page - 1) * this.filteredData.limit >= this.filteredData.total) { |
|
|
this.loading = false |
|
|
this.loading = false; |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: '暂无更多', |
|
|
title: '暂无更多', |
|
|
icon: 'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}); |
|
|
return |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(data.page == 1){ |
|
|
if(data.page == 1){ |
|
|
this.tableList = [] |
|
|
this.tableList = [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let res = await commonApi.getContactMessage(data)//获取消息列表 |
|
|
let res = await apiRoute.xs_chatGetChatMessagesList(data)//获取消息列表 |
|
|
this.loading = false |
|
|
this.loading = false |
|
|
this.isReachedBottom = false; |
|
|
this.isReachedBottom = false; |
|
|
if (res.code != 1){ |
|
|
if (res.code != 1){ |
|
|
@ -141,9 +220,32 @@ export default { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// this.tableList = this.tableList.concat(res.data.data); // 使用 concat 方法 将新数据追加到数组中 |
|
|
// this.tableList = this.tableList.concat(res.data.data); // 使用 concat 方法 将新数据追加到数组中 |
|
|
this.tableList.unshift(...res.data.data); // 将新数据插入到数组头部 |
|
|
|
|
|
|
|
|
|
|
|
console.log('列表',this.tableList) |
|
|
let list = res.data.data |
|
|
|
|
|
|
|
|
|
|
|
list.forEach((v, k) => { |
|
|
|
|
|
|
|
|
|
|
|
if (this.from_type == 'personnel') { |
|
|
|
|
|
//当前是员工登陆聊天页面时 |
|
|
|
|
|
if (v.from_type == 'personnel') { |
|
|
|
|
|
v.direction = 'right'//是员工发的消息 |
|
|
|
|
|
} else { |
|
|
|
|
|
v.direction = 'left'//是学生发的消息 |
|
|
|
|
|
} |
|
|
|
|
|
} else if (this.from_type == 'customer') { |
|
|
|
|
|
//当前是学生登陆聊天页面时 |
|
|
|
|
|
if (v.from_type == 'customer') { |
|
|
|
|
|
v.direction = 'right'//是员工发的消息 |
|
|
|
|
|
} else { |
|
|
|
|
|
v.direction = 'left'//是学生发的消息 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
list.reverse() |
|
|
|
|
|
this.tableList.unshift(...list); // 将新数据插入到数组头部 |
|
|
|
|
|
|
|
|
|
|
|
console.log('列表',res.data.total) |
|
|
this.filteredData.total = res.data.total |
|
|
this.filteredData.total = res.data.total |
|
|
this.filteredData.page++ |
|
|
this.filteredData.page++ |
|
|
}, |
|
|
}, |
|
|
@ -165,10 +267,7 @@ export default { |
|
|
|
|
|
|
|
|
//发送站内信 |
|
|
//发送站内信 |
|
|
async submitForm() { |
|
|
async submitForm() { |
|
|
let data = { |
|
|
let data = {...this.formData} |
|
|
hair_staff_id: this.filteredData.hair_staff_id, |
|
|
|
|
|
content: this.formData.content, |
|
|
|
|
|
} |
|
|
|
|
|
if (!data.content) { |
|
|
if (!data.content) { |
|
|
//反馈内容为必填项 |
|
|
//反馈内容为必填项 |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
@ -177,7 +276,7 @@ export default { |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
let res = await commonApi.sendMessage(data) |
|
|
let res = await apiRoute.xs_chatSendChatMessages(data) |
|
|
if (res.code != 1) { |
|
|
if (res.code != 1) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: res.msg, |
|
|
title: res.msg, |
|
|
|