Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
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
高淑倩
7-Eleven
Commits
d1e20fee
Commit
d1e20fee
authored
Sep 25, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单倒计时
parent
365303fa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
2 deletions
+65
-2
orderDetail.js
src/pages/orderDetail/orderDetail.js
+64
-1
orderDetail.wxml
src/pages/orderDetail/orderDetail.wxml
+1
-1
No files found.
src/pages/orderDetail/orderDetail.js
View file @
d1e20fee
...
@@ -11,7 +11,12 @@ wxService.page({
...
@@ -11,7 +11,12 @@ wxService.page({
*/
*/
data
:
{
data
:
{
detail
:
null
,
detail
:
null
,
id
:
''
id
:
''
,
localNowTime
:
0
,
hour
:
'00'
,
min
:
'00'
,
sec
:
'00'
,
ms
:
'0'
,
},
},
/**
/**
...
@@ -50,13 +55,71 @@ wxService.page({
...
@@ -50,13 +55,71 @@ wxService.page({
const
{
result
,
data
}
=
res
.
data
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
if
(
result
==
0
)
{
wx
.
hideLoading
()
wx
.
hideLoading
()
const
{
localNowTime
}
=
this
.
data
data
.
localNowTime
=
localNowTime
?
localNowTime
:
new
Date
().
getTime
();
data
.
createOrderTime
=
new
Date
(
data
.
createTime
.
replace
(
/-/g
,
'/'
)).
getTime
()
||
[];
data
.
countDownOrderTime
=
7200000
;
// 2时(h)=7200000毫秒(ms)
// 订单倒计时 超多两小时 刷新当前页
// 本地时间 - 创建时间 > 2小时 刷新当前页
this
.
setData
({
this
.
setData
({
detail
:
data
detail
:
data
},
()
=>
{
this
.
initCountDown
(
data
.
countDownOrderTime
,
data
.
createOrderTime
,
data
.
localNowTime
)
})
})
}
}
}
}
})
})
},
},
initCountDown
(
countDownOrderTime
,
startTime
,
localTime
)
{
// 毫秒差 本地时间 - 创建时间
let
countTimeSpan
=
localTime
-
startTime
let
countDownTimer
=
setInterval
(()
=>
{
countDownOrderTime
-=
1000
let
result
=
this
.
getCountDown
(
countTimeSpan
,
countDownOrderTime
);
if
(
result
.
isOver
)
{
clearInterval
(
countDownTimer
);
}
else
{
this
.
setData
({
hour
:
result
.
hour
,
min
:
result
.
min
,
sec
:
result
.
sec
,
ms
:
result
.
ms
,
})
}
},
1000
);
},
getCountDown
(
time
,
countDownOrderTime
)
{
// 判断是否为时间戳
let
distancetime
=
time
<
countDownOrderTime
?
countDownOrderTime
-
time
:
0
;
// 毫秒差 本地时间 - 创建时间 7200000毫秒(ms)
let
result
=
{
hour
:
'00'
,
min
:
'00'
,
sec
:
'00'
,
ms
:
'00'
,
isOver
:
true
,
};
if
(
distancetime
)
{
// 如果大于7200000.说明尚未到达截止时间
result
.
ms
=
Math
.
floor
((
distancetime
%
1000
)
/
100
);
result
.
sec
=
Math
.
floor
((
distancetime
/
1000
)
%
60
);
result
.
min
=
Math
.
floor
((
distancetime
/
1000
/
60
)
%
60
);
result
.
hour
=
Math
.
floor
((
distancetime
/
1000
/
60
/
60
)
%
24
);
result
.
isOver
=
false
;
if
(
result
.
ms
<
10
)
result
.
ms
=
result
.
ms
;
if
(
result
.
sec
<
10
)
result
.
sec
=
'0'
+
result
.
sec
;
if
(
result
.
min
<
10
)
result
.
min
=
'0'
+
result
.
min
;
if
(
result
.
hour
<
10
)
result
.
hour
=
'0'
+
result
.
hour
;
}
else
{
const
{
id
}
=
this
.
data
this
.
getOrderDetail
(
id
)
}
return
result
;
},
// 删除订单
// 删除订单
handelDelOrder
(
e
)
{
handelDelOrder
(
e
)
{
const
{
id
}
=
e
.
currentTarget
.
dataset
const
{
id
}
=
e
.
currentTarget
.
dataset
...
...
src/pages/orderDetail/orderDetail.wxml
View file @
d1e20fee
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
</view>
</view>
<view class="order-status" wx-if="{{detail.status == 'N'}}">
<view class="order-status" wx-if="{{detail.status == 'N'}}">
<view class="status">待付款</view>
<view class="status">待付款</view>
<view class="desc">支付时间仅剩:
2小时34分钟
,超时将自动关闭</view>
<view class="desc">支付时间仅剩:
{{hour}}小时{{min}}分钟{{sec}}秒
,超时将自动关闭</view>
</view>
</view>
<view class="order-status" wx-if="{{detail.status == 'P'}}">
<view class="order-status" wx-if="{{detail.status == 'P'}}">
<view class="status">待发货</view>
<view class="status">待发货</view>
...
...
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