Commit cc11e77d authored by 王勇霞's avatar 王勇霞

xhr.send

parent bd582a83
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>21天"云"健身</title>
<title>21天“云”健身</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
......
......@@ -76,7 +76,9 @@ export function ajax(options: ajaxParameterInt) {
/**
* POST请求设置请求头
*/
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
if (options.headers) {
for (let key in options.headers) {
xhr.setRequestHeader(key, options.headers[key]);
......@@ -85,7 +87,7 @@ export function ajax(options: ajaxParameterInt) {
/**
* 发送请求参数
*/
xhr.send(params);
xhr.send(JSON.stringify(options.data));
}
}
......
......@@ -10,11 +10,7 @@ let urlParams: { [key: string]: string | true };
export function getUrlParams(key: string, refreshCache: boolean = false): string | true {
if (urlParams && !refreshCache) return urlParams[key];
urlParams = {};
let search = window.location.search;
try {
search = top.location.search; //尝试获取顶层的链接
} catch (e) {
}
let search = '?' + window.location.href.split("?")[1]
//获取链接参数
for (let item of search.replace('?', '').split('&')) {
let arr = item.split('=');
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,11 +4,6 @@ import { GDispatcher } from "./Main";
import { getUrlParams } from "../module/web/webTools";
import { isFromShare, newUser } from 'duiba-utils';
let mergeData = {
user_type: newUser ? '0' : '1',
is_from_share: isFromShare ? '0' : '1',
}
//////////////星速台接口方法集成
/**
* web接口枚举,mock 文件名类似aaa/homeInfo.do
......@@ -79,7 +74,7 @@ export function sendWebNet(
headers?: any,
): Promise<dataOut> {
//处理下参数
parameter = { ...parameter, ...mergeData };
parameter = { ...parameter };
return new Promise((resolve, reject) => {
......@@ -123,11 +118,11 @@ export function sendWebNet(
//网络请求
ajax({
url: netName.replace("{projectId}", getProjectId()), //请求地址
url: netName, //请求地址
type: isGet ? 'GET' : "POST", //请求方式
data: parameter || {}, //请求参数
dataType: "json", // 返回值类型的设定,暂时只有json
async: true, //是否异步
dataType: "json",// 返回值类型的设定,暂时只有json
async: true,//是否异步
headers: headers,
success: function (response) {
//发现有些接口成功了,但是response为空
......@@ -154,7 +149,7 @@ export function sendWebNet(
);
},
error: function (status) {
if (!hideMsg) showToast("网络超时");
if (!hideMsg) showToast("网络开小差了, 请稍后再试");
callback && callback(false)
resolve({ success: false });
console.log("接口" + netName + ":网络超时");
......
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