Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
schedule
Overview
Overview
Details
Activity
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
fengzhaoyu
schedule
Commits
254834c1
Commit
254834c1
authored
5 years ago
by
xiexiaoqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:http request
parent
93f2546a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
93 deletions
+82
-93
http.js
api/http.js
+9
-66
login.js
api/login.js
+9
-11
request.js
api/request.js
+12
-10
xFetch.js
api/xFetch.js
+36
-0
app.js
app.js
+2
-2
index.axml
pages/index/index.axml
+7
-4
index.js
pages/index/index.js
+7
-0
No files found.
api/http.js
View file @
254834c1
import
{
login
}
from
"./login"
;
export
default
function
http
(
data
)
{
if
(
getApp
().
globalData
.
token
!==
""
)
{
return
new
Promise
((
resolve
,
rejects
)
=>
{
dd
.
httpRequest
({
headers
:
{
"Content-Type"
:
"application/json;charset=UTF-8"
,
Authorization
:
`Bearer
${
getApp
().
globalData
.
token
}
`
},
url
:
`
${
getApp
().
globalData
.
globalUrl
}${
data
.
url
}
`
,
method
:
data
.
method
,
dataType
:
"json"
,
data
:
data
.
data
,
success
:
function
(
res
)
{
if
(
res
.
data
.
code
==
0
)
{
resolve
(
res
);
}
else
{
dd
.
alert
({
content
:
res
.
data
.
msg
||
"网络异常"
,
buttonText
:
"确定"
});
}
},
fail
:
function
(
res
)
{
dd
.
alert
({
content
:
"网络异常"
,
buttonText
:
"确定"
});
rejects
(
res
);
}
});
});
}
else
{
return
new
Promise
((
resolve
,
rejects
)
=>
{
login
().
then
(
res
=>
{
// const { oapiUser } = res.data.data;
// getApp().globalData.token = res.data.data.accessToken.access_token;
// // getApp().globalData.token = 'd2563d3a-7723-4f76-ad04-005815893328';
// getApp().globalData.name = res.data.data.oapiUser.name;
// getApp().globalData.userid = res.data.data.oapiUser.userid;
// getApp().globalData.avatar = res.data.data.oapiUser.avatar;
// getApp().globalData.userInfo = JSON.stringify({
// username: oapiUser.name,
// userId: oapiUser.userid,
// headUrl: oapiUser.avatar,
// platform: "dingtalk"
// });
dd
.
httpRequest
({
headers
:
{
"Content-Type"
:
"application/json"
,
Authorization
:
`Bearer
${
getApp
().
globalData
.
token
}
`
},
url
:
`
${
getApp
().
globalData
.
globalUrl
}${
data
.
url
}
`
,
method
:
data
.
method
,
data
:
data
.
data
,
dataType
:
"json"
,
success
:
function
(
res
)
{
resolve
(
res
);
},
fail
:
function
(
res
)
{
rejects
(
res
);
}
});
});
});
}
import
login
from
"./login"
;
import
xFetch
from
'./xFetch'
;
export
default
async
function
http
(
options
)
{
if
(
!
getApp
().
globalData
.
token
)
{
await
login
();
}
return
xFetch
(
options
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/login.js
View file @
254834c1
let
lock
=
false
;
export
async
function
login
(
data
)
{
export
default
async
function
login
(
)
{
if
(
lock
==
true
)
{
await
waitLockRelease
(
2
0
);
return
Promise
.
resolve
()
;
await
waitLockRelease
(
5
0
);
return
;
}
lock
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -18,11 +18,8 @@ export async function login(data) {
method
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
const
{
oapiUser
}
=
res
.
data
.
data
;
getApp
().
globalData
.
token
=
res
.
data
.
data
.
accessToken
.
access_token
;
// getApp().globalData.token = 'd2563d3a-7723-4f76-ad04-005815893328';
getApp
().
globalData
.
name
=
res
.
data
.
data
.
oapiUser
.
name
;
getApp
().
globalData
.
userid
=
res
.
data
.
data
.
oapiUser
.
userid
;
getApp
().
globalData
.
avatar
=
res
.
data
.
data
.
oapiUser
.
avatar
;
...
...
@@ -35,16 +32,17 @@ export async function login(data) {
lock
=
false
;
resolve
(
res
)
},
fail
:
function
(
res
)
{
fail
:
function
(
err
)
{
lock
=
false
;
resolve
(
res
)
console
.
log
(
'err'
,
res
)
reject
(
err
);
console
.
log
(
'err:'
+
err
);
}
})
},
fail
:
function
(
err
)
{
console
.
log
(
err
)
lock
=
false
;
reject
(
err
);
console
.
log
(
'fail:'
+
err
);
}
})
})
...
...
This diff is collapsed.
Click to expand it.
api/request.js
View file @
254834c1
const
app
=
getApp
();
import
$http
from
"./http"
;
import
$binding
from
"./binding"
;
// 区域标签树
export
function
getRoomTree
()
{
return
$http
({
...
...
@@ -199,18 +197,20 @@ export function meetingCollection(data) {
}
// 获取outlook页面授权地址
export
function
getOutlookUrl
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"POST"
,
data
:
""
,
url
:
`/microsoft/getThirdLoginUrl?state=
${
data
}
`
url
:
`/microsoft/getThirdLoginUrl?state=
${
data
}
`
,
type
:
'binding'
});
}
// 发送给后端outlook code
export
function
authorizationCodeReplacementToken
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
data
:
data
,
url
:
`/microsoft/authorizationCodeReplacementToken`
url
:
`/microsoft/authorizationCodeReplacementToken`
,
type
:
'binding'
});
}
// 发送给后端outlook code
...
...
@@ -232,18 +232,20 @@ export function unbindingApp(data) {
}
// 获取zoom授权页面
export
function
getZoomUrl
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
data
:
""
,
url
:
"/zoom/auth"
url
:
"/zoom/auth"
,
type
:
'binding'
});
}
//
export
function
sendZoomCode
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
data
:
data
,
url
:
"/zoom/notice"
url
:
"/zoom/notice"
,
type
:
'binding'
});
}
This diff is collapsed.
Click to expand it.
api/xFetch.js
0 → 100644
View file @
254834c1
export
default
function
xFetch
({
url
,
method
,
data
,
type
})
{
if
(
type
==
'binding'
)
{
url
=
`
${
getApp
().
globalData
.
globalUrl2
}${
url
}
`
}
else
{
url
=
`
${
getApp
().
globalData
.
globalUrl
}${
url
}
`
}
return
new
Promise
((
resolve
,
rejects
)
=>
{
dd
.
httpRequest
({
headers
:
{
"Content-Type"
:
"application/json;charset=UTF-8"
,
Authorization
:
`Bearer
${
getApp
().
globalData
.
token
}
`
},
url
:
url
,
method
:
method
,
dataType
:
"json"
,
data
:
data
,
// timeout: 280,
success
:
function
(
res
)
{
if
(
res
.
data
.
code
==
0
)
{
resolve
(
res
);
}
else
{
rejects
(
res
);
dd
.
alert
({
content
:
res
.
data
.
msg
||
"请求数据异常"
,
buttonText
:
"确定"
});
}
},
fail
:
function
(
err
)
{
rejects
({
refresh
:
true
});
}
});
});
}
This diff is collapsed.
Click to expand it.
app.js
View file @
254834c1
...
...
@@ -2,19 +2,19 @@ import { setGlobalStore } from "dd-store";
import
exampleStore
from
"./stores/exampleStore"
;
import
{
checkFullScren
}
from
"./utils/checkFullScren"
;
setGlobalStore
(
exampleStore
);
import
login
from
'./api/login'
;
App
({
onLaunch
(
options
)
{
// 第一次打开
// options.query == {number:1}
// console.info('App onLaunch'
);
login
(
);
this
.
globalData
.
isFullScren
=
checkFullScren
;
},
onShow
(
options
)
{
// 从后台被 scheme 重新打开
// options.query == {number:1}
},
globalData
:
{
isFullScren
:
false
,
loading
:
false
,
...
...
This diff is collapsed.
Click to expand it.
pages/index/index.axml
View file @
254834c1
<import src="../../template/loading/loading.axml"/>
<import src="../../template/fullScreen/fullScreen.axml"/>
<view hidden="{{$data.tabBarIndex === '1'}}">
<view a:if='{{refresh}}' onTap="onLoad">连接超时,请重试,刷新按钮</view>
<block a:else>
<view hidden="{{$data.tabBarIndex === '1'}}">
<import src="../../template/affairBlank/index.axml"/>
<view class="{{isStopBodyScroll ? 'scroll-lock' : ''}}" onTap="closeSwipe" onTouchStart="closeSwipe" onTouchMove="closeSwipe" onTouchEnd="closeSwipe">
<block a:if="{{!listLoading}}">
...
...
@@ -42,8 +44,8 @@
<template is="loading" a:else>
</template>
</view>
</view>
<view hidden="{{$data.tabBarIndex === '0'}}">
</view>
<view hidden="{{$data.tabBarIndex === '0'}}">
<view a:if="{{!loading}}">
<view class="scheduleHeader">
<view>{{currentData.split('/')[0]}}年{{currentData.split('/')[1] || '1'}}月</view>
...
...
@@ -119,7 +121,8 @@
</view>
<template is="loading" a:else>
</template>
</view>
</view>
</block>
<view class="tabBarContent">
<view class="tabBar">
<view onTap="changeTabBar" data-tabbar='0' data-title='动态'>
...
...
This diff is collapsed.
Click to expand it.
pages/index/index.js
View file @
254834c1
...
...
@@ -28,6 +28,7 @@ import create from "dd-store";
let
maxClickCount
=
5
;
create
.
Page
({
data
:
{
refresh
:
false
,
$data
:
null
,
iconDay
:
currentDate
.
getDate
(),
scheduleList
:
[],
...
...
@@ -173,6 +174,12 @@ create.Page({
if
(
callBack
)
{
callBack
();
}
}).
catch
(
err
=>
{
// if (err && err.refresh) {
// this.setData({
// refresh: true
// })
// }
});
},
//动态置顶
...
...
This diff is collapsed.
Click to expand it.
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