You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zfbqy.vue 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <!-- 在需要使用组件的页面或组件的相应位置引入 -->
  3. <!-- 在当前页面或组件中引入外部组件 -->
  4. <!-- <uni-import name="home" src="plugin://myPlugin/home"></uni-import> -->
  5. <div>
  6. <home ref="homeRef" :subscribeStatus="subscribeStatus" @onGetAuthCode="getAuthCode" @onSubscribe="subscribe" />
  7. </div>
  8. </template>
  9. <script setup lang="ts">
  10. // // #ifdef MP-ALIPAY
  11. // import home from 'plugin://myPlugin/home'
  12. // // #endif
  13. import { ref } from 'vue';
  14. import {
  15. onShow
  16. } from '@dcloudio/uni-app'
  17. const subscribeStatus = ref(false); // 订阅状态
  18. let homeRef: any = ref(null); // 插件实例
  19. // 从某个页面返回后 需要刷新插件内部任务列表
  20. onShow(() => {
  21. console.log(homeRef,homeRef.value,'onRefreshRights刷新了---');
  22. homeRef && homeRef.value.onRefreshRights();
  23. })
  24. // 获取车辆信息authCode
  25. const getAuthCode = ({ authCode, vid }) => {
  26. console.log('我是宿主我收到authCode和vid了---', authCode, vid);
  27. };
  28. // 监听订阅的按钮的点击
  29. const subscribe = () => {
  30. console.log('我是宿主我监听到订阅按钮点击了---');
  31. // 宿主小程序todo:拉取消息订阅,订阅成功后subscribeStatus设置为true
  32. };
  33. // 任务类型为3,为宿主自定义操作,插件给宿主一个task_code
  34. const customActions = ({ code }) => {
  35. console.log('我是宿主,我收到了插件给我的任务code', code);
  36. };
  37. </script>
  38. <style lang='scss' scoped>
  39. </style>