123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template></template>
- <script lang="ts" setup>
- import { ref, vueVersion } from "../../TUIKit/adapter-vue";
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import { TUITranslateService } from "@tencentcloud/chat-uikit-engine";
- import { loginChat } from "../../loginChat";
- const inputValue: any = ref("");
- const userSigs = ref();
- onLoad(() => {
- const paramsToFetch = [
- "share",
- "spuId",
- "personId",
- "type",
- "openid",
- "token",
- "id",
- "userSig",
- "messageType",
- ];
- // 批量获取参数并存储到storage
- const params: any = {};
- paramsToFetch.forEach((key) => {
- const value = getQueryString(key);
- if (value !== undefined && value !== "undefined") {
- uni.setStorageSync(key, value);
- params[key] = value;
- } else {
- uni.removeStorageSync(key);
- }
- });
- console.log("params", params);
- // 单独处理userSig
- userSigs.value = params.userSig || "";
- inputValue.value = params;
- handleLoginInfo();
- });
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) {
- return unescape(r[2]);
- }
- return null;
- }
- const handleLoginInfo = () => {
- const loginInfo = {
- SDKAppID: uni.$chat_SDKAppID,
- userID: inputValue.value.id,
- userSig: inputValue.value.userSig,
- useUploadPlugin: true,
- framework: `vue${vueVersion}`,
- };
- login(loginInfo);
- };
- const login = (loginInfo: any) => {
- loginChat(loginInfo).catch(() => {
- uni.showToast({
- title: TUITranslateService.t("Login.登录失败"),
- icon: "none",
- });
- });
- };
- </script>
- <style lang="scss" scoped>
- @import "../../styles/login";
- .icon {
- display: inline;
- }
- .btn {
- background: none;
- border: none;
- }
- .icon-unselected {
- display: inline-block;
- width: 12px;
- height: 12px;
- background: #fff;
- border: 1px solid #ddd;
- border-radius: 8px;
- }
- .selected-icon {
- width: 14px;
- height: 14px;
- }
- .icon-default {
- margin: 7px 6px 0 0;
- }
- .login-input-uniapp {
- border: 1px solid #ccc;
- border-radius: 4px;
- outline: none;
- height: 40px;
- padding: 0 0 0 14px;
- }
- .logo-back-png {
- width: 4.61rem;
- height: 3.23rem;
- }
- .private-content-link {
- display: inline-block;
- }
- </style>
|