diff --git a/jiuyi2/api/news.js b/jiuyi2/api/news.js index 239fe08c..b6611e7a 100644 --- a/jiuyi2/api/news.js +++ b/jiuyi2/api/news.js @@ -127,6 +127,13 @@ export const news = { method: 'POST', query: param }) + }, + //获取好友列表 + getFriendList() { + return util.request({ + url: `/user/chat/relation/myFriends`, + method: 'GET' + }) } } diff --git a/jiuyi2/pages/news/news.vue b/jiuyi2/pages/news/news.vue index c141f0ba..0505be54 100644 --- a/jiuyi2/pages/news/news.vue +++ b/jiuyi2/pages/news/news.vue @@ -28,7 +28,11 @@ // 底部菜单 import footerMneu from '@/components/footerMenu/footerMenu' import videoApi from '@/api/video.js'; - // vuex + // 工具库 + import util from '@/common/js/util.js' + // api + import newsApi from '@/api/news.js' + // vuex const store = useStore() // 菜单列表 const menuList = reactive([{ @@ -72,16 +76,35 @@ handleMenuIndex(2) }) - /** - * 切换下标 - * @param {Number} index - */ - function handleMenuIndex(index) { - if (menuIndex.value === index) return - menuIndex.value = index - if (!menuList[index].load) menuList[index].load = true - } - + /** + * 切换下标 + * @param {Number} index + */ + function handleMenuIndex(index) { + if (menuIndex.value === index) return + menuIndex.value = index + if (!menuList[index].load) menuList[index].load = true + // 点击通讯录时调用获取好友列表的函数 + if (index === 0) { + getFriends(); + } + } + const viewData = ref([]) + // 获取好友列表 + function getFriends() { + newsApi.getFriendList().then(response => { + if (response.success) { + viewData.value = response.data; + // 这里可以将好友列表传递给book组件进行展示 + console.log('好友列表:', viewData.value); + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } // 打开菜单 function showActionSheet() { uni.showActionSheet({ @@ -199,7 +222,7 @@