| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <template>
- <page-meta root-font-size="system" />
- <view class="container">
- <web-view :src="homeSrc"></web-view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- nextTick,
- onMounted,
- reactive
- } from 'vue';
- import { onLoad } from '@dcloudio/uni-app'
- import { useUserStore } from '@/store/user.js'
- import { getHomeAssistantLoginFlowId, getHomeAssistantLoginCode } from '@/api/work.js'
- const userStore = useUserStore()
- const homeSrc = ref('')
- const homeCode = ref('')
- const authCode = ref('')
- onLoad((options) => {
- console.log(options)
- homeCode.value = options.homeCode
- })
- onMounted(() => {
- const username = 'yunzhuoa'
- const password = 'HNYZ0821'
- getHomeAssistantLoginFlowId(homeCode.value).then((data) => {
- console.log('getHomeAssistantLoginFlowId', data)
- getHomeAssistantLoginCode(data.flow_id, username, password).then(({result}) => {
- console.log('getHomeAssistantLoginCode', result);
- authCode.value = result
- homeSrc.value =
- 'https://api.ygtxfj.com:8125/lovelace/'+homeCode.value+'?kiosk=&%3Fauth_callback=1&auth_callback=1&code='+result+'&state=eyJoYXNzVXJsIjoiaHR0cHM6Ly9hcGkueWd0eGZqLmNvbTo4MTI1IiwiY2xpZW50SWQiOiJodHRwczovL2FwaS55Z3R4ZmouY29tOjgxMjUvIn0%3D&storeToken=true'
- })
- })
- // switch (userStore.user.userName) {
- // case 'hez':
- // homeSrc.value = 'https://api.ygtxfj.com:8125/lovelace/dongshizhang?kiosk';
- // break;
- // case 'yzadmin':
- // homeSrc.value = 'https://api.ygtxfj.com:8125/lovelace/workshop?kiosk';
- // break;
- // default:
- // break;
- // }
- });
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- height: 100vh;
- position: relative;
- }
- </style>
|