10
This commit is contained in:
@@ -0,0 +1,367 @@
|
||||
<template>
|
||||
<view class="contact_choose_container">
|
||||
<custom-nav-bar title="联系人">
|
||||
<view slot="more" style="margin-right: 10rpx;">
|
||||
<u-button type="primary" @click="confirm" :disabled="!isConfirmEnable">确定</u-button>
|
||||
</view>
|
||||
</custom-nav-bar>
|
||||
|
||||
<view class="search_bar_wrap">
|
||||
<u-search shape="square" placeholder="搜索" :showAction="false" v-model="keyword" />
|
||||
</view>
|
||||
|
||||
<view class="tab_container">
|
||||
<template v-if="activeTab === 0">
|
||||
<setting-item @click="tabChange(tabs[0].idx)" :title="tabs[0].title" :border="false" />
|
||||
<view class="tab_pane">
|
||||
<template v-for="cell in conversationList">
|
||||
<template v-if="cell.groupID">
|
||||
<user-item
|
||||
v-if="allowGroup"
|
||||
@itemClick="updateCheckedUserOrGroup"
|
||||
@updateCheck="updateCheckedUserOrGroup"
|
||||
:checked="checkedGroupIDList.includes(cell.groupID)"
|
||||
:disabled="disabledGroupIDList.includes(cell.groupID)"
|
||||
:checkVisible="muitple"
|
||||
:item="cell" :key="cell.groupID" />
|
||||
</template>
|
||||
<template v-if="cell.userID">
|
||||
<user-item
|
||||
@itemClick="updateCheckedUserOrGroup"
|
||||
@updateCheck="updateCheckedUserOrGroup"
|
||||
:checked="checkedUserIDList.includes(cell.userID)"
|
||||
:disabled="disabledUserIDList.includes(cell.userID)"
|
||||
:checkVisible="muitple"
|
||||
:item="cell" :key="cell.userID" />
|
||||
</template>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<view class="tab_pane" v-show="activeTab === 1">
|
||||
<choose-index-list
|
||||
@updateCheck="updateCheckedUser"
|
||||
:indexList="getChooseData.indexList"
|
||||
:itemArr="getChooseData.dataList"
|
||||
:checkedIDList="checkedUserIDList"
|
||||
:disabledIDList="disabledUserIDList"
|
||||
:showCheck="muitple" />
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters} from "vuex";
|
||||
import {ContactChooseTypes} from "@/constant";
|
||||
import {formatChooseData,toastWithCallback} from "@/util/common";
|
||||
import IMSDK from "openim-uniapp-polyfill";
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import UserItem from "@/components/UserItem/index.vue";
|
||||
import ChooseIndexList from "@/components/ChooseIndexList/index.vue";
|
||||
import ChooseIndexFooter from "@/components/ChooseIndexFooter/index.vue";
|
||||
import SettingItem from "@/components/SettingItem/index.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
UserItem,
|
||||
ChooseIndexList,
|
||||
ChooseIndexFooter,
|
||||
SettingItem,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: "",
|
||||
type: ContactChooseTypes.Card,
|
||||
activeTab: 0,
|
||||
groupID: "",
|
||||
checkedUserIDList: [],
|
||||
disabledUserIDList: [],
|
||||
checkedGroupIDList: [],
|
||||
disabledGroupIDList: [],
|
||||
comfirmLoading: false,
|
||||
tabs: [
|
||||
{
|
||||
idx: 1,
|
||||
title: "我的好友",
|
||||
},
|
||||
],
|
||||
muitple:true,
|
||||
allowGroup:true,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
"storeFriendList",
|
||||
"storeCurrentConversation",
|
||||
"storeCurrentUserID",
|
||||
"storeConversationList",
|
||||
]),
|
||||
getChooseData() {
|
||||
if (this.keyword) {
|
||||
return {
|
||||
indexList: ["#"],
|
||||
dataList: [
|
||||
this.storeFriendList.filter(
|
||||
(friend) =>
|
||||
friend.nickname.includes(this.keyword) ||
|
||||
friend.remark.includes(this.keyword)
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
return formatChooseData(this.storeFriendList);
|
||||
},
|
||||
|
||||
conversationList(){
|
||||
const _this = this;
|
||||
let list = [...this.storeConversationList];
|
||||
if(this.keyword){
|
||||
list = list.filter((item)=>{77
|
||||
return item.showName.indexOf(_this.kw)>-1 || item.userID.indexOf(_this.kw)>-1 || item.groupID.indexOf(_this.kw)>-1
|
||||
})
|
||||
}
|
||||
return list;
|
||||
},
|
||||
getCheckedUserInfo() {
|
||||
const tmpUserIDList = [...this.checkedUserIDList];
|
||||
const checkedFriends = this.storeFriendList.filter((friend) => {
|
||||
const idx = tmpUserIDList.findIndex(
|
||||
(userID) => userID === friend.userID
|
||||
);
|
||||
if (idx > -1) {
|
||||
tmpUserIDList.splice(idx, 1);
|
||||
}
|
||||
return idx > -1;
|
||||
});
|
||||
return [...checkedFriends];
|
||||
},
|
||||
getCheckedGroupInfo() {
|
||||
const tmpGroupIDList = [...this.checkedGroupIDList];
|
||||
const checkedGroups = this.storeConversationList.filter((item) => {
|
||||
const idx = tmpGroupIDList.findIndex(
|
||||
(groupID) => groupID === item.groupID
|
||||
);
|
||||
if (idx > -1) {
|
||||
tmpGroupIDList.splice(idx, 1);
|
||||
}
|
||||
return idx > -1;
|
||||
});
|
||||
return [...checkedGroups];
|
||||
},
|
||||
isConfirmEnable(){
|
||||
if(this.checkedUserIDList.length){
|
||||
return true;
|
||||
}
|
||||
if(this.allowGroup){
|
||||
if(this.checkedGroupIDList.length){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
const {groupID,type,checkedUserIDList,muitple} = options;
|
||||
this.type = type;
|
||||
this.groupID = groupID;
|
||||
if(muitple){
|
||||
this.muitple = muitple;
|
||||
}
|
||||
//this.muitple = true;
|
||||
this.checkedUserIDList = checkedUserIDList ? JSON.parse(checkedUserIDList) : [];
|
||||
//console.log(this.checkedUserIDList);
|
||||
//console.log(this.groupID);
|
||||
//console.log(this.muitple);
|
||||
//console.log(this.type);
|
||||
if (this.type === ContactChooseTypes.Invite) {
|
||||
this.allowGroup = false;
|
||||
this.checkDisabledUser();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkDisabledUser() {
|
||||
const friendIDList = this.storeFriendList.map((friend) => friend.userID);
|
||||
IMSDK.asyncApi("getUsersInGroup", IMSDK.uuid(), {
|
||||
groupID: this.groupID,
|
||||
userIDList: friendIDList,
|
||||
}).then(({data}) => {
|
||||
this.disabledUserIDList = data;
|
||||
});
|
||||
},
|
||||
tabChange(idx) {
|
||||
this.keyword = "";
|
||||
this.activeTab = idx;
|
||||
},
|
||||
updateCheckedUserOrGroup(item) {
|
||||
if (item.userID) {
|
||||
this.updateCheckedUser(item);
|
||||
}
|
||||
if (item.groupID) {
|
||||
this.updateCheckedGroup(item);
|
||||
}
|
||||
},
|
||||
updateCheckedGroup({groupID}) {
|
||||
if(!this.muitple){
|
||||
this.checkedGroupIDList = [groupID];
|
||||
this.confirm();
|
||||
}else{
|
||||
if (this.checkedGroupIDList.includes(groupID)) {
|
||||
const idx = this.checkedGroupIDList.findIndex((item) => item === groupID);
|
||||
const tmpArr = [...this.checkedGroupIDList];
|
||||
tmpArr.splice(idx, 1);
|
||||
this.checkedGroupIDList = [...tmpArr];
|
||||
} else {
|
||||
this.checkedGroupIDList = [...this.checkedGroupIDList, groupID];
|
||||
}
|
||||
}
|
||||
},
|
||||
updateCheckedUser({userID}) {
|
||||
if(!this.muitple){
|
||||
this.checkedUserIDList = [userID];
|
||||
this.confirm();
|
||||
}else{
|
||||
if (this.checkedUserIDList.includes(userID)) {
|
||||
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
|
||||
const tmpArr = [...this.checkedUserIDList];
|
||||
tmpArr.splice(idx, 1);
|
||||
this.checkedUserIDList = [...tmpArr];
|
||||
} else {
|
||||
this.checkedUserIDList = [...this.checkedUserIDList, userID];
|
||||
}
|
||||
}
|
||||
},
|
||||
confirm() {
|
||||
//console.log(this.checkedUserIDList,this.checkedGroupIDList);
|
||||
//return false;
|
||||
// if (this.activeTab) {
|
||||
// this.activeTab = 0;
|
||||
// return;
|
||||
// }
|
||||
this.comfirmLoading = true;
|
||||
if (this.type === ContactChooseTypes.GetList || this.type === ContactChooseTypes.ShareCard) {
|
||||
try{
|
||||
let pages = getCurrentPages();
|
||||
let prevPage = pages[pages.length - 2];
|
||||
if(prevPage.$vm.getCheckedUsers){
|
||||
prevPage.$vm.getCheckedUsers(this.getCheckedUserInfo,this.getCheckedGroupInfo);
|
||||
}else{
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.emit('onSelectedConfirm', this.getCheckedUserInfo,this.getCheckedGroupInfo);
|
||||
}
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
this.comfirmLoading = false;
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.type === ContactChooseTypes.Invite) {
|
||||
IMSDK.asyncApi(IMSDK.IMMethods.InviteUserToGroup, IMSDK.uuid(), {
|
||||
groupID: this.groupID,
|
||||
reason: "",
|
||||
userIDList: this.getCheckedUserInfo.map((user) => user.userID),
|
||||
})
|
||||
.then(() => {
|
||||
toastWithCallback("操作成功", () => uni.navigateBack());
|
||||
this.comfirmLoading = false;
|
||||
})
|
||||
.catch(() => toastWithCallback("操作失败"));
|
||||
return;
|
||||
}
|
||||
|
||||
this.comfirmLoading = false;
|
||||
},
|
||||
},
|
||||
onBackPress() {
|
||||
if (this.activeTab) {
|
||||
this.activeTab = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep.u-popup {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.contact_choose_container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.search_bar_wrap {
|
||||
height: 34px;
|
||||
padding: 12px 22px;
|
||||
}
|
||||
|
||||
.tab_container {
|
||||
@include colBox(false);
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
|
||||
.setting_item {
|
||||
padding: 32rpx 36rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
// padding: 16rpx 8rpx;
|
||||
background: #f8f9fa;
|
||||
color: #8e9ab0;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.tabs_bar {
|
||||
@include vCenterBox();
|
||||
justify-content: space-evenly;
|
||||
|
||||
.tab_item {
|
||||
@include colBox(false);
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab_pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
|
||||
.member_list {
|
||||
flex: 1;
|
||||
height: 80% !important;
|
||||
|
||||
::v-deepuni-scroll-view {
|
||||
max-height: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.user_list {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.member_anchor {
|
||||
background-color: #f8f8f8 !important;
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -9,8 +9,14 @@
|
||||
<view class="tab_container">
|
||||
<template v-if="activeTab === 0">
|
||||
<setting-item @click="tabChange(tabs[0].idx)" :title="tabs[0].title" :border="false" />
|
||||
|
||||
<view class="tab_pane"></view>
|
||||
<view class="tab_pane">
|
||||
<user-item
|
||||
@updateCheck="updateCheckedUser"
|
||||
:checked="checkedUserIDList.includes(cell.userID)"
|
||||
:disabled="disabledUserIDList.includes(cell.userID)"
|
||||
:checkVisible="true"
|
||||
v-for="cell in storeConversationList" :item="cell" :key="cell.userID" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
@@ -21,7 +27,7 @@
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<choose-index-footer :comfirmLoading="comfirmLoading" @removeItem="updateCheckedUserOrGroup" @confirm="confirm"
|
||||
<choose-index-footer v-show="limit != 1" :comfirmLoading="comfirmLoading" @removeItem="updateCheckedUserOrGroup" @confirm="confirm"
|
||||
:choosedData="getCheckedInfo" />
|
||||
</view>
|
||||
</template>
|
||||
@@ -60,6 +66,7 @@
|
||||
title: "我的好友",
|
||||
},
|
||||
],
|
||||
limit:0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -99,16 +106,17 @@
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
const {groupID,type,checkedUserIDList,} = options;
|
||||
console.log(this.storeFriendList);
|
||||
const {groupID,type,checkedUserIDList,limit} = options;
|
||||
//console.log(this.storeFriendList);
|
||||
this.type = type;
|
||||
this.groupID = groupID;
|
||||
this.checkedUserIDList = checkedUserIDList ?
|
||||
JSON.parse(checkedUserIDList) :
|
||||
[];
|
||||
this.checkedUserIDList = checkedUserIDList ? JSON.parse(checkedUserIDList) : [];
|
||||
if (this.type === ContactChooseTypes.Invite) {
|
||||
this.checkDisabledUser();
|
||||
}
|
||||
if(limit){
|
||||
this.limit = limit;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkDisabledUser() {
|
||||
@@ -131,16 +139,19 @@
|
||||
this.updateCheckedUser(item);
|
||||
}
|
||||
},
|
||||
updateCheckedUser({
|
||||
userID
|
||||
}) {
|
||||
if (this.checkedUserIDList.includes(userID)) {
|
||||
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
|
||||
const tmpArr = [...this.checkedUserIDList];
|
||||
tmpArr.splice(idx, 1);
|
||||
this.checkedUserIDList = [...tmpArr];
|
||||
} else {
|
||||
this.checkedUserIDList = [...this.checkedUserIDList, userID];
|
||||
updateCheckedUser({userID}) {
|
||||
if(this.limit == 1){
|
||||
this.checkedUserIDList = [userID];
|
||||
this.confirm();
|
||||
}else{
|
||||
if (this.checkedUserIDList.includes(userID)) {
|
||||
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
|
||||
const tmpArr = [...this.checkedUserIDList];
|
||||
tmpArr.splice(idx, 1);
|
||||
this.checkedUserIDList = [...tmpArr];
|
||||
} else {
|
||||
this.checkedUserIDList = [...this.checkedUserIDList, userID];
|
||||
}
|
||||
}
|
||||
},
|
||||
confirm() {
|
||||
@@ -215,7 +226,7 @@
|
||||
.title {
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
justify-content: start;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
// padding: 16rpx 8rpx;
|
||||
background: #f8f9fa;
|
||||
|
||||
@@ -88,9 +88,7 @@ export default {
|
||||
(member) => member.userID,
|
||||
);
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/contactChoose/index?type=${
|
||||
ContactChooseTypes.GetList
|
||||
}&checkedUserIDList=${JSON.stringify(checkedIDList)}`,
|
||||
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.GetList}&checkedUserIDList=${JSON.stringify(checkedIDList)}`,
|
||||
});
|
||||
},
|
||||
complateCreate() {
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
const info = JSON.parse(sourceInfo);
|
||||
this.sourceID = info.userID;
|
||||
}
|
||||
//console.log(this.storeSelfInfo);
|
||||
this.getSourceUserInfo();
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user