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
Apr 20, 2020
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"
;
import
login
from
"./login"
;
export
default
function
http
(
data
)
{
import
xFetch
from
'./xFetch'
;
if
(
getApp
().
globalData
.
token
!==
""
)
{
return
new
Promise
((
resolve
,
rejects
)
=>
{
export
default
async
function
http
(
options
)
{
dd
.
httpRequest
({
if
(
!
getApp
().
globalData
.
token
)
{
headers
:
{
await
login
();
"Content-Type"
:
"application/json;charset=UTF-8"
,
}
Authorization
:
`Bearer
${
getApp
().
globalData
.
token
}
`
return
xFetch
(
options
);
},
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
);
}
});
});
});
}
}
}
\ No newline at end of file
api/login.js
View file @
254834c1
let
lock
=
false
;
let
lock
=
false
;
export
async
function
login
(
data
)
{
export
default
async
function
login
(
)
{
if
(
lock
==
true
)
{
if
(
lock
==
true
)
{
await
waitLockRelease
(
2
0
);
await
waitLockRelease
(
5
0
);
return
Promise
.
resolve
()
;
return
;
}
}
lock
=
true
;
lock
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -18,11 +18,8 @@ export async function login(data) {
...
@@ -18,11 +18,8 @@ export async function login(data) {
method
:
'POST'
,
method
:
'POST'
,
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
const
{
oapiUser
}
=
res
.
data
.
data
;
const
{
oapiUser
}
=
res
.
data
.
data
;
getApp
().
globalData
.
token
=
res
.
data
.
data
.
accessToken
.
access_token
;
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
.
name
=
res
.
data
.
data
.
oapiUser
.
name
;
getApp
().
globalData
.
userid
=
res
.
data
.
data
.
oapiUser
.
userid
;
getApp
().
globalData
.
userid
=
res
.
data
.
data
.
oapiUser
.
userid
;
getApp
().
globalData
.
avatar
=
res
.
data
.
data
.
oapiUser
.
avatar
;
getApp
().
globalData
.
avatar
=
res
.
data
.
data
.
oapiUser
.
avatar
;
...
@@ -35,16 +32,17 @@ export async function login(data) {
...
@@ -35,16 +32,17 @@ export async function login(data) {
lock
=
false
;
lock
=
false
;
resolve
(
res
)
resolve
(
res
)
},
},
fail
:
function
(
res
)
{
fail
:
function
(
err
)
{
lock
=
false
;
lock
=
false
;
resolve
(
res
)
reject
(
err
);
console
.
log
(
'err'
,
res
)
console
.
log
(
'err:'
+
err
);
}
}
})
})
},
},
fail
:
function
(
err
)
{
fail
:
function
(
err
)
{
console
.
log
(
err
)
lock
=
false
;
reject
(
err
);
console
.
log
(
'fail:'
+
err
);
}
}
})
})
})
})
...
...
api/request.js
View file @
254834c1
const
app
=
getApp
();
import
$http
from
"./http"
;
import
$http
from
"./http"
;
import
$binding
from
"./binding"
;
// 区域标签树
// 区域标签树
export
function
getRoomTree
()
{
export
function
getRoomTree
()
{
return
$http
({
return
$http
({
...
@@ -199,18 +197,20 @@ export function meetingCollection(data) {
...
@@ -199,18 +197,20 @@ export function meetingCollection(data) {
}
}
// 获取outlook页面授权地址
// 获取outlook页面授权地址
export
function
getOutlookUrl
(
data
)
{
export
function
getOutlookUrl
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"POST"
,
method
:
"POST"
,
data
:
""
,
data
:
""
,
url
:
`/microsoft/getThirdLoginUrl?state=
${
data
}
`
url
:
`/microsoft/getThirdLoginUrl?state=
${
data
}
`
,
type
:
'binding'
});
});
}
}
// 发送给后端outlook code
// 发送给后端outlook code
export
function
authorizationCodeReplacementToken
(
data
)
{
export
function
authorizationCodeReplacementToken
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
method
:
"get"
,
data
:
data
,
data
:
data
,
url
:
`/microsoft/authorizationCodeReplacementToken`
url
:
`/microsoft/authorizationCodeReplacementToken`
,
type
:
'binding'
});
});
}
}
// 发送给后端outlook code
// 发送给后端outlook code
...
@@ -232,18 +232,20 @@ export function unbindingApp(data) {
...
@@ -232,18 +232,20 @@ export function unbindingApp(data) {
}
}
// 获取zoom授权页面
// 获取zoom授权页面
export
function
getZoomUrl
(
data
)
{
export
function
getZoomUrl
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
method
:
"get"
,
data
:
""
,
data
:
""
,
url
:
"/zoom/auth"
url
:
"/zoom/auth"
,
type
:
'binding'
});
});
}
}
//
//
export
function
sendZoomCode
(
data
)
{
export
function
sendZoomCode
(
data
)
{
return
$
binding
({
return
$
http
({
method
:
"get"
,
method
:
"get"
,
data
:
data
,
data
:
data
,
url
:
"/zoom/notice"
url
:
"/zoom/notice"
,
type
:
'binding'
});
});
}
}
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
});
}
});
});
}
app.js
View file @
254834c1
...
@@ -2,19 +2,19 @@ import { setGlobalStore } from "dd-store";
...
@@ -2,19 +2,19 @@ import { setGlobalStore } from "dd-store";
import
exampleStore
from
"./stores/exampleStore"
;
import
exampleStore
from
"./stores/exampleStore"
;
import
{
checkFullScren
}
from
"./utils/checkFullScren"
;
import
{
checkFullScren
}
from
"./utils/checkFullScren"
;
setGlobalStore
(
exampleStore
);
setGlobalStore
(
exampleStore
);
import
login
from
'./api/login'
;
App
({
App
({
onLaunch
(
options
)
{
onLaunch
(
options
)
{
// 第一次打开
// 第一次打开
// options.query == {number:1}
// options.query == {number:1}
// console.info('App onLaunch'
);
login
(
);
this
.
globalData
.
isFullScren
=
checkFullScren
;
this
.
globalData
.
isFullScren
=
checkFullScren
;
},
},
onShow
(
options
)
{
onShow
(
options
)
{
// 从后台被 scheme 重新打开
// 从后台被 scheme 重新打开
// options.query == {number:1}
// options.query == {number:1}
},
},
globalData
:
{
globalData
:
{
isFullScren
:
false
,
isFullScren
:
false
,
loading
:
false
,
loading
:
false
,
...
...
pages/index/index.axml
View file @
254834c1
<import src="../../template/loading/loading.axml"/>
<import src="../../template/loading/loading.axml"/>
<import src="../../template/fullScreen/fullScreen.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"/>
<import src="../../template/affairBlank/index.axml"/>
<view class="{{isStopBodyScroll ? 'scroll-lock' : ''}}" onTap="closeSwipe" onTouchStart="closeSwipe" onTouchMove="closeSwipe" onTouchEnd="closeSwipe">
<view class="{{isStopBodyScroll ? 'scroll-lock' : ''}}" onTap="closeSwipe" onTouchStart="closeSwipe" onTouchMove="closeSwipe" onTouchEnd="closeSwipe">
<block a:if="{{!listLoading}}">
<block a:if="{{!listLoading}}">
...
@@ -42,8 +44,8 @@
...
@@ -42,8 +44,8 @@
<template is="loading" a:else>
<template is="loading" a:else>
</template>
</template>
</view>
</view>
</view>
</view>
<view hidden="{{$data.tabBarIndex === '0'}}">
<view hidden="{{$data.tabBarIndex === '0'}}">
<view a:if="{{!loading}}">
<view a:if="{{!loading}}">
<view class="scheduleHeader">
<view class="scheduleHeader">
<view>{{currentData.split('/')[0]}}年{{currentData.split('/')[1] || '1'}}月</view>
<view>{{currentData.split('/')[0]}}年{{currentData.split('/')[1] || '1'}}月</view>
...
@@ -119,7 +121,8 @@
...
@@ -119,7 +121,8 @@
</view>
</view>
<template is="loading" a:else>
<template is="loading" a:else>
</template>
</template>
</view>
</view>
</block>
<view class="tabBarContent">
<view class="tabBarContent">
<view class="tabBar">
<view class="tabBar">
<view onTap="changeTabBar" data-tabbar='0' data-title='动态'>
<view onTap="changeTabBar" data-tabbar='0' data-title='动态'>
...
...
pages/index/index.js
View file @
254834c1
...
@@ -28,6 +28,7 @@ import create from "dd-store";
...
@@ -28,6 +28,7 @@ import create from "dd-store";
let
maxClickCount
=
5
;
let
maxClickCount
=
5
;
create
.
Page
({
create
.
Page
({
data
:
{
data
:
{
refresh
:
false
,
$data
:
null
,
$data
:
null
,
iconDay
:
currentDate
.
getDate
(),
iconDay
:
currentDate
.
getDate
(),
scheduleList
:
[],
scheduleList
:
[],
...
@@ -173,6 +174,12 @@ create.Page({
...
@@ -173,6 +174,12 @@ create.Page({
if
(
callBack
)
{
if
(
callBack
)
{
callBack
();
callBack
();
}
}
}).
catch
(
err
=>
{
// if (err && err.refresh) {
// this.setData({
// refresh: true
// })
// }
});
});
},
},
//动态置顶
//动态置顶
...
...
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