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