根目录下引入JS文件
企业微信官方接口文档
index.html
<script src="https://wwcdn.weixin.qq.com/node/wework/wwopen/js/wwLogin-1.2.5.js"></script>
在需要使用微信登录的地方实例JS对象
new WwLogin({
id: "QRcode_Area",
appid: '',
agentid: '',
redirect_uri: '',
state: "",
href: "",
lang: "zh",
});
完整案例
<template>
<div class="loginBack">
<div class="company">
<div class="" @click="checkQrCode(true)">
<span class="icon_common company_selected_icon" v-if="isSzkj"></span>
<span class="icon_common company_selecte_icon" v-else></span>
<p :class="isSzkj ? 'company_selected_text' : ''">公司A</p>
</div>
<div class="" @click="checkQrCode(false)">
<span class="icon_common company_selected_icon" v-if="!isSzkj"></span>
<span class="icon_common company_selecte_icon" v-else></span>
<p :class="!isSzkj ? 'company_selected_text' : ''">公司B</p>
</div>
</div>
<div class="loginCode" id="QRcode_Area"></div>
</div>
</template>
<script lang="ts" setup>
import { ref, PropType } from "vue";
interface IredirectUri {
URL1?: String;
URL2?: String;
URL3?: String;
}
const props = defineProps({
appid: {
type: String,
default: "",
},
agentid: {
type: String,
default: "",
},
redirect_uri: {
type: Object as PropType<IredirectUri>,
default: () => {
return {};
},
},
href: {
type: String,
default: "",
},
state: {
type: String,
default: "",
},
lang: {
type: String,
default: "zh",
},
});
const isSzkj = ref<Boolean>(true);
const checkQrCode = (val: Boolean) => {
isSzkj.value = val;
new WwLogin({
id: "QRcode_Area",
appid: props.appid,
agentid: props.agentid,
redirect_uri: isSzkj.value
? "http://boriska.top:6666"
: "http://boriska.top:1996",
state: "",
href: "data:text/css;base64,...",
lang: "zh",
});
};
</script>
<style lang="less" scoped>
.loginBack {
width: 354px;
height: 429px;
display: flex;
flex-direction: column;
align-items: center;
}
.loginCode {
width: 300px;
height: 300px;
}
.company_selected_icon {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAA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XhsU5rBiAJKWxK4Io59JcCVZ1rHB9zsHfU8cjdJNQjmPUc9UZCqNqe4Z72La9BH8lNJHVGCDMklQpjSuY3+a9tRz0Lre3l6d3E9UcBvyYGx3OBzZcmMq8tjYWCm4GWJ8gleWlJRUyv3UfGT6nJycLhK0Yrjn8Xgu19bWii95rSXGuwCfck5uZkD66UCQJEfQ7QoGgz04hywWy0zsSx4aGsrX6/UPMB4AdN/lcl3jfRHfxaqL4DUEbAdbAOD64uJiX01NzbLNZtvMqO5DdwpbIdQXSyCi4FTMacQHE6SKwxkZGXkkzFpaWvridDp9lK6m0i1MzCYu9SK4c9DCysrKXt6hOeTY4sPbjZ+YKD2Kl9q/ehVTME2CBYzLRqOxGf15KJPl5inx4iAGwsjT8BOsqHYH+ykq2QOPJxAHbgLrw/4GfiORgL6l4ZyLUlx0EQAHsge5FL4NHkHnRv4ATbAfxEdKS0vr4qLNyAO0OQv9Vu6kgcN+npub8yYSYBTZ3dA4Ae5yD87s7OwojppAICBOr+LJjoAL05JltrFHjckTz8QgbbuA3yO/339pfHzcwyMqflCqxB2Ijd1u306PfV6vN5DK30r4iCnkqXdS3X62Dp75pDEVmA0vqjhBm6bhdcpgSRUojanuaU0iDpXEWpeq74ZxfwDvOKD+yttkDgAAAABJRU5ErkJggg==);
}
.company {
display: flex;
width: 280px;
justify-content: space-around;
}
.icon_common {
width: 24px;
height: 24px;
display: inline-block;
}
.company_selected_text {
color: #247cea;
}
.company_selecte_text {
color: #000000;
}
</style>
|