IM部分处理

This commit is contained in:
abu 2025-04-30 14:28:07 +08:00
parent eaa9f50e7a
commit 192f493535
22 changed files with 2957 additions and 2398 deletions

16
App.vue
View File

@ -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

View File

@ -8,7 +8,9 @@
v-if="extension.hyperlinks_text"
:href="extension.hyperlinks_text.value"
target="view_window"
>{{ extension.hyperlinks_text.key }}</a>
>
{{ extension.hyperlinks_text.key }}
</a>
</h1>
<ul v-if="extension.item && extension.item.length > 0">
<li
@ -19,7 +21,9 @@
v-if="isUrl(item.value)"
:href="item.value"
target="view_window"
>{{ item.key }}</a>
>
{{ item.key }}
</a>
<p v-else>
{{ item.key }}
</p>
@ -30,7 +34,7 @@
</template>
<template v-else-if="customData.businessID === CHAT_MSG_CUSTOM_TYPE.EVALUATE">
<div class="evaluate">
<h1>{{ TUITranslateService.t("message.custom.对本次服务评价") }}</h1>
<h1>{{ TUITranslateService.t('message.custom.对本次服务评价') }}</h1>
<ul class="evaluate-list">
<li
v-for="(item, index) in Math.max(customData.score, 0)"
@ -46,14 +50,27 @@
<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"
>
<img :src="customData.imageUrl" />
<main>
<h1>{{ customData.title }}</h1>
<p>{{ customData.description }}</p>
@ -67,9 +84,9 @@
<a
:href="customData.link"
target="view_window"
>{{
TUITranslateService.t("message.custom.查看详情>>")
}}</a>
>
{{ TUITranslateService.t('message.custom.查看详情>>') }}
</a>
</div>
</template>
<template v-else>
@ -80,6 +97,7 @@
<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';
@ -93,14 +111,14 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
messageItem: undefined,
content: undefined,
content: undefined
});
const custom = ref();
const message = ref<IMessageModel>();
const extension = ref();
const customData = ref<ICustomMessagePayload>({
businessID: '',
businessID: ''
});
watchEffect(() => {
@ -116,9 +134,14 @@ watchEffect(() => {
const openLink = (url: any) => {
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;

View File

@ -14,18 +14,14 @@
v-for="(conversation, index) in conversationList"
:id="`convlistitem-${index}`"
:key="index"
:class="[
'tui-conversation-content',
isMobile && 'tui-conversation-content-h5 disable-select',
]"
: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',
currentConversationID === conversation.conversationID && 'tui-conversation-item-selected',
conversation.isPinned && 'tui-conversation-item-pinned'
]"
@click="enterConversationChat(conversation.conversationID)"
@longpress="showConversationActionMenu($event, conversation, index)"
@ -42,22 +38,17 @@
:class="[
'online-status',
Object.keys(userOnlineStatusMap).length > 0 &&
Object.keys(userOnlineStatusMap).includes(
conversation.userProfile.userID
) &&
userOnlineStatusMap[conversation.userProfile.userID]
.statusType === 1
Object.keys(userOnlineStatusMap).includes(conversation.userProfile.userID) &&
userOnlineStatusMap[conversation.userProfile.userID].statusType === 1
? 'online-status-online'
: 'online-status-offline',
: 'online-status-offline'
]"
/>
<span
v-if="conversation.unreadCount > 0 && !conversation.isMuted"
class="num"
>
{{
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
}}
{{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
</span>
<span
v-if="conversation.unreadCount > 0 && conversation.isMuted"
@ -73,22 +64,22 @@
<span
v-if="conversation.draftText && conversation.conversationID !== currentConversationID"
class="middle-box-draft"
>{{ TUITranslateService.t('TUIChat.[草稿]') }}</span>
>
{{ TUITranslateService.t('TUIChat.[草稿]') }}
</span>
<span
v-else-if="
conversation.type === 'GROUP' &&
conversation.groupAtInfoList &&
conversation.groupAtInfoList.length > 0
"
v-else-if="conversation.type === 'GROUP' && conversation.groupAtInfoList && conversation.groupAtInfoList.length > 0"
class="middle-box-at"
>{{ conversation.getGroupAtInfo() }}</span>
>
{{ conversation.getGroupAtInfo() }}
</span>
<div class="middle-box-content">
{{ conversation.getLastMessage("text") }}
{{ conversation.getLastMessage('text') }}
</div>
</div>
</div>
<div class="content-footer">
<span class="time">{{ conversation.getLastMessage("time") }}</span>
<span class="time">{{ conversation.getLastMessage('time') }}</span>
<Icon
v-if="conversation.isMuted"
:file="muteIcon"
@ -111,13 +102,7 @@ interface IUserStatusMap {
}
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';
@ -140,7 +125,7 @@ const actionsMenuPosition = ref<{
}>({
top: 0,
left: undefined,
conversationHeight: undefined,
conversationHeight: undefined
});
const displayOnlineStatus = ref(false);
const userOnlineStatusMap = ref<IUserStatusMap>();
@ -148,16 +133,15 @@ const userOnlineStatusMap = ref<IUserStatusMap>();
let lastestOpenActionsMenuTime: number | null = null;
onMounted(() => {
console.log(conversationList)
TUIStore.watch(StoreName.CONV, {
currentConversationID: onCurrentConversationIDUpdated,
conversationList: onConversationListUpdated,
currentConversation: onCurrentConversationUpdated,
currentConversation: onCurrentConversationUpdated
});
TUIStore.watch(StoreName.USER, {
displayOnlineStatus: onDisplayOnlineStatusUpdated,
userStatusList: onUserStatusListUpdated,
userStatusList: onUserStatusListUpdated
});
if (!isUniFrameWork && isIOS && !isPC) {
@ -169,28 +153,20 @@ onUnmounted(() => {
TUIStore.unwatch(StoreName.CONV, {
currentConversationID: onCurrentConversationIDUpdated,
conversationList: onConversationListUpdated,
currentConversation: onCurrentConversationUpdated,
currentConversation: onCurrentConversationUpdated
});
TUIStore.unwatch(StoreName.USER, {
displayOnlineStatus: onDisplayOnlineStatusUpdated,
userStatusList: onUserStatusListUpdated,
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,
) => {
const showConversationActionMenu = (event: Event, conversation: IConversationModel, index: number, isContextMenuEvent?: boolean) => {
if (isContextMenuEvent) {
event.preventDefault();
if (isUniFrameWork) {
@ -204,10 +180,7 @@ const showConversationActionMenu = (
const closeConversationActionMenu = () => {
// Prevent continuous triggering of overlay tap events
if (
lastestOpenActionsMenuTime
&& Date.now() - lastestOpenActionsMenuTime > 300
) {
if (lastestOpenActionsMenuTime && Date.now() - lastestOpenActionsMenuTime > 300) {
currentConversation.value = undefined;
isShowOverlay.value = false;
}
@ -219,25 +192,28 @@ const getActionsMenuPosition = (event: Event, index: number) => {
emits('getPassingRef', conversationListDomRef);
}
const query = TUIGlobal?.createSelectorQuery().in(conversationListDomRef.value);
query.select(`#convlistitem-${index}`).boundingClientRect((data) => {
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,
conversationHeight: data.height
};
isShowOverlay.value = true;
}
}).exec();
})
.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,
conversationHeight: rect.height
};
}
isShowOverlay.value = true;
@ -261,9 +237,9 @@ function addLongPressHandler() {
},
options: {
eventDelegation: {
subSelector: '.tui-conversation-content',
},
},
subSelector: '.tui-conversation-content'
}
}
});
}
@ -273,6 +249,8 @@ function onCurrentConversationUpdated(conversation: IConversationModel) {
function onConversationListUpdated(list: IConversationModel[]) {
conversationList.value = list;
console.log('会话列表数据', conversationList.value);
console.log('Conversation实例:', TUIStore);
}
function onCurrentConversationIDUpdated(id: string) {
@ -285,13 +263,10 @@ function onDisplayOnlineStatusUpdated(status: boolean) {
function onUserStatusListUpdated(list: Map<string, IUserStatus>) {
if (list.size !== 0) {
userOnlineStatusMap.value = [...list.entries()].reduce(
(obj, [key, value]) => {
userOnlineStatusMap.value = [...list.entries()].reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
},
{} as IUserStatusMap,
);
}, {} as IUserStatusMap);
}
}
// Expose to the parent component and close actionsMenu when a sliding event is detected
@ -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
View 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
}
});
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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",
};
//默认生产环境

View File

@ -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'
});
}
},

