Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-front
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
doublescreen-front
Commits
0c01dc9c
Commit
0c01dc9c
authored
Feb 28, 2020
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfixed
parent
fdc651fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
17 deletions
+40
-17
scan.js
pages/scan/scan.js
+40
-17
No files found.
pages/scan/scan.js
View file @
0c01dc9c
...
...
@@ -82,6 +82,8 @@ Page({
scanDialogDisplay
:
res
.
data
.
discCouponState
,
totalDisc
:
res
.
data
.
discCouponPrice
});
if
(
res
.
data
.
discCouponState
==
1
)
{
var
speechContent
=
"请扫描优惠券码"
;
my
.
ix
.
speech
({
text
:
speechContent
,
...
...
@@ -89,6 +91,8 @@ Page({
success
:
(
r
)
=>
{
}
});
}
}
}
...
...
@@ -116,18 +120,36 @@ Page({
setTimeout
(()
=>
{
let
totalDiscTemp
=
this
.
data
.
totalDisc
+
Math
.
round
(
Math
.
random
()
*
4
)
+
1
;
let
context
=
this
;
//超额
if
(
totalDiscTemp
>
this
.
data
.
totalPrice
){
let
req
=
{}
req
.
discCouponErrMsg
=
"超额优惠券"
req
.
discCouponState
=
4
;
this
.
useCouponCallback
(
ACTION_USE_COUPON
,
req
)
return
}
let
req
=
{}
req
.
discCouponPrice
=
totalDiscTemp
;
req
.
discCouponState
=
3
;
var
commonRequest
=
{
action
:
ACTION_USE_COUPON
,
data
:
req
};
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
commonRequest
,
success
:
(
res
)
=>
{
this
.
useCouponCallback
(
ACTION_USE_COUPON
,
req
)
},
700
);
},
//用券回调
useCouponCallback
(
action
,
result
)
{
let
context
=
this
;
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
{
action
:
action
,
data
:
result
},
success
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
//用券成功
if
(
result
.
discCouponState
==
3
){
//模拟数据 1 - 5 随机整数
context
.
setData
({
scanDialogDisplay
:
0
,
totalDisc
:
totalDiscTemp
})
my
.
showToast
({
...
...
@@ -138,15 +160,16 @@ Page({
},
});
console
.
log
(
"用券成功到后屏小程序成功 ===》"
+
JSON
.
stringify
(
res
));
},
fail
:
(
res
)
=>
{
console
.
log
(
"用券成功后屏小程序 失败 ===》 "
+
JSON
.
stringify
(
res
));
//发送失败重试
context
.
sendGoodInfoToBack
();
//用券失败
}
else
if
(
result
.
discCouponState
==
4
){
context
.
setData
({
scanDialogDisplay
:
4
})
}
})
},
700
);
},
fail
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
context
.
useCouponCallback
(
action
,
result
)
}
});
},
//获取商品信息
...
...
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