消息接口调试
This commit is contained in:
parent
1e572b05b8
commit
8341f3595b
|
|
@ -3,7 +3,7 @@
|
||||||
<view class="h5-container message-pages">
|
<view class="h5-container message-pages">
|
||||||
<view style="padding: 15px">
|
<view style="padding: 15px">
|
||||||
<van-icon name="arrow-left" @click="onClickLeft" />
|
<van-icon name="arrow-left" @click="onClickLeft" />
|
||||||
<text style="color: #000"> {{ contactUser }} </text>
|
<text style="color: #000"> {{ sendParams.toCompanyName }} </text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view scroll-y style="padding-bottom: 60px">
|
<scroll-view scroll-y style="padding-bottom: 60px">
|
||||||
|
|
@ -47,11 +47,11 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useMemberStore } from '@/stores/index.js'
|
import { useMemberStore } from '@/stores/index.js'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onShow, onHide } from '@dcloudio/uni-app'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import { sendMessageAPI, getMessageInfoAPI } from '@/services/message/index.js'
|
import { sendMessageAPI, getMessageInfoAPI } from '@/services/message/index.js'
|
||||||
const memberStore = useMemberStore()
|
const memberStore = useMemberStore()
|
||||||
const contactUser = ref('')
|
const messageInterval = ref(null)
|
||||||
const messageList = ref([])
|
const messageList = ref([])
|
||||||
const myCompanyId = ref()
|
const myCompanyId = ref()
|
||||||
|
|
||||||
|
|
@ -59,6 +59,7 @@ const sendParams = ref({
|
||||||
toUser: '',
|
toUser: '',
|
||||||
toCompany: '',
|
toCompany: '',
|
||||||
messageContent: '',
|
messageContent: '',
|
||||||
|
toCompanyName: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const onClickLeft = () => {
|
const onClickLeft = () => {
|
||||||
|
|
@ -75,6 +76,7 @@ const onSendMessage = debounce(async () => {
|
||||||
const res = await sendMessageAPI(sendParams.value)
|
const res = await sendMessageAPI(sendParams.value)
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
getMessageInfoData()
|
getMessageInfoData()
|
||||||
|
sendParams.value.messageContent = ''
|
||||||
} else {
|
} else {
|
||||||
showNotify({ type: 'success', message: '发送失败' })
|
showNotify({ type: 'success', message: '发送失败' })
|
||||||
}
|
}
|
||||||
|
|
@ -84,9 +86,21 @@ onLoad((options) => {
|
||||||
myCompanyId.value = memberStore.userInfo?.companyId
|
myCompanyId.value = memberStore.userInfo?.companyId
|
||||||
sendParams.value.toCompany = options?.id
|
sendParams.value.toCompany = options?.id
|
||||||
sendParams.value.toUser = options?.ownId
|
sendParams.value.toUser = options?.ownId
|
||||||
contactUser.value = options?.name
|
sendParams.value.toCompanyName = options?.name
|
||||||
getMessageInfoData()
|
getMessageInfoData()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
messageInterval.value = setInterval(() => {
|
||||||
|
getMessageInfoData()
|
||||||
|
}, 3000)
|
||||||
|
})
|
||||||
|
onHide(() => {
|
||||||
|
if (messageInterval.value) {
|
||||||
|
clearInterval(messageInterval.value)
|
||||||
|
messageInterval.value = null
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
@ -132,7 +146,7 @@ onLoad((options) => {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
text {
|
text {
|
||||||
height: 28px;
|
min-height: 28px;
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background-color: #22ab9a;
|
background-color: #22ab9a;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
>
|
>
|
||||||
<view>
|
<view>
|
||||||
<text style="color: #000"> 消息 </text>
|
<text style="color: #000"> 消息 </text>
|
||||||
<text> (3) </text>
|
<text> ({{ messageCount }}) </text>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<van-icon name="guide-o" />
|
<van-icon name="guide-o" />
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
<van-cell-group inset style="flex: 1">
|
<van-cell-group inset style="flex: 1">
|
||||||
<view
|
<view
|
||||||
class="message-items"
|
class="message-items"
|
||||||
v-for="item in 20"
|
v-for="item in messageList"
|
||||||
:key="item"
|
:key="item.uuid"
|
||||||
@click="onJumpToMessagePages"
|
@click="onJumpToMessagePages(item)"
|
||||||
>
|
>
|
||||||
<van-image
|
<van-image
|
||||||
round
|
round
|
||||||
|
|
@ -37,12 +37,15 @@
|
||||||
|
|
||||||
<view style="flex: 1">
|
<view style="flex: 1">
|
||||||
<view class="message-list">
|
<view class="message-list">
|
||||||
<text style="font-weight: bold"> 老张租赁 </text>
|
<text style="font-weight: bold"> {{ item.fromCompany }} </text>
|
||||||
<text> 9:12 </text>
|
<!-- <text> 9:12 </text> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="message-list message-info">
|
<view class="message-list message-info">
|
||||||
<text> 公司洽谈··· </text>
|
<text> {{ item.messageContent }} </text>
|
||||||
<text class="message-count"> 2 </text>
|
<!-- <text class="message-count">
|
||||||
|
|
||||||
|
</text> -->
|
||||||
|
<van-badge dot> </van-badge>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -52,14 +55,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
import { onHide, onLoad } from '@dcloudio/uni-app'
|
||||||
import { useMemberStore } from '@/stores/index.js'
|
import { useMemberStore } from '@/stores/index.js'
|
||||||
import { getMessageListAPI } from '@/services/message/index.js'
|
import { getMessageListAPI } from '@/services/message/index.js'
|
||||||
const memberStore = useMemberStore()
|
const memberStore = useMemberStore()
|
||||||
const userName = ref('')
|
const userName = ref('')
|
||||||
const userAccount = ref('')
|
const userAccount = ref('')
|
||||||
const messageInterval = ref(null)
|
const messageInterval = ref(null)
|
||||||
|
const messageList = ref([])
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
userName.value = memberStore.userInfo.nickName
|
userName.value = memberStore.userInfo.nickName
|
||||||
|
|
@ -70,7 +74,7 @@ onLoad(() => {
|
||||||
}, 3000)
|
}, 3000)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnload(() => {
|
onHide(() => {
|
||||||
if (messageInterval.value) {
|
if (messageInterval.value) {
|
||||||
clearInterval(messageInterval.value)
|
clearInterval(messageInterval.value)
|
||||||
messageInterval.value = null
|
messageInterval.value = null
|
||||||
|
|
@ -78,11 +82,19 @@ onUnload(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const getMessageListData = async () => {
|
const getMessageListData = async () => {
|
||||||
const res = await getMessageListAPI()
|
const { data: res } = await getMessageListAPI()
|
||||||
|
messageList.value = res
|
||||||
|
console.log(res, '消息列表')
|
||||||
}
|
}
|
||||||
const onJumpToMessagePages = () => {
|
const onJumpToMessagePages = (item) => {
|
||||||
uni.navigateTo({ url: '/pages/message-pages/index' })
|
const { fromCompany, fromUser } = item
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/message-pages/index?id=${fromCompany}&name=${996}&ownId=${fromUser}`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
const messageCount = computed(() => {
|
||||||
|
return messageList.value.length
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue