This commit is contained in:
parent
b1b68d68ef
commit
307b25d08d
|
@ -14,6 +14,8 @@
|
||||||
getUserinfo()
|
getUserinfo()
|
||||||
// 获取系统配置
|
// 获取系统配置
|
||||||
getConfig()
|
getConfig()
|
||||||
|
// 获取未读消息数量
|
||||||
|
getNoReadNum()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
|
@ -51,6 +53,41 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取未读消息数量
|
||||||
|
async function getNoReadNum() {
|
||||||
|
// uni.removeTabBarBadge({
|
||||||
|
// index: 2,
|
||||||
|
// text: "",
|
||||||
|
// });
|
||||||
|
// api.getNoReadNum().then(rs => {
|
||||||
|
// if (rs.code == 200) {
|
||||||
|
// uni.setTabBarBadge({
|
||||||
|
// index: 0,
|
||||||
|
// text: "11",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// uni.setTabBarBadge({
|
||||||
|
// index: 2,
|
||||||
|
// text: "11",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const res = await uni.request({ url: 'API_URL' });
|
||||||
|
// const count = res.data.unread;
|
||||||
|
|
||||||
|
|
||||||
|
// setTimeout(() => {
|
||||||
|
// uni.setTabBarBadge({
|
||||||
|
// index: 1,
|
||||||
|
// text: '10',
|
||||||
|
// success: function () {
|
||||||
|
// console.log(11111);
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// }, 1000)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -85,6 +85,17 @@ const api = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取未读消息数量
|
||||||
|
* @param {Object} param
|
||||||
|
*/
|
||||||
|
getNoReadNum() {
|
||||||
|
return util.request({
|
||||||
|
url: '/shopify/region/all',
|
||||||
|
method: 'GET',
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default api
|
export default api
|
|
@ -6,8 +6,8 @@ const config = {
|
||||||
// host: 'h5api',
|
// host: 'h5api',
|
||||||
// #endif
|
// #endif
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
host: 'http://91f.xyz:8080',
|
// host: 'http://91f.xyz:8080',
|
||||||
// host: 'https://b433d23.r24.cpolar.top/',
|
host: 'https://b433d23.r24.cpolar.top/',
|
||||||
// host: 'http://hvw2rn.natappfree.cc',
|
// host: 'http://hvw2rn.natappfree.cc',
|
||||||
// #endif
|
// #endif
|
||||||
// 支付方式配置
|
// 支付方式配置
|
||||||
|
|
|
@ -132,6 +132,9 @@
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 未读数量
|
||||||
|
const noReadNum = ref(0)
|
||||||
|
|
||||||
// 加载完成之后
|
// 加载完成之后
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 开启监听
|
// 开启监听
|
||||||
|
@ -145,6 +148,9 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// proxy.$refs.alert.open()
|
// proxy.$refs.alert.open()
|
||||||
|
|
||||||
|
// 获取未读消息数量
|
||||||
|
getNoReadNum()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 卸载
|
// 卸载
|
||||||
|
@ -203,6 +209,23 @@
|
||||||
//
|
//
|
||||||
proxy.$refs.alert.close()
|
proxy.$refs.alert.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取未读消息数量
|
||||||
|
function getNoReadNum() {
|
||||||
|
// 验证sdk是否准备完毕
|
||||||
|
let isReady = uni.$chat.isReady();
|
||||||
|
if (!isReady) {
|
||||||
|
setTimeout(function () {
|
||||||
|
getNoReadNum();
|
||||||
|
}, 800);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const unreadCount = uni.$chat.getTotalUnreadMessageCount();
|
||||||
|
|
||||||
|
noReadNum.value = +unreadCount > 99 ? '99+' : unreadCount;
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -215,6 +238,7 @@
|
||||||
|
|
||||||
<view class="option" :class="{ active: item.page === page }" v-if="item.type == 'option'">
|
<view class="option" :class="{ active: item.page === page }" v-if="item.type == 'option'">
|
||||||
<text class="text">{{ item.name }}</text>
|
<text class="text">{{ item.name }}</text>
|
||||||
|
<span class="pot" v-if="item.page == 'news' && noReadNum != 0">{{ noReadNum }}</span>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="middle" v-else-if="item.type === 'middle'">
|
<view class="middle" v-else-if="item.type === 'middle'">
|
||||||
|
@ -319,6 +343,25 @@
|
||||||
.text {
|
.text {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.option {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.pot {
|
||||||
|
position: absolute;
|
||||||
|
top: -16rpx;
|
||||||
|
right: -30rpx;
|
||||||
|
height: 24rpx;
|
||||||
|
min-width: 24rpx;
|
||||||
|
line-height: 24rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
background: #FF6B17;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 20rpx;
|
||||||
|
padding: 4rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.middle {
|
.middle {
|
||||||
|
|
|
@ -54,17 +54,32 @@ const systemRightOption = [{
|
||||||
backgroundColor: '#00ADEE'
|
backgroundColor: '#00ADEE'
|
||||||
},
|
},
|
||||||
},]
|
},]
|
||||||
|
// 传入参数
|
||||||
|
const props = defineProps({
|
||||||
|
// 类型
|
||||||
|
type: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// 用户列表
|
// 用户列表
|
||||||
const list = reactive([])
|
const list = reactive([])
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (props.type == 0) {
|
||||||
getList()
|
getList()
|
||||||
|
} else if(props.type == 1) {
|
||||||
|
// 视频消息
|
||||||
|
} else if (props.type == 2) {
|
||||||
|
// 商城消息
|
||||||
|
}
|
||||||
|
|
||||||
addListener()
|
addListener()
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
removeListener()
|
// removeListener()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 开启监听消息
|
// 开启监听消息
|
||||||
|
@ -81,7 +96,7 @@ function removeListener() {
|
||||||
uni.$chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED);
|
uni.$chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取朋友列表
|
// 获取消息列表
|
||||||
function getList() {
|
function getList() {
|
||||||
api.news.getMessageList({
|
api.news.getMessageList({
|
||||||
query: {
|
query: {
|
||||||
|
@ -97,6 +112,17 @@ function getList() {
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// // 验证sdk是否准备完毕
|
||||||
|
// let isReady = uni.$chat.isReady();
|
||||||
|
// if (!isReady) {
|
||||||
|
// setTimeout(function () {
|
||||||
|
// getList();
|
||||||
|
// }, 1000);
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// uni.$chat.getMessageList({})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +170,7 @@ function getGroupNoReadNum(groupId) {
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
getGroupNoReadNum(groupId);
|
getGroupNoReadNum(groupId);
|
||||||
}, 200);
|
}, 800);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +213,8 @@ function handleChat(item) {
|
||||||
param.msgId = `${item.groupId}`
|
param.msgId = `${item.groupId}`
|
||||||
param.num = `${item.groupChatDTO.memberCount}`
|
param.num = `${item.groupChatDTO.memberCount}`
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
setRead(item)
|
||||||
util.toChat(param)
|
util.toChat(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +236,7 @@ function delMsg(item) {
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
delMsg(item);
|
delMsg(item);
|
||||||
}, 200);
|
}, 800);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +254,7 @@ function setRead(item) {
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setRead(item);
|
setRead(item);
|
||||||
}, 200);
|
}, 800);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +324,7 @@ function setRead(item) {
|
||||||
|
|
||||||
<uni-swipe-action-item :right-options="rightOption" v-for="(item, index) in list.data" :key="index"
|
<uni-swipe-action-item :right-options="rightOption" v-for="(item, index) in list.data" :key="index"
|
||||||
@click="handleMenu($event, item)">
|
@click="handleMenu($event, item)">
|
||||||
<view class="item rows ptb20 plr30" @click="handleChat(item)">
|
<view class="item rows ptb20 plr30" @click.stop="handleChat(item)">
|
||||||
<view class="image wh90 pr">
|
<view class="image wh90 pr">
|
||||||
<template v-if="item.groupId == null">
|
<template v-if="item.groupId == null">
|
||||||
<image class="cir wh90" :src="item.callbackJson.from_url" mode="aspectFill" />
|
<image class="cir wh90" :src="item.callbackJson.from_url" mode="aspectFill" />
|
||||||
|
|
|
@ -33,14 +33,14 @@
|
||||||
// vuex
|
// vuex
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
// 菜单列表
|
// 菜单列表
|
||||||
const menuList = reactive([{
|
const menuList = reactive([
|
||||||
key: 'friend',
|
|
||||||
name: '通讯录',
|
|
||||||
load: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'group',
|
key: 'group',
|
||||||
name: '即时消息',
|
name: '即时消息',
|
||||||
|
load: true,
|
||||||
|
}, {
|
||||||
|
key: 'friend',
|
||||||
|
name: '通讯录',
|
||||||
load: false,
|
load: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@
|
||||||
name: '视讯消息',
|
name: '视讯消息',
|
||||||
load: false,
|
load: false,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// key: 'video',
|
key: 'store',
|
||||||
// name: '商城消息',
|
name: '商城消息',
|
||||||
// load: false,
|
load: false,
|
||||||
// },
|
},
|
||||||
])
|
])
|
||||||
// 菜单下标
|
// 菜单下标
|
||||||
const menuIndex = ref('')
|
const menuIndex = ref('')
|
||||||
|
@ -103,8 +103,11 @@
|
||||||
*/
|
*/
|
||||||
function handleMenuIndex(index) {
|
function handleMenuIndex(index) {
|
||||||
if (menuIndex.value === index) return
|
if (menuIndex.value === index) return
|
||||||
|
menuList.forEach(item => {
|
||||||
|
item.load = false;
|
||||||
|
});
|
||||||
|
menuList[index].load = true;
|
||||||
menuIndex.value = index
|
menuIndex.value = index
|
||||||
if (!menuList[index].load) menuList[index].load = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开菜单
|
// 打开菜单
|
||||||
|
@ -194,27 +197,27 @@
|
||||||
|
|
||||||
<!-- 轮播图 -->
|
<!-- 轮播图 -->
|
||||||
<swiper class="swiper" :current="menuIndex" disable-touch="true">
|
<swiper class="swiper" :current="menuIndex" disable-touch="true">
|
||||||
<!-- 通讯录 -->
|
<!-- 群组 -->
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<book v-if="menuList[0].load" />
|
<msgList v-if="menuList[0].load" :type="menuIndex" />
|
||||||
<view class="loading" v-else>正在加载</view>
|
<view class="loading" v-else>正在加载</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
|
|
||||||
<!-- 群组 -->
|
<!-- 通讯录 -->
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<msgList v-if="menuList[1].load" />
|
<book v-if="menuList[1].load" />
|
||||||
<view class="loading" v-else>正在加载</view>
|
<view class="loading" v-else>正在加载</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
|
|
||||||
<!-- 视频消息 -->
|
<!-- 视频消息 -->
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<msgList v-if="menuList[2].load" />
|
<msgList v-if="menuList[2].load" :type="menuIndex" />
|
||||||
<view class="loading" v-else>正在加载</view>
|
<view class="loading" v-else>正在加载</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
|
|
||||||
<!-- 商城消息 -->
|
<!-- 商城消息 -->
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<msgList />
|
<msgList v-if="menuList[3].load" :type="menuIndex" />
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</swiper>
|
</swiper>
|
||||||
</view>
|
</view>
|
||||||
|
|
Loading…
Reference in New Issue