- 微信OAuth2.0授权登录能否拿到已绑定公众号的openid?
微信OAuth2.0授权登录机制,我方系统的登录页通过开放平台的网站应用来让微信用户扫码登录,服务端拿到的openid是微信用户在微信开放平台的unionid,但我需要拿到微信用户的公众号的openid,因为微信开放平台已经绑定了微信公众号,微信开放平台和微信公众号都同属一个主体,并且该微信用户已经关注了微信公众号,此时微信用户在网页进行微信扫码登录时,能否拿到微信公众号的openid?急急急!!!
03-13 - 为什么接收事件推送的回包中没有数据?
用户扫码后关注公众号,微信方推送消息到我方服务器回调地址,query参数接收到了,说明回调接口是能正常访问,但文档中说的推送的包体没有接收到,导致无法进行解密消息体, @Public() @Post('wechat-official/callback') @HttpCode(HttpStatus.OK) async postWechatOfficialCallbackNotify( @Query() query: WechatOfficialCallbackDto, @Body() body: any ): Promise<string> { console.log('推送的包体 => ', body) return 'SUCCESS' } 打印出来的body是个空内容
03-07 - wx.request发送请求流数据时,会出现不触发success、fail、complete
https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html 在未执行onStopRequestTask停止监听流数据函数前,请求是正常能触发wx.request的success/fail/compile回调, 在某个时机执行了onStopRequestTask后,再次发送请求时就不触发wx.request的success/fail/compile回调, 尝试了开发版 1.06.2502142 和 最新稳定版 1.06.2412050,降到1.06.2402040版本则正常触发,其他版本没有测试 const setChat = async (request) => { const listener = (res) => { const arrayBuffer = res.data; const uint8Array = new Uint8Array(arrayBuffer); let text = new TextEncoding.TextDecoder('utf-8').decode(uint8Array); const str = text.split('data:'); str.forEach((item) => { if (item) { // 映射处理事件类型 const handler = handlers[request.data.modelType]; try { handler(JSON.parse(item)); // 执行处理事件 } catch (e) {} } }); }; requestTask.value = uni.request({ ...request, complete: () => { // 请求完成,停止监听并再计算一次滚动高度 requestTask.value.offChunkReceived(); emit('update:outputing', false); setTimeout(() => { nextTick(() => { onScrollBottom(); // 推进评价 if (list.value[list.value.length - 1].needEvaluate) onPushRecommend(); }); }, 500); } }); // 这里监听消息 requestTask.value.onChunkReceived(listener); }; // 停止监听流数据 const onStopRequestTask = () => { // 停止监听 requestTask.value.offChunkReceived(); // 取消请求 requestTask.value.abort(); };
02-18 - Component自定义组件中methods的this指向问题
import { getLoginCode, login } from "../../api/index"; import { TOKEN } from "../../constant/index"; const app = getApp(); Component({ data: { hidden: true, height: "0%", padding: "0rpx", logo: "", appName: "", isAgree: false, }, properties: {}, observers: { hidden: function (hidden) { if (!hidden) { this.setData({ height: "68%", padding: "24rpx", logo: app.globalData.appConfig.logo, appName: app.globalData.appConfig.app_name, }); } }, }, methods: { onShowLogin: function () { this.setData({ hidden: false, }); }, onHiddenLogin: function () { console.log(this); this.setData({ hidden: true, height: "0%", padding: "0rpx", logo: "", appName: "", isAgree: false, }); }, onAgree: function () { this.setData({ isAgree: !this.data.isAgree }); }, onAgreement: function () { console.log("协议"); }, onLogin: async function () { if (!this.data.isAgree) return wx.showToast({ title: "请先勾选同意", icon: "none", duration: 1500, }); const loginCode = await getLoginCode(); const payload = { code: loginCode, appid: app.globalData.appConfig.appid, secret: app.globalData.appConfig.appsecret, key: app.globalData.appConfig.key, }; const { code, data } = await login(payload); if (code !== 0) return; wx.setStorageSync(TOKEN, data); this.onHidden(); this.onEmit(); }, onEmit: function () { // 执行父组件传递过来的方法 this.triggerEvent("onEmit"); }, }, options: { styleIsolation: "apply-shared", }, });
2023-11-20 - 获取access_token填写client_credential?
auth.getAccessToken接口所必传的参数grant_type在哪获取?
2022-08-15