12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
-
-
- <template>
- <!-- 在需要使用组件的页面或组件的相应位置引入 -->
- <!-- 在当前页面或组件中引入外部组件 -->
- <!-- <uni-import name="home" src="plugin://myPlugin/home"></uni-import> -->
- <div>
- <home ref="homeRef" :subscribeStatus="subscribeStatus" @onGetAuthCode="getAuthCode" @onSubscribe="subscribe" />
- </div>
- </template>
- <script setup lang="ts">
- // // #ifdef MP-ALIPAY
- // import home from 'plugin://myPlugin/home'
- // // #endif
- import { ref } from 'vue';
- import {
- onShow
- } from '@dcloudio/uni-app'
-
- const subscribeStatus = ref(false); // 订阅状态
- let homeRef: any = ref(null); // 插件实例
-
- // 从某个页面返回后 需要刷新插件内部任务列表
- onShow(() => {
- console.log(homeRef,homeRef.value,'onRefreshRights刷新了---');
- homeRef && homeRef.value.onRefreshRights();
- })
-
- // 获取车辆信息authCode
- const getAuthCode = ({ authCode, vid }) => {
- console.log('我是宿主我收到authCode和vid了---', authCode, vid);
- };
-
- // 监听订阅的按钮的点击
- const subscribe = () => {
- console.log('我是宿主我监听到订阅按钮点击了---');
- // 宿主小程序todo:拉取消息订阅,订阅成功后subscribeStatus设置为true
- };
-
- // 任务类型为3,为宿主自定义操作,插件给宿主一个task_code
- const customActions = ({ code }) => {
- console.log('我是宿主,我收到了插件给我的任务code', code);
- };
-
- </script>
-
- <style lang='scss' scoped>
-
- </style>
|