1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <script>
- import { onMounted, ref } from 'vue'
- import * as link from '@/lib/link'
- import rest from '@/stores/rest'
- import dd from 'gdt-jsapi';
- import { useUserStore } from '@/lib/store'
- import { storeToRefs } from 'pinia'
- export default {
- setup() {
- const store = useUserStore();
- const { globalParameter } = storeToRefs(store);
- const formData = ref({
- appkey: null,
- appsecret: null,
- authCode: null,
- domainname: null,
- })
- const getBasicInfo = ()=> {
- console.log("监听咯")
- getAuthCode()
- }
-
- const getAuthCode = () => {
- console.log("监听咯-getAuthCode")
- dd.ready(()=> {
- dd.getAuthCode({}).then((result) => {
- if (result.code){
- formData.value.authCode = result.code
- }else {
- formData.value.authCode = result.auth_code
- }
- globalParameter.value.authCode = formData.value.authCode
- localStorage.setItem('authCode', formData.value.authCode);
- }).catch(err => {
- link.goLogin()
- })
- })
- }
-
- const getUserInfo = async () => {
- try {
- await rest.post('/zyyp/ykz/getUserInfo?authCode='+ formData.value.authCode,'')
- } catch (error) {
- console.error(error);
- }
- };
-
- const startIntervalTask = () => {
- // 每 60 分钟执行一次任务
- setInterval(() => {
- getBasicInfo();
- }, 60 * 60 * 1000); // 60 分钟
- };
- onMounted(() => {
- console.log('App Created');
- startIntervalTask();
- });
- return {
- formData,
- getBasicInfo,
- getAuthCode,
- getUserInfo,
- startIntervalTask,
- };
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "uni.scss";
- @import "static/style/base.scss";
- </style>
|