Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
walk_daka_wx
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
穆启卓
walk_daka_wx
Commits
7cbece87
Commit
7cbece87
authored
Apr 02, 2019
by
穆启卓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
逻辑完善
parent
e4c13551
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
270 deletions
+101
-270
app.js
app.js
+37
-224
authorization.js
pages/authorization/authorization.js
+5
-0
index.js
pages/index/index.js
+30
-13
index.wxml
pages/index/index.wxml
+14
-14
util.js
utils/util.js
+15
-19
No files found.
app.js
View file @
7cbece87
This diff is collapsed.
Click to expand it.
pages/authorization/authorization.js
View file @
7cbece87
...
@@ -71,6 +71,11 @@ Page({
...
@@ -71,6 +71,11 @@ Page({
this
.
setData
({
this
.
setData
({
stepAuth
:
true
stepAuth
:
true
});
});
}
else
{
app
.
globalData
.
stepAuth
=
false
;
this
.
setData
({
stepAuth
:
false
});
}
}
this
.
checkAuth
();
this
.
checkAuth
();
}
}
...
...
pages/index/index.js
View file @
7cbece87
...
@@ -4,7 +4,6 @@ Page({
...
@@ -4,7 +4,6 @@ Page({
data
:
{
data
:
{
userAuth
:
false
,
// 用户信息授权(为了拿unionId)
userAuth
:
false
,
// 用户信息授权(为了拿unionId)
stepAuth
:
false
,
// 步数授权
stepAuth
:
false
,
// 步数授权
getStepLoading
:
false
,
// commitStepPopupShow: false, // 同步步数成功弹窗
// commitStepPopupShow: false, // 同步步数成功弹窗
activityExplainShow
:
false
,
// 活动说明弹窗
activityExplainShow
:
false
,
// 活动说明弹窗
currentSteps
:
0
,
currentSteps
:
0
,
...
@@ -40,7 +39,7 @@ Page({
...
@@ -40,7 +39,7 @@ Page({
stepAuth
:
app
.
globalData
.
stepAuth
stepAuth
:
app
.
globalData
.
stepAuth
});
});
if
(
app
.
globalData
.
unionAuth
&&
app
.
globalData
.
stepAuth
)
{
if
(
app
.
globalData
.
unionAuth
&&
app
.
globalData
.
stepAuth
)
{
this
.
c
lickStepData
();
this
.
getC
lickStepData
();
}
else
if
(
app
.
globalData
.
stepAuth
)
{
}
else
if
(
app
.
globalData
.
stepAuth
)
{
this
.
loadStepData
();
this
.
loadStepData
();
}
}
...
@@ -114,22 +113,23 @@ Page({
...
@@ -114,22 +113,23 @@ Page({
},
},
// 用户点击提交步数打卡1(处理授权情况)
// 用户点击提交步数打卡1(处理授权情况)
clickStepData
()
{
clickStepData
(
resCheck
=
false
)
{
console
.
log
(
'clickStepData'
)
console
.
log
(
'clickStepData'
)
if
(
!
this
.
data
.
isFirstReq
&&
wx
.
getStorageSync
(
'getStepLoading'
)
&&
Date
.
now
()
-
wx
.
getStorageSync
(
'getStepLoading'
)
<
60000
)
{
if
(
!
resCheck
&&
!
this
.
data
.
isFirstReq
&&
wx
.
getStorageSync
(
'getStepLoading'
)
&&
Date
.
now
()
-
wx
.
getStorageSync
(
'getStepLoading'
)
<
60000
)
{
wx
.
showToast
({
wx
.
showToast
({
title
:
'已是最新步数,建议前往微信运动获取最新步数再返回同步'
,
title
:
'已是最新步数,建议前往微信运动获取最新步数再返回同步'
,
icon
:
'none'
,
icon
:
'none'
,
duration
:
2000
duration
:
2000
});
});
//
return;
return
;
}
}
let
needStepAuth
=
()
=>
{
let
needStepAuth
=
(
resCheck
)
=>
{
wx
.
authorize
({
// 调起授权窗口
wx
.
authorize
({
// 调起授权窗口
scope
:
'scope.werun'
,
scope
:
'scope.werun'
,
success
:()
=>
{
// 授权成功
success
:()
=>
{
// 授权成功
app
.
globalData
.
stepAuth
=
true
;
app
.
globalData
.
stepAuth
=
true
;
this
.
clickStepData
();
if
(
resCheck
)
this
.
clickStepData
(
true
);
else
this
.
getClickStepData
();
},
},
fail
:(
err
)
=>
{
// 授权失败,因为用户拒绝或者用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去
fail
:(
err
)
=>
{
// 授权失败,因为用户拒绝或者用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去
this
.
authorizationFail
();
this
.
authorizationFail
();
...
@@ -147,10 +147,10 @@ Page({
...
@@ -147,10 +147,10 @@ Page({
wx
.
navigateTo
({
wx
.
navigateTo
({
url
:
'/pages/authorization/authorization'
url
:
'/pages/authorization/authorization'
});
});
}
else
if
(
app
.
globalData
.
userAuth
&&
!
app
.
globalData
.
stepAuth
)
{
needStepAuth
();
}
else
if
(
!
app
.
globalData
.
userAuth
&&
app
.
globalData
.
stepAuth
)
{
}
else
if
(
!
app
.
globalData
.
userAuth
&&
app
.
globalData
.
stepAuth
)
{
this
.
showUserInfoPopup
();
this
.
showUserInfoPopup
();
}
else
if
(
app
.
globalData
.
userAuth
&&
!
app
.
globalData
.
stepAuth
)
{
needStepAuth
(
true
);
}
else
if
(
app
.
globalData
.
userAuth
&&
app
.
globalData
.
stepAuth
)
{
}
else
if
(
app
.
globalData
.
userAuth
&&
app
.
globalData
.
stepAuth
)
{
wx
.
getUserInfo
({
wx
.
getUserInfo
({
withCredentials
:
true
,
withCredentials
:
true
,
...
@@ -226,8 +226,11 @@ Page({
...
@@ -226,8 +226,11 @@ Page({
// 用户同意授权
// 用户同意授权
onGotUserInfo
(
event
)
{
onGotUserInfo
(
event
)
{
console
.
log
(
'onGotUserInfo'
)
console
.
log
(
'onGotUserInfo'
)
this
.
showUserInfoPopup
();
app
.
globalData
.
userAuth
=
true
;
app
.
globalData
.
userAuth
=
true
;
this
.
setData
({
showGetUserInfo
:
!
this
.
data
.
showGetUserInfo
,
userAuth
:
true
});
this
.
sendUserInfo
(
event
.
detail
.
encryptedData
,
event
.
detail
.
iv
);
this
.
sendUserInfo
(
event
.
detail
.
encryptedData
,
event
.
detail
.
iv
);
},
},
...
@@ -263,18 +266,32 @@ Page({
...
@@ -263,18 +266,32 @@ Page({
authorizationFail
()
{
authorizationFail
()
{
console
.
log
(
'authorizationFail'
)
console
.
log
(
'authorizationFail'
)
wx
.
showModal
({
wx
.
showModal
({
content
:
'如需完成步数打卡,
\
n
请点击确定允许微信授权'
,
content
:
'如需完成步数打卡,请点击确定允许微信授权'
,
success
:(
res
)
=>
{
success
:(
res
)
=>
{
if
(
res
.
confirm
)
{
if
(
res
.
confirm
)
{
wx
.
openSetting
({
wx
.
openSetting
({
success
:(
res
)
=>
{
success
:(
res
)
=>
{
if
(
res
.
authSetting
[
'scope.userInfo'
])
{
app
.
globalData
.
userAuth
=
true
;
this
.
setData
({
userAuth
:
true
});
}
else
{
app
.
globalData
.
userAuth
=
false
;
this
.
setData
({
userAuth
:
false
});
}
if
(
res
.
authSetting
[
'scope.werun'
])
{
if
(
res
.
authSetting
[
'scope.werun'
])
{
app
.
globalData
.
stepAuth
=
true
;
this
.
setData
({
this
.
setData
({
stepAuth
:
true
stepAuth
:
true
});
});
// this.getPageData();
}
else
{
}
else
{
// this.authorizationFail();
app
.
globalData
.
stepAuth
=
false
;
this
.
setData
({
stepAuth
:
false
});
}
}
}
}
});
});
...
...
pages/index/index.wxml
View file @
7cbece87
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
<image class="status-mark" src="/images/index/sy_{{item.status===1?'wancheng':'shibai'}}.png" wx:if="{{item.status}}"></image>
<image class="status-mark" src="/images/index/sy_{{item.status===1?'wancheng':'shibai'}}.png" wx:if="{{item.status}}"></image>
<view class="date-container">
<view class="date-container">
<view class="date-item">{{item.date}}总步数</view>
<view class="date-item">{{item.date}}总步数</view>
<view class="date-item">{{item.date_time}}</view>
</view>
</view>
<view class="other-step-num">+{{item.step}}</view>
<view class="other-step-num">+{{item.step}}</view>
</view>
</view>
...
@@ -38,12 +37,22 @@
...
@@ -38,12 +37,22 @@
<view class="hr"></view>
<view class="hr"></view>
<view class="content-title title1">运动步数为0怎么办?</view>
<view class="content-title title1">运动步数为0怎么办?</view>
<view class="content-text">请检查是否关注微信运动公众号,如已关注请继续行走;</view>
<view class="content-text">请检查是否关注微信运动公众号,如已关注请继续行走;</view>
<view class="content-text">如未关注,则进入微信【添加好友】
-
搜索【微信运动】找到公众号并关注,进入公众号后你会收到一条提示是否要让微信访问我们的活动记录点击“好”即可。</view>
<view class="content-text">如未关注,则进入微信【添加好友】
—
搜索【微信运动】找到公众号并关注,进入公众号后你会收到一条提示是否要让微信访问我们的活动记录点击“好”即可。</view>
<view class="content-title title2">如何参与步数打卡?</view>
<view class="content-title title2">如何参与步数打卡?</view>
<view class="content-text">关注公众号【
XXXX
】,点击菜单栏【打卡入口】,成功报名活动后,活动结束24点前登录小程序同步最新步数。</view>
<view class="content-text">关注公众号【
步步运动赚
】,点击菜单栏【打卡入口】,成功报名活动后,活动结束24点前登录小程序同步最新步数。</view>
<image class="activity-explain-close-btn" src="/images/index/pop_ic_close.png" bindtap="changeActivityExplainShow"></image>
<image class="activity-explain-close-btn" src="/images/index/pop_ic_close.png" bindtap="changeActivityExplainShow"></image>
</view>
</view>
</view>
</view>
<!-- 用戶信息授权,为了拿unionId -->
<view class="commit-step-popup-bg" wx:if="{{showGetUserInfo}}">
<view class="commit-step-popup">
<view class="popup-content">请允许授权获取步数数据</view>
<view class="popup-btn-container">
<view class="cancel-btn" bindtap="showUserInfoPopup">取消</view>
<button class="confirm-btn" plain open-type="getUserInfo" bindgetuserinfo="onGotUserInfo">确定</button>
</view>
</view>
</view>
<!-- 同步步数成功弹窗 -->
<!-- 同步步数成功弹窗 -->
<!-- <view class="commit-step-popup-bg" wx:if="{{commitStepPopupShow}}">
<!-- <view class="commit-step-popup-bg" wx:if="{{commitStepPopupShow}}">
<view class="commit-step-popup">
<view class="commit-step-popup">
...
@@ -53,13 +62,4 @@
...
@@ -53,13 +62,4 @@
<navigator class="confirm-btn" hover-class="none" open-type="exit" target="miniProgram">确定</navigator>
<navigator class="confirm-btn" hover-class="none" open-type="exit" target="miniProgram">确定</navigator>
</view>
</view>
</view>
</view>
</view> -->
</view> -->
<view class="commit-step-popup-bg" wx:if="{{showGetUserInfo}}">
\ No newline at end of file
<view class="commit-step-popup">
<view class="popup-content">请允许授权获取步数数据</view>
<view class="popup-btn-container">
<view class="cancel-btn" bindtap="showUserInfoPopup">取消</view>
<button class="confirm-btn" plain open-type="getUserInfo" bindgetuserinfo="onGotUserInfo">确定</button>
</view>
</view>
</view>
\ No newline at end of file
utils/util.js
View file @
7cbece87
function
formatTime
(
date
)
{
var
year
=
date
.
getFullYear
()
var
month
=
date
.
getMonth
()
+
1
var
day
=
date
.
getDate
()
var
hour
=
date
.
getHours
()
var
minute
=
date
.
getMinutes
()
var
second
=
date
.
getSeconds
()
return
[
year
,
month
,
day
].
map
(
formatNumber
).
join
(
'/'
)
+
' '
+
[
hour
,
minute
,
second
].
map
(
formatNumber
).
join
(
':'
)
}
function
formatNumber
(
n
)
{
n
=
n
.
toString
()
return
n
[
1
]
?
n
:
'0'
+
n
}
module
.
exports
=
{
module
.
exports
=
{
formatTime
:
formatTime
formatTime
(
date
)
{
}
var
year
=
date
.
getFullYear
()
var
month
=
date
.
getMonth
()
+
1
var
day
=
date
.
getDate
()
var
hour
=
date
.
getHours
()
var
minute
=
date
.
getMinutes
()
var
second
=
date
.
getSeconds
()
var
formatNumber
=
n
=>
{
n
=
n
.
toString
()
return
n
[
1
]
?
n
:
'0'
+
n
}
return
[
year
,
month
,
day
].
map
(
formatNumber
).
join
(
'/'
)
+
' '
+
[
hour
,
minute
,
second
].
map
(
formatNumber
).
join
(
':'
)
}
}
\ No newline at end of file
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