Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thinkApp
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
游洁
thinkApp
Commits
01b1ad50
Commit
01b1ad50
authored
Sep 27, 2022
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
be01c52d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
67 deletions
+106
-67
requestErp.js
src/utils/requestErp.js
+106
-67
No files found.
src/utils/requestErp.js
View file @
01b1ad50
//请求教育接口
let
host
=
''
if
(
process
.
env
.
NODE_ENV
===
"development"
)
{
//host = 'https://jjswapi.oytour.com/api'
// host = 'http://192.168.10.206:5005/api'
host
=
'http://192.168.10.128:8900/api'
}
else
{
host
=
'https://jjswapi.oytour.com/api'
}
import
Toast
from
'../wxcomponents/vant/toast/toast'
;
let
request
=
(
param
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
token
=
uni
.
getStorageSync
(
'erpUserInfo'
).
Token
;
uni
.
request
({
url
:
host
+
param
.
url
,
method
:
param
.
method
||
"Post"
,
header
:
param
.
header
||
{
'content-type'
:
"application/json"
,
'token'
:
token
||
""
},
data
:
{
Msg
:
param
.
data
,
},
success
:
res
=>
{
if
(
res
.
data
.
Code
===
1
)
{
resolve
(
res
.
data
)
}
else
{
if
(
res
.
data
.
Code
==
10001
||
res
.
data
.
Code
==
10000
)
{
// uni.showToast({
// title: "用户凭证失效,请重新授权",
// duration: 2000,
// icon: "none",
// });
// uni.removeStorageSync('erpUserInfo');
// uni.reLaunch({
// url:"/pages/login/login"
// })
//请求教育接口
let
host
=
''
if
(
process
.
env
.
NODE_ENV
===
"development"
)
{
//host = 'https://jjswapi.oytour.com/api'
// host = 'http://192.168.10.206:5005/api'
host
=
'http://192.168.10.128:8900/api'
}
else
{
host
=
'https://jjswapi.oytour.com/api'
}
import
Toast
from
'../wxcomponents/vant/toast/toast'
;
let
request
=
(
param
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
token
=
uni
.
getStorageSync
(
'erpUserInfo'
).
Token
;
uni
.
request
({
url
:
host
+
param
.
url
,
method
:
param
.
method
||
"Post"
,
header
:
param
.
header
||
{
'content-type'
:
"application/json"
,
'token'
:
token
||
""
},
data
:
{
Msg
:
param
.
data
,
},
success
:
res
=>
{
if
(
res
.
data
.
Code
===
1
)
{
resolve
(
res
.
data
)
}
else
{
if
(
res
.
data
.
Code
==
10001
||
res
.
data
.
Code
==
10000
)
{
// uni.showToast({
// title: "用户凭证失效,请重新授权",
// duration: 2000,
// icon: "none",
// });
// uni.removeStorageSync('erpUserInfo');
// uni.reLaunch({
// url:"/pages/login/login"
// })
// reject()
}
else
{
uni
.
showToast
({
title
:
res
.
data
.
Message
,
duration
:
2000
,
icon
:
"none"
,
success
()
{
if
(
res
.
data
.
Code
===
0
){
resolve
(
res
.
data
)
}
else
{
reject
()
}
}
});
}
}
},
fail
:
(
err
)
=>
{
console
.
warn
(
"fail:"
+
JSON
.
stringify
(
err
));
uni
.
showToast
({
title
:
'网络请求失败'
,
duration
:
2000
,
icon
:
"error"
,
});
reject
()
}
});
})
}
//重新获取TOKEN
// updateToken()
// request(param)
}
else
{
uni
.
showToast
({
title
:
res
.
data
.
Message
,
duration
:
2000
,
icon
:
"none"
,
success
()
{
if
(
res
.
data
.
Code
===
0
)
{
resolve
(
res
.
data
)
}
else
{
reject
()
}
}
});
}
}
},
fail
:
(
err
)
=>
{
console
.
warn
(
"fail:"
+
JSON
.
stringify
(
err
));
uni
.
showToast
({
title
:
'网络请求失败'
,
duration
:
2000
,
icon
:
"error"
,
});
reject
()
}
});
})
}
let
updateToken
=
()
=>
{
let
u
=
uni
.
getStorageSync
(
'erpUserInfo'
)
let
userWxInfo
=
uni
.
getStorageSync
(
'userWxInfo'
)
let
wxUserAuthInfo
=
uni
.
getStorageSync
(
'wxUserAuthInfo'
)
if
(
u
)
{
request
({
url
:
'/AppletLogin/GetStudentsByClassInAccount'
,
method
:
'post'
,
data
:
{
Account
:
u
.
Account
,
WName
:
userWxInfo
.
userInfo
.
nickName
,
WImage
:
userWxInfo
.
userInfo
.
avatarUrl
,
UnionId
:
wxUserAuthInfo
.
unionid
}
}).
then
(
r
=>
{
if
(
r
.
Data
&&
r
.
Data
.
length
>
0
)
{
r
.
Data
.
forEach
(
x
=>
{
if
(
x
.
ClassInAccount
==
u
.
Account
)
{
uni
.
setStorageSync
(
'erpUserInfo'
,
x
)
}
})
if
(
!
flag
)
{
r
.
Data
.
forEach
(
x
=>
{
if
(
x
.
RealPhone
==
u
.
Account
)
{
flag
=
true
uni
.
setStorageSync
(
'erpUserInfo'
,
x
)
}
})
}
uni
.
setStorageSync
(
"ErpStus"
,
r
.
Data
)
}
})
}
}
export
default
request
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