From 28843fa3d38656f88935571b841788f91e5cee0c Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Tue, 11 Feb 2025 09:34:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jiuyi2/api/team.js | 13 ++++--- jiuyi2/common/js/config.js | 4 +-- jiuyi2/components/news/book.vue | 62 ++++++++++++++++++++++++++------- jiuyi2/manifest.json | 4 +-- jiuyi2/pages/index/myTeam.vue | 48 ++++++++++++++++++++++++- jiuyi2/pages/login/invite.vue | 4 --- jiuyi2/pages/login/register.vue | 4 --- jiuyi2/pages/news/news.vue | 13 +++---- jiuyi2/readme.md | 5 +++ jiuyi2/vite.config.js | 4 +-- 10 files changed, 123 insertions(+), 38 deletions(-) diff --git a/jiuyi2/api/team.js b/jiuyi2/api/team.js index 7d485e98..9fabec0d 100644 --- a/jiuyi2/api/team.js +++ b/jiuyi2/api/team.js @@ -7,7 +7,7 @@ const team = { * 我的团队 * @param {Object} param */ - myTeam(param = {}) { + myTeam(param) { return util.request({ url: `/user/team/get`, query: param, @@ -15,11 +15,16 @@ const team = { }) }, - lowTeam(param) { + /** + * 修改我的上级推荐人 + * @param {Object} param + */ + updateReferrer(param) { return util.request({ - url: `/home/lowTeam`, - method: 'post', + url: `/user/user/updateReferrer`, query: param.query, + method: 'PUT', + load: true, }) }, } diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index a9af306b..9ef496fa 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -7,8 +7,8 @@ const config = { // #endif // #ifndef H5 host: 'http://91f.xyz:8080', - // host: 'http://ybfhhn.natappfree.cc', - // host: 'http://hnjcg2.natappfree.cc', + // host: 'http://22vn9z.natappfree.cc', + // host: 'https://63fdb472.r24.cpolar.top', // #endif // 支付方式配置 payType: { diff --git a/jiuyi2/components/news/book.vue b/jiuyi2/components/news/book.vue index 17eeed78..f32387a7 100644 --- a/jiuyi2/components/news/book.vue +++ b/jiuyi2/components/news/book.vue @@ -21,6 +21,9 @@ // api import api from '@/api/index.js' import pinyin from 'js-pinyin' + import { + forEach + } from 'lodash'; const { proxy } = getCurrentInstance(); @@ -198,14 +201,15 @@ function addlistener() { let onFriendListUpdated = (event) => { console.log('onFriendListUpdated', event.data); + getFriendList() } - uni.$chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, onFriendListUpdated); + uni.$chat.on(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED, onFriendListUpdated); } // 移除加好友监听 function removelistener() { - uni.$chat.off(TencentCloudChat.EVENT.MESSAGE_RECEIVED); + uni.$chat.off(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED); } // 获取朋友列表 @@ -220,21 +224,12 @@ return } + // api.news.getFriendList().then(rs => { if (rs.code == 200) { const result = rs.data userList.data.length = 0 - // - userList.data.push(...result.map(item => { - // 取拼音 - let char = pinyin.getCamelChars(item.remark || item.userNickname); - return { - key: char.charAt(0), - letter: char.charAt(0), - child: [item] - } - })) - console.log('userList', userList.data) + userList.data = handleUserList(result) return } util.alert({ @@ -244,6 +239,47 @@ }) } + /** + * 用户列表排序 + * @param {Object} userList + */ + function handleUserList(userList) { + // 筛选后的用户列表 + const userArr = [] + // 遍历用户列表 + for (let i = 0; i < userList.length; i++) { + const user = userList[i] + // 取拼音 + let char = pinyin.getCamelChars(user.remark || user.userNickname); + // 假设姓名的第一个字符为姓氏 + const letter = char.charAt(0) + // 下标 + let find_index = userArr.findIndex(item => { + return item.key === letter + }) + + // 未找到追加整过数组 找到追加到子数组 + if (find_index == -1) { + userArr.push({ + letter: letter, + key: letter, + child: [user] + }) + } else { + userArr[find_index].child.push(user) + } + } + + // 按照姓氏的字典序对二维数组进行排序 + // userArr.sort((a, b) => { + // const surnameA = a.key; + // const surnameB = b.key; + // return surnameA.localeCompare(surnameB); + // }); + return userArr; + } + + // 获取 function getLetterProperty() { const query = uni.createSelectorQuery().in(proxy); diff --git a/jiuyi2/manifest.json b/jiuyi2/manifest.json index 578b80ac..67c19413 100644 --- a/jiuyi2/manifest.json +++ b/jiuyi2/manifest.json @@ -2,8 +2,8 @@ "name" : "九亿", "appid" : "__UNI__08B31BC", "description" : "", - "versionName" : "1.0.3", - "versionCode" : 1003, + "versionName" : "1.0.4", + "versionCode" : 1004, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/jiuyi2/pages/index/myTeam.vue b/jiuyi2/pages/index/myTeam.vue index c20ec567..23d8bee8 100644 --- a/jiuyi2/pages/index/myTeam.vue +++ b/jiuyi2/pages/index/myTeam.vue @@ -37,6 +37,10 @@ const team = ref({}) // 展示我的团队 const showTeam = ref(false) + // 是否显示修改 + const editTigger = ref(false) + // 修改值 + const edit = ref('') onLoad(() => { myQrcode() @@ -68,6 +72,28 @@ qrData.value = `data:image/png;base64, ${uni.arrayBufferToBase64(rs)}` }) } + + // 修改上级推荐人 + function updateReferrer() { + api.team.updateReferrer({ + query: { + invitationCode: edit.value, + }, + }).then(rs => { + if (rs.code == 200) { + // + edit.value = '' + editTigger.value = false + // + myTeam() + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + }