7
This commit is contained in:
@@ -1,246 +1,235 @@
|
||||
<template>
|
||||
<view @click="clickItem" class="application_item">
|
||||
<my-avatar
|
||||
:src="getAvatarUrl"
|
||||
:isGroup="isGroupApplication"
|
||||
:desc="application[isRecv ? 'fromNickname' : 'toNickname']"
|
||||
size="42"
|
||||
/>
|
||||
<view class="application_item_details">
|
||||
<view class="content">
|
||||
<text class="user_name">{{ getShowName }}</text>
|
||||
<view @click="clickItem" class="application_item">
|
||||
<my-avatar :src="getAvatarUrl" :isGroup="isGroupApplication"
|
||||
:desc="application[isRecv ? 'fromNickname' : 'toNickname']" size="42" />
|
||||
<view class="application_item_details">
|
||||
<view class="content">
|
||||
<text class="user_name">{{ getShowName }}</text>
|
||||
|
||||
<view v-if="isGroupApplication" class="title">
|
||||
申请加入
|
||||
<text class="group_name">{{ application.groupName }}</text>
|
||||
</view>
|
||||
<text class="req_message">{{ application.reqMsg }}</text>
|
||||
</view>
|
||||
<view v-if="isGroupApplication" class="title">
|
||||
申请加入
|
||||
<text class="group_name">{{ application.groupName }}</text>
|
||||
</view>
|
||||
<text class="req_message">{{ application.reqMsg }}</text>
|
||||
</view>
|
||||
|
||||
<view class="application_action">
|
||||
<text v-if="showStateStr" class="status_tip">{{ getStateStr }}</text>
|
||||
<text v-if="showGreet" @tap.stop="greetToUser" class="status_tip greet"
|
||||
>打招呼</text
|
||||
>
|
||||
<button
|
||||
:loading="accessLoading"
|
||||
v-if="showAccept"
|
||||
class="access_btn"
|
||||
@tap.stop="acceptApplication"
|
||||
type="primary"
|
||||
:plain="true"
|
||||
size="mini"
|
||||
>
|
||||
{{ isGroupApplication ? "同意" : "接受" }}
|
||||
</button>
|
||||
</view>
|
||||
<view class="application_action">
|
||||
<text v-if="showStateStr" class="status_tip">{{ getStateStr }}</text>
|
||||
<text v-if="showGreet" @tap.stop="greetToUser" class="status_tip greet">打招呼</text>
|
||||
<button :loading="accessLoading" v-if="showAccept" class="access_btn" @tap.stop="acceptApplication"
|
||||
type="primary" :plain="true" size="mini">
|
||||
{{ isGroupApplication ? "同意" : "接受" }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="bottom_line"> </view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom_line"> </view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { navigateToDesignatedConversation } from "@/util/imCommon";
|
||||
import IMSDK, { SessionType } from "openim-uniapp-polyfill";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
export default {
|
||||
name: "ApplicationItem",
|
||||
components: {
|
||||
MyAvatar,
|
||||
},
|
||||
props: {
|
||||
application: Object,
|
||||
isRecv: Boolean,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accessLoading: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isGroupApplication() {
|
||||
return this.application.groupID !== undefined;
|
||||
},
|
||||
getShowName() {
|
||||
if (this.isRecv) {
|
||||
return this.application[
|
||||
this.isGroupApplication ? "nickname" : "fromNickname"
|
||||
];
|
||||
}
|
||||
return this.application[
|
||||
this.isGroupApplication ? "groupName" : "toNickname"
|
||||
];
|
||||
},
|
||||
showGreet() {
|
||||
return !this.isGroupApplication && this.application.handleResult === 1;
|
||||
},
|
||||
showStateStr() {
|
||||
if (
|
||||
(this.isRecv && this.application.handleResult === 0) ||
|
||||
this.showGreet
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
showAccept() {
|
||||
return this.application.handleResult === 0 && this.isRecv;
|
||||
},
|
||||
getStateStr() {
|
||||
if (this.application.handleResult === -1) {
|
||||
return "已拒绝";
|
||||
}
|
||||
if (this.application.handleResult === 0) {
|
||||
return "等待验证";
|
||||
}
|
||||
return "已同意";
|
||||
},
|
||||
getAvatarUrl() {
|
||||
if (this.isGroupApplication) {
|
||||
return this.application.groupFaceURL;
|
||||
}
|
||||
return this.application[this.isRecv ? "fromFaceURL" : "toFaceURL"];
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickItem() {
|
||||
if (this.showAccept) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/contact/applicationDetails/index?application=${JSON.stringify(
|
||||
import {
|
||||
navigateToDesignatedConversation
|
||||
} from "@/util/imCommon";
|
||||
import IMSDK, {
|
||||
SessionType
|
||||
} from "openim-uniapp-polyfill";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
export default {
|
||||
name: "ApplicationItem",
|
||||
components: {
|
||||
MyAvatar,
|
||||
},
|
||||
props: {
|
||||
application: Object,
|
||||
isRecv: Boolean,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accessLoading: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isGroupApplication() {
|
||||
return this.application.groupID !== undefined;
|
||||
},
|
||||
getShowName() {
|
||||
if (this.isRecv) {
|
||||
return this.application[
|
||||
this.isGroupApplication ? "nickname" : "fromNickname"
|
||||
];
|
||||
}
|
||||
return this.application[
|
||||
this.isGroupApplication ? "groupName" : "toNickname"
|
||||
];
|
||||
},
|
||||
showGreet() {
|
||||
return !this.isGroupApplication && this.application.handleResult === 1;
|
||||
},
|
||||
showStateStr() {
|
||||
if (
|
||||
(this.isRecv && this.application.handleResult === 0) ||
|
||||
this.showGreet
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
showAccept() {
|
||||
return this.application.handleResult === 0 && this.isRecv;
|
||||
},
|
||||
getStateStr() {
|
||||
if (this.application.handleResult === -1) {
|
||||
return "已拒绝";
|
||||
}
|
||||
if (this.application.handleResult === 0) {
|
||||
return "等待验证";
|
||||
}
|
||||
return "已同意";
|
||||
},
|
||||
getAvatarUrl() {
|
||||
if (this.isGroupApplication) {
|
||||
return this.application.groupFaceURL;
|
||||
}
|
||||
return this.application[this.isRecv ? "fromFaceURL" : "toFaceURL"];
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickItem() {
|
||||
if (this.showAccept) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/contact/applicationDetails/index?application=${JSON.stringify(
|
||||
this.application,
|
||||
)}`,
|
||||
});
|
||||
} else {
|
||||
let sourceID =
|
||||
this.application.groupID ??
|
||||
(this.isRecv
|
||||
? this.application.fromUserID
|
||||
: this.application.toUserID);
|
||||
let cardType = this.isGroupApplication ? "groupCard" : "userCard";
|
||||
const url = `/pages/common/${cardType}/index?sourceID=${sourceID}`;
|
||||
uni.navigateTo({
|
||||
url,
|
||||
});
|
||||
}
|
||||
},
|
||||
acceptApplication() {
|
||||
this.accessLoading = true;
|
||||
let func;
|
||||
if (this.isGroupApplication) {
|
||||
func = IMSDK.asyncApi(
|
||||
IMSDK.IMMethods.AcceptGroupApplication,
|
||||
IMSDK.uuid(),
|
||||
{
|
||||
groupID: this.application.groupID,
|
||||
fromUserID: this.application.userID,
|
||||
handleMsg: "",
|
||||
},
|
||||
);
|
||||
} else {
|
||||
func = IMSDK.asyncApi(
|
||||
IMSDK.IMMethods.AcceptFriendApplication,
|
||||
IMSDK.uuid(),
|
||||
{
|
||||
toUserID: this.application.fromUserID,
|
||||
handleMsg: "",
|
||||
},
|
||||
);
|
||||
}
|
||||
func
|
||||
.then(() => uni.$u.toast("操作成功"))
|
||||
.catch(() => uni.$u.toast("操作失败"))
|
||||
.finally(() => (this.accessLoading = false));
|
||||
},
|
||||
greetToUser() {
|
||||
navigateToDesignatedConversation(
|
||||
this.application[this.isRecv ? "fromUserID" : "toUserID"],
|
||||
SessionType.Single,
|
||||
).catch(() => uni.$u.toast("获取会话信息失败"));
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
let sourceID =
|
||||
this.application.groupID ??
|
||||
(this.isRecv ?
|
||||
this.application.fromUserID :
|
||||
this.application.toUserID);
|
||||
let cardType = this.isGroupApplication ? "groupCard" : "userCard";
|
||||
const url = `/pages/common/${cardType}/index?sourceID=${sourceID}`;
|
||||
uni.navigateTo({
|
||||
url,
|
||||
});
|
||||
}
|
||||
},
|
||||
acceptApplication() {
|
||||
this.accessLoading = true;
|
||||
let func;
|
||||
if (this.isGroupApplication) {
|
||||
func = IMSDK.asyncApi(
|
||||
IMSDK.IMMethods.AcceptGroupApplication,
|
||||
IMSDK.uuid(), {
|
||||
groupID: this.application.groupID,
|
||||
fromUserID: this.application.userID,
|
||||
handleMsg: "",
|
||||
},
|
||||
);
|
||||
} else {
|
||||
func = IMSDK.asyncApi(
|
||||
IMSDK.IMMethods.AcceptFriendApplication,
|
||||
IMSDK.uuid(), {
|
||||
toUserID: this.application.fromUserID,
|
||||
handleMsg: "",
|
||||
},
|
||||
);
|
||||
}
|
||||
func
|
||||
.then(() => uni.$u.toast("操作成功"))
|
||||
.catch(() => uni.$u.toast("操作失败"))
|
||||
.finally(() => (this.accessLoading = false));
|
||||
},
|
||||
greetToUser() {
|
||||
navigateToDesignatedConversation(
|
||||
this.application[this.isRecv ? "fromUserID" : "toUserID"],
|
||||
SessionType.Single,
|
||||
).catch(() => uni.$u.toast("获取会话信息失败"));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.application_item {
|
||||
// @include vCenterBox();
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
padding: 24rpx 44rpx;
|
||||
color: $uni-text-color;
|
||||
background-color: #fff;
|
||||
.application_item {
|
||||
// @include vCenterBox();
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
padding: 24rpx 44rpx;
|
||||
color: $uni-text-color;
|
||||
background-color: #fff;
|
||||
|
||||
&_details {
|
||||
@include vCenterBox();
|
||||
margin-left: 24rpx;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
&_details {
|
||||
@include vCenterBox();
|
||||
margin-left: 24rpx;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
.content {
|
||||
@include colBox(false);
|
||||
font-size: 26rpx;
|
||||
width: 100%;
|
||||
.content {
|
||||
@include colBox(false);
|
||||
font-size: 26rpx;
|
||||
width: 100%;
|
||||
|
||||
.user_name {
|
||||
@include nomalEllipsis();
|
||||
max-width: 400rpx;
|
||||
font-size: 28rpx;
|
||||
color: $uni-text-color;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
.user_name {
|
||||
@include nomalEllipsis();
|
||||
max-width: 400rpx;
|
||||
font-size: 28rpx;
|
||||
color: $uni-text-color;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.req_message {
|
||||
@include ellipsisWithLine(2);
|
||||
max-width: 80%;
|
||||
color: #999;
|
||||
}
|
||||
.req_message {
|
||||
@include ellipsisWithLine(2);
|
||||
max-width: 80%;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-bottom: 20rpx;
|
||||
word-break: break-all;
|
||||
width: 75%;
|
||||
.title {
|
||||
margin-bottom: 20rpx;
|
||||
word-break: break-all;
|
||||
width: 75%;
|
||||
|
||||
.group_name {
|
||||
margin-left: 12rpx;
|
||||
color: $uni-color-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
.group_name {
|
||||
margin-left: 12rpx;
|
||||
color: $uni-color-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.application_action {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
.application_action {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
||||
.status_tip {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
.status_tip {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.access_btn {
|
||||
padding: 0 12rpx;
|
||||
height: 48rpx;
|
||||
line-height: 48rpx;
|
||||
}
|
||||
.access_btn {
|
||||
padding: 0 12rpx;
|
||||
height: 48rpx;
|
||||
line-height: 48rpx;
|
||||
}
|
||||
|
||||
.greet {
|
||||
color: #418ae5;
|
||||
}
|
||||
}
|
||||
.greet {
|
||||
color: #418ae5;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom_line {
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
background-color: #f0f0f0;
|
||||
position: absolute;
|
||||
bottom: -24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.bottom_line {
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
background-color: #f0f0f0;
|
||||
position: absolute;
|
||||
bottom: -24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.u-list-item:last-child {
|
||||
.bottom_line {
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
.u-list-item:last-child {
|
||||
.bottom_line {
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,93 +1,131 @@
|
||||
<template>
|
||||
<view class="friend_list_container">
|
||||
<custom-nav-bar title="我的好友" />
|
||||
<view class="search_bar_wrap">
|
||||
<u-search
|
||||
class="search_bar"
|
||||
shape="square"
|
||||
placeholder="搜索"
|
||||
:showAction="false"
|
||||
disabled
|
||||
/>
|
||||
</view>
|
||||
<view class="friend_list_container">
|
||||
<view class="header">
|
||||
<uni-nav-bar
|
||||
right-icon="plus"
|
||||
@clickRight="contactAddClick"
|
||||
:border="false"
|
||||
title="通讯录"
|
||||
backgroundColor="transparent"
|
||||
>
|
||||
</uni-nav-bar>
|
||||
<SearchbarPlace>搜索</SearchbarPlace>
|
||||
</view>
|
||||
<uni-list class="contact_menus">
|
||||
<uni-list-item title="新的好友" :showBadge="storeUnHandleFriendApplicationNum>0" :badgeText="storeUnHandleFriendApplicationNum+''" badgeType="error" thumbSize="lg" to="/pages/contact/applicationList/index?applicationType=NewFriend" thumb="/static/images/contact_new_friend.png"></uni-list-item>
|
||||
<uni-list-item title="新的群组" thumbSize="lg" to="/pages/contact/applicationList/index?applicationType=NewGroup" thumb="/static/images/contact_new_group.png"></uni-list-item>
|
||||
<uni-list-item title="群聊" thumbSize="lg" to="/pages/contact/groupList/index" thumb="/static/images/contact_my_group.png"></uni-list-item>
|
||||
</uni-list>
|
||||
|
||||
<choose-index-list
|
||||
v-if="getIndexData.dataList.length > 0"
|
||||
@itemClick="userClick"
|
||||
:height="`${listHeight}px`"
|
||||
:indexList="getIndexData.indexList"
|
||||
:itemArr="getIndexData.dataList"
|
||||
/>
|
||||
<u-empty v-else mode="list" />
|
||||
</view>
|
||||
<choose-index-list v-if="getIndexData.dataList.length > 0" @itemClick="userClick" :height="`${listHeight}px`"
|
||||
:indexList="getIndexData.indexList" :itemArr="getIndexData.dataList" />
|
||||
<u-empty v-else mode="list" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import { formatChooseData } from "@/util/common";
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import ChooseIndexList from "@/components/ChooseIndexList/index.vue";
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
ChooseIndexList,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: "",
|
||||
listHeight: 0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["storeFriendList"]),
|
||||
getIndexData() {
|
||||
return formatChooseData(this.storeFriendList);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getListHeight();
|
||||
},
|
||||
methods: {
|
||||
userClick(friend) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/userCard/index?sourceID=${friend.userID}`,
|
||||
});
|
||||
},
|
||||
async getListHeight() {
|
||||
const windowInfo = uni.getWindowInfo();
|
||||
const data = await this.getEl(".search_bar_wrap");
|
||||
const searchBarHeight = Number(data.height.toFixed());
|
||||
this.listHeight =
|
||||
windowInfo.windowHeight -
|
||||
windowInfo.statusBarHeight -
|
||||
44 -
|
||||
searchBarHeight;
|
||||
},
|
||||
getEl(el) {
|
||||
return new Promise((resolve) => {
|
||||
const query = uni.createSelectorQuery().in(this);
|
||||
query
|
||||
.select(el)
|
||||
.boundingClientRect((data) => {
|
||||
// 存在data,且存在宽和高,视为渲染完毕
|
||||
resolve(data);
|
||||
})
|
||||
.exec();
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
import {mapGetters,mapActions} from "vuex";
|
||||
import {formatChooseData} from "@/util/common";
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import SearchbarPlace from "@/components/searchbar_place.vue";
|
||||
import ChooseIndexList from "@/components/ChooseIndexList/index.vue";
|
||||
import ContactMenus from "../index/components/ContactMenus.vue";
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
ChooseIndexList,
|
||||
ContactMenus,
|
||||
SearchbarPlace
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: "",
|
||||
listHeight: 0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["storeFriendList",'storeUnHandleFriendApplicationNum']),
|
||||
getIndexData() {
|
||||
return formatChooseData(this.storeFriendList);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getListHeight();
|
||||
},
|
||||
async onShow() {
|
||||
await this.getFriendList();
|
||||
},
|
||||
methods: {
|
||||
...mapActions('contact',['getFriendList']),
|
||||
clear(){},
|
||||
cancel(){},
|
||||
input(){},
|
||||
search() {},
|
||||
contactAddClick() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/contact/contactAdd/index",
|
||||
});
|
||||
},
|
||||
goto(url){
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
});
|
||||
},
|
||||
userClick(friend) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/userCard/index?sourceID=${friend.userID}`,
|
||||
});
|
||||
},
|
||||
async getListHeight() {
|
||||
const windowInfo = uni.getWindowInfo();
|
||||
//const data = await this.getEl(".search_bar_wrap");
|
||||
const contact_menus = await this.getEl(".contact_menus");
|
||||
const header = await this.getEl(".header");
|
||||
|
||||
//const searchBarHeight = Number(data.height.toFixed());
|
||||
const contact_menusHeight = contact_menusHeight ? Number(contact_menus.height.toFixed()) : 0;
|
||||
const headerBarHeight = header ? Number(header.height.toFixed()) : 0;
|
||||
this.listHeight =
|
||||
windowInfo.windowHeight -
|
||||
windowInfo.statusBarHeight -
|
||||
44 -
|
||||
contact_menusHeight -
|
||||
headerBarHeight;
|
||||
},
|
||||
getEl(el) {
|
||||
return new Promise((resolve) => {
|
||||
const query = uni.createSelectorQuery().in(this);
|
||||
query
|
||||
.select(el)
|
||||
.boundingClientRect((data) => {
|
||||
// 存在data,且存在宽和高,视为渲染完毕
|
||||
resolve(data);
|
||||
})
|
||||
.exec();
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.friend_list_container {
|
||||
.search_bar_wrap {
|
||||
height: 34px;
|
||||
padding: 12px 22px;
|
||||
}
|
||||
.friend_list_container {
|
||||
padding-top: 36rpx;
|
||||
.header{
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.search_bar_wrap {
|
||||
height: 34px;
|
||||
padding: 12px 22px;
|
||||
}
|
||||
|
||||
.u-empty {
|
||||
margin-top: 25vh !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
.u-empty {
|
||||
margin-top: 25vh !important;
|
||||
}
|
||||
.contact_menus{
|
||||
::v-deep .uni-list-item__container{
|
||||
padding: 24rpx 44rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user