View File

@ -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

View File

@ -1,29 +1,63 @@
<template>
<view class="person-msg">
<view class="head c-content" @click="changeFace">
<image :src="form.face || '/static/missing-face.png'" mode=""></image>
<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-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
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-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 || "请选择出生日期" }}
<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"
@ -40,22 +74,27 @@
right-icon="arrow-right"
>
<div
style="
width: 32vh;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
"
style="width: 32vh; white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
@click="clickRegion"
>
{{ form.___path || "请选择城市" }}
{{ 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>
<view
class="submit"
@click="submit"
>
保存
</view>
<view
class="submit light"
@click="showModalDialog"
>
退出登录
</view>
</div>
<u-modal
show-cancel-button
@ -75,52 +114,53 @@
</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 { 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,
'm-city': gkcity
},
data() {
return {
erwei: "",
erwei: '',
quitShow: false,
userInfo: {},
lightColor: this.$lightColor, //
form: {
nickName: storage.getUserInfo().nickName || "",
birthday: storage.getUserInfo().birthday || "",
face: storage.getUserInfo().face || "/static/imlogo.png", //
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,
___path: storage.getUserInfo().region
},
birthday: storage.getUserInfo().birthday || "", //
birthday: storage.getUserInfo().birthday || '', //
photo: [
{
text: "立即拍照",
color: this.$mainColor,
text: '立即拍照',
color: this.$mainColor
},
{
text: "从相册选择",
color: this.$mainColor,
},
text: '从相册选择',
color: this.$mainColor
}
],
region: [
//
{
id: "",
localName: "请选择",
children: [],
},
id: '',
localName: '请选择',
children: []
}
],
showBirthday: false, //
showBirthday: false //
};
},
onShow() {
@ -131,7 +171,7 @@ export default {
showQrCodeInFullSize() {
uni.previewImage({
urls: [this.erwei],
current: this.erwei,
current: this.erwei
});
},
getgeterwei() {
@ -143,13 +183,20 @@ export default {
this.quitShow = true;
},
clear() {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setRefreshVlogIndex('1'); //
storage.setHasLogin(false);
storage.setAccessToken('');
storage.setRefreshToken('');
storage.setUuid('');
storage.setUserInfo({});
// vlog
storage.setVlogToken("");
storage.setVlogUserInfo({});
this.$options.filters.navigateToLogin("redirectTo");
storage.setVlogToken('');
storage.setVlogUserInfo(null);
//
storage.setRefreshVlogIndex('1'); //
// 退im
clearIm();
this.$options.filters.navigateToLogin('redirectTo');
},
/**
* 确认退出
@ -171,7 +218,7 @@ export default {
getpickerParentValue(e) {
this.form.region = [];
this.form.regionId = [];
let name = "";
let name = '';
e.forEach((item, index) => {
if (item.id) {
@ -180,7 +227,7 @@ export default {
if (index == e.length - 1) {
name += item.localName;
} else {
name += item.localName + ",";
name += item.localName + ',';
}
this.form.___path = name;
}
@ -218,16 +265,16 @@ export default {
uni.uploadFile({
url: upload,
filePath: tempFilePaths[0],
name: "file",
name: 'file',
header: {
accessToken: storage.getAccessToken(),
accessToken: storage.getAccessToken()
},
success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data);
this.form.face = data.result;
},
}
});
},
}
});
},
@ -235,11 +282,7 @@ export default {
* 选择地址
*/
selectRegion(region) {
this.$set(
this.form,
"address",
`${region.province.label} ${region.city.label} ${region.area.label}`
);
this.$set(this.form, 'address', `${region.province.label} ${region.city.label} ${region.area.label}`);
},
/**
@ -248,13 +291,13 @@ export default {
selectTime(time) {
this.form.birthday = `${time.year}-${time.month}-${time.day}`;
this.birthday = `${time.year} - ${time.month} - ${time.day}`;
},
}
},
/**
* 加载数据
*/
onLoad() {},
onLoad() {}
};
</script>

View File

@ -1,37 +1,72 @@
<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="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>
<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>
<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>
<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-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
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 { 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 {
@ -40,27 +75,34 @@ export default {
quitShow: false,
isCertificate: false,
userInfo: {},
fileSizeString: "0B",
fileSizeString: '0B'
};
},
methods: {
navigateTo(url) {
if (url == "/pages/set/securityCenter/securityCenter") {
if (url == '/pages/set/securityCenter/securityCenter') {
url += `?mobile=${this.userInfo.mobile}`;
}
uni.navigateTo({
url: url,
url: url
});
},
clear() {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setRefreshVlogIndex('1'); //
storage.setHasLogin(false);
storage.setAccessToken('');
storage.setRefreshToken('');
storage.setUuid('');
storage.setUserInfo({});
// vlog
storage.setVlogToken("")
storage.setVlogUserInfo({})
this.$options.filters.navigateToLogin("redirectTo");
storage.setVlogToken('');
storage.setVlogUserInfo(null);
//
storage.setRefreshVlogIndex('1'); //
// 退im
clearIm();
this.$options.filters.navigateToLogin('redirectTo');
},
/**
@ -88,15 +130,15 @@ export default {
plus.cache.calculate(function (size) {
let sizeCache = parseInt(size);
if (sizeCache == 0) {
that.fileSizeString = "0B";
that.fileSizeString = '0B';
} else if (sizeCache < 1024) {
that.fileSizeString = sizeCache + "B";
that.fileSizeString = sizeCache + 'B';
} else if (sizeCache < 1048576) {
that.fileSizeString = (sizeCache / 1024).toFixed(2) + "KB";
that.fileSizeString = (sizeCache / 1024).toFixed(2) + 'KB';
} else if (sizeCache < 1073741824) {
that.fileSizeString = (sizeCache / 1048576).toFixed(2) + "MB";
that.fileSizeString = (sizeCache / 1048576).toFixed(2) + 'MB';
} else {
that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + "GB";
that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + 'GB';
}
});
},
@ -106,13 +148,13 @@ export default {
* 判断当前是否进入用户中心
*/
checkUserInfo() {
if (this.$options.filters.isLogin("auth")) {
this.navigateTo("/pages/mine/set/personMsg");
if (this.$options.filters.isLogin('auth')) {
this.navigateTo('/pages/mine/set/personMsg');
} else {
uni.showToast({
title: "当前暂无用户请登录后重试",
title: '当前暂无用户请登录后重试',
duration: 2000,
icon: "none",
icon: 'none'
});
}
},
@ -124,13 +166,13 @@ export default {
//
let that = this;
let os = plus.os.name;
if (os == "Android") {
if (os == 'Android') {
let main = plus.android.runtimeMainActivity();
let sdRoot = main.getCacheDir();
let files = plus.android.invoke(sdRoot, "listFiles");
let files = plus.android.invoke(sdRoot, 'listFiles');
let len = files.length;
for (let i = 0; i < len; i++) {
let filePath = "" + files[i]; //
let filePath = '' + files[i]; //
plus.io.resolveLocalFileSystemURL(
filePath,
function (entry) {
@ -139,9 +181,9 @@ export default {
function (entry) {
//
uni.showToast({
title: "缓存清理完成",
title: '缓存清理完成',
duration: 2000,
icon: "none",
icon: 'none'
});
that.getCacheSize(); //
},
@ -153,9 +195,9 @@ export default {
},
function (e) {
uni.showToast({
title: "文件路径读取失败",
title: '文件路径读取失败',
duration: 2000,
icon: "none",
icon: 'none'
});
}
);
@ -164,25 +206,25 @@ export default {
// ios
plus.cache.clear(function () {
uni.showToast({
title: "缓存清理完成",
title: '缓存清理完成',
duration: 2000,
icon: "none",
icon: 'none'
});
that.getCacheSize();
});
}
},
}
},
onShow() {
this.userInfo = this.$options.filters.isLogin();
// #ifdef APP-PLUS
this.getCacheSize();
// #endif
},
}
};
</script>
<style lang='scss' scoped>
<style lang="scss" scoped>
.submit {
height: 90rpx;
line-height: 90rpx;

View File

@ -11,7 +11,10 @@
</div> -->
</div>
<!-- 手机号 -->
<div v-show="current == 0" style="padding: 0px 40px">
<div
v-show="current == 0"
style="padding: 0px 40px"
>
<u-input
:custom-style="inputStyle"
:placeholder-style="placeholderStyle"
@ -30,7 +33,10 @@
获取验证码
</div>
<div class="flex">
<u-checkbox-group :icon-size="24" width="45rpx">
<u-checkbox-group
:icon-size="24"
width="45rpx"
>
<u-checkbox
shape="circle"
v-model="enabulePrivacy"
@ -38,15 +44,16 @@
></u-checkbox>
</u-checkbox-group>
<div class="tips">
未注册的手机号验证后将自动创建用户账号登录即代表您已同意<span
@click="navigateToPrivacy('privacy')"
>使用条款及隐私协议</span
>
未注册的手机号验证后将自动创建用户账号登录即代表您已同意
<span @click="navigateToPrivacy('privacy')">使用条款及隐私协议</span>
</div>
</div>
</div>
<!-- 输入验证码 -->
<div v-show="current == 1" class="box-code">
<div
v-show="current == 1"
class="box-code"
>
<verifyCode
type="bottom"
@confirm="submit"
@ -68,9 +75,12 @@
ref="uCode"
@change="codeChange"
></u-verification-code>
<span @tap="fetchCode" :style="{ color: codeColor }">
{{ tips }}</span
<span
@tap="fetchCode"
:style="{ color: codeColor }"
>
{{ tips }}
</span>
</div>
</div>
@ -116,22 +126,23 @@
</template>
<script>
import { openIdLogin, loginCallback } from "@/api/connect.js";
import api from "@/config/api.js";
import { sendMobile, smsLogin } from "@/api/login";
import myVerification from "@/components/verification/verification.vue"; //
import uuid from "@/utils/uuid.modified.js"; // uuid
import verifyCode from "@/components/verify-code/verify-code";
import { getUserInfo } from "@/api/members";
import { whetherNavigate } from "@/utils/Foundation"; //
import storage from "@/utils/storage.js"; //
import wechatH5Login from "./wechatH5Login.vue";
import { webConnect } from "@/api/connect.js";
import { openIdLogin, loginCallback } from '@/api/connect.js';
import api from '@/config/api.js';
import { sendMobile, smsLogin } from '@/api/login';
import myVerification from '@/components/verification/verification.vue'; //
import uuid from '@/utils/uuid.modified.js'; // uuid
import verifyCode from '@/components/verify-code/verify-code';
import { getUserInfo } from '@/api/members';
import { whetherNavigate } from '@/utils/Foundation'; //
import storage from '@/utils/storage.js'; //
import wechatH5Login from './wechatH5Login.vue';
import { webConnect } from '@/api/connect.js';
import { loginIm } from '@/utils/handleim.js';
export default {
components: {
myVerification,
verifyCode,
wechatH5Login,
wechatH5Login
},
data() {
@ -140,57 +151,57 @@ export default {
wechatLogin: false, //
flage: false, //
codeFlag: true, //
tips: "",
tips: '',
current: 0,
codeColor: "#999", //
codeColor: '#999', //
lightColor: this.$lightColor,
seconds: 60, //
loginTitleWay: [
{
title: "欢迎登录",
desc: "登录后更精彩,美好生活即将开始",
title: '欢迎登录',
desc: '登录后更精彩,美好生活即将开始'
},
{
title: "请输入验证码",
desc: "已经发送验证码至",
},
title: '请输入验证码',
desc: '已经发送验证码至'
}
],
showBack: false,
enabuleFetchCode: false,
enabulePrivacy: false, //
mobile: "", //
code: "", //
mobile: '', //
code: '', //
inputStyle: {
height: "104rpx",
"border-bottom": "1rpx solid #D8D8D8",
"letter-spacing": "1rpx",
"font-size": "40rpx",
"line-height": "40rpx",
color: "#333",
height: '104rpx',
'border-bottom': '1rpx solid #D8D8D8',
'letter-spacing': '1rpx',
'font-size': '40rpx',
'line-height': '40rpx',
color: '#333'
},
placeholderStyle: "font-size: 32rpx;line-height: 32rpx;color: #999999;",
placeholderStyle: 'font-size: 32rpx;line-height: 32rpx;color: #999999;',
loginList: [
//
{
icon: "weixin-fill",
color: "#00a327",
title: "微信",
code: "WECHAT",
icon: 'weixin-fill',
color: '#00a327',
title: '微信',
code: 'WECHAT'
},
{
icon: "qq-fill",
color: "#38ace9",
title: "QQ",
code: "QQ",
icon: 'qq-fill',
color: '#38ace9',
title: 'QQ',
code: 'QQ'
},
{
icon: "apple-fill",
color: "#000000",
title: "Apple",
code: "APPLE",
},
icon: 'apple-fill',
color: '#000000',
title: 'Apple',
code: 'APPLE'
}
],
initurl: false,
initurl: false
};
},
@ -198,7 +209,7 @@ export default {
//#ifdef H5
let isWXBrowser = /micromessenger/i.test(navigator.userAgent);
if (isWXBrowser) {
webConnect("WECHAT").then((res) => {
webConnect('WECHAT').then((res) => {
let data = res.data;
if (data.success) {
window.location = data.result;
@ -212,7 +223,7 @@ export default {
// #ifndef APP-PLUS
//
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
this.wechatLogin = true;
return;
}
@ -221,45 +232,45 @@ export default {
* 条件编译判断当前客户端类型
*/
//#ifdef H5
this.clientType = "H5";
this.clientType = 'H5';
//#endif
//#ifdef APP-PLUS
this.clientType = "APP";
this.clientType = 'APP';
/**如果是app 加载支持的登录方式*/
let _this = this;
uni.getProvider({
service: "oauth",
service: 'oauth',
success: (result) => {
_this.loginList = result.provider.map((value) => {
//title
let title = "";
let title = '';
//code
let code = "";
let code = '';
//
let color = "#8b8b8b";
let color = '#8b8b8b';
//
let icon = "";
let icon = '';
//uni code
let appcode = "";
let appcode = '';
switch (value) {
case "weixin":
icon = "weixin-circle-fill";
color = "#00a327";
title = "微信";
code = "WECHAT";
case 'weixin':
icon = 'weixin-circle-fill';
color = '#00a327';
title = '微信';
code = 'WECHAT';
break;
case "qq":
icon = "qq-circle-fill";
color = "#38ace9";
title = "QQ";
code = "QQ";
case 'qq':
icon = 'qq-circle-fill';
color = '#38ace9';
title = 'QQ';
code = 'QQ';
break;
case "apple":
icon = "apple-fill";
color = "#000000";
title = "Apple";
code = "APPLE";
case 'apple':
icon = 'apple-fill';
color = '#000000';
title = 'Apple';
code = 'APPLE';
break;
}
return {
@ -267,28 +278,28 @@ export default {
code: code,
color: color,
icon: icon,
appcode: value,
appcode: value
};
});
},
fail: (error) => {
uni.showToast({
title: "获取登录通道失败" + error,
title: '获取登录通道失败' + error,
duration: 2000,
icon: "none",
icon: 'none'
});
},
}
});
//#endif
//
// #ifdef H5
this.methodFilter(["QQ"]);
this.methodFilter(['QQ']);
// #endif
//
// #ifdef MP-WEIXIN
this.methodFilter(["WECHAT"]);
this.methodFilter(['WECHAT']);
// #endif
},
watch: {
@ -300,7 +311,7 @@ export default {
if (val.length == 11) {
this.enabuleFetchCode = true;
}
},
}
},
async flage(val) {
@ -318,20 +329,20 @@ export default {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: "none",
icon: 'none'
});
this.flage = false;
}
} else {
this.$u.toast("请倒计时结束后再发送");
this.$u.toast('请倒计时结束后再发送');
}
} else {
this.$refs.verification.hide();
}
},
}
},
onLoad(options) {
if (options.init == "index") {
if (options.init == 'index') {
this.initurl = true;
}
if (options && options.state) {
@ -342,7 +353,7 @@ export default {
customback() {
if (this.initurl) {
uni.switchTab({
url: "/pages/tabbar/vlog/index?init=ok",
url: '/pages/tabbar/vlog/index?init=ok'
});
} else {
uni.navigateBack();
@ -358,8 +369,8 @@ export default {
storage.setRefreshToken(data.result.refreshToken);
//
uni.showToast({
title: "登录成功!",
icon: "none",
title: '登录成功!',
icon: 'none'
});
getUserInfo().then((user) => {
storage.setUserInfo(user.data.result);
@ -367,10 +378,10 @@ export default {
});
getCurrentPages().length > 1
? uni.navigateBack({
delta: getCurrentPages().length - 2,
delta: getCurrentPages().length - 2
})
: uni.switchTab({
url: "/pages/tabbar/home/index",
url: '/pages/tabbar/home/index'
});
}
});
@ -387,9 +398,9 @@ export default {
});
} else {
uni.showToast({
title: "配置有误请联系管理员",
title: '配置有误请联系管理员',
duration: 2000,
icon: "none",
icon: 'none'
});
}
});
@ -402,20 +413,20 @@ export default {
await uni.login({
provider: item.appcode,
// #ifdef MP-ALIPAY
scopes: "auth_user", //
scopes: 'auth_user', //
// #endif
success: function (res) {
uni.setStorageSync("type", item.code);
uni.setStorageSync('type', item.code);
//storageopenid
// #ifndef MP-WEIXIN
uni.setStorageSync("openid", res.authResult.openid);
uni.setStorageSync('openid', res.authResult.openid);
// #endif
},
fail(e) {
uni.showToast({
title: "第三方登录暂不可用!",
icon: "none",
duration: 3000,
title: '第三方登录暂不可用!',
icon: 'none',
duration: 3000
});
},
complete(e) {
@ -424,43 +435,43 @@ export default {
provider: item.appcode,
success: function (infoRes) {
//
uni.setStorageSync("nickname", infoRes.userInfo.nickName);
uni.setStorageSync("avatar", infoRes.userInfo.avatarUrl);
uni.setStorageSync('nickname', infoRes.userInfo.nickName);
uni.setStorageSync('avatar', infoRes.userInfo.avatarUrl);
// #ifdef MP-WEIXIN
//openid openiduni-id: https://uniapp.dcloud.net.cn/uniCloud/uni-id
_this.weixinMPOpenID(res).then((res) => {
//openid使openid
_this.goOpenidLogin("WECHAT_MP");
_this.goOpenidLogin('WECHAT_MP');
});
// #endif
// #ifndef MP-WEIXIN
_this.goOpenidLogin("APP");
_this.goOpenidLogin('APP');
//#endif
},
}
});
},
}
});
},
//openid
goOpenidLogin(clientType) {
//
let params = {
uuid: uni.getStorageSync("openid"), //id
source: uni.getStorageSync("type"), //
nickname: uni.getStorageSync("nickname"), //
avatar: uni.getStorageSync("avatar"), //
uniAccessToken: uni.getStorageSync("uni_access_token"), //token
uuid: uni.getStorageSync('openid'), //id
source: uni.getStorageSync('type'), //
nickname: uni.getStorageSync('nickname'), //
avatar: uni.getStorageSync('avatar'), //
uniAccessToken: uni.getStorageSync('uni_access_token') //token
};
openIdLogin(params, clientType).then((res) => {
if (!res.data.success) {
let errormessage = "第三方登录暂不可用";
let errormessage = '第三方登录暂不可用';
uni.showToast({
// title: '',
title: errormessage,
icon: "none",
duration: 3000,
icon: 'none',
duration: 3000
});
return;
} else {
@ -473,8 +484,8 @@ export default {
storage.setVlogUserInfo(vlogInfo);
//
uni.showToast({
title: "第三方登录成功!",
icon: "none",
title: '第三方登录成功!',
icon: 'none'
});
//
getUserInfo().then((user) => {
@ -493,7 +504,7 @@ export default {
whetherNavigate();
} else {
uni.switchTab({
url: "/pages/tabbar/home/index",
url: '/pages/tabbar/home/index'
});
}
});
@ -503,7 +514,7 @@ export default {
//openid
async weixinMPOpenID(res) {
await miniProgramLogin(res.code).then((res) => {
uni.setStorageSync("openid", res.data);
uni.setStorageSync('openid', res.data);
});
},
/**跳转到登录页面 */
@ -511,10 +522,7 @@ export default {
// #ifdef H5
let code = connectLogin.code;
let buyer = api.buyer;
window.open(
buyer + `/passport/connect/connect/login/web/` + code,
"_self"
);
window.open(buyer + `/passport/connect/connect/login/web/` + code, '_self');
// #endif
// #ifdef APP-PLUS
this.nonH5OpenId(connectLogin);
@ -527,23 +535,26 @@ export default {
* 清空当前账号信息
*/
storage.setHasLogin(false);
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setAccessToken('');
storage.setRefreshToken('');
storage.setUuid('');
storage.setUserInfo({});
// vlog
storage.setVlogToken("");
storage.setVlogUserInfo({});
storage.setVlogToken('');
storage.setVlogUserInfo(null);
//
storage.setRefreshVlogIndex('1'); //
/**
* 执行登录
*/
smsLogin(
{
mobile: this.mobile,
code: this.code,
code: this.code
},
this.clientType
).then((res) => {
// console.log(res)
console.log(res);
if (res.data.success) {
const infoData = res.data.result;
const vlogInfo = JSON.parse(infoData.tikUser);
@ -564,10 +575,12 @@ export default {
*/
storage.setUserInfo(user.data.result);
storage.setHasLogin(true);
// loginIm
loginIm();
//
uni.showToast({
title: "登录成功!",
icon: "none",
title: '登录成功!',
icon: 'none'
});
/**
@ -578,7 +591,7 @@ export default {
whetherNavigate();
} else {
uni.switchTab({
url: "/pages/tabbar/home/index",
url: '/pages/tabbar/home/index'
});
}
});
@ -594,13 +607,13 @@ export default {
//
navigateToPrivacy(val) {
uni.navigateTo({
url: "/pages/mine/help/tips?type=" + val,
url: '/pages/mine/help/tips?type=' + val
});
},
//
start() {
this.codeColor = "#999";
this.$u.toast("验证码已发送");
this.codeColor = '#999';
this.$u.toast('验证码已发送');
this.flage = false;
this.codeFlag = false;
@ -620,24 +633,24 @@ export default {
fetchCode() {
if (!this.enabulePrivacy) {
uni.showToast({
title: "请同意用户隐私",
title: '请同意用户隐私',
duration: 2000,
icon: "none",
icon: 'none'
});
return false;
}
if (!this.$u.test.mobile(this.mobile)) {
uni.showToast({
title: "请填写正确手机号",
title: '请填写正确手机号',
duration: 2000,
icon: "none",
icon: 'none'
});
return false;
}
if (this.tips == "重新获取验证码") {
if (this.tips == '重新获取验证码') {
uni.showLoading({
title: "加载中",
title: '加载中'
});
if (!this.codeFlag) {
let timer = setInterval(() => {
@ -654,8 +667,8 @@ export default {
return false;
}
},
},
}
}
};
</script>
<style>
@ -708,11 +721,11 @@ page {
.disable {
// background: linear-gradient(90deg, #ffdcba 2.21%, #ffcfb2 99.86%);
background: #FE3C3C;
background: #fe3c3c;
}
.fetch {
background: #FE3C3C;
background: #fe3c3c;
}
.btn {
@ -775,7 +788,7 @@ page {
.imgage {
width: 100%;
height: 37.5vh;
background: url("./static/logn.png");
background: url('./static/logn.png');
background-size: 100% 100%;
& > div {
width: 100%;

View File

@ -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);
} else {
uni.showToast({
title: result.data.msg,
@ -205,6 +215,10 @@ export default {
duration: 3000
});
}
},
complete() {
this.upFlage = true;
uni.hideLoading();
}
});
},

View File

@ -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);

View File

@ -1,5 +1,8 @@
<template>
<div style="height: 100%" @click="handleTouchStart">
<div
style="height: 100%"
@click="handleTouchStart"
>
<div class="jolkp">
<div
class="fan"
@ -8,7 +11,7 @@
<div
@click="hui(0)"
:style="{ marginTop: '45px' }"
v-if="statue !=0"
v-if="statue != 0"
>
<u-icon name="arrow-left"></u-icon>
</div>
@ -29,9 +32,16 @@
v-if="statue == 0 || 6"
:style="{ marginTop: '45px' }"
></div>
<view class="jolkp_l" :style="{ marginTop: '45px' }"></view>
<view
class="jolkp_l"
:style="{ marginTop: '45px' }"
></view>
<!-- 弹出框 -->
<view v-if="isPopupVisible" class="popup" ref="popup">
<view
v-if="isPopupVisible"
class="popup"
ref="popup"
>
<ul>
<li @click="handleAddFriend">添加好友/群聊</li>
<li @click="handleMenu()">发起群聊</li>
@ -40,9 +50,15 @@
</view>
</div>
<!-- 搜索添加 -->
<TUIContactsea v-if="statue == 2" @switchConversation="hui" />
<TUIContactsea
v-if="statue == 2"
@switchConversation="hui"
/>
<!-- 联系人 -->
<TUIContact v-else-if="statue == 1" style="height: 100%" />
<TUIContact
v-else-if="statue == 1"
style="height: 100%"
/>
<!-- 群选择的 -->
<SelectFriend
v-else-if="statue == 3"
@ -50,9 +66,18 @@
:style="{ marginTop: '20px', heigth: '80%' }"
/>
<!-- 群类型 -->
<CreateGroup v-else-if="statue == 10" @con="confn" />
<SelectFriendqlioa v-else-if="statue == 4" @concen="concen" />
<ContactInfo v-else-if="statue == 7" @concen="concen" />
<CreateGroup
v-else-if="statue == 10"
@con="confn"
/>
<SelectFriendqlioa
v-else-if="statue == 4"
@concen="concen"
/>
<ContactInfo
v-else-if="statue == 7"
@concen="concen"
/>
<!-- 站内信数据 -->
<!-- <div > -->
<scroll-view
@ -85,48 +110,45 @@
<!-- </div> -->
<!-- 会话 -->
<TUIConversation style="height: 100%" v-else @state="state" />
<TUIConversation
style="height: 100%"
v-else
@state="state"
/>
<!-- 未登录显示 -->
<view
v-if="showNoLoginPage"
class="no-login"
@click="toLogin"
>
请登录
</view>
</div>
</template>
<script>
//
import TUIConversation from "@/TUIKit/components/TUIConversation/index";
import TUIContact from "@/TUIKit/components/TUIContact/index";
import TUIContactsea from "@/TUIKit/components/TUIContact/indexsea";
import { TUILogin } from "@tencentcloud/tui-core";
import ContactSearch from "@/TUIKit/components/TUIContact/contact-search/index.vue";
import CreateGroup from "@/TUIKit/components/TUIGroup/create-group/index.vue";
import { TUIChatKit } from "@/TUIKit";
import SelectFriend from "@/TUIKit/components/TUIContact/select-friend/index.vue";
import ContactInfo from "@/TUIKit/components/TUIContact/contact-info/index.vue";
import SelectFriendqlioa from "@/TUIKit/components/TUIGroup/index.vue";
import TUIConversation from '@/TUIKit/components/TUIConversation/index';
import TUIContact from '@/TUIKit/components/TUIContact/index';
import TUIContactsea from '@/TUIKit/components/TUIContact/indexsea';
import { TUILogin } from '@tencentcloud/tui-core';
import ContactSearch from '@/TUIKit/components/TUIContact/contact-search/index.vue';
import CreateGroup from '@/TUIKit/components/TUIGroup/create-group/index.vue';
// import { TUIChatKit } from '@/TUIKit';
import SelectFriend from '@/TUIKit/components/TUIContact/select-friend/index.vue';
import ContactInfo from '@/TUIKit/components/TUIContact/contact-info/index.vue';
import SelectFriendqlioa from '@/TUIKit/components/TUIGroup/index.vue';
import TUICore, { ExtensionInfo, TUIConstants } from "@tencentcloud/tui-core";
import storage from "@/utils/storage.js";
import TUICore, { ExtensionInfo, TUIConstants } from '@tencentcloud/tui-core';
import storage from '@/utils/storage.js';
// push
import { TUIConversationService } from "@tencentcloud/chat-uikit-engine";
import * as Push from "@/uni_modules/TencentCloud-Push";
// import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
// import * as Push from '@/uni_modules/TencentCloud-Push';
import {
getUserimInfo,
getMember,
getMemberstate,
getMemberdelete,
geterweijki,
} from "@/api/members";
import {
TUITranslateService,
TUIStore,
StoreName,
IGroupModel,
TUIFriendService,
Friend,
FriendApplication,
TUIUserService,
} from "@tencentcloud/chat-uikit-engine";
TUIChatKit.init();
let vueVersion = 2;
import { getUserimInfo, getMember, getMemberstate, getMemberdelete, geterweijki } from '@/api/members';
import { TUITranslateService, TUIStore, StoreName, IGroupModel, TUIFriendService, Friend, FriendApplication, TUIUserService } from '@tencentcloud/chat-uikit-engine';
// TUIChatKit.init();
// let vueVersion = 2;
// vueVersion = 3;
export default {
@ -138,12 +160,13 @@ export default {
ContactSearch,
SelectFriend,
SelectFriendqlioa,
TUIChatKit,
// TUIChatKit,
CreateGroup,
ContactInfo,
ContactInfo
},
data() {
return {
showNoLoginPage: false,
statue: 0, // 0 1 2/ 3 4 6 10 7
isPopupVisible: false, //
isq: false,
@ -152,90 +175,48 @@ export default {
swipeStates: [],
startX: 0,
tole: 0, //
cleartime: null,
timer: null, //
pageSize: 20,
pageNumber: 1,
total: 0,
loadMoreStatus: "more", //
loadMoreStatus: 'more' //
};
},
created() {},
onShow() {
//
//
getUserimInfo()
.then(({ 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: `vue${vueVersion}`, // framework used vue2 / vue3
}).then(() => {
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, (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);
}
});
// 线
Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, (res) => {
// res
console.log("message received", res);
});
// 线
Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, (res) => {
// res ID
console.log("message revoked", res);
});
onTabItemTap(e) {
let tabIndex = e.index;
console.log(tabIndex);
if (tabIndex == 2) {
//
if (!storage.getHasLogin()) {
this.removeTimer();
//
uni.navigateTo({
url: '/pages/passport/login'
});
this.showNoLoginPage = true;
} else {
// 200
uni.navigateTo({
url: "/pages/passport/login",
});
this.removeTimer();
this.setTime();
this.showNoLoginPage = false;
}
}
},
onUnload() {},
created() {},
onHide() {
console.log('IM页面隐藏');
this.removeTimer();
},
onShow() {
//
if (!storage.getHasLogin()) {
this.removeTimer();
//
this.showNoLoginPage = true;
} else {
this.setTime();
this.showNoLoginPage = false;
}
})
.catch(() => {
//
uni.navigateTo({
url: "/pages/passport/login",
});
});
},
mounted() {
@ -243,7 +224,7 @@ export default {
this.setTime();
//
uni.$on("globalClick", (event) => {
uni.$on('globalClick', (event) => {
// console.log(event, "====+++");
this.handleGlobalClick(event);
});
@ -255,35 +236,39 @@ export default {
},
beforeDestroy() {
//
uni.$off("globalClick");
uni.$off('globalClick');
//
clearTimeout(this.cleartime);
this.removeTimer();
},
methods: {
toLogin() {
uni.navigateTo({
url: '/pages/passport/login'
});
},
state(item) {
this.isPopupVisible = item;
},
handleTouchStart(event) {
uni.$emit("globalClick", event);
uni.$emit('globalClick', event);
},
handleGlobalClick(event) {
const query = uni.createSelectorQuery().in(this);
query
.select(".jolkp_l")
.select('.jolkp_l')
//
.boundingClientRect((rect) => {
if (rect) {
const clickX = event.clientX || event.touches[0].clientX;
const clickY = event.clientY || event.touches[0].clientY;
if (clickX >= rect.left && clickX <= rect.width+rect.left
&& clickY >= rect.top && clickY <= rect.top + rect.height*2) {
if (clickX >= rect.left && clickX <= rect.width + rect.left && clickY >= rect.top && clickY <= rect.top + rect.height * 2) {
// this.statue = 0; //
console.log("点击是在节点范围");
console.log('点击是在节点范围');
this.isPopupVisible = !this.isPopupVisible; //
}else{
} else {
// this.statue = 0; //
console.log("否");
console.log('否');
this.isPopupVisible = false; //
}
}
@ -299,11 +284,18 @@ export default {
this.getMembermethod();
}
},
removeTimer() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
setTime() {
const th = this;
this.cleartime = setTimeout(() => {
if (this.timer) {
return;
}
this.timer = setInterval(() => {
this.getMembermethod();
th.setTime(); //setTime10getMembermethod
}, 10000);
},
torut(item) {
@ -311,7 +303,7 @@ export default {
const itemJson = encodeURIComponent(JSON.stringify(item));
// 使 uni.navigateTo
uni.navigateTo({
url: `/pages/tabbar/im/details/index?item=${itemJson}`,
url: `/pages/tabbar/im/details/index?item=${itemJson}`
});
getMemberstate({ messageId: item.messageId }).then((res) => {
this.getMembermethod();
@ -336,7 +328,7 @@ export default {
getMembermethod() {
const param = {
pageSize: this.pageSize,
pageNumber: this.pageNumber,
pageNumber: this.pageNumber
};
getMember(param).then((res) => {
this.total = res.data.result.total;
@ -346,22 +338,16 @@ export default {
this.meList = this.meList.concat(res.data.result.records);
}
this.swipeStates = new Array(this.meList.length).fill(0);
this.tole = this.meList.filter(
(item) => item.status === "UN_READY"
).length;
this.tole = this.meList.filter((item) => item.status === 'UN_READY').length;
});
},
handleMenu() {
const fn = [
...TUICore.getExtensionList(
TUIConstants.TUISearch.EXTENSION.SEARCH_MORE.EXT_ID
),
];
const fn = [...TUICore.getExtensionList(TUIConstants.TUISearch.EXTENSION.SEARCH_MORE.EXT_ID)];
const item = fn[1];
const {
listener = {
onClicked: () => {},
},
onClicked: () => {}
}
} = item;
listener?.onClicked?.(item);
this.statue = 3;
@ -375,39 +361,54 @@ export default {
this.isPopupVisible = false;
uni.scanCode({
success: (res) => {
console.log("扫码结果:---", res.result);
console.log('扫码结果:---', res.result);
const params = {
userID: res.result, //userID
userID: res.result //userID
};
console.log("params", params);
TUIStore.update(StoreName.CUSTOM, "currentContactInfo", params);
console.log('params', params);
TUIStore.update(StoreName.CUSTOM, 'currentContactInfo', params);
this.statue = 7;
},
}
});
},
startLongPress(item, index) {
this.longPressTimer = setTimeout(() => {
uni.showModal({
title: "确认删除",
content: "确定要删除这条消息吗?",
title: '确认删除',
content: '确定要删除这条消息吗?',
success: (res) => {
if (res.confirm) {
getMemberdelete({ messageId: item.messageId }).then((res) => {
this.getMembermethod();
});
}
},
}
});
}, 2000);
},
endLongPress() {
clearTimeout(this.longPressTimer);
},
},
}
}
};
</script>
<style scoped>
.no-login {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: #000;
display: flex;
align-items: center;
justify-content: center;
z-index: 9999999;
font-size: 36rpx;
font-weight: 600;
color: #fff;
}
uni-page-body,
html,
body,
@ -417,6 +418,8 @@ page {
overflow: hidden;
}
.jolkp {
position: sticky;
top: 0;
height: 75px;
display: flex;
font-size: 15px;
@ -433,7 +436,7 @@ page {
.jolkp_l {
width: 1.8rem;
height: 1.8rem;
background-image: url("@/static/im/Frame.png");
background-image: url('@/static/im/Frame.png');
/* 让背景图覆盖整个元素 */
background-size: cover;
/* 背景图不重复 */
@ -445,7 +448,7 @@ page {
.jolkp_h {
width: 1.8rem;
height: 1.8rem;
background-image: url("@/static/im/user.png");
background-image: url('@/static/im/user.png');
/* 让背景图覆盖整个元素 */
background-size: cover;
/* 背景图不重复 */
@ -456,7 +459,7 @@ page {
.jolkp_z {
width: 1.8rem;
height: 1.8rem;
background-image: url("@/static/im/znx.png");
background-image: url('@/static/im/znx.png');
/* 让背景图覆盖整个元素 */
background-size: cover;
/* 背景图不重复 */
@ -499,7 +502,7 @@ page {
.fan {
width: 10%;
height: "100%";
height: '100%';
font-size: 18px;
display: flex;
@ -509,7 +512,7 @@ page {
.fan {
margin-right: 56% !important;
width: 10%;
height: "100%";
height: '100%';
font-size: 18px;
display: flex;
margin-top: 80%;
@ -535,7 +538,7 @@ page {
.three_div1 {
height: 3rem;
width: 40%;
background-image: url("@/static/im/kf.png");
background-image: url('@/static/im/kf.png');
background-size: 100% 100%;
background-repeat: no-repeat;
display: flex;
@ -546,7 +549,7 @@ page {
.three_div2 {
width: 40%;
height: 3rem;
background-image: url("@/static/im/hy.png");
background-image: url('@/static/im/hy.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 40%;
@ -554,7 +557,7 @@ page {
.three_div3 {
height: 3rem;
background-image: url("@/static/im/da.png");
background-image: url('@/static/im/da.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 40%;

View File

@ -210,13 +210,32 @@ export default {
let tabIndex = e.index;
if (tabIndex == 0) {
var prop = this.pageList[this.curIndex];
// 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++) {

View File

@ -7,7 +7,7 @@ Vue.use(Vuex);
const store = new Vuex.Store({
state: {
verificationKey: "", //获取key表示验证通过
distributionId:"", //分销员Id 如果当前账户从未登录过时记录
distributionId: "", //分销员Id 如果当前账户从未登录过时记录
hasLogin: storage.getHasLogin(),
userInfo: storage.getUserInfo(),
uuid: storage.getUuid(),

View File

@ -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
View 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;
}
}

View File

@ -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: "你的登录状态已过期,请重新登录",
@ -30,7 +36,10 @@ function cleanStorage() {
storage.setVlogToken("");
storage.setVlogUserInfo(null);
// 清除初始化数据内容
storage.setRefreshVlogIndex("0"); //不需要刷新
storage.setRefreshVlogIndex("1"); //需要刷新
// 退出im登录
clearIm()
// 获取当前页面栈
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
@ -38,12 +47,16 @@ function cleanStorage() {
// 防抖处理跳转
// #ifdef MP-WEIXIN
if (currentRoute !== 'pages/passport/wechatMPLogin') {
uni.navigateTo({ url: "/pages/passport/wechatMPLogin" });
uni.navigateTo({
url: "/pages/passport/wechatMPLogin"
});
}
// #endif
// #ifndef MP-WEIXIN
if (currentRoute !== 'pages/passport/login') {
uni.navigateTo({ url: "/pages/passport/login" });
uni.navigateTo({
url: "/pages/passport/login"
});
}
// #endif
}
@ -117,18 +130,26 @@ let requests = [];
http.interceptors.response.use(
async (response) => {
// console.log(isRefreshing)
// console.log(response)
console.log(response)
/* 请求之后拦截器。可以使用async await 做异步操作 */
// token存在并且token过期
if (isRefreshing && response.statusCode === 403) {
cleanStorage();
isRefreshing = false;
}
/**
* 后续进来的请求此时异步获取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);
})
@ -160,17 +183,19 @@ http.interceptors.response.use(
return new Promise((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为不正常时
@ -180,7 +205,8 @@ http.interceptors.response.use(
) {
if (response.data.message) {
uni.showToast({
title: response.data.message,
// title: response.data.message,
title: "请重试",
icon: "none",
duration: 1500,
});

View File

@ -12,16 +12,16 @@ 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)
return uni.setStorageSync('cityCode', val)
},
getCityCode(){
getCityCode() {
return uni.getStorageSync('cityCode')
},
/**
* 写入RefreshVlogIndex
*/
setRefreshVlogIndex(val) {
return uni.setStorageSync('refreshVlogIndex',val) //0=不需要刷新
return uni.setStorageSync('refreshVlogIndex', val) //0=不需要刷新
},
getRefreshVlogIndex() {
return uni.getStorageSync('refreshVlogIndex') //0=不需要刷新
@ -48,7 +48,7 @@ export default {
* 获取VlogUserInfo
*/
getVlogUserInfo(val) {
return uni.getStorageSync(VLOG_USER_INFO)||null;
return uni.getStorageSync(VLOG_USER_INFO) || null;
},
// 写入热门搜索时间戳