登录
This commit is contained in:
69
App.vue
69
App.vue
@@ -1,49 +1,68 @@
|
||||
<script lang="ts">
|
||||
import { TUILogin } from '@tencentcloud/tui-core';
|
||||
// #ifdef APP-PLUS || H5
|
||||
import { TUIChatKit } from './TUIKit';
|
||||
|
||||
// #ifdef APP-PLUS || H5
|
||||
import { TUIChatKit } from "./TUIKit";
|
||||
import TUIlogin from "./components/TUILogin.js";
|
||||
|
||||
TUIChatKit.init();
|
||||
// #endif
|
||||
|
||||
let vueVersion = 2;
|
||||
// #ifdef VUE3
|
||||
vueVersion = 3;
|
||||
// #endif
|
||||
let vueVersion = 3;
|
||||
|
||||
|
||||
// Required information
|
||||
// You can get userSig from TencentCloud chat console for Testing TUIKit.
|
||||
// Deploy production environment please get it from your server.
|
||||
// View https://cloud.tencent.com/document/product/269/32688
|
||||
uni.$SDKAppID = 1600086550; // Your SDKAppID
|
||||
uni.$userID = '123'; // Your userID
|
||||
uni.$userSig = 'eJwtzF0LgjAYhuH-suOQ132K0IkYdGAYOaQOs614GclaI4Lov7fUw*d64P4Q3XTZywZSEpoBWU0bjR0jXnHinLKFn8advUdDylwCQCGFgPmxb4-BJhdC0HTNGvH*N8WVZBx4sVTwlqrq4f2muYQKtj090GPdQhwBtaqHE9OwE1UbBu-2Xe-W5PsDP3YvSw__'; // Your userSig
|
||||
|
||||
export default {
|
||||
provide() {
|
||||
data() {
|
||||
return {
|
||||
$global: {
|
||||
lastPage: null
|
||||
}
|
||||
info: {},
|
||||
userSig: "",
|
||||
chatInfo: {},
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.info = res.data;
|
||||
},
|
||||
});
|
||||
uni.getStorage({
|
||||
key: "userSig",
|
||||
success: (res) => {
|
||||
this.userSig = res.data;
|
||||
},
|
||||
});
|
||||
uni.getStorage({
|
||||
key: "chatInfo",
|
||||
success: (res) => {
|
||||
this.chatInfo = res.data;
|
||||
},
|
||||
});
|
||||
if (this.userSig) {
|
||||
TUIlogin(this.chatInfo.appId, this.info.userChatId, this.userSig);
|
||||
}
|
||||
},
|
||||
onLaunch: function () {
|
||||
TUILogin.login({
|
||||
SDKAppID: uni.$SDKAppID,
|
||||
userID: uni.$userID,
|
||||
userSig: uni.$userSig,
|
||||
useUploadPlugin: true, // If you need to send rich media messages, please set to true.
|
||||
framework: `vue${vueVersion}` // framework used vue2 / vue3
|
||||
}).catch(() => {});
|
||||
}
|
||||
provide() {
|
||||
return {
|
||||
$global: {
|
||||
lastPage: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
/* common css for page */
|
||||
uni-page-body,html,body,page {
|
||||
uni-page-body,
|
||||
html,
|
||||
body,
|
||||
page {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user