|
@@ -28,14 +28,15 @@
|
|
|
:key="index"
|
|
|
@click="toView(item)"
|
|
|
>
|
|
|
- <div class="line" v-if="item._id == _id"></div>
|
|
|
+ <div class="line" v-if="item.user == id"></div>
|
|
|
<el-col :span="4" class="left">
|
|
|
- <el-image class="image" :src="item.url" fit="fill" />
|
|
|
+ <el-image class="image" v-if="item.url" :src="item.url" fit="fill" />
|
|
|
+ <el-image class="image" v-else :src="kf" fit="fill" />
|
|
|
</el-col>
|
|
|
<el-col :span="20" class="right">
|
|
|
<el-col :span="24" class="right_1">
|
|
|
<div class="name">{{ item.name }}</div>
|
|
|
- <div class="time">{{ item.time }}</div>
|
|
|
+ <div class="time">{{ item.send_time }}</div>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="right_2">{{ item.content }}</el-col>
|
|
|
</el-col>
|
|
@@ -71,17 +72,17 @@
|
|
|
|
|
|
<script setup>
|
|
|
// 基础
|
|
|
-import { get } from 'lodash-es'
|
|
|
-const $checkRes = inject('$checkRes')
|
|
|
+import moment from 'moment'
|
|
|
import Chat from './parts/chat.vue'
|
|
|
import { SearchOutlined } from '@ant-design/icons-vue'
|
|
|
// 接口
|
|
|
-import { DemandStore } from '@/store/api/platform/demand'
|
|
|
-import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
-const store = DemandStore()
|
|
|
-const dictDataStore = DictDataStore()
|
|
|
+import { ChatStore } from '@/store/api/platform/chat'
|
|
|
+import { UsersStore } from '@/store/api/user/user'
|
|
|
+const store = UsersStore()
|
|
|
+const chatstore = ChatStore()
|
|
|
import { UserStore } from '@/store/user'
|
|
|
const userStore = UserStore()
|
|
|
+
|
|
|
const user = computed(() => userStore.user)
|
|
|
// 图片引入
|
|
|
import kf from '@/assets/kf.png'
|
|
@@ -91,63 +92,80 @@ const route = useRoute()
|
|
|
const loading = ref(false)
|
|
|
// 是否弹框客服
|
|
|
const dialog = ref(false)
|
|
|
-const _id = ref(route.query.id || '')
|
|
|
-const chatList = ref([
|
|
|
- { _id: '1', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '2', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '3', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '4', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '5', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '6', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '7', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '8', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '9', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '10', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' }
|
|
|
-])
|
|
|
-const list = ref([
|
|
|
- { _id: '1', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- {
|
|
|
- _id: '2',
|
|
|
- url: kf,
|
|
|
- name: '新浪微博',
|
|
|
- content:
|
|
|
- '研究防颠簸及坡地机身平衡的机械结构和控制方法,能有效克服履带式行走机构在起伏地形下难以实现机身有效平衡的缺点,以确保采摘装备在采摘过程中的行走的稳定。行走速度:0-5m/s;在坡度小于25度的环境下能平稳行走',
|
|
|
- type: '0',
|
|
|
- time: '2024-03-30'
|
|
|
- },
|
|
|
- { _id: '1', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' },
|
|
|
- { _id: '2', url: kf, name: '新浪微博', content: '内容', type: '0', time: '2024-03-30' }
|
|
|
-])
|
|
|
-const info = ref({
|
|
|
- _id: '1',
|
|
|
- url: kf,
|
|
|
- name: '新浪微博',
|
|
|
- content: '内容',
|
|
|
- type: '0',
|
|
|
- time: '2024-03-30'
|
|
|
-})
|
|
|
+// 聊天者id
|
|
|
+const id = ref(route.query.id || '')
|
|
|
+// 聊天室
|
|
|
+const chatList = ref([])
|
|
|
+// 列表
|
|
|
+const list = ref([])
|
|
|
+let skip = 0
|
|
|
+let limit = inject('limit')
|
|
|
+// 搜索
|
|
|
+const searchForm = ref({})
|
|
|
+// 个人信息
|
|
|
+const info = ref({})
|
|
|
+// 消息
|
|
|
+const textarea = ref('')
|
|
|
+
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
|
- await searchOther()
|
|
|
await search()
|
|
|
loading.value = false
|
|
|
})
|
|
|
const search = async () => {
|
|
|
- let id = route.query.id
|
|
|
- if (id) {
|
|
|
- // let res = await store.fetch(id)
|
|
|
- // if (res.errcode == '0') info.value = res.data
|
|
|
+ searchList({ skip, limit })
|
|
|
+ if (id.value) {
|
|
|
+ let res = await store.fetch(id.value)
|
|
|
+ if (res.errcode == '0') info.value = res.data
|
|
|
+ searchChat({ skip, limit })
|
|
|
+ }
|
|
|
+}
|
|
|
+const searchList = async (query = { skip: 0, limit }) => {
|
|
|
+ const info = {
|
|
|
+ skip: query.skip,
|
|
|
+ limit: query.limit,
|
|
|
+ ...searchForm.value
|
|
|
}
|
|
|
+ const res = await chatstore.chat(info)
|
|
|
+ if (res.errcode == '0') chatList.value = res.data
|
|
|
}
|
|
|
-const searchOther = async () => {}
|
|
|
const toView = async (item) => {
|
|
|
- _id.value = item._id
|
|
|
+ id.value = item.user
|
|
|
+ let res = await store.fetch(item.user)
|
|
|
+ if (res.errcode == '0') info.value = res.data
|
|
|
+ await searchChat({ skip, limit })
|
|
|
+}
|
|
|
+const searchChat = async (query = { skip: 0, limit }) => {
|
|
|
+ const data = {
|
|
|
+ skip: query.skip,
|
|
|
+ limit: query.limit,
|
|
|
+ user: info.value._id,
|
|
|
+ ...searchForm.value
|
|
|
+ }
|
|
|
+ const res = await chatstore.query(data)
|
|
|
+ if (res.errcode == '0') list.value = res.data
|
|
|
+}
|
|
|
+const toSend = async () => {
|
|
|
+ const data = {
|
|
|
+ sender_id: user.value._id,
|
|
|
+ receiver_id: id.value,
|
|
|
+ type: '0',
|
|
|
+ content: textarea.value,
|
|
|
+ send_time: moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ }
|
|
|
+ const res = await chatstore.create(data)
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ textarea.value = ''
|
|
|
+ searchChat()
|
|
|
+ }
|
|
|
}
|
|
|
// provide
|
|
|
-provide('_id', _id)
|
|
|
+provide('id', id)
|
|
|
provide('list', list)
|
|
|
provide('info', info)
|
|
|
+provide('textarea', textarea)
|
|
|
+provide('toSend', toSend)
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
.main {
|