<!-- --> <template> <div id="rong-template-login"> <div class="rong-box"> <div class="rong-login-inner text_center"> <p>音视频通话</p> <input v-model="userId" type="text" placeholder="请输入 用户id" @keyup.13="login" /> <el-button @click="login" class="login_btn" type="primary" >登录</el-button > </div> </div> </div> </template> <script> var setting = window.RongCall.setting; export default { name: "login", data() { return { title: "音视频通话", userId: "", }; }, created() { let userId = this.$route.query.phone || ""; if (!!userId) { this.userId = userId; this.login(); } }, mounted() {}, methods: { login() { if (this.userId === "") { this.$message.closeAll(); this.$message({ type: "warning", message: "请填写用户ID", }); return; } var userId = this.userId; let _this = this; var loginDetail; // let result = await this.$axios.login({ // userId, // }); this.$http .post(this.nozzle.login, { userId: userId, }) .then((result) => { if (result.data.code !== 200) { _this.$message("登录失败, 请检查 CallLib Demo Server 是否启动"); } else { setting.token = result.data.token; loginDetail = result.data; let RongCall = window.RongCall; RongCall.initIM(setting); _this.$router.push({ name: "index", params: loginDetail, }); } }); }, }, }; </script> <style scoped></style>