Files
im/pages/common/userCardMore/index.vue
T

131 lines
3.5 KiB
Vue
Raw Normal View History

2025-11-07 09:56:20 +08:00
<template>
2025-12-02 03:05:52 +08:00
<view class="user_more_container">
<custom-nav-bar title="好友设置" />
2025-11-07 09:56:20 +08:00
2025-12-02 03:05:52 +08:00
<view class="info_row">
<user-info-row-item @click="toMark" lable="设置备注" arrow />
<user-info-row-item @click="toMore" lable="个人资料" arrow />
</view>
2025-11-07 09:56:20 +08:00
2025-12-02 03:05:52 +08:00
<view class="info_row">
<user-info-row-item lable="加入黑名单" arrow>
<u-switch asyncChange :loading="blackLoading" size="20" :value="isBlacked" @change="change"></u-switch>
</user-info-row-item>
</view>
2025-11-07 09:56:20 +08:00
2025-12-02 03:05:52 +08:00
<view v-if="isFriend" class="info_row">
<u-button @click="() => (showConfirm = true)" type="error" plain text="解除好友关系"></u-button>
</view>
<u-toast ref="uToast"></u-toast>
<u-modal :content="`确定要解除与${sourceInfo.nickname}的好友关系吗?`" asyncClose :show="showConfirm" showCancelButton
@confirm="confirmRemove" @cancel="() => (showConfirm = false)"></u-modal>
</view>
2025-11-07 09:56:20 +08:00
</template>
<script>
2025-12-02 03:05:52 +08:00
import IMSDK from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import UserInfoRowItem from "../userCard/components/UserInfoRowItem.vue";
2026-01-01 04:15:30 +08:00
import {ContactChooseTypes} from "@/constant";
import util from "@/util/index.js"
2025-12-02 03:05:52 +08:00
export default {
components: {
CustomNavBar,
UserInfoRowItem,
},
data() {
return {
blackLoading: false,
sourceInfo: {},
showConfirm: false,
};
},
computed: {
isFriend() {
return (
this.$store.getters.storeFriendList.findIndex(
(friend) => friend.userID === this.sourceInfo.userID,
) !== -1
);
},
isBlacked() {
return (
this.$store.getters.storeBlackList.findIndex(
(black) => black.userID === this.sourceInfo.userID,
) !== -1
);
},
},
onLoad(options) {
const {sourceInfo} = options;
2026-01-01 04:15:30 +08:00
this.sourceInfo = util.aesdecode(sourceInfo);
2025-12-02 03:05:52 +08:00
},
methods: {
change(isBlack) {
this.blackLoading = true;
if (isBlack) {
IMSDK.asyncApi(IMSDK.IMMethods.AddBlack, IMSDK.uuid(), {toUserID: this.sourceInfo.userID,ex: "",})
.catch(() => this.showToast("操作失败"))
.finally(() => (this.blackLoading = false));
return;
}
IMSDK.asyncApi(IMSDK.IMMethods.RemoveBlack,IMSDK.uuid(),this.sourceInfo.userID)
.catch(() => this.showToast("操作失败"))
.finally(() => (this.blackLoading = false));
},
confirmRemove() {
IMSDK.asyncApi(IMSDK.IMMethods.DeleteFriend,IMSDK.uuid(),this.sourceInfo.userID,)
2026-02-15 19:40:36 +08:00
.then(() => {
this.showToast("操作成功");
uni.navigateBack({
delta: 2,
})
})
2025-12-02 03:05:52 +08:00
.catch(() => this.showToast("操作失败"))
.finally(() => (this.showConfirm = false));
},
toMore() {
2026-01-01 04:15:30 +08:00
const s = util.aesencode(this.sourceInfo);
2025-12-02 03:05:52 +08:00
uni.navigateTo({
2026-01-01 04:15:30 +08:00
url: `/pages/common/detailsFileds/index?sourceInfo=${s}`,
2025-12-02 03:05:52 +08:00
});
},
toMark() {
2026-01-01 04:15:30 +08:00
const s = util.aesencode(this.sourceInfo);
2025-12-02 03:05:52 +08:00
uni.navigateTo({
2026-01-01 04:15:30 +08:00
url: `/pages/common/markOrIDPage/index?isRemark=true&sourceInfo=${s}`,
2025-12-02 03:05:52 +08:00
});
},
toShare() {
2026-01-01 04:15:30 +08:00
const s = util.aesencode(this.sourceInfo);
2025-12-02 03:05:52 +08:00
uni.navigateTo({
2026-01-01 04:15:30 +08:00
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.ShareCard}&cardInfo=${s}`,
2025-12-02 03:05:52 +08:00
});
},
showToast(message) {
this.$refs.uToast.show({
message,
});
},
},
};
2025-11-07 09:56:20 +08:00
</script>
<style lang="scss">
2025-12-02 03:05:52 +08:00
.user_more_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
2025-11-07 09:56:20 +08:00
2025-12-02 03:05:52 +08:00
.info_row {
background-color: #fff;
margin: 24rpx;
border-radius: 6px;
overflow: hidden;
2025-11-07 09:56:20 +08:00
2025-12-02 03:05:52 +08:00
.u-button {
border: none;
}
}
}
</style>