Commit d2746184 authored by haiyoucuv's avatar haiyoucuv

整理一下代码

parent 8d883218
......@@ -43,14 +43,14 @@ export function isLogin() {
}
export function appJump(url, hideNavbar = false, data = {}) {
sendWebNet("/autoLogin/tempSaveCookie", null, null, true)
.then((res) => {
if (res?.data) {
localStorage.setItem("db_zheshang_cookie", res.data);
setCookieId(res.data);
}
})
.finally(() => {
// sendWebNet("/autoLogin/tempSaveCookie", null, null, true)
// .then((res) => {
// if (res?.data) {
// localStorage.setItem("db_zheshang_cookie", res.data);
// setCookieId(res.data);
// }
// })
// .finally(() => {
window["MarsJSBridge"].invoke("pushPage", {
uri: url,
data,
......@@ -58,7 +58,7 @@ export function appJump(url, hideNavbar = false, data = {}) {
hideNavbar,
}
});
})
// })
}
export function appJumpToMini(username, path, type = "0") {
......
......@@ -1482,7 +1482,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 375.00000000000006,
"x": 375,
"y": 812,
"z": 0
},
......@@ -1698,7 +1698,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -117.50000000000006,
"x": -117.5,
"y": -110,
"z": 0
},
......@@ -1982,7 +1982,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 153.99999999999994,
"x": 154,
"y": -110,
"z": 0
},
......@@ -2397,7 +2397,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 313.99999999999994,
"x": 314,
"y": -109,
"z": 0
},
......@@ -3391,7 +3391,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -334.00000000000006,
"x": -334,
"y": -109,
"z": 0
},
......@@ -3571,7 +3571,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 750.0000000000001,
"width": 750,
"height": 0
},
"_anchorPoint": {
......@@ -3645,7 +3645,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 291.99999999999994,
"x": 292,
"y": -404,
"z": 0
},
......@@ -6780,7 +6780,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 750.0000000000001,
"width": 750,
"height": 1624
},
"_anchorPoint": {
......@@ -7064,7 +7064,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 172.99999999999994,
"x": 173,
"y": -481.5,
"z": 0
},
......@@ -7194,7 +7194,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 750.0000000000001,
"width": 750,
"height": 1624
},
"_anchorPoint": {
......@@ -7246,7 +7246,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 750.0000000000001,
"width": 750,
"height": 1624
},
"_anchorPoint": {
......
......@@ -4,6 +4,7 @@ import { changeScene, showToast } from "db://assets/Module/UIFast";
import { PREVIEW } from 'cc/env';
import { resetBackCookie } from "../../../AppTool";
import { LimitedPage } from "../../Scenes/LimitedPage";
import { getUrlParam } from "../Utils";
// import { isFromShare, newUser } from 'duiba-utils';
......@@ -186,6 +187,19 @@ let dataRecord: {
[name: string]: any
} = {};
let paramJson = null;
if (getUrlParam("params")) {
const params = decodeURIComponent(getUrlParam("params"));
const paramArr = params.split("&");
const paramObj = {};
paramArr.forEach(item => {
const arr = item.split("=");
paramObj[arr[0]] = arr[1];
});
paramJson = encodeURIComponent(JSON.stringify(paramObj));
}
/**
* 发送接口
* @param netName
......@@ -201,7 +215,7 @@ export function sendWebNet(
callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false,
isGet: boolean = true,//这两个参数基本不设置,放后面吧
headers?: any,
headers = {},
): Promise<dataOut> {
//处理下参数
// 统一加上渠道参数
......@@ -268,19 +282,23 @@ export function sendWebNet(
}
// const duibaTempCookieId = localStorage.getItem("db_zheshang_cookie");
const duibaTempCookieId = tempCookieId || localStorage.getItem("db_zheshang_cookie");
if (duibaTempCookieId) {
localStorage.removeItem("db_zheshang_cookie");
tempCookieId = "";
const res = await sendWebNet("userLogin.check")
.catch(async () => {
await resetBackCookie(duibaTempCookieId);
});
if (!res || !res.success) {
await resetBackCookie(duibaTempCookieId);
}
// const duibaTempCookieId = tempCookieId || localStorage.getItem("db_zheshang_cookie");
//
// if (duibaTempCookieId) {
// localStorage.removeItem("db_zheshang_cookie");
// tempCookieId = "";
//
// const res = await sendWebNet("userLogin.check")
// .catch(async () => {
// await resetBackCookie(duibaTempCookieId);
// });
// if (!res || !res.success) {
// await resetBackCookie(duibaTempCookieId);
// }
// }
if (paramJson) {
headers["identityKey"] = paramJson;
}
//网络请求
......@@ -297,7 +315,7 @@ export function sendWebNet(
})
}
export function sendWebNetWithToken(
export async function sendWebNetWithToken(
netName: WebNetName,
parameter?: any,
callback?: (success: boolean, res?: dataOut) => void,
......@@ -305,22 +323,31 @@ export function sendWebNetWithToken(
isGet: boolean = true,//这两个参数基本不设置,放后面吧
headers?: any,
): Promise<dataOut> {
return new Promise(async r => {
const token = await getPxTokenSave();
// getPxToken(async (msg, token) => {
if (!token) {
showToast(DEFAULF_ERROR);
r({success: false})
return;
}
const res = await sendWebNet(netName, {token, ...parameter}, callback, hideMsg, isGet, headers);
r(res);
// })
})
return await sendWebNet(netName, {...parameter}, callback, hideMsg, isGet, headers);
}
// export function sendWebNetWithToken(
// netName: WebNetName,
// parameter?: any,
// callback?: (success: boolean, res?: dataOut) => void,
// hideMsg: boolean = false,
// isGet: boolean = true,//这两个参数基本不设置,放后面吧
// headers?: any,
// ): Promise<dataOut> {
// return new Promise(async r => {
// const token = await getPxTokenSave();
// // getPxToken(async (msg, token) => {
// if (!token) {
// showToast(DEFAULF_ERROR);
// r({success: false})
// return;
// }
// const res = await sendWebNet(netName, {token, ...parameter}, callback, hideMsg, isGet, headers);
// r(res);
// // })
// });
// }
/**
* 获取数据
......
......@@ -55,10 +55,10 @@ export class Start extends Component {
this.keepLive();
}, 1000 * 60 * 5);
this.tempSaveCookie();
setInterval(() => {
this.tempSaveCookie();
}, 5 * 1000);
// this.tempSaveCookie();
// setInterval(() => {
// this.tempSaveCookie();
// }, 5 * 1000);
}
......
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