123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <script>
- import { onMounted, ref } from 'vue'
- import * as link from '@/lib/link'
- import rest from '@/stores/rest'
- import dd from 'gdt-jsapi';
- import { useGlobalStore } from '@/lib/store';
- export default {
- setup() {
- const globalStore = useGlobalStore();
- 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
- }
- globalStore.setAuthCode(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>
|