惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
博客园 - 叶小钗
F
Fortinet All Blogs
GbyAI
GbyAI
Martin Fowler
Martin Fowler
博客园 - 聂微东
I
InfoQ
B
Blog
IT之家
IT之家
美团技术团队
L
LangChain Blog
小众软件
小众软件
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
Last Week in AI
Last Week in AI
A
About on SuperTechFans
博客园 - Franky
P
Proofpoint News Feed
罗磊的独立博客
月光博客
月光博客
V
Visual Studio Blog
MyScale Blog
MyScale Blog

时间的朋友

Windows 命令行密码重置 Anaconda安装 typescript 注解解读1 Konvajs Shape加载自定义图片 sshpass 使用 why-is-node-running webgl笔记 SharedArrayBuffer is not defined blender 常用快捷键 | 时间的朋友 vue -- v3.4commit提交记录2 vue2 升级vue3报错问题整理 着色器 expressjs 源码 hyper-V arch linux 网络配置 element input数字格式化 three 拼接货架 WebAudio笔记 Windows nginx重启bat脚本 vue -- v3.4commit提交记录 URI malformed vue3 -- Class 对象在组件中使用范例 | 时间的朋友 ruby 安装和升级 element-plus 老版本cascader使用卡死问题 vue3 内置Transition组件 | 时间的朋友 前端memo的实现 | 时间的朋友 Vue -- vue-class-component源码 | 时间的朋友 linux 优化脚本 typescript 装饰器 | 时间的朋友 microbundle 源码 | 时间的朋友 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc
小程序 -- 内部使用webview绑定微信公众号openId | 时间的朋友
2023-04-12 · via 时间的朋友

Published: · LastMod: April 14, 2023 · 203 words

小程序 – 内部使用webview绑定微信公众号openId 🔗

小程序内部 🔗

1
2
3
4
5
6
7
<template>
	<web-view :src="url"></web-view>
</template>
<script setup>
    // 最后路径
const url = computed(() => `${baseURL}/chat-list?token=${userStore.switchToken}&officialIsBind=${official.value}&schema=${userStore.schema}&userInfo=${JSON.stringify(userStore.wxUserInfo)}`)
</script>

h5内部 🔗

1
2
3
4
5
6

router.beforeEach(() => {
    if(query.officialIsBind === 'false') {
        window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa40d62540ee5255f&redirect_uri=http://xxxxxxxxxx/login&response_type=code&scope=snsapi_base&connect_redirect=1#wechat_redirect`
    }
})

这里redirect_uri要设置另外一个页面,比如说login

微信会在回调时调用这个login页面

/login?code=xxxxx&state=xxxx

这里code是微信回调的,state可以在上面这个链接中附带,128个字节

在login页面调用后端接口绑定小程序和公众号两边的openId