Commit 8ebceaed authored by haiyoucuv's avatar haiyoucuv

上传

parent f8fd2e42
declare const window: any;
...@@ -12,6 +12,23 @@ export interface IHomeInfo { ...@@ -12,6 +12,23 @@ export interface IHomeInfo {
class Store { class Store {
miniAppQuery: any = {};
async getMiniQuery() {
return new Promise<void>((resolve) => {
window["my"].onMessage = (e: any = {}) => {
const {query, type} = e;
if (type == "getMiniAppQuery") {
this.miniAppQuery = query;
resolve();
}
}
window["my"].postMessage({type: "getMiniAppQuery"});
});
}
frontVariable: { [key in string]: any } = {} frontVariable: { [key in string]: any } = {}
async updateFrontVariable() { async updateFrontVariable() {
......
...@@ -5,11 +5,10 @@ import { changeScene, showToast } from "db://assets/Module/UIFast"; ...@@ -5,11 +5,10 @@ import { changeScene, showToast } from "db://assets/Module/UIFast";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene"; import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import { sendWebNet, WebNetName } from "../Scripts/Utils/WebNet/WebNet"; import { sendWebNet, WebNetName } from "../Scripts/Utils/WebNet/WebNet";
import { getUrlParams } from "../Scripts/Utils/WebNet/web/webTools"; import { getUrlParams } from "../Scripts/Utils/WebNet/web/webTools";
import store from "../Scripts/store/store";
const {ccclass, property} = _decorator; const {ccclass, property} = _decorator;
declare const window: any;
const _FPS = 61; const _FPS = 61;
@ccclass('Start') @ccclass('Start')
...@@ -45,13 +44,13 @@ export class Start extends Component { ...@@ -45,13 +44,13 @@ export class Start extends Component {
async getAuthCode() { async getAuthCode() {
return new Promise((resolve) => { return new Promise((resolve) => {
window.my.onMessage = (e: any = {}) => { window["my"].onMessage = (e: any = {}) => {
const {authCode, type} = e; const {authCode, type} = e;
if (type == "getAuthCode") { if (type == "getAuthCode") {
resolve(authCode); resolve(authCode);
} }
} }
window.my.postMessage({type: "getAuthCode"}); window["my"].postMessage({type: "getAuthCode"});
}); });
} }
...@@ -75,6 +74,8 @@ export class Start extends Component { ...@@ -75,6 +74,8 @@ export class Start extends Component {
} }
} else { } else {
await store.getMiniQuery();
const authCode = await this.getAuthCode(); const authCode = await this.getAuthCode();
if (!authCode) { if (!authCode) {
......
...@@ -48,8 +48,11 @@ ...@@ -48,8 +48,11 @@
window.my = { window.my = {
postMessage(e){ postMessage(e){
if (e.type === "getAuthCode") { const eventType = e.detail.type;
if (eventType === "getAuthCode") {
this.onMessage({type: e.type, authCode: "authCode"}); this.onMessage({type: e.type, authCode: "authCode"});
}else if(eventType === "getMiniAppQuery"){
this.onMessage({type: eventType, query: {}});
} }
}, },
onMessage: () => 0, onMessage: () => 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment