IM部分处理
This commit is contained in:
parent
eaa9f50e7a
commit
192f493535
16
App.vue
16
App.vue
@ -11,8 +11,14 @@ import provinceList from './json/area_province.js';
|
||||
import cityList from './json/area_city.js';
|
||||
import districtList from './json/area_district.js';
|
||||
import storage from '@/utils/storage.js'; //缓存
|
||||
|
||||
//初始化im
|
||||
import { TUIChatKit } from '@/TUIKit';
|
||||
import { loginIm } from '@/utils/handleim.js';
|
||||
export default {
|
||||
// 全局属性
|
||||
globalData: {
|
||||
chat: null
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
config
|
||||
@ -56,6 +62,14 @@ export default {
|
||||
plus.globalEvent.addEventListener('newintent', (e) => {
|
||||
this.checkArguments(); // 检测启动参数
|
||||
});
|
||||
// init im
|
||||
var ddd = TUIChatKit.init();
|
||||
console.log('dasjdlasjdlajsldjaslkdjasljdklasdljasldadjaldjlkasdlkasjdalsdjl', ddd);
|
||||
// 如果有缓存登录信息
|
||||
console.log('是否登录', storage.getHasLogin());
|
||||
if (storage.getHasLogin()) {
|
||||
loginIm();
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
|
||||
@ -1,85 +1,103 @@
|
||||
<template>
|
||||
<div class="custom">
|
||||
<template v-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.SERVICE">
|
||||
<div>
|
||||
<h1>
|
||||
<label>{{ extension.title }}</label>
|
||||
<a
|
||||
v-if="extension.hyperlinks_text"
|
||||
:href="extension.hyperlinks_text.value"
|
||||
target="view_window"
|
||||
>{{ extension.hyperlinks_text.key }}</a>
|
||||
</h1>
|
||||
<ul v-if="extension.item && extension.item.length > 0">
|
||||
<li
|
||||
v-for="(item, index) in extension.item"
|
||||
:key="index"
|
||||
>
|
||||
<a
|
||||
v-if="isUrl(item.value)"
|
||||
:href="item.value"
|
||||
target="view_window"
|
||||
>{{ item.key }}</a>
|
||||
<p v-else>
|
||||
{{ item.key }}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<article>{{ extension.description }}</article>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.EVALUATE">
|
||||
<div class="evaluate">
|
||||
<h1>{{ TUITranslateService.t("message.custom.对本次服务评价") }}</h1>
|
||||
<ul class="evaluate-list">
|
||||
<li
|
||||
v-for="(item, index) in Math.max(customData.score, 0)"
|
||||
:key="index"
|
||||
class="evaluate-list-item"
|
||||
>
|
||||
<Icon
|
||||
:file="star"
|
||||
class="file-icon"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<article>{{ customData.comment }}</article>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.ORDER">
|
||||
<div
|
||||
class="order"
|
||||
@click="openLink(customData.link)"
|
||||
>
|
||||
<img
|
||||
:src="customData.imageUrl"
|
||||
>
|
||||
<main>
|
||||
<h1>{{ customData.title }}</h1>
|
||||
<p>{{ customData.description }}</p>
|
||||
<span>{{ customData.price }}</span>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.LINK">
|
||||
<div class="textLink">
|
||||
<p>{{ customData.text }}</p>
|
||||
<a
|
||||
:href="customData.link"
|
||||
target="view_window"
|
||||
>{{
|
||||
TUITranslateService.t("message.custom.查看详情>>")
|
||||
}}</a>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span v-html="content.custom" />
|
||||
</template>
|
||||
</div>
|
||||
<div class="custom">
|
||||
<template v-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.SERVICE">
|
||||
<div>
|
||||
<h1>
|
||||
<label>{{ extension.title }}</label>
|
||||
<a
|
||||
v-if="extension.hyperlinks_text"
|
||||
:href="extension.hyperlinks_text.value"
|
||||
target="view_window"
|
||||
>
|
||||
{{ extension.hyperlinks_text.key }}
|
||||
</a>
|
||||
</h1>
|
||||
<ul v-if="extension.item && extension.item.length > 0">
|
||||
<li
|
||||
v-for="(item, index) in extension.item"
|
||||
:key="index"
|
||||
>
|
||||
<a
|
||||
v-if="isUrl(item.value)"
|
||||
:href="item.value"
|
||||
target="view_window"
|
||||
>
|
||||
{{ item.key }}
|
||||
</a>
|
||||
<p v-else>
|
||||
{{ item.key }}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<article>{{ extension.description }}</article>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.EVALUATE">
|
||||
<div class="evaluate">
|
||||
<h1>{{ TUITranslateService.t('message.custom.对本次服务评价') }}</h1>
|
||||
<ul class="evaluate-list">
|
||||
<li
|
||||
v-for="(item, index) in Math.max(customData.score, 0)"
|
||||
:key="index"
|
||||
class="evaluate-list-item"
|
||||
>
|
||||
<Icon
|
||||
:file="star"
|
||||
class="file-icon"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<article>{{ customData.comment }}</article>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 自定义视频消息 -->
|
||||
<template v-else-if="customData.businessID === 'video'">
|
||||
<div
|
||||
class="order"
|
||||
@click="openRouter(customData.link)"
|
||||
>
|
||||
<img :src="customData.imageUrl" />
|
||||
<main>
|
||||
<h1>{{ customData.title }}</h1>
|
||||
<p>{{ customData.description }}</p>
|
||||
<span>{{ customData.price }}</span>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.ORDER">
|
||||
<div
|
||||
class="order"
|
||||
@click="openLink(customData.link)"
|
||||
>
|
||||
<img :src="customData.imageUrl" />
|
||||
<main>
|
||||
<h1>{{ customData.title }}</h1>
|
||||
<p>{{ customData.description }}</p>
|
||||
<span>{{ customData.price }}</span>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.LINK">
|
||||
<div class="textLink">
|
||||
<p>{{ customData.text }}</p>
|
||||
<a
|
||||
:href="customData.link"
|
||||
target="view_window"
|
||||
>
|
||||
{{ TUITranslateService.t('message.custom.查看详情>>') }}
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span v-html="content.custom" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watchEffect, ref } from '../../../../adapter-vue';
|
||||
import { TUIGlobal } from '@tencentcloud/universal-api';
|
||||
import { TUITranslateService, IMessageModel } from '@tencentcloud/chat-uikit-engine';
|
||||
import { isUrl, JSONToObject } from '../../../../utils/index';
|
||||
import { CHAT_MSG_CUSTOM_TYPE } from '../../../../constant';
|
||||
@ -87,101 +105,106 @@ import { ICustomMessagePayload } from '../../../../interface';
|
||||
import Icon from '../../../common/Icon.vue';
|
||||
import star from '../../../../assets/icon/star-light.png';
|
||||
interface Props {
|
||||
messageItem: IMessageModel;
|
||||
content: any;
|
||||
messageItem: IMessageModel;
|
||||
content: any;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
messageItem: undefined,
|
||||
content: undefined,
|
||||
messageItem: undefined,
|
||||
content: undefined
|
||||
});
|
||||
|
||||
const custom = ref();
|
||||
const message = ref<IMessageModel>();
|
||||
const extension = ref();
|
||||
const customData = ref<ICustomMessagePayload>({
|
||||
businessID: '',
|
||||
businessID: ''
|
||||
});
|
||||
|
||||
watchEffect(() => {
|
||||
custom.value = props.content;
|
||||
message.value = props.messageItem;
|
||||
const { payload } = props.messageItem;
|
||||
customData.value = payload.data || '';
|
||||
customData.value = JSONToObject(payload.data);
|
||||
if (payload.data === CHAT_MSG_CUSTOM_TYPE.SERVICE) {
|
||||
extension.value = JSONToObject(payload.extension);
|
||||
}
|
||||
custom.value = props.content;
|
||||
message.value = props.messageItem;
|
||||
const { payload } = props.messageItem;
|
||||
customData.value = payload.data || '';
|
||||
customData.value = JSONToObject(payload.data);
|
||||
if (payload.data === CHAT_MSG_CUSTOM_TYPE.SERVICE) {
|
||||
extension.value = JSONToObject(payload.extension);
|
||||
}
|
||||
});
|
||||
const openLink = (url: any) => {
|
||||
window.open(url);
|
||||
window.open(url);
|
||||
};
|
||||
const openRouter = (url: any) => {
|
||||
TUIGlobal.navigateTo({
|
||||
url
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import "../../../../assets/styles/common";
|
||||
@import '../../../../assets/styles/common';
|
||||
|
||||
a {
|
||||
color: #679ce1;
|
||||
color: #679ce1;
|
||||
}
|
||||
|
||||
.custom {
|
||||
font-size: 14px;
|
||||
font-size: 14px;
|
||||
|
||||
h1 {
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
h1 {
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
h1,
|
||||
a,
|
||||
p {
|
||||
font-size: 14px;
|
||||
}
|
||||
h1,
|
||||
a,
|
||||
p {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.evaluate {
|
||||
ul {
|
||||
display: flex;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.evaluate {
|
||||
ul {
|
||||
display: flex;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
&-list {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
&-list {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
&-item {
|
||||
padding: 0 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-item {
|
||||
padding: 0 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.order {
|
||||
display: flex;
|
||||
.order {
|
||||
display: flex;
|
||||
|
||||
main {
|
||||
padding-left: 5px;
|
||||
main {
|
||||
padding-left: 5px;
|
||||
|
||||
p {
|
||||
font-family: PingFangSC-Regular;
|
||||
width: 145px;
|
||||
line-height: 17px;
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
letter-spacing: 0;
|
||||
margin-bottom: 6px;
|
||||
word-break: break-word;
|
||||
}
|
||||
p {
|
||||
font-family: PingFangSC-Regular;
|
||||
width: 145px;
|
||||
line-height: 17px;
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
letter-spacing: 0;
|
||||
margin-bottom: 6px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
span {
|
||||
font-family: PingFangSC-Regular;
|
||||
line-height: 25px;
|
||||
color: #ff7201;
|
||||
}
|
||||
}
|
||||
span {
|
||||
font-family: PingFangSC-Regular;
|
||||
line-height: 25px;
|
||||
color: #ff7201;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
width: 67px;
|
||||
height: 67px;
|
||||
}
|
||||
}
|
||||
img {
|
||||
width: 67px;
|
||||
height: 67px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,123 +1,108 @@
|
||||
<template>
|
||||
<div
|
||||
ref="conversationListInnerDomRef"
|
||||
class="tui-conversation-list"
|
||||
>
|
||||
<ActionsMenu
|
||||
v-if="isShowOverlay"
|
||||
:selectedConversation="currentConversation"
|
||||
:actionsMenuPosition="actionsMenuPosition"
|
||||
:selectedConversationDomRect="currentConversationDomRect"
|
||||
@closeConversationActionMenu="closeConversationActionMenu"
|
||||
/>
|
||||
<div
|
||||
v-for="(conversation, index) in conversationList"
|
||||
:id="`convlistitem-${index}`"
|
||||
:key="index"
|
||||
:class="[
|
||||
'tui-conversation-content',
|
||||
isMobile && 'tui-conversation-content-h5 disable-select',
|
||||
]"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
isPC && 'isPC',
|
||||
'tui-conversation-item',
|
||||
currentConversationID === conversation.conversationID &&
|
||||
'tui-conversation-item-selected',
|
||||
conversation.isPinned && 'tui-conversation-item-pinned',
|
||||
]"
|
||||
@click="enterConversationChat(conversation.conversationID)"
|
||||
@longpress="showConversationActionMenu($event, conversation, index)"
|
||||
@contextmenu="showConversationActionMenu($event, conversation, index, true)"
|
||||
>
|
||||
<aside class="left">
|
||||
<Avatar
|
||||
useSkeletonAnimation
|
||||
:url="conversation.getAvatar()"
|
||||
size="30px"
|
||||
/>
|
||||
<div
|
||||
v-if="userOnlineStatusMap && isShowUserOnlineStatus(conversation)"
|
||||
:class="[
|
||||
'online-status',
|
||||
Object.keys(userOnlineStatusMap).length > 0 &&
|
||||
Object.keys(userOnlineStatusMap).includes(
|
||||
conversation.userProfile.userID
|
||||
) &&
|
||||
userOnlineStatusMap[conversation.userProfile.userID]
|
||||
.statusType === 1
|
||||
? 'online-status-online'
|
||||
: 'online-status-offline',
|
||||
]"
|
||||
/>
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0 && !conversation.isMuted"
|
||||
class="num"
|
||||
>
|
||||
{{
|
||||
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
||||
}}
|
||||
</span>
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0 && conversation.isMuted"
|
||||
class="num-notify"
|
||||
/>
|
||||
</aside>
|
||||
<div class="content">
|
||||
<div class="content-header">
|
||||
<label class="content-header-label">
|
||||
<p class="name">{{ conversation.getShowName() }}</p>
|
||||
</label>
|
||||
<div class="middle-box">
|
||||
<span
|
||||
v-if="conversation.draftText && conversation.conversationID !== currentConversationID"
|
||||
class="middle-box-draft"
|
||||
>{{ TUITranslateService.t('TUIChat.[草稿]') }}</span>
|
||||
<span
|
||||
v-else-if="
|
||||
conversation.type === 'GROUP' &&
|
||||
conversation.groupAtInfoList &&
|
||||
conversation.groupAtInfoList.length > 0
|
||||
"
|
||||
class="middle-box-at"
|
||||
>{{ conversation.getGroupAtInfo() }}</span>
|
||||
<div class="middle-box-content">
|
||||
{{ conversation.getLastMessage("text") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-footer">
|
||||
<span class="time">{{ conversation.getLastMessage("time") }}</span>
|
||||
<Icon
|
||||
v-if="conversation.isMuted"
|
||||
:file="muteIcon"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="conversationListInnerDomRef"
|
||||
class="tui-conversation-list"
|
||||
>
|
||||
<ActionsMenu
|
||||
v-if="isShowOverlay"
|
||||
:selectedConversation="currentConversation"
|
||||
:actionsMenuPosition="actionsMenuPosition"
|
||||
:selectedConversationDomRect="currentConversationDomRect"
|
||||
@closeConversationActionMenu="closeConversationActionMenu"
|
||||
/>
|
||||
<div
|
||||
v-for="(conversation, index) in conversationList"
|
||||
:id="`convlistitem-${index}`"
|
||||
:key="index"
|
||||
:class="['tui-conversation-content', isMobile && 'tui-conversation-content-h5 disable-select']"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
isPC && 'isPC',
|
||||
'tui-conversation-item',
|
||||
currentConversationID === conversation.conversationID && 'tui-conversation-item-selected',
|
||||
conversation.isPinned && 'tui-conversation-item-pinned'
|
||||
]"
|
||||
@click="enterConversationChat(conversation.conversationID)"
|
||||
@longpress="showConversationActionMenu($event, conversation, index)"
|
||||
@contextmenu="showConversationActionMenu($event, conversation, index, true)"
|
||||
>
|
||||
<aside class="left">
|
||||
<Avatar
|
||||
useSkeletonAnimation
|
||||
:url="conversation.getAvatar()"
|
||||
size="30px"
|
||||
/>
|
||||
<div
|
||||
v-if="userOnlineStatusMap && isShowUserOnlineStatus(conversation)"
|
||||
:class="[
|
||||
'online-status',
|
||||
Object.keys(userOnlineStatusMap).length > 0 &&
|
||||
Object.keys(userOnlineStatusMap).includes(conversation.userProfile.userID) &&
|
||||
userOnlineStatusMap[conversation.userProfile.userID].statusType === 1
|
||||
? 'online-status-online'
|
||||
: 'online-status-offline'
|
||||
]"
|
||||
/>
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0 && !conversation.isMuted"
|
||||
class="num"
|
||||
>
|
||||
{{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
|
||||
</span>
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0 && conversation.isMuted"
|
||||
class="num-notify"
|
||||
/>
|
||||
</aside>
|
||||
<div class="content">
|
||||
<div class="content-header">
|
||||
<label class="content-header-label">
|
||||
<p class="name">{{ conversation.getShowName() }}</p>
|
||||
</label>
|
||||
<div class="middle-box">
|
||||
<span
|
||||
v-if="conversation.draftText && conversation.conversationID !== currentConversationID"
|
||||
class="middle-box-draft"
|
||||
>
|
||||
{{ TUITranslateService.t('TUIChat.[草稿]') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="conversation.type === 'GROUP' && conversation.groupAtInfoList && conversation.groupAtInfoList.length > 0"
|
||||
class="middle-box-at"
|
||||
>
|
||||
{{ conversation.getGroupAtInfo() }}
|
||||
</span>
|
||||
<div class="middle-box-content">
|
||||
{{ conversation.getLastMessage('text') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-footer">
|
||||
<span class="time">{{ conversation.getLastMessage('time') }}</span>
|
||||
<Icon
|
||||
v-if="conversation.isMuted"
|
||||
:file="muteIcon"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
interface IUserStatus {
|
||||
statusType: number;
|
||||
customStatus: string;
|
||||
statusType: number;
|
||||
customStatus: string;
|
||||
}
|
||||
|
||||
interface IUserStatusMap {
|
||||
[userID: string]: IUserStatus;
|
||||
[userID: string]: IUserStatus;
|
||||
}
|
||||
|
||||
import { ref, onMounted, onUnmounted } from '../../../adapter-vue';
|
||||
import TUIChatEngine, {
|
||||
TUIStore,
|
||||
StoreName,
|
||||
TUIConversationService,
|
||||
TUITranslateService,
|
||||
IConversationModel,
|
||||
} from '@tencentcloud/chat-uikit-engine';
|
||||
import TUIChatEngine, { TUIStore, StoreName, TUIConversationService, TUITranslateService, IConversationModel } from '@tencentcloud/chat-uikit-engine';
|
||||
import { TUIGlobal, isIOS, addLongPressListener } from '@tencentcloud/universal-api';
|
||||
import Icon from '../../common/Icon.vue';
|
||||
import Avatar from '../../common/Avatar/index.vue';
|
||||
@ -134,13 +119,13 @@ const conversationList = ref<IConversationModel[]>([]);
|
||||
const conversationListDomRef = ref<HTMLElement | undefined>();
|
||||
const conversationListInnerDomRef = ref<HTMLElement | undefined>();
|
||||
const actionsMenuPosition = ref<{
|
||||
top: number;
|
||||
left: number | undefined;
|
||||
conversationHeight: number | undefined;
|
||||
top: number;
|
||||
left: number | undefined;
|
||||
conversationHeight: number | undefined;
|
||||
}>({
|
||||
top: 0,
|
||||
left: undefined,
|
||||
conversationHeight: undefined,
|
||||
top: 0,
|
||||
left: undefined,
|
||||
conversationHeight: undefined
|
||||
});
|
||||
const displayOnlineStatus = ref(false);
|
||||
const userOnlineStatusMap = ref<IUserStatusMap>();
|
||||
@ -148,151 +133,141 @@ const userOnlineStatusMap = ref<IUserStatusMap>();
|
||||
let lastestOpenActionsMenuTime: number | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
console.log(conversationList)
|
||||
TUIStore.watch(StoreName.CONV, {
|
||||
currentConversationID: onCurrentConversationIDUpdated,
|
||||
conversationList: onConversationListUpdated,
|
||||
currentConversation: onCurrentConversationUpdated,
|
||||
});
|
||||
TUIStore.watch(StoreName.CONV, {
|
||||
currentConversationID: onCurrentConversationIDUpdated,
|
||||
conversationList: onConversationListUpdated,
|
||||
currentConversation: onCurrentConversationUpdated
|
||||
});
|
||||
|
||||
TUIStore.watch(StoreName.USER, {
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated,
|
||||
});
|
||||
TUIStore.watch(StoreName.USER, {
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated
|
||||
});
|
||||
|
||||
if (!isUniFrameWork && isIOS && !isPC) {
|
||||
addLongPressHandler();
|
||||
}
|
||||
if (!isUniFrameWork && isIOS && !isPC) {
|
||||
addLongPressHandler();
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
TUIStore.unwatch(StoreName.CONV, {
|
||||
currentConversationID: onCurrentConversationIDUpdated,
|
||||
conversationList: onConversationListUpdated,
|
||||
currentConversation: onCurrentConversationUpdated,
|
||||
});
|
||||
TUIStore.unwatch(StoreName.CONV, {
|
||||
currentConversationID: onCurrentConversationIDUpdated,
|
||||
conversationList: onConversationListUpdated,
|
||||
currentConversation: onCurrentConversationUpdated
|
||||
});
|
||||
|
||||
TUIStore.unwatch(StoreName.USER, {
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated,
|
||||
});
|
||||
TUIStore.unwatch(StoreName.USER, {
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated
|
||||
});
|
||||
});
|
||||
|
||||
const isShowUserOnlineStatus = (conversation: IConversationModel): boolean => {
|
||||
return (
|
||||
displayOnlineStatus.value
|
||||
&& conversation.type === TUIChatEngine.TYPES.CONV_C2C
|
||||
);
|
||||
return displayOnlineStatus.value && conversation.type === TUIChatEngine.TYPES.CONV_C2C;
|
||||
};
|
||||
|
||||
const showConversationActionMenu = (
|
||||
event: Event,
|
||||
conversation: IConversationModel,
|
||||
index: number,
|
||||
isContextMenuEvent?: boolean,
|
||||
) => {
|
||||
if (isContextMenuEvent) {
|
||||
event.preventDefault();
|
||||
if (isUniFrameWork) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
currentConversation.value = conversation;
|
||||
lastestOpenActionsMenuTime = Date.now();
|
||||
getActionsMenuPosition(event, index);
|
||||
const showConversationActionMenu = (event: Event, conversation: IConversationModel, index: number, isContextMenuEvent?: boolean) => {
|
||||
if (isContextMenuEvent) {
|
||||
event.preventDefault();
|
||||
if (isUniFrameWork) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
currentConversation.value = conversation;
|
||||
lastestOpenActionsMenuTime = Date.now();
|
||||
getActionsMenuPosition(event, index);
|
||||
};
|
||||
|
||||
const closeConversationActionMenu = () => {
|
||||
// Prevent continuous triggering of overlay tap events
|
||||
if (
|
||||
lastestOpenActionsMenuTime
|
||||
&& Date.now() - lastestOpenActionsMenuTime > 300
|
||||
) {
|
||||
currentConversation.value = undefined;
|
||||
isShowOverlay.value = false;
|
||||
}
|
||||
// Prevent continuous triggering of overlay tap events
|
||||
if (lastestOpenActionsMenuTime && Date.now() - lastestOpenActionsMenuTime > 300) {
|
||||
currentConversation.value = undefined;
|
||||
isShowOverlay.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getActionsMenuPosition = (event: Event, index: number) => {
|
||||
if (isUniFrameWork) {
|
||||
if (typeof conversationListDomRef.value === 'undefined') {
|
||||
emits('getPassingRef', conversationListDomRef);
|
||||
}
|
||||
const query = TUIGlobal?.createSelectorQuery().in(conversationListDomRef.value);
|
||||
query.select(`#convlistitem-${index}`).boundingClientRect((data) => {
|
||||
if (data) {
|
||||
actionsMenuPosition.value = {
|
||||
// The uni-page-head of uni-h5 is not considered a member of the viewport, so the height of the head is manually increased.
|
||||
top: data.bottom + (isH5 ? 44 : 0),
|
||||
// @ts-expect-error in uniapp event has touches property
|
||||
left: event.touches[0].pageX,
|
||||
conversationHeight: data.height,
|
||||
};
|
||||
isShowOverlay.value = true;
|
||||
}
|
||||
}).exec();
|
||||
} else {
|
||||
const rect = ((event.currentTarget || event.target) as HTMLElement)?.getBoundingClientRect() || {};
|
||||
if (rect) {
|
||||
actionsMenuPosition.value = {
|
||||
top: rect.bottom,
|
||||
left: isPC ? (event as MouseEvent).clientX : undefined,
|
||||
conversationHeight: rect.height,
|
||||
};
|
||||
}
|
||||
isShowOverlay.value = true;
|
||||
}
|
||||
if (isUniFrameWork) {
|
||||
if (typeof conversationListDomRef.value === 'undefined') {
|
||||
emits('getPassingRef', conversationListDomRef);
|
||||
}
|
||||
const query = TUIGlobal?.createSelectorQuery().in(conversationListDomRef.value);
|
||||
query
|
||||
.select(`#convlistitem-${index}`)
|
||||
.boundingClientRect((data) => {
|
||||
if (data) {
|
||||
actionsMenuPosition.value = {
|
||||
// The uni-page-head of uni-h5 is not considered a member of the viewport, so the height of the head is manually increased.
|
||||
top: data.bottom + (isH5 ? 44 : 0),
|
||||
// @ts-expect-error in uniapp event has touches property
|
||||
left: event.touches[0].pageX,
|
||||
conversationHeight: data.height
|
||||
};
|
||||
isShowOverlay.value = true;
|
||||
}
|
||||
})
|
||||
.exec();
|
||||
} else {
|
||||
const rect = ((event.currentTarget || event.target) as HTMLElement)?.getBoundingClientRect() || {};
|
||||
if (rect) {
|
||||
actionsMenuPosition.value = {
|
||||
top: rect.bottom,
|
||||
left: isPC ? (event as MouseEvent).clientX : undefined,
|
||||
conversationHeight: rect.height
|
||||
};
|
||||
}
|
||||
isShowOverlay.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const enterConversationChat = (conversationID: string) => {
|
||||
emits('handleSwitchConversation', conversationID);
|
||||
TUIConversationService.switchConversation(conversationID);
|
||||
emits('handleSwitchConversation', conversationID);
|
||||
TUIConversationService.switchConversation(conversationID);
|
||||
};
|
||||
|
||||
function addLongPressHandler() {
|
||||
if (!conversationListInnerDomRef.value) {
|
||||
return;
|
||||
}
|
||||
addLongPressListener({
|
||||
element: conversationListInnerDomRef.value,
|
||||
onLongPress: (event, target) => {
|
||||
const index = (Array.from(conversationListInnerDomRef.value!.children) as HTMLElement[]).indexOf(target!);
|
||||
showConversationActionMenu(event, conversationList.value[index], index);
|
||||
},
|
||||
options: {
|
||||
eventDelegation: {
|
||||
subSelector: '.tui-conversation-content',
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!conversationListInnerDomRef.value) {
|
||||
return;
|
||||
}
|
||||
addLongPressListener({
|
||||
element: conversationListInnerDomRef.value,
|
||||
onLongPress: (event, target) => {
|
||||
const index = (Array.from(conversationListInnerDomRef.value!.children) as HTMLElement[]).indexOf(target!);
|
||||
showConversationActionMenu(event, conversationList.value[index], index);
|
||||
},
|
||||
options: {
|
||||
eventDelegation: {
|
||||
subSelector: '.tui-conversation-content'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onCurrentConversationUpdated(conversation: IConversationModel) {
|
||||
currentConversation.value = conversation;
|
||||
currentConversation.value = conversation;
|
||||
}
|
||||
|
||||
function onConversationListUpdated(list: IConversationModel[]) {
|
||||
conversationList.value = list;
|
||||
conversationList.value = list;
|
||||
console.log('会话列表数据', conversationList.value);
|
||||
console.log('Conversation实例:', TUIStore);
|
||||
}
|
||||
|
||||
function onCurrentConversationIDUpdated(id: string) {
|
||||
currentConversationID.value = id;
|
||||
currentConversationID.value = id;
|
||||
}
|
||||
|
||||
function onDisplayOnlineStatusUpdated(status: boolean) {
|
||||
displayOnlineStatus.value = status;
|
||||
displayOnlineStatus.value = status;
|
||||
}
|
||||
|
||||
function onUserStatusListUpdated(list: Map<string, IUserStatus>) {
|
||||
if (list.size !== 0) {
|
||||
userOnlineStatusMap.value = [...list.entries()].reduce(
|
||||
(obj, [key, value]) => {
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
},
|
||||
{} as IUserStatusMap,
|
||||
);
|
||||
}
|
||||
if (list.size !== 0) {
|
||||
userOnlineStatusMap.value = [...list.entries()].reduce((obj, [key, value]) => {
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
}, {} as IUserStatusMap);
|
||||
}
|
||||
}
|
||||
// Expose to the parent component and close actionsMenu when a sliding event is detected
|
||||
defineExpose({ closeChildren: closeConversationActionMenu });
|
||||
@ -301,11 +276,11 @@ defineExpose({ closeChildren: closeConversationActionMenu });
|
||||
<style lang="scss" scoped src="./style/index.scss"></style>
|
||||
<style lang="scss" scoped>
|
||||
.disable-select {
|
||||
-webkit-touch-callout:none;
|
||||
-webkit-user-select:none;
|
||||
-khtml-user-select:none;
|
||||
-moz-user-select:none;
|
||||
-ms-user-select:none;
|
||||
user-select:none;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
35
api/checkInfo.js
Normal file
35
api/checkInfo.js
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @description 文本内容审核
|
||||
* AuditName:1600080789_1745821176_amtwGf
|
||||
* ContentType:Text|Image|Audio|Video
|
||||
* Content:需要审核的文本内容
|
||||
* ExtSender:im的id,这里对应的是用户手机号
|
||||
* ExtReceiver:接收方的信息,选填
|
||||
*/
|
||||
import {
|
||||
http,
|
||||
Method
|
||||
} from "@/utils/request.js";
|
||||
|
||||
export function checkText({
|
||||
ExtSender,
|
||||
Content,
|
||||
}) {
|
||||
return http.request({
|
||||
url: 'https://console.tim.qq.com/v4/im_msg_audit/content_moderation'
|
||||
method: Method.POST,
|
||||
params: {
|
||||
sdkappid: '1600080789',
|
||||
identifier: 'administrator',
|
||||
usersig: 'eJwtjEELgjAYhv-LroV9zi2n0CU6VBSRJV28jLbiK7SxjRxE-z1Tj*-zvDwfct6dore2JCc0AjLtNyrdeLxhj6WqsUHnrfQvOx6cekpjUJE8ngOAgFRkg9HBoNUd55zTTg3UY-1nKeOCJomIxwreu76BMnv4TcGXZTVrgMVMFm6795NQH8OateqK7CBbu7oYWJDvD4AYNPU_',
|
||||
random: Math.floor(Math.random() * (4294967295 + 1)),
|
||||
contenttype: 'json'
|
||||
},
|
||||
data: {
|
||||
AuditName: '1600080789_1745821176_amtwGf'
|
||||
ContentType: 'Text',
|
||||
Content,
|
||||
ExtSender
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -192,7 +192,7 @@
|
||||
<!-- 4.分享 -->
|
||||
<view
|
||||
v-if="item.isShowProgressBarTime == false"
|
||||
@click="share"
|
||||
@click="share(item)"
|
||||
style="opacity: 0.9; margin-top: 17px"
|
||||
>
|
||||
<image
|
||||
@ -415,6 +415,7 @@
|
||||
:thisVlogId="pinglunInfo.vlogId"
|
||||
:vlogUrl="pinglunInfo.url"
|
||||
:isPrivate="pinglunInfo.isPrivate"
|
||||
:vlogItem="pinglunInfo"
|
||||
></uni-popup-share>
|
||||
</uni-popup>
|
||||
</view>
|
||||
@ -984,6 +985,7 @@ export default {
|
||||
}, 50);
|
||||
} else {
|
||||
this.noData = '暂无数据';
|
||||
this.isShow1 = false;
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
@ -1103,7 +1105,8 @@ export default {
|
||||
animation: true
|
||||
});
|
||||
},
|
||||
share() {
|
||||
share(item) {
|
||||
this.pinglunInfo = item;
|
||||
this.$refs.share.open();
|
||||
uni.hideTabBar({
|
||||
animation: true
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<!-- 4.分享 -->
|
||||
<view
|
||||
v-if="item.isShowProgressBarTime == false"
|
||||
@click="share"
|
||||
@click="share(item)"
|
||||
style="opacity: 0.9; margin-top: 17px"
|
||||
>
|
||||
<image
|
||||
@ -415,6 +415,7 @@
|
||||
:thisVlogId="pinglunInfo.vlogId"
|
||||
:vlogUrl="pinglunInfo.url"
|
||||
:isPrivate="pinglunInfo.isPrivate"
|
||||
:vlogItem="pinglunInfo"
|
||||
></uni-popup-share>
|
||||
</uni-popup>
|
||||
</view>
|
||||
@ -985,6 +986,7 @@ export default {
|
||||
}, 50);
|
||||
} else {
|
||||
this.noData = '暂无数据';
|
||||
this.isShow1 = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -1105,7 +1107,8 @@ export default {
|
||||
animation: true
|
||||
});
|
||||
},
|
||||
share() {
|
||||
share(item) {
|
||||
this.pinglunInfo = item;
|
||||
this.$refs.share.open();
|
||||
uni.hideTabBar({
|
||||
animation: true
|
||||
|
||||
@ -185,7 +185,7 @@
|
||||
<!-- 4.分享 -->
|
||||
<view
|
||||
v-if="item.isShowProgressBarTime == false"
|
||||
@click="share"
|
||||
@click="share(item)"
|
||||
style="opacity: 0.9; margin-top: 17px"
|
||||
>
|
||||
<image
|
||||
@ -408,6 +408,7 @@
|
||||
:thisVlogId="pinglunInfo.vlogId"
|
||||
:vlogUrl="pinglunInfo.url"
|
||||
:isPrivate="pinglunInfo.isPrivate"
|
||||
:vlogItem="pinglunInfo"
|
||||
></uni-popup-share>
|
||||
</uni-popup>
|
||||
</view>
|
||||
@ -1087,7 +1088,8 @@ export default {
|
||||
animation: true
|
||||
});
|
||||
},
|
||||
share() {
|
||||
share(item) {
|
||||
this.pinglunInfo = item;
|
||||
this.$refs.share.open();
|
||||
uni.hideTabBar({
|
||||
animation: true
|
||||
|
||||
@ -17,7 +17,7 @@ const prod = {
|
||||
// buyer: "https://buyer-api.pickmall.cn",
|
||||
common: "http://192.168.1.211:8890",
|
||||
buyer: "http://192.168.1.211:8888",
|
||||
vlog: "http://192.168.1.86:8099",
|
||||
vlog: "http://192.168.1.211:8099",
|
||||
};
|
||||
|
||||
//默认生产环境
|
||||
|
||||
@ -270,7 +270,7 @@ export default {
|
||||
onShow() {
|
||||
let me = this;
|
||||
// 判断我有没有登录
|
||||
this.userIsLogin = filters.isLogin('auth');
|
||||
this.userIsLogin = storage.getHasLogin();
|
||||
console.log(this.userIsLogin);
|
||||
if (this.userIsLogin) {
|
||||
this.getUinfo();
|
||||
@ -280,9 +280,9 @@ export default {
|
||||
},
|
||||
onTabItemTap: (e) => {
|
||||
console.log(e);
|
||||
if (!filters.isLogin('auth')) {
|
||||
if (!storage.getHasLogin()) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/passport/login?init=index'
|
||||
url: '/pages/passport/login'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -195,7 +195,7 @@
|
||||
<!-- 4.分享 -->
|
||||
<view
|
||||
v-if="item.isShowProgressBarTime == false"
|
||||
@click="share"
|
||||
@click="share(item)"
|
||||
style="opacity: 0.9; margin-top: 17px"
|
||||
>
|
||||
<image
|
||||
@ -418,6 +418,7 @@
|
||||
:thisVlogId="pinglunInfo.vlogId"
|
||||
:vlogUrl="pinglunInfo.url"
|
||||
:isPrivate="pinglunInfo.isPrivate"
|
||||
:vlogItem="pinglunInfo"
|
||||
></uni-popup-share>
|
||||
</uni-popup>
|
||||
</view>
|
||||
@ -1123,7 +1124,8 @@ export default {
|
||||
animation: true
|
||||
});
|
||||
},
|
||||
share() {
|
||||
share(item) {
|
||||
this.pinglunInfo = item;
|
||||
this.$refs.share.open();
|
||||
uni.hideTabBar({
|
||||
animation: true
|
||||
|
||||
@ -1,331 +1,374 @@
|
||||
<template>
|
||||
<view class="person-msg">
|
||||
<view class="head c-content" @click="changeFace">
|
||||
<image :src="form.face || '/static/missing-face.png'" mode=""></image>
|
||||
<view>点击修改头像</view>
|
||||
</view>
|
||||
<u-form :model="form" ref="uForm" class="form">
|
||||
<u-form-item label="昵称" label-width="150">
|
||||
<u-input
|
||||
v-model="form.nickName"
|
||||
placeholder="请输入昵称"
|
||||
maxlength="10"
|
||||
/>
|
||||
</u-form-item>
|
||||
<u-form-item label="二维码" label-width="150">
|
||||
<img :src="erwei" alt="" width="60" @click="showQrCodeInFullSize" />
|
||||
</u-form-item>
|
||||
<u-form-item label="性别" label-width="150">
|
||||
<u-radio-group v-model="form.sex" :active-color="lightColor">
|
||||
<u-radio name="1">男</u-radio>
|
||||
<u-radio name="0">女</u-radio>
|
||||
</u-radio-group>
|
||||
</u-form-item>
|
||||
<u-form-item label="生日" label-width="150" right-icon="arrow-right">
|
||||
<div style="width: 100%" @click="showBirthday = true">
|
||||
{{ birthday || "请选择出生日期" }}
|
||||
</div>
|
||||
<u-picker
|
||||
v-model="showBirthday"
|
||||
mode="time"
|
||||
:confirm-color="lightColor"
|
||||
@confirm="selectTime"
|
||||
></u-picker>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item
|
||||
label="城市"
|
||||
label-width="150"
|
||||
placeholder="请选择城市"
|
||||
right-icon="arrow-right"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
width: 32vh;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
"
|
||||
@click="clickRegion"
|
||||
>
|
||||
{{ form.___path || "请选择城市" }}
|
||||
</div>
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
<div style="display: flex; justify-content: center"></div>
|
||||
<div class="bottom">
|
||||
<view class="submit" @click="submit">保存</view>
|
||||
<view class="submit light" @click="showModalDialog">退出登录</view>
|
||||
</div>
|
||||
<u-modal
|
||||
show-cancel-button
|
||||
v-model="quitShow"
|
||||
@confirm="confirm"
|
||||
:confirm-color="lightColor"
|
||||
:async-close="true"
|
||||
:content="userInfo.id ? '确定要退出登录么?' : '确定要返回登录么?'"
|
||||
></u-modal>
|
||||
<m-city
|
||||
:provinceData="region"
|
||||
headTitle="区域选择"
|
||||
ref="cityPicker"
|
||||
@funcValue="getpickerParentValue"
|
||||
pickerSize="4"
|
||||
></m-city>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { saveUserInfo, geterwei } from "@/api/members.js";
|
||||
import { upload } from "@/api/common.js";
|
||||
import { logout } from "@/api/login";
|
||||
import storage from "@/utils/storage.js";
|
||||
import uFormItem from "@/uview-ui/components/u-form-item/u-form-item.vue";
|
||||
import gkcity from "@/components/m-city/m-city.vue";
|
||||
export default {
|
||||
components: {
|
||||
uFormItem,
|
||||
"m-city": gkcity,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
erwei: "",
|
||||
quitShow: false,
|
||||
userInfo: {},
|
||||
lightColor: this.$lightColor, //高亮颜色
|
||||
form: {
|
||||
nickName: storage.getUserInfo().nickName || "",
|
||||
birthday: storage.getUserInfo().birthday || "",
|
||||
face: storage.getUserInfo().face || "/static/imlogo.png", //默认头像
|
||||
regionId: [], //地址Id
|
||||
region: storage.getUserInfo().region || [], //地址
|
||||
sex: storage.getUserInfo().sex, //性别
|
||||
___path: storage.getUserInfo().region,
|
||||
},
|
||||
birthday: storage.getUserInfo().birthday || "", //生日
|
||||
photo: [
|
||||
{
|
||||
text: "立即拍照",
|
||||
color: this.$mainColor,
|
||||
},
|
||||
{
|
||||
text: "从相册选择",
|
||||
color: this.$mainColor,
|
||||
},
|
||||
],
|
||||
region: [
|
||||
//请求城市默认地址
|
||||
{
|
||||
id: "",
|
||||
localName: "请选择",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
showBirthday: false, //显示生日日期
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = this.$options.filters.isLogin();
|
||||
this.getgeterwei();
|
||||
},
|
||||
methods: {
|
||||
showQrCodeInFullSize() {
|
||||
uni.previewImage({
|
||||
urls: [this.erwei],
|
||||
current: this.erwei,
|
||||
});
|
||||
},
|
||||
getgeterwei() {
|
||||
geterwei().then((res) => {
|
||||
this.erwei = res.data.result;
|
||||
});
|
||||
},
|
||||
showModalDialog() {
|
||||
this.quitShow = true;
|
||||
},
|
||||
clear() {
|
||||
storage.setAccessToken("");
|
||||
storage.setRefreshToken("");
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken("");
|
||||
storage.setVlogUserInfo({});
|
||||
this.$options.filters.navigateToLogin("redirectTo");
|
||||
},
|
||||
/**
|
||||
* 确认退出
|
||||
* 清除缓存重新登录
|
||||
*/
|
||||
async confirm() {
|
||||
await logout();
|
||||
this.clear();
|
||||
},
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
quiteLoginOut() {
|
||||
this.$options.filters.quiteLoginOut();
|
||||
},
|
||||
/**
|
||||
* 选择地址回调
|
||||
*/
|
||||
getpickerParentValue(e) {
|
||||
this.form.region = [];
|
||||
this.form.regionId = [];
|
||||
let name = "";
|
||||
|
||||
e.forEach((item, index) => {
|
||||
if (item.id) {
|
||||
this.form.region.push(item.localName);
|
||||
this.form.regionId.push(item.id);
|
||||
if (index == e.length - 1) {
|
||||
name += item.localName;
|
||||
} else {
|
||||
name += item.localName + ",";
|
||||
}
|
||||
this.form.___path = name;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击选择地址
|
||||
*/
|
||||
clickRegion() {
|
||||
this.$refs.cityPicker.show();
|
||||
},
|
||||
|
||||
/**
|
||||
* 提交保存
|
||||
*/
|
||||
submit() {
|
||||
delete this.form.___path;
|
||||
let params = JSON.parse(JSON.stringify(this.form));
|
||||
saveUserInfo(params).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
storage.setUserInfo(res.data.result);
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改头像
|
||||
*/
|
||||
changeFace(index) {
|
||||
uni.chooseImage({
|
||||
success: (chooseImageRes) => {
|
||||
const tempFilePaths = chooseImageRes.tempFilePaths;
|
||||
uni.uploadFile({
|
||||
url: upload,
|
||||
filePath: tempFilePaths[0],
|
||||
name: "file",
|
||||
header: {
|
||||
accessToken: storage.getAccessToken(),
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
let data = JSON.parse(uploadFileRes.data);
|
||||
this.form.face = data.result;
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择地址
|
||||
*/
|
||||
selectRegion(region) {
|
||||
this.$set(
|
||||
this.form,
|
||||
"address",
|
||||
`${region.province.label} ${region.city.label} ${region.area.label}`
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择时间
|
||||
*/
|
||||
selectTime(time) {
|
||||
this.form.birthday = `${time.year}-${time.month}-${time.day}`;
|
||||
this.birthday = `${time.year} - ${time.month} - ${time.day}`;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 加载数据
|
||||
*/
|
||||
onLoad() {},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.submit {
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
margin-top: 90rpx;
|
||||
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
color: $main-color;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
.head {
|
||||
height: 260rpx;
|
||||
color: $font-color-light;
|
||||
font-size: $font-sm;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
line-height: 2em;
|
||||
|
||||
image {
|
||||
width: 144rpx;
|
||||
height: 144rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .u-form {
|
||||
background-color: #ffffff;
|
||||
padding: 0;
|
||||
margin-top: 30rpx;
|
||||
|
||||
.u-form-item {
|
||||
padding: 0 20rpx;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.form {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.bottom {
|
||||
position: fixed;
|
||||
bottom: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
> .submit {
|
||||
background: $light-color;
|
||||
background: #fe3c3c;
|
||||
color: #fff;
|
||||
width: 40%;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep {
|
||||
.u-radio__icon-wrap--checked {
|
||||
// background: #FE3C3C;
|
||||
// border: 1px solid #FE3C3C;
|
||||
border-color: #fe3c3c !important;
|
||||
background-color: #fe3c3c !important;
|
||||
}
|
||||
}
|
||||
|
||||
.u-form-item div {
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="person-msg">
|
||||
<view
|
||||
class="head c-content"
|
||||
@click="changeFace"
|
||||
>
|
||||
<image
|
||||
:src="form.face || '/static/missing-face.png'"
|
||||
mode=""
|
||||
></image>
|
||||
<view>点击修改头像</view>
|
||||
</view>
|
||||
<u-form
|
||||
:model="form"
|
||||
ref="uForm"
|
||||
class="form"
|
||||
>
|
||||
<u-form-item
|
||||
label="昵称"
|
||||
label-width="150"
|
||||
>
|
||||
<u-input
|
||||
v-model="form.nickName"
|
||||
placeholder="请输入昵称"
|
||||
maxlength="10"
|
||||
/>
|
||||
</u-form-item>
|
||||
<u-form-item
|
||||
label="二维码"
|
||||
label-width="150"
|
||||
>
|
||||
<img
|
||||
:src="erwei"
|
||||
alt=""
|
||||
width="60"
|
||||
@click="showQrCodeInFullSize"
|
||||
/>
|
||||
</u-form-item>
|
||||
<u-form-item
|
||||
label="性别"
|
||||
label-width="150"
|
||||
>
|
||||
<u-radio-group
|
||||
v-model="form.sex"
|
||||
:active-color="lightColor"
|
||||
>
|
||||
<u-radio name="1">男</u-radio>
|
||||
<u-radio name="0">女</u-radio>
|
||||
</u-radio-group>
|
||||
</u-form-item>
|
||||
<u-form-item
|
||||
label="生日"
|
||||
label-width="150"
|
||||
right-icon="arrow-right"
|
||||
>
|
||||
<div
|
||||
style="width: 100%"
|
||||
@click="showBirthday = true"
|
||||
>
|
||||
{{ birthday || '请选择出生日期' }}
|
||||
</div>
|
||||
<u-picker
|
||||
v-model="showBirthday"
|
||||
mode="time"
|
||||
:confirm-color="lightColor"
|
||||
@confirm="selectTime"
|
||||
></u-picker>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item
|
||||
label="城市"
|
||||
label-width="150"
|
||||
placeholder="请选择城市"
|
||||
right-icon="arrow-right"
|
||||
>
|
||||
<div
|
||||
style="width: 32vh; white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
|
||||
@click="clickRegion"
|
||||
>
|
||||
{{ form.___path || '请选择城市' }}
|
||||
</div>
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
<div style="display: flex; justify-content: center"></div>
|
||||
<div class="bottom">
|
||||
<view
|
||||
class="submit"
|
||||
@click="submit"
|
||||
>
|
||||
保存
|
||||
</view>
|
||||
<view
|
||||
class="submit light"
|
||||
@click="showModalDialog"
|
||||
>
|
||||
退出登录
|
||||
</view>
|
||||
</div>
|
||||
<u-modal
|
||||
show-cancel-button
|
||||
v-model="quitShow"
|
||||
@confirm="confirm"
|
||||
:confirm-color="lightColor"
|
||||
:async-close="true"
|
||||
:content="userInfo.id ? '确定要退出登录么?' : '确定要返回登录么?'"
|
||||
></u-modal>
|
||||
<m-city
|
||||
:provinceData="region"
|
||||
headTitle="区域选择"
|
||||
ref="cityPicker"
|
||||
@funcValue="getpickerParentValue"
|
||||
pickerSize="4"
|
||||
></m-city>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { saveUserInfo, geterwei } from '@/api/members.js';
|
||||
import { upload } from '@/api/common.js';
|
||||
import { logout } from '@/api/login';
|
||||
import storage from '@/utils/storage.js';
|
||||
import uFormItem from '@/uview-ui/components/u-form-item/u-form-item.vue';
|
||||
import gkcity from '@/components/m-city/m-city.vue';
|
||||
import { clearIm } from '@/utils/handleim.js';
|
||||
export default {
|
||||
components: {
|
||||
uFormItem,
|
||||
'm-city': gkcity
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
erwei: '',
|
||||
quitShow: false,
|
||||
userInfo: {},
|
||||
lightColor: this.$lightColor, //高亮颜色
|
||||
form: {
|
||||
nickName: storage.getUserInfo().nickName || '',
|
||||
birthday: storage.getUserInfo().birthday || '',
|
||||
face: storage.getUserInfo().face || '/static/imlogo.png', //默认头像
|
||||
regionId: [], //地址Id
|
||||
region: storage.getUserInfo().region || [], //地址
|
||||
sex: storage.getUserInfo().sex, //性别
|
||||
___path: storage.getUserInfo().region
|
||||
},
|
||||
birthday: storage.getUserInfo().birthday || '', //生日
|
||||
photo: [
|
||||
{
|
||||
text: '立即拍照',
|
||||
color: this.$mainColor
|
||||
},
|
||||
{
|
||||
text: '从相册选择',
|
||||
color: this.$mainColor
|
||||
}
|
||||
],
|
||||
region: [
|
||||
//请求城市默认地址
|
||||
{
|
||||
id: '',
|
||||
localName: '请选择',
|
||||
children: []
|
||||
}
|
||||
],
|
||||
showBirthday: false //显示生日日期
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = this.$options.filters.isLogin();
|
||||
this.getgeterwei();
|
||||
},
|
||||
methods: {
|
||||
showQrCodeInFullSize() {
|
||||
uni.previewImage({
|
||||
urls: [this.erwei],
|
||||
current: this.erwei
|
||||
});
|
||||
},
|
||||
getgeterwei() {
|
||||
geterwei().then((res) => {
|
||||
this.erwei = res.data.result;
|
||||
});
|
||||
},
|
||||
showModalDialog() {
|
||||
this.quitShow = true;
|
||||
},
|
||||
clear() {
|
||||
storage.setRefreshVlogIndex('1'); //需要刷新
|
||||
storage.setHasLogin(false);
|
||||
storage.setAccessToken('');
|
||||
storage.setRefreshToken('');
|
||||
storage.setUuid('');
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken('');
|
||||
storage.setVlogUserInfo(null);
|
||||
// 清除初始化数据内容
|
||||
storage.setRefreshVlogIndex('1'); //需要刷新
|
||||
// 退出im登录
|
||||
clearIm();
|
||||
this.$options.filters.navigateToLogin('redirectTo');
|
||||
},
|
||||
/**
|
||||
* 确认退出
|
||||
* 清除缓存重新登录
|
||||
*/
|
||||
async confirm() {
|
||||
await logout();
|
||||
this.clear();
|
||||
},
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
quiteLoginOut() {
|
||||
this.$options.filters.quiteLoginOut();
|
||||
},
|
||||
/**
|
||||
* 选择地址回调
|
||||
*/
|
||||
getpickerParentValue(e) {
|
||||
this.form.region = [];
|
||||
this.form.regionId = [];
|
||||
let name = '';
|
||||
|
||||
e.forEach((item, index) => {
|
||||
if (item.id) {
|
||||
this.form.region.push(item.localName);
|
||||
this.form.regionId.push(item.id);
|
||||
if (index == e.length - 1) {
|
||||
name += item.localName;
|
||||
} else {
|
||||
name += item.localName + ',';
|
||||
}
|
||||
this.form.___path = name;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击选择地址
|
||||
*/
|
||||
clickRegion() {
|
||||
this.$refs.cityPicker.show();
|
||||
},
|
||||
|
||||
/**
|
||||
* 提交保存
|
||||
*/
|
||||
submit() {
|
||||
delete this.form.___path;
|
||||
let params = JSON.parse(JSON.stringify(this.form));
|
||||
saveUserInfo(params).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
storage.setUserInfo(res.data.result);
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改头像
|
||||
*/
|
||||
changeFace(index) {
|
||||
uni.chooseImage({
|
||||
success: (chooseImageRes) => {
|
||||
const tempFilePaths = chooseImageRes.tempFilePaths;
|
||||
uni.uploadFile({
|
||||
url: upload,
|
||||
filePath: tempFilePaths[0],
|
||||
name: 'file',
|
||||
header: {
|
||||
accessToken: storage.getAccessToken()
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
let data = JSON.parse(uploadFileRes.data);
|
||||
this.form.face = data.result;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择地址
|
||||
*/
|
||||
selectRegion(region) {
|
||||
this.$set(this.form, 'address', `${region.province.label} ${region.city.label} ${region.area.label}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择时间
|
||||
*/
|
||||
selectTime(time) {
|
||||
this.form.birthday = `${time.year}-${time.month}-${time.day}`;
|
||||
this.birthday = `${time.year} - ${time.month} - ${time.day}`;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 加载数据
|
||||
*/
|
||||
onLoad() {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.submit {
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
margin-top: 90rpx;
|
||||
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
color: $main-color;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
.head {
|
||||
height: 260rpx;
|
||||
color: $font-color-light;
|
||||
font-size: $font-sm;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
line-height: 2em;
|
||||
|
||||
image {
|
||||
width: 144rpx;
|
||||
height: 144rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .u-form {
|
||||
background-color: #ffffff;
|
||||
padding: 0;
|
||||
margin-top: 30rpx;
|
||||
|
||||
.u-form-item {
|
||||
padding: 0 20rpx;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.form {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.bottom {
|
||||
position: fixed;
|
||||
bottom: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
> .submit {
|
||||
background: $light-color;
|
||||
background: #fe3c3c;
|
||||
color: #fff;
|
||||
width: 40%;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep {
|
||||
.u-radio__icon-wrap--checked {
|
||||
// background: #FE3C3C;
|
||||
// border: 1px solid #FE3C3C;
|
||||
border-color: #fe3c3c !important;
|
||||
background-color: #fe3c3c !important;
|
||||
}
|
||||
}
|
||||
|
||||
.u-form-item div {
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,231 +1,273 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="person" @click="checkUserInfo()">
|
||||
<u-image width=140 height="140" shape="circle" :src="userInfo.face || '/static/missing-face.png'" mode="">
|
||||
</u-image>
|
||||
<view class="user-name">
|
||||
|
||||
{{ userInfo.id ? userInfo.nickName || '' : '暂未登录' }}
|
||||
</view>
|
||||
<u-icon color="#ccc" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view style="height: 20rpx; width: 100%"></view>
|
||||
<!-- #endif -->
|
||||
<u-cell-group :border="false">
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<u-cell-item title="清除缓存" :value="fileSizeString" @click="clearCache"></u-cell-item>
|
||||
<!-- #endif -->
|
||||
<u-cell-item title="安全中心" @click="navigateTo('/pages/mine/set/securityCenter/securityCenter')"></u-cell-item>
|
||||
<u-cell-item title="意见反馈" @click="navigateTo('/pages/mine/set/feedBack')"></u-cell-item>
|
||||
<!-- #ifndef H5 -->
|
||||
<!-- #endif -->
|
||||
<u-cell-item :title="`关于我们`" @click="navigateTo('/pages/mine/set/editionIntro')"></u-cell-item>
|
||||
</u-cell-group>
|
||||
<view class="submit" @click="showModalDialog">{{userInfo.id ?'退出登录':'返回登录'}}</view>
|
||||
<u-modal show-cancel-button v-model="quitShow" @confirm="confirm" :confirm-color="lightColor" :async-close="true"
|
||||
:content="userInfo.id ? '确定要退出登录么?' : '确定要返回登录么?'"></u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { logout } from "@/api/login";
|
||||
import storage from "@/utils/storage.js";
|
||||
import config from "@/config/config";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
config,
|
||||
lightColor: this.$lightColor,
|
||||
quitShow: false,
|
||||
isCertificate: false,
|
||||
userInfo: {},
|
||||
fileSizeString: "0B",
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
navigateTo(url) {
|
||||
if (url == "/pages/set/securityCenter/securityCenter") {
|
||||
url += `?mobile=${this.userInfo.mobile}`;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
});
|
||||
},
|
||||
clear() {
|
||||
storage.setAccessToken("");
|
||||
storage.setRefreshToken("");
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken("")
|
||||
storage.setVlogUserInfo({})
|
||||
this.$options.filters.navigateToLogin("redirectTo");
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认退出
|
||||
* 清除缓存重新登录
|
||||
*/
|
||||
async confirm() {
|
||||
await logout();
|
||||
this.clear();
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示退出登录对话框
|
||||
*/
|
||||
showModalDialog() {
|
||||
this.quitShow = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 读取当前缓存
|
||||
*/
|
||||
getCacheSize() {
|
||||
//获取缓存数据
|
||||
let that = this;
|
||||
plus.cache.calculate(function (size) {
|
||||
let sizeCache = parseInt(size);
|
||||
if (sizeCache == 0) {
|
||||
that.fileSizeString = "0B";
|
||||
} else if (sizeCache < 1024) {
|
||||
that.fileSizeString = sizeCache + "B";
|
||||
} else if (sizeCache < 1048576) {
|
||||
that.fileSizeString = (sizeCache / 1024).toFixed(2) + "KB";
|
||||
} else if (sizeCache < 1073741824) {
|
||||
that.fileSizeString = (sizeCache / 1048576).toFixed(2) + "MB";
|
||||
} else {
|
||||
that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + "GB";
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击用户详情
|
||||
* 判断当前是否进入用户中心
|
||||
*/
|
||||
checkUserInfo() {
|
||||
if (this.$options.filters.isLogin("auth")) {
|
||||
this.navigateTo("/pages/mine/set/personMsg");
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "当前暂无用户请登录后重试",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除当前设备缓存
|
||||
*/
|
||||
clearCache() {
|
||||
//清理缓存
|
||||
let that = this;
|
||||
let os = plus.os.name;
|
||||
if (os == "Android") {
|
||||
let main = plus.android.runtimeMainActivity();
|
||||
let sdRoot = main.getCacheDir();
|
||||
let files = plus.android.invoke(sdRoot, "listFiles");
|
||||
let len = files.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
let filePath = "" + files[i]; // 没有找到合适的方法获取路径,这样写可以转成文件路径
|
||||
plus.io.resolveLocalFileSystemURL(
|
||||
filePath,
|
||||
function (entry) {
|
||||
if (entry.isDirectory) {
|
||||
entry.removeRecursively(
|
||||
function (entry) {
|
||||
//递归删除其下的所有文件及子目录
|
||||
uni.showToast({
|
||||
title: "缓存清理完成",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
that.getCacheSize(); // 重新计算缓存
|
||||
},
|
||||
function (e) {}
|
||||
);
|
||||
} else {
|
||||
entry.remove();
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
uni.showToast({
|
||||
title: "文件路径读取失败",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// ios
|
||||
plus.cache.clear(function () {
|
||||
uni.showToast({
|
||||
title: "缓存清理完成",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
that.getCacheSize();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = this.$options.filters.isLogin();
|
||||
// #ifdef APP-PLUS
|
||||
this.getCacheSize();
|
||||
// #endif
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.submit {
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
margin-top: 90rpx;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
color: $main-color;
|
||||
}
|
||||
.person {
|
||||
height: 208rpx;
|
||||
display: flex;
|
||||
padding: 0 20rpx;
|
||||
font-size: $font-base;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
.user-name {
|
||||
width: 500rpx;
|
||||
overflow: hidden;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
|
||||
white-space: nowrap;
|
||||
margin-left: 30rpx;
|
||||
line-height: 2em;
|
||||
font-size: 34rpx;
|
||||
}
|
||||
}
|
||||
.u-cell {
|
||||
height: 110rpx;
|
||||
/* line-height: 110rpx; */
|
||||
padding: 0 20rpx;
|
||||
align-items: center;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
/deep/ .u-cell__value {
|
||||
color: #cccccc !important;
|
||||
}
|
||||
|
||||
/deep/ .u-cell__right-icon-wrap {
|
||||
color: #cccccc !important;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="container">
|
||||
<view
|
||||
class="person"
|
||||
@click="checkUserInfo()"
|
||||
>
|
||||
<u-image
|
||||
width="140"
|
||||
height="140"
|
||||
shape="circle"
|
||||
:src="userInfo.face || '/static/missing-face.png'"
|
||||
mode=""
|
||||
></u-image>
|
||||
<view class="user-name">
|
||||
{{ userInfo.id ? userInfo.nickName || '' : '暂未登录' }}
|
||||
</view>
|
||||
<u-icon
|
||||
color="#ccc"
|
||||
name="arrow-right"
|
||||
></u-icon>
|
||||
</view>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view style="height: 20rpx; width: 100%"></view>
|
||||
<!-- #endif -->
|
||||
<u-cell-group :border="false">
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<u-cell-item
|
||||
title="清除缓存"
|
||||
:value="fileSizeString"
|
||||
@click="clearCache"
|
||||
></u-cell-item>
|
||||
<!-- #endif -->
|
||||
<u-cell-item
|
||||
title="安全中心"
|
||||
@click="navigateTo('/pages/mine/set/securityCenter/securityCenter')"
|
||||
></u-cell-item>
|
||||
<u-cell-item
|
||||
title="意见反馈"
|
||||
@click="navigateTo('/pages/mine/set/feedBack')"
|
||||
></u-cell-item>
|
||||
<!-- #ifndef H5 -->
|
||||
<!-- #endif -->
|
||||
<u-cell-item
|
||||
:title="`关于我们`"
|
||||
@click="navigateTo('/pages/mine/set/editionIntro')"
|
||||
></u-cell-item>
|
||||
</u-cell-group>
|
||||
<view
|
||||
class="submit"
|
||||
@click="showModalDialog"
|
||||
>
|
||||
{{ userInfo.id ? '退出登录' : '返回登录' }}
|
||||
</view>
|
||||
<u-modal
|
||||
show-cancel-button
|
||||
v-model="quitShow"
|
||||
@confirm="confirm"
|
||||
:confirm-color="lightColor"
|
||||
:async-close="true"
|
||||
:content="userInfo.id ? '确定要退出登录么?' : '确定要返回登录么?'"
|
||||
></u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { logout } from '@/api/login';
|
||||
import storage from '@/utils/storage.js';
|
||||
import config from '@/config/config';
|
||||
import { clearIm } from '@/utils/handleim.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
config,
|
||||
lightColor: this.$lightColor,
|
||||
quitShow: false,
|
||||
isCertificate: false,
|
||||
userInfo: {},
|
||||
fileSizeString: '0B'
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
navigateTo(url) {
|
||||
if (url == '/pages/set/securityCenter/securityCenter') {
|
||||
url += `?mobile=${this.userInfo.mobile}`;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
},
|
||||
clear() {
|
||||
storage.setRefreshVlogIndex('1'); //需要刷新
|
||||
storage.setHasLogin(false);
|
||||
storage.setAccessToken('');
|
||||
storage.setRefreshToken('');
|
||||
storage.setUuid('');
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken('');
|
||||
storage.setVlogUserInfo(null);
|
||||
// 清除初始化数据内容
|
||||
storage.setRefreshVlogIndex('1'); //需要刷新
|
||||
// 退出im登录
|
||||
clearIm();
|
||||
this.$options.filters.navigateToLogin('redirectTo');
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认退出
|
||||
* 清除缓存重新登录
|
||||
*/
|
||||
async confirm() {
|
||||
await logout();
|
||||
this.clear();
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示退出登录对话框
|
||||
*/
|
||||
showModalDialog() {
|
||||
this.quitShow = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 读取当前缓存
|
||||
*/
|
||||
getCacheSize() {
|
||||
//获取缓存数据
|
||||
let that = this;
|
||||
plus.cache.calculate(function (size) {
|
||||
let sizeCache = parseInt(size);
|
||||
if (sizeCache == 0) {
|
||||
that.fileSizeString = '0B';
|
||||
} else if (sizeCache < 1024) {
|
||||
that.fileSizeString = sizeCache + 'B';
|
||||
} else if (sizeCache < 1048576) {
|
||||
that.fileSizeString = (sizeCache / 1024).toFixed(2) + 'KB';
|
||||
} else if (sizeCache < 1073741824) {
|
||||
that.fileSizeString = (sizeCache / 1048576).toFixed(2) + 'MB';
|
||||
} else {
|
||||
that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + 'GB';
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击用户详情
|
||||
* 判断当前是否进入用户中心
|
||||
*/
|
||||
checkUserInfo() {
|
||||
if (this.$options.filters.isLogin('auth')) {
|
||||
this.navigateTo('/pages/mine/set/personMsg');
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '当前暂无用户请登录后重试',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除当前设备缓存
|
||||
*/
|
||||
clearCache() {
|
||||
//清理缓存
|
||||
let that = this;
|
||||
let os = plus.os.name;
|
||||
if (os == 'Android') {
|
||||
let main = plus.android.runtimeMainActivity();
|
||||
let sdRoot = main.getCacheDir();
|
||||
let files = plus.android.invoke(sdRoot, 'listFiles');
|
||||
let len = files.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
let filePath = '' + files[i]; // 没有找到合适的方法获取路径,这样写可以转成文件路径
|
||||
plus.io.resolveLocalFileSystemURL(
|
||||
filePath,
|
||||
function (entry) {
|
||||
if (entry.isDirectory) {
|
||||
entry.removeRecursively(
|
||||
function (entry) {
|
||||
//递归删除其下的所有文件及子目录
|
||||
uni.showToast({
|
||||
title: '缓存清理完成',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
});
|
||||
that.getCacheSize(); // 重新计算缓存
|
||||
},
|
||||
function (e) {}
|
||||
);
|
||||
} else {
|
||||
entry.remove();
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
uni.showToast({
|
||||
title: '文件路径读取失败',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// ios
|
||||
plus.cache.clear(function () {
|
||||
uni.showToast({
|
||||
title: '缓存清理完成',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
});
|
||||
that.getCacheSize();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = this.$options.filters.isLogin();
|
||||
// #ifdef APP-PLUS
|
||||
this.getCacheSize();
|
||||
// #endif
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.submit {
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
margin-top: 90rpx;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
color: $main-color;
|
||||
}
|
||||
.person {
|
||||
height: 208rpx;
|
||||
display: flex;
|
||||
padding: 0 20rpx;
|
||||
font-size: $font-base;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
.user-name {
|
||||
width: 500rpx;
|
||||
overflow: hidden;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
|
||||
white-space: nowrap;
|
||||
margin-left: 30rpx;
|
||||
line-height: 2em;
|
||||
font-size: 34rpx;
|
||||
}
|
||||
}
|
||||
.u-cell {
|
||||
height: 110rpx;
|
||||
/* line-height: 110rpx; */
|
||||
padding: 0 20rpx;
|
||||
align-items: center;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
/deep/ .u-cell__value {
|
||||
color: #cccccc !important;
|
||||
}
|
||||
|
||||
/deep/ .u-cell__right-icon-wrap {
|
||||
color: #cccccc !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -95,6 +95,7 @@ import api from '@/config/api.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
upFlage: true,
|
||||
publishTouched: false,
|
||||
preplayTouched: false,
|
||||
tempFilePath: '',
|
||||
@ -107,6 +108,7 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(params) {
|
||||
this.upFlage = false;
|
||||
let me = this;
|
||||
let vlogInfo = storage.getVlogUserInfo();
|
||||
// 上个页面传过来的文件事件对象, 其中包含了相册中选择的视频内容
|
||||
@ -147,6 +149,9 @@ export default {
|
||||
// (res.progress * 100) / res.total
|
||||
// );
|
||||
me.percentCompleted = res.progress;
|
||||
if (res.progress == 100) {
|
||||
me.upFlage = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
@ -155,6 +160,9 @@ export default {
|
||||
this.title = e.detail.value;
|
||||
},
|
||||
doPublich() {
|
||||
if (!this.upFlage) {
|
||||
return;
|
||||
}
|
||||
if (this.title.length < 5) {
|
||||
uni.showToast({
|
||||
title: '请输入5个字以上的标题!',
|
||||
@ -162,6 +170,10 @@ export default {
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.upFlage = false;
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
});
|
||||
let me = this;
|
||||
let vlogInfo = storage.getVlogUserInfo();
|
||||
let userId = vlogInfo.id;
|
||||
@ -187,17 +199,15 @@ export default {
|
||||
data: vlog,
|
||||
success(result) {
|
||||
if (result.data.status == 200) {
|
||||
uni.showToast({
|
||||
title: result.data.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
// uni.showToast({
|
||||
// title: result.data.msg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// });
|
||||
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: '/pages/me/me'
|
||||
});
|
||||
}, 2000);
|
||||
uni.switchTab({
|
||||
url: '/pages/me/me'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: result.data.msg,
|
||||
@ -205,6 +215,10 @@ export default {
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
},
|
||||
complete() {
|
||||
this.upFlage = true;
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -114,6 +114,10 @@ export default {
|
||||
}
|
||||
data.forEach((i) => {
|
||||
i.doIflow = false;
|
||||
if (i.followStatus == null) {
|
||||
// 处理未登录时的状态
|
||||
i.followStatus = '未关注';
|
||||
}
|
||||
this.flowList.push(i);
|
||||
});
|
||||
// this.flowList.push(...data);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -210,13 +210,32 @@ export default {
|
||||
let tabIndex = e.index;
|
||||
if (tabIndex == 0) {
|
||||
var prop = this.pageList[this.curIndex];
|
||||
this.$refs[prop].showVd();
|
||||
// this.$refs[prop].showVd();
|
||||
console.log('是否刷新:' + storage.getRefreshVlogIndex());
|
||||
if (storage.getRefreshVlogIndex() === '1') {
|
||||
try {
|
||||
storage.setRefreshVlogIndex('0'); //初始完数据修改状态不需要刷新
|
||||
console.log('是否刷新:' + storage.getRefreshVlogIndex());
|
||||
// 登录后需要刷新数据
|
||||
for (var i = 0; i < this.pageList.length; i++) {
|
||||
this.$refs[i].dataList = []; //所有数据清空
|
||||
}
|
||||
this.$refs[prop].get(); //只初始化当前所在位置的数据
|
||||
} catch (err) {
|
||||
console.log(err + '255');
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.$refs[prop].showVd();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
var prop = this.pageList[this.curIndex];
|
||||
this.getLocation();
|
||||
this.myUserInfo = storage.getVlogUserInfo();
|
||||
if (storage.getRefreshVlogIndex() == '1') {
|
||||
// 登录后需要刷新数据
|
||||
for (var i = 0; i < this.pageList.length; i++) {
|
||||
|
||||
@ -5,27 +5,27 @@ import storage from "@/utils/storage";
|
||||
Vue.use(Vuex);
|
||||
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
verificationKey: "", //获取key表示验证通过
|
||||
distributionId:"", //分销员Id 如果当前账户从未登录过时记录
|
||||
hasLogin: storage.getHasLogin(),
|
||||
userInfo: storage.getUserInfo(),
|
||||
uuid: storage.getUuid(),
|
||||
token: "",
|
||||
},
|
||||
mutations: {
|
||||
login(state, userInfo) {
|
||||
state.userInfo = userInfo || {};
|
||||
state.userName =
|
||||
userInfo.Name || userInfo.Nickname || userInfo.Username || "匿名用户";
|
||||
state.hasLogin = true;
|
||||
},
|
||||
logout(state) {
|
||||
state.userName = "";
|
||||
state.hasLogin = false;
|
||||
},
|
||||
},
|
||||
actions: {},
|
||||
state: {
|
||||
verificationKey: "", //获取key表示验证通过
|
||||
distributionId: "", //分销员Id 如果当前账户从未登录过时记录
|
||||
hasLogin: storage.getHasLogin(),
|
||||
userInfo: storage.getUserInfo(),
|
||||
uuid: storage.getUuid(),
|
||||
token: "",
|
||||
},
|
||||
mutations: {
|
||||
login(state, userInfo) {
|
||||
state.userInfo = userInfo || {};
|
||||
state.userName =
|
||||
userInfo.Name || userInfo.Nickname || userInfo.Username || "匿名用户";
|
||||
state.hasLogin = true;
|
||||
},
|
||||
logout(state) {
|
||||
state.userName = "";
|
||||
state.hasLogin = false;
|
||||
},
|
||||
},
|
||||
actions: {},
|
||||
});
|
||||
|
||||
export default store;
|
||||
export default store;
|
||||
@ -15,13 +15,16 @@
|
||||
.all-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
/* justify-content: space-around; */
|
||||
height: 280rpx;
|
||||
}
|
||||
.share-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 60rpx;
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
width: 120rpx;
|
||||
}
|
||||
.icon-wrapper {
|
||||
width: 120rpx;
|
||||
@ -39,8 +42,12 @@
|
||||
}
|
||||
.icon-tag-text {
|
||||
color: #ffffff;
|
||||
width: 120rpx;
|
||||
font-size: 14px;
|
||||
margin-top: 10rpx;
|
||||
lines: 1;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -70,6 +77,7 @@
|
||||
</view> -->
|
||||
|
||||
<view
|
||||
v-if="userId == ''"
|
||||
class="share-item"
|
||||
@click="copyLink()"
|
||||
>
|
||||
@ -90,6 +98,73 @@
|
||||
复制链接
|
||||
</text>
|
||||
</view>
|
||||
<!-- 会话列表 storage.getHasLogin() -->
|
||||
<scroll-view
|
||||
v-if="userId != ''"
|
||||
:scroll-x="true"
|
||||
:show-scrollbar="false"
|
||||
class="all-box"
|
||||
>
|
||||
<view
|
||||
class="share-item"
|
||||
@click="copyLink()"
|
||||
>
|
||||
<view
|
||||
class="icon-wrapper"
|
||||
style="align-self: center"
|
||||
>
|
||||
<image
|
||||
class="icon-image"
|
||||
src="/static/images/link.png"
|
||||
style="align-self: center"
|
||||
></image>
|
||||
</view>
|
||||
<text
|
||||
class="icon-tag-text"
|
||||
style="align-self: center"
|
||||
>
|
||||
复制链接
|
||||
</text>
|
||||
</view>
|
||||
<view
|
||||
v-for="(i, index) in converList"
|
||||
:key="index"
|
||||
class="share-item"
|
||||
@click="toIm(i)"
|
||||
>
|
||||
<view
|
||||
class="icon-wrapper"
|
||||
style="align-self: center"
|
||||
>
|
||||
<image
|
||||
v-if="i.type == 'C2C'"
|
||||
class="icon-image"
|
||||
:src="i.userProfile.avatar || ''"
|
||||
style="align-self: center"
|
||||
></image>
|
||||
<image
|
||||
v-if="i.type == 'GROUP'"
|
||||
class="icon-image"
|
||||
:src="i.groupProfile.avatar || ''"
|
||||
style="align-self: center"
|
||||
></image>
|
||||
</view>
|
||||
<text
|
||||
v-if="i.type == 'C2C'"
|
||||
class="icon-tag-text"
|
||||
style="align-self: center"
|
||||
>
|
||||
{{ i.userProfile.nick || '' }}
|
||||
</text>
|
||||
<text
|
||||
v-if="i.type == 'GROUP'"
|
||||
class="icon-tag-text"
|
||||
style="align-self: center"
|
||||
>
|
||||
{{ i.groupProfile.name || '' }}
|
||||
</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- <view
|
||||
class="share-item"
|
||||
@ -190,8 +265,10 @@
|
||||
|
||||
<script>
|
||||
import storage from '@/utils/storage.js'; //缓存
|
||||
import config from '@/config/config.js';
|
||||
import { vlogChangeToPublic, vlogChangeToPrivate } from '@/api/vlog';
|
||||
import { dateFormat, graceNumber, getDateBeforeNow } from '@/utils/tools.js';
|
||||
import { conversationData, sendVlogCustomMsg } from '@/utils/handleim.js';
|
||||
import popup from '../uni-popup/popup.js';
|
||||
export default {
|
||||
name: 'UniPopupShare',
|
||||
@ -221,12 +298,15 @@ export default {
|
||||
isPrivate: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
vlogItem: {}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userId: '',
|
||||
cancelTouched: false
|
||||
cancelTouched: false,
|
||||
converList: [],
|
||||
flag: true
|
||||
};
|
||||
},
|
||||
|
||||
@ -234,10 +314,51 @@ export default {
|
||||
console.log('挂载');
|
||||
var info = storage.getVlogUserInfo();
|
||||
if (info != null) {
|
||||
console.log('登录了');
|
||||
this.userId = info.id;
|
||||
this.conversationList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取会话列表
|
||||
async conversationList() {
|
||||
var data = await conversationData();
|
||||
console.log(data);
|
||||
this.converList = data.data.conversationList;
|
||||
console.log(this.converList);
|
||||
},
|
||||
toIm(i) {
|
||||
if (this.flag) {
|
||||
this.flag = false;
|
||||
sendVlogCustomMsg(i, this.vlogItem)
|
||||
.then((res) => {
|
||||
console.log('发送成功,返回结果:', res);
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '分享成功',
|
||||
duration: 3000
|
||||
});
|
||||
var timer = setTimeout(() => {
|
||||
clearTimeout(timer);
|
||||
this.flag = true;
|
||||
}, 3000);
|
||||
})
|
||||
.catch((err) => {
|
||||
this.flag = true;
|
||||
console.error('发送失败了', err);
|
||||
// 这里可以做失败之后的处理,比如弹个错误提示
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: '云服务异常'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '点太快了'
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 选择内容
|
||||
*/
|
||||
@ -293,8 +414,9 @@ export default {
|
||||
|
||||
copyLink() {
|
||||
// this.thisVlogId 视频id
|
||||
var url = config.shareLink + '/pages/me/vlog?vlogId=' + this.thisVlogId;
|
||||
uni.setClipboardData({
|
||||
data: this.vlogUrl,
|
||||
data: url,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
//提示
|
||||
|
||||
216
utils/handleim.js
Normal file
216
utils/handleim.js
Normal file
@ -0,0 +1,216 @@
|
||||
import {
|
||||
getUserimInfo
|
||||
} from '@/api/members';
|
||||
|
||||
import {
|
||||
TUILogin
|
||||
} from '@tencentcloud/tui-core';
|
||||
|
||||
import {
|
||||
TUIConversationService,
|
||||
} from '@tencentcloud/chat-uikit-engine';
|
||||
|
||||
|
||||
import {
|
||||
TUIGlobal
|
||||
} from '@tencentcloud/universal-api';
|
||||
|
||||
|
||||
import * as Push from '@/uni_modules/TencentCloud-Push';
|
||||
|
||||
import storage from "@/utils/storage.js";
|
||||
|
||||
// sdkStateNotReady IM断了
|
||||
// onMessageReceived 收到推送的单聊、群聊、群提示、群系统通知的新消息
|
||||
|
||||
// im断开链接时
|
||||
const onSdkNotReady = function(event) {
|
||||
console.log('IM断了')
|
||||
var islogin = storage.getVlogUserInfo();
|
||||
if (islogin != null) {
|
||||
// 重新执行IM登录
|
||||
loginIm()
|
||||
}
|
||||
}
|
||||
|
||||
const onMessageReceived = function(event) {
|
||||
// event.data - 存储 Message 对象的数组 - [Message]
|
||||
// 这里处理消息通知相关业务,4.0版本后续进行开发
|
||||
console.log('收到了消息通知内容')
|
||||
console.log(event.data)
|
||||
}
|
||||
|
||||
const pushClick = (res) => {
|
||||
console.log('notification clicked', res);
|
||||
// 解析扩展信息,跳转到相应的会话(代码仅供参考,发布前需要完善)
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
const conv_type = data?.entity?.chatType === 1 ? 'C2C' : 'GROUP';
|
||||
// 根据推送信息拼的 conversationID
|
||||
const conversationID = `${conv_type}${data.entity.sender}`;
|
||||
// 切换会话
|
||||
TUIConversationService.switchConversation(conversationID);
|
||||
const chatPath = '/TUIKit/components/TUIChat/index';
|
||||
uni.navigateTo({
|
||||
url: chatPath
|
||||
});
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
}
|
||||
}
|
||||
|
||||
const pushOnLine = (res) => {
|
||||
// res 为消息内容
|
||||
console.log('在线推送', res);
|
||||
}
|
||||
|
||||
const pushMsgBack = (res) => {
|
||||
// res 为被撤回的消息 ID
|
||||
console.log('撤回消息推送', res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const loginIm = () => {
|
||||
console.log('执行im登录')
|
||||
getUserimInfo()
|
||||
.then(({
|
||||
data
|
||||
}) => {
|
||||
console.log(data)
|
||||
if (data.code == 200) {
|
||||
const par = data.result;
|
||||
TUILogin.login({
|
||||
SDKAppID: par.sdkAppId,
|
||||
userID: par.userID,
|
||||
userSig: par.userSig,
|
||||
useUploadPlugin: true, // If you need to send rich media messages, please set to true.
|
||||
framework: `vue2` // framework used vue2 / vue3
|
||||
}).then((res) => {
|
||||
|
||||
var {
|
||||
SDKAppID,
|
||||
userID,
|
||||
userSig,
|
||||
chat
|
||||
} = TUILogin.getContext();
|
||||
getApp().globalData.chat = chat;
|
||||
console.log('我是个老板', res)
|
||||
// 每次登录先移除,避免多次监听
|
||||
chat.off('sdkStateNotReady', onSdkNotReady);
|
||||
chat.off('onMessageReceived', onMessageReceived);
|
||||
// 监听im断开链接后重新链接
|
||||
chat.on('sdkStateNotReady', onSdkNotReady);
|
||||
// 监听消息通知
|
||||
chat.on('onMessageReceived', onMessageReceived);
|
||||
|
||||
|
||||
Push.setRegistrationID(par.userID, () => {
|
||||
console.log('设置id设置id设置id设置id设置id设置id设置id设置id设置id设置id', par.userID);
|
||||
|
||||
Push.registerPush(
|
||||
par.sdkAppId,
|
||||
'vkFpe55aYqfV7Sk5uGaoxhEstJ3tcI9dquk7JwG1GloDSLD2HeMWeQweWWXgNlhC',
|
||||
(data) => {
|
||||
console.log('registerPush ok', data);
|
||||
Push.getRegistrationID((registrationID) => {
|
||||
console.log('getRegistrationID ok',
|
||||
registrationID);
|
||||
});
|
||||
},
|
||||
(errCode, errMsg) => {
|
||||
console.error('registerPush failed', errCode, errMsg);
|
||||
}
|
||||
);
|
||||
});
|
||||
// 监听通知栏点击事件,获取推送扩展信息
|
||||
Push.addPushListener(Push.EVENT.NOTIFICATION_CLICKED, pushClick);
|
||||
// 监听在线推送
|
||||
Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, pushOnLine);
|
||||
// 监听在线推送被撤回
|
||||
Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, pushMsgBack);
|
||||
});
|
||||
} else {
|
||||
// 接口返回非 200 状态码,跳转登录页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/passport/login'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
});
|
||||
}
|
||||
|
||||
export const clearIm = async () => {
|
||||
var chat = getApp().globalData.chat;
|
||||
var res_out = await chat.logout()
|
||||
console.log(res_out)
|
||||
console.log('IM退出登录')
|
||||
getApp().globalData.chat = null;
|
||||
// chat.logout中做了关闭推送服务
|
||||
// Push.unRegisterPush().then(res => {
|
||||
// //反注册关闭推送服务
|
||||
// console.log(res)
|
||||
// console.log('反注册关闭推送服务')
|
||||
// })
|
||||
Push.removePushListener(Push.EVENT.NOTIFICATION_CLICKED, pushClick)
|
||||
Push.removePushListener(Push.EVENT.MESSAGE_RECEIVED, pushOnLine)
|
||||
Push.removePushListener(Push.EVENT.MESSAGE_REVOKED, pushMsgBack)
|
||||
}
|
||||
|
||||
export const conversationData = async () => {
|
||||
// 会话列表
|
||||
try {
|
||||
const chatInstance = getApp().globalData.chat
|
||||
console.log(chatInstance)
|
||||
var res = await chatInstance.getConversationList()
|
||||
return res
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
export const sendVlogCustomMsg = async (i, vlogItem) => {
|
||||
// i=IM相关用户信息
|
||||
console.log(i);
|
||||
console.log(vlogItem);
|
||||
try {
|
||||
var chat = getApp().globalData.chat;
|
||||
var conversationType = i.type;
|
||||
if (conversationType == 'C2C') {
|
||||
var to = i.userProfile.userID;
|
||||
} else {
|
||||
var to = i.groupProfile.groupID;
|
||||
}
|
||||
var message = chat.createCustomMessage({
|
||||
to,
|
||||
conversationType,
|
||||
payload: {
|
||||
data: JSON.stringify({
|
||||
businessID: 'video',
|
||||
title: vlogItem.vlogerName,
|
||||
description: vlogItem.content,
|
||||
price: '分享好视频',
|
||||
link: '/pages/me/vlog?vlogId=' + vlogItem.vlogId,
|
||||
imageUrl: vlogItem.cover || vlogItem.firstFrameImg
|
||||
}),
|
||||
description: '[分享视频]',
|
||||
extension: '',
|
||||
|
||||
},
|
||||
cloudCustomData: JSON.stringify({
|
||||
pushTitle: vlogItem.vlogerName,
|
||||
pushDesc: vlogItem.content,
|
||||
businessID: 'video', // 保持一致
|
||||
})
|
||||
})
|
||||
var result = await chat.sendMessage(message)
|
||||
console.log('发送成功:', result);
|
||||
return result; // 成功就把发送结果返回出去
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
}
|
||||
178
utils/request.js
178
utils/request.js
@ -11,6 +11,12 @@ import api from "@/config/api.js";
|
||||
|
||||
import uuid from "@/utils/uuid.modified.js";
|
||||
|
||||
import {
|
||||
clearIm
|
||||
} from "@/utils/handleim.js";
|
||||
|
||||
|
||||
|
||||
function cleanStorage() {
|
||||
uni.showToast({
|
||||
title: "你的登录状态已过期,请重新登录",
|
||||
@ -21,31 +27,38 @@ function cleanStorage() {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
storage.setHasLogin(false);
|
||||
storage.setAccessToken("");
|
||||
storage.setRefreshToken("");
|
||||
storage.setUuid("");
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken("");
|
||||
storage.setVlogUserInfo(null);
|
||||
// 清除初始化数据内容
|
||||
storage.setRefreshVlogIndex("0"); //不需要刷新
|
||||
// 获取当前页面栈
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentRoute = currentPage.route;
|
||||
// 防抖处理跳转
|
||||
// #ifdef MP-WEIXIN
|
||||
if (currentRoute !== 'pages/passport/wechatMPLogin') {
|
||||
uni.navigateTo({ url: "/pages/passport/wechatMPLogin" });
|
||||
}
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
if (currentRoute !== 'pages/passport/login') {
|
||||
uni.navigateTo({ url: "/pages/passport/login" });
|
||||
}
|
||||
// #endif
|
||||
storage.setHasLogin(false);
|
||||
storage.setAccessToken("");
|
||||
storage.setRefreshToken("");
|
||||
storage.setUuid("");
|
||||
storage.setUserInfo({});
|
||||
// 清理vlog信息
|
||||
storage.setVlogToken("");
|
||||
storage.setVlogUserInfo(null);
|
||||
// 清除初始化数据内容
|
||||
storage.setRefreshVlogIndex("1"); //需要刷新
|
||||
// 退出im登录
|
||||
clearIm()
|
||||
|
||||
// 获取当前页面栈
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentRoute = currentPage.route;
|
||||
// 防抖处理跳转
|
||||
// #ifdef MP-WEIXIN
|
||||
if (currentRoute !== 'pages/passport/wechatMPLogin') {
|
||||
uni.navigateTo({
|
||||
url: "/pages/passport/wechatMPLogin"
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
if (currentRoute !== 'pages/passport/login') {
|
||||
uni.navigateTo({
|
||||
url: "/pages/passport/login"
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
let http = new Request();
|
||||
@ -88,25 +101,25 @@ http.interceptors.request.use(
|
||||
..._params,
|
||||
};
|
||||
|
||||
config.params = params;
|
||||
config.header.accessToken = accessToken;
|
||||
}
|
||||
// 配置vlog所需参数
|
||||
let vlogToken = storage.getVlogToken();
|
||||
let vlogId = storage.getVlogUserInfo();
|
||||
if (vlogToken) {
|
||||
config.header.headerUserToken = vlogToken;
|
||||
config.header.headerUserId = vlogId.id;
|
||||
}
|
||||
config.header = {
|
||||
...config.header,
|
||||
uuid: storage.getUuid() || uuid.v1(),
|
||||
};
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
return Promise.reject(config);
|
||||
}
|
||||
config.params = params;
|
||||
config.header.accessToken = accessToken;
|
||||
}
|
||||
// 配置vlog所需参数
|
||||
let vlogToken = storage.getVlogToken();
|
||||
let vlogId = storage.getVlogUserInfo();
|
||||
if (vlogToken) {
|
||||
config.header.headerUserToken = vlogToken;
|
||||
config.header.headerUserId = vlogId.id;
|
||||
}
|
||||
config.header = {
|
||||
...config.header,
|
||||
uuid: storage.getUuid() || uuid.v1(),
|
||||
};
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
return Promise.reject(config);
|
||||
}
|
||||
);
|
||||
|
||||
// 是否正在刷新的标记
|
||||
@ -115,20 +128,28 @@ let isRefreshing = false;
|
||||
let requests = [];
|
||||
// 必须使用异步函数,注意
|
||||
http.interceptors.response.use(
|
||||
async (response) => {
|
||||
// console.log(isRefreshing)
|
||||
// console.log(response)
|
||||
/* 请求之后拦截器。可以使用async await 做异步操作 */
|
||||
// token存在并且token过期
|
||||
if (isRefreshing && response.statusCode === 403) {
|
||||
cleanStorage();
|
||||
isRefreshing = false;
|
||||
}
|
||||
async (response) => {
|
||||
// console.log(isRefreshing)
|
||||
console.log(response)
|
||||
/* 请求之后拦截器。可以使用async await 做异步操作 */
|
||||
// token存在并且token过期
|
||||
|
||||
/**
|
||||
* 后续进来的请求,此时异步获取token时isRefreshing一定为true
|
||||
* 那么也就代表此时token一定是过期状态,响应码也一定为403
|
||||
* 也就会去清理缓存
|
||||
* 所以会导致页面多次刷新到登录页
|
||||
*/
|
||||
|
||||
// if (isRefreshing && response.statusCode === 403) {
|
||||
// cleanStorage();
|
||||
// isRefreshing = false;
|
||||
// }
|
||||
|
||||
let token = storage.getAccessToken();
|
||||
if (
|
||||
(token && response.statusCode === 403) ||
|
||||
response.data.status === 403
|
||||
(token && response.data.status === 403)
|
||||
) {
|
||||
if (!isRefreshing) {
|
||||
isRefreshing = true;
|
||||
@ -149,6 +170,8 @@ http.interceptors.response.use(
|
||||
return http.request(response.config);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('刷新token失败刷新token失败刷新token失败刷新token失败刷新token失败刷新token失败')
|
||||
console.log(err);
|
||||
cleanStorage();
|
||||
return Promise.reject(err);
|
||||
})
|
||||
@ -158,41 +181,44 @@ http.interceptors.response.use(
|
||||
} else {
|
||||
// 返回未执行 resolve 的 Promise
|
||||
return new Promise((resolve) => {
|
||||
// 用函数形式将 resolve 存入,等待刷新后再执行
|
||||
// 用函数形式将 resolve 存入,等待刷新后再执行
|
||||
requests.push((token) => {
|
||||
// 刷新token后传入新的token
|
||||
response.header.accessToken = `${token}`;
|
||||
resolve(http.request(response.config));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 如果当前返回没登录
|
||||
// 这是没有token的情况
|
||||
} else if (
|
||||
(!token && response.statusCode === 403) ||
|
||||
response.data.code === 403
|
||||
) {
|
||||
console.log('没有token的情况');
|
||||
cleanStorage();
|
||||
|
||||
// 如果当前状态码为正常但是success为不正常时
|
||||
} else if (
|
||||
(response.statusCode == 200 && !response.data.success) ||
|
||||
response.statusCode == 400
|
||||
) {
|
||||
if (response.data.message) {
|
||||
uni.showToast({
|
||||
title: response.data.message,
|
||||
icon: "none",
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
} else if (response.data.code == 502) {
|
||||
cleanStorage();
|
||||
}
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
return error;
|
||||
}
|
||||
// 如果当前状态码为正常但是success为不正常时
|
||||
} else if (
|
||||
(response.statusCode == 200 && !response.data.success) ||
|
||||
response.statusCode == 400
|
||||
) {
|
||||
if (response.data.message) {
|
||||
uni.showToast({
|
||||
// title: response.data.message,
|
||||
title: "请重试",
|
||||
icon: "none",
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
} else if (response.data.code == 502) {
|
||||
cleanStorage();
|
||||
}
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
return error;
|
||||
}
|
||||
);
|
||||
|
||||
export {
|
||||
|
||||
@ -10,21 +10,21 @@ const FACE_LOGIN = isDev ? "face_login_dev" : "face_login";
|
||||
const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login";
|
||||
const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn";
|
||||
const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data";
|
||||
export default {
|
||||
setCityCode(val) {
|
||||
return uni.setStorageSync('cityCode',val)
|
||||
},
|
||||
getCityCode(){
|
||||
return uni.getStorageSync('cityCode')
|
||||
export default {
|
||||
setCityCode(val) {
|
||||
return uni.setStorageSync('cityCode', val)
|
||||
},
|
||||
/**
|
||||
* 写入RefreshVlogIndex
|
||||
*/
|
||||
setRefreshVlogIndex(val) {
|
||||
return uni.setStorageSync('refreshVlogIndex',val) //0=不需要刷新
|
||||
},
|
||||
getRefreshVlogIndex() {
|
||||
return uni.getStorageSync('refreshVlogIndex') //0=不需要刷新
|
||||
getCityCode() {
|
||||
return uni.getStorageSync('cityCode')
|
||||
},
|
||||
/**
|
||||
* 写入RefreshVlogIndex
|
||||
*/
|
||||
setRefreshVlogIndex(val) {
|
||||
return uni.setStorageSync('refreshVlogIndex', val) //0=不需要刷新
|
||||
},
|
||||
getRefreshVlogIndex() {
|
||||
return uni.getStorageSync('refreshVlogIndex') //0=不需要刷新
|
||||
},
|
||||
/**
|
||||
* 获取Vlogtoken
|
||||
@ -39,16 +39,16 @@ export default {
|
||||
return uni.setStorageSync(VLOG_TOKEN, val);
|
||||
},
|
||||
/**
|
||||
* 写入VlogUserInfo
|
||||
* 写入VlogUserInfo
|
||||
*/
|
||||
setVlogUserInfo(val) {
|
||||
return uni.setStorageSync(VLOG_USER_INFO, val);
|
||||
},
|
||||
/**
|
||||
* 获取VlogUserInfo
|
||||
*/
|
||||
getVlogUserInfo(val) {
|
||||
return uni.getStorageSync(VLOG_USER_INFO)||null;
|
||||
},
|
||||
/**
|
||||
* 获取VlogUserInfo
|
||||
*/
|
||||
getVlogUserInfo(val) {
|
||||
return uni.getStorageSync(VLOG_USER_INFO) || null;
|
||||
},
|
||||
|
||||
// 写入热门搜索时间戳
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user