Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
xiaoxiaole
Commits
933632f0
Commit
933632f0
authored
Aug 13, 2020
by
zjz1994
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整post
parent
a45598d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
getIOSversion.ts
egret/libs/new_tc/getIOSversion.ts
+13
-0
ABNetManager.ts
egret/libs/tc/manager/ABNetManager.ts
+95
-0
No files found.
egret/libs/new_tc/getIOSversion.ts
0 → 100644
View file @
933632f0
import
getIsIOS
from
"./getIsIOS"
;
const
getIOSversion
=
()
=>
{
if
(
getIsIOS
()){
var
str
=
navigator
.
userAgent
.
toLowerCase
();
var
ver
=
str
.
match
(
/cpu iphone os
(
.*
?)
like mac os/
);
var
iosversion
=
ver
[
1
].
replace
(
/_/g
,
"."
)
return
iosversion
;
}
else
{
return
null
;
}
}
export
default
getIOSversion
\ No newline at end of file
egret/libs/tc/manager/ABNetManager.ts
View file @
933632f0
...
@@ -61,10 +61,105 @@ export abstract class ABNetManager {
...
@@ -61,10 +61,105 @@ export abstract class ABNetManager {
'Authorization'
:
'my-auth-token'
'Authorization'
:
'my-auth-token'
}
}
}
}
if
(
net
.
type
==
"post"
){
var
testplatform
=
!
iswx
()
&&
getIsIOS
()
&&
window
[
'SNNativeClient'
]
&&
window
[
'SNNativeClient'
].
callNativeFormDataReq
&&
getIOSversion
()
&&
parseInt
(
getIOSversion
().
split
(
'.'
)[
0
])
<
11
?
true
:
false
;
console
.
log
(
"平台测试"
,
testplatform
);
console
.
log
(
"isWX"
,
iswx
());
console
.
log
(
"isIOS"
,
getIsIOS
(),
"IOSver"
,
getIOSversion
());
testplatform
=
true
;
if
(
testplatform
){
//ios 11以下
var
netpro
=
new
Promise
(
function
(
resolve
,
reject
){
if
(
net
.
name
==
'imgURL'
)
{
this
.
callNativePost
(
obj
.
url
,
{},
{
imagePostKey
:
'picture'
,
name
:
"test"
,
type
:
'png'
,
dataUrl
:
obj
.
data
},
false
)
.
then
(
res
=>
{
resolve
(
res
)
})
.
catch
(
err
=>
{
reject
(
err
)
})
}
else
{
this
.
callNativePost
(
obj
.
url
,
obj
.
data
)
.
then
(
res
=>
{
resolve
(
res
);
})
.
catch
(
err
=>
{
reject
(
err
);
})
}
}.
bind
(
this
));
netpro
.
then
((
result
:
IData
)
=>
{
this
.
onResponse
(
net
,
result
);
},
err
=>
{
console
.
error
(
"post-----error"
,
obj
.
url
)
this
.
onError
(
net
);
});
return
;
}
}
window
[
'$'
].
ajax
(
obj
);
window
[
'$'
].
ajax
(
obj
);
}
}
protected
callNativePost
(
url
,
postData
,
photoInfo
=
null
,
needSuAES
:
boolean
=
false
)
{
var
dataArr
=
[],
photoInfo
=
typeof
photoInfo
==
'object'
?
photoInfo
:
null
,
//非图片上传 默认null
// needSuAES = needSuAES !== false && SuAES && typeof SuAES.encrypt == 'function' ? true : false, //判断是否加密
_href
=
window
.
location
.
href
,
_refer
=
_href
.
indexOf
(
'#'
)
>
-
1
?
_href
.
split
(
'#'
)[
0
]
:
_href
;
//客户端需要refer
// if (needSuAES) {
// console.log("加密请求post");
// //加密时拼接建值
// for (var key in postData) {
// dataArr.push(encodeURIComponent(key) + '=' + encodeURIComponent(postData[key]))
// }
// //拼接地址,加协议头
// url = url.indexOf('http:') > -1 || url.indexOf('https:') > -1 ? url + '?_x_req_block_=' + encodeURIComponent(SuAES.encrypt(dataArr.join("&"))) + '&_x_resp_flag_=2' : window.location.protocol + url + '?_x_req_block_=' + encodeURIComponent(SuAES.encrypt(dataArr.join("&"))) + '&_x_resp_flag_=2';
// } else {
// console.log("不加密请求post");
//修改
url
=
"https://"
+
window
.
location
.
host
+
url
;
url
=
url
.
indexOf
(
'http:'
)
>
-
1
||
url
.
indexOf
(
'https:'
)
>
-
1
?
url
:
window
.
location
.
protocol
+
url
;
// }
// console.log("新post------发送请求",url,_refer,photoInfo,postData);
var
upload
=
new
Promise
(
function
(
resolve
,
reject
)
{
//调用客户端方法,根据加密与否修改传参
window
[
'SNNativeClient'
].
callNativeFormDataReq
(
url
,
_refer
,
photoInfo
,
postData
,
function
callback
(
res
)
{
// console.log("新post------res",res);
//ios返回为字符串 需格式化
res
=
JSON
.
parse
(
res
)
//加密数据解密
// if(needSuAES && res && res.x_response_security == 1 && res.security_data) {
// res = JSON.parse(decodeURIComponent(SuAES.decrypt(res.security_data)))
// }
//返回处理逻辑
if
(
!
res
||
(
res
&&
res
.
statusCode
>=
400
))
{
// console.error("新post---error",res);
reject
(
res
)
}
else
if
(
res
)
{
// console.log("新post---response",res);
resolve
(
res
)
}
});
});
return
upload
;
}
/**
/**
* 消息响应
* 消息响应
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment