We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<script setup lang="ts"> import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'; import { ref } from 'vue'; const coldCode = [1011, 1017, 1025, 1047, 1124] //冷启动 const hotCode = [1001, 1038, 1041, 1089, 1090, 1104, 1131, 1187] //热启动 const isCode = ref(false) onLaunch(async (e) => { console.log('App Launch', e); const scene = e?.scene as number; if (coldCode.includes(scene)) { isCode.value = true } else { isCode.value = false } }); onShow((e) => { console.log('App Show', e); const scene = e?.scene as number; if (isCode.value && (hotCode.includes(scene) || coldCode.includes(scene))) { uni.setStorageSync('SHOWOFFICIAL', true);//SHOWOFFICIAL表示是否可以使用微信自带的关注公众号组件 } else { uni.setStorageSync('SHOWOFFICIAL', false); } }); onHide(() => { console.log('App Hide'); }); </script> <style lang="scss"></style>
const startAsk = () => { console.log('startAsk'); // 轮询请求await infoStore.getUserInfo(); 当res.subscribed为true时,中止轮询,跳转 timer = setInterval(async () => { const res = await infoStore.getUserInfo(); if (res.subscribed) { clearInterval(timer); uni.navigateBack(); } }, 1000); } // 注意要关闭定时器!! onHide(() => { clearInterval(timer); })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
前置知识:
代码如下:
实际操作:
如何知道用户是否点击组件关注了公众号并执行某些操作? 答案是无法做到!!!
解决方案:可通过轮询的方式来访问服务器获取用户是否关注公众号
代码如下:
The text was updated successfully, but these errors were encountered: