Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-program
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
陈玉桐
wx-program
Commits
9ef9a745
Commit
9ef9a745
authored
Oct 09, 2019
by
陈玉桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加授权异步promise
parent
f9987e18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
210 additions
and
41 deletions
+210
-41
app.js
app.js
+53
-36
app.json
app.json
+1
-1
index.js
pages/index/index.js
+0
-0
index.wxml
pages/index/index.wxml
+1
-1
mine.js
pages/mine/mine.js
+5
-3
updatePlan.js
pages/updatePlan/updatePlan.js
+150
-0
No files found.
app.js
View file @
9ef9a745
...
...
@@ -5,44 +5,60 @@ App({
apiUrl
:
'https://seex.inner.iouou.cn/AppApi/'
,
},
onLaunch
:
function
()
{
},
getToken
:
function
()
{
let
me
=
this
;
// 获取本地缓存的token
wx
.
getStorage
({
key
:
'token'
,
fail
(
res
)
{
// 没登录(没有token时)
console
.
log
(
res
.
errMsg
)
wx
.
login
({
success
(
res
)
{
console
.
log
(
res
)
if
(
res
.
code
)
{
// 发送 res.code 到后台换取 openId, sessionKey, unionId
wx
.
request
({
url
:
me
.
globalData
.
apiUrl
+
'users/token'
,
method
:
'POST'
,
data
:
{
code
:
res
.
code
},
success
:
function
(
res
)
{
if
(
res
.
data
.
errno
==
200
){
// 获取token并本地缓存
console
.
log
(
res
.
data
.
data
.
token
)
wx
.
setStorage
({
key
:
"token"
,
data
:
res
.
data
.
data
.
token
})
}
else
{
//打印错误信息
console
.
log
(
res
.
data
.
msg
)
return
new
Promise
(
function
(
resolve
,
reject
)
{
// 获取本地缓存的token
wx
.
getStorage
({
key
:
'token'
,
fail
(
res
)
{
// 没登录(没有token时)
console
.
log
(
res
.
errMsg
)
wx
.
login
({
success
(
res
)
{
console
.
log
(
res
)
if
(
res
.
code
)
{
// 发送 res.code 到后台换取 openId, sessionKey, unionId
wx
.
request
({
url
:
me
.
globalData
.
apiUrl
+
'users/token'
,
method
:
'POST'
,
data
:
{
code
:
res
.
code
},
success
:
function
(
res
)
{
if
(
res
.
data
.
errno
==
200
){
// 获取token并本地缓存
console
.
log
(
res
.
data
.
data
.
token
)
wx
.
setStorage
({
key
:
"token"
,
data
:
res
.
data
.
data
.
token
})
let
resStatus
=
{
status
:
200
}
resolve
(
resStatus
);
}
else
{
//打印错误信息
console
.
log
(
res
.
data
.
msg
)
reject
(
'error'
);
}
}
}
})
}
else
{
console
.
log
(
'登录失败!'
+
res
.
errMsg
)
})
}
else
{
console
.
log
(
'获取用户登录态失败!'
+
res
.
errMsg
);
reject
(
'error'
);
}
}
})
},
success
(){
let
resStatus
=
{
status
:
200
}
})
}
})
}
resolve
(
resStatus
);
}
})
});
},
})
\ No newline at end of file
app.json
View file @
9ef9a745
{
"pages"
:
[
"pages/plan/plan"
,
"pages/index/index"
,
"pages/historyDetail/historyDetail"
,
"pages/user/user"
,
...
...
@@ -7,7 +8,6 @@
"pages/idea/idea"
,
"pages/message/message"
,
"pages/updatePlan/updatePlan"
,
"pages/plan/plan"
,
"pages/trainReport/trainReport"
,
"pages/starSort/starSort"
,
"pages/trainSort/trainSort"
,
...
...
pages/index/index.js
View file @
9ef9a745
This diff is collapsed.
Click to expand it.
pages/index/index.wxml
View file @
9ef9a745
...
...
@@ -258,7 +258,7 @@
<!-- 内容 -->
<view id="mustUpdateCon">
<view id="mustUpdateTitle">尊敬的家长您好</view>
<view id="mustUpdateDes">因您长时间未更新视力信息,眼保仪已被暂时锁定
,请您立即前往"训练计划"更新“视力数据”进行解锁
!</view>
<view id="mustUpdateDes">因您长时间未更新视力信息,眼保仪已被暂时锁定
。为了保障孩子的训练成效,请您立即前往"训练计划"更新“视力数据”
!</view>
</view>
<!-- 按钮组 -->
<view id="mustUpdateBtn">
...
...
pages/mine/mine.js
View file @
9ef9a745
...
...
@@ -40,8 +40,8 @@ Page({
// 解绑
unbundle
()
{
wx
.
showModal
({
title
:
'
删除
提示'
,
content
:
'
删除后无法恢复,是否删除?
'
,
title
:
'
解绑
提示'
,
content
:
'
解除绑定设备后,家长端部分功能将无法使用。
'
,
success
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
)
...
...
@@ -60,7 +60,9 @@ Page({
// 请求成功后关闭Loading
wx
.
hideLoading
();
if
(
res
.
data
.
errno
==
200
){
wx
.
redirectTo
({
url
:
'/pages/index/index'
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
...
...
pages/updatePlan/updatePlan.js
View file @
9ef9a745
...
...
@@ -108,6 +108,156 @@ Page({
}
}
}
if
(
res
.
data
.
data
.
trainingList
[
0
].
type
==
'单词训练'
){
// 请求前加Loading
wx
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/publisher'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
},
success
:
function
(
res
)
{
// // 请求成功后关闭Loading
// wx.hideLoading();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
teachArray
:
res
.
data
.
data
.
list
,
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/book'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
publisherId
:
res
.
data
.
data
.
list
[
0
].
id
},
success
:
function
(
res
)
{
// 请求成功后关闭Loading
// wx.hideLoading();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
bookArray
:
res
.
data
.
data
.
data
,
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/chapter'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
bookId
:
res
.
data
.
data
.
data
[
0
].
id
},
success
:
function
(
res
)
{
// 请求成功后关闭Loading
wx
.
hideLoading
();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
unitArray
:
res
.
data
.
data
.
data
,
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
if
(
res
.
data
.
data
.
trainingList
[
1
].
type
==
'单词训练'
){
// 请求前加Loading
wx
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/publisher'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
},
success
:
function
(
res
)
{
// // 请求成功后关闭Loading
// wx.hideLoading();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
teachArray
:
res
.
data
.
data
.
list
,
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/book'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
publisherId
:
res
.
data
.
data
.
list
[
0
].
id
},
success
:
function
(
res
)
{
// 请求成功后关闭Loading
// wx.hideLoading();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
bookArray
:
res
.
data
.
data
.
data
,
})
wx
.
request
({
url
:
app
.
globalData
.
apiUrl
+
'Trainings/chapter'
,
method
:
'POST'
,
data
:
{
token
:
wx
.
getStorageSync
(
'token'
),
bookId
:
res
.
data
.
data
.
data
[
0
].
id
},
success
:
function
(
res
)
{
// 请求成功后关闭Loading
wx
.
hideLoading
();
if
(
res
.
data
.
errno
==
200
){
me
.
setData
({
unitArraySecond
:
res
.
data
.
data
.
data
,
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
else
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
res
.
data
.
msg
})
}
}
})
}
}
else
{
wx
.
showModal
({
title
:
'提示'
,
...
...
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