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
85644c73
Commit
85644c73
authored
Feb 24, 2020
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改home页面
parent
4423a557
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
47 deletions
+55
-47
home.js
pages/home/home.js
+55
-47
No files found.
pages/home/home.js
View file @
85644c73
...
@@ -14,6 +14,7 @@ Page({
...
@@ -14,6 +14,7 @@ Page({
data
:
{
data
:
{
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay
:
0
,
scanDialogDisplay
:
0
,
dialogShowType
:
""
,
//弹窗类型:如refund
dialogRemindText
:
"请扫描兑换码"
,
dialogRemindText
:
"请扫描兑换码"
,
dialogLoadingText
:
"识别中"
,
dialogLoadingText
:
"识别中"
,
dialogResultSuccessRemind
:
"兑换码已识别"
,
dialogResultSuccessRemind
:
"兑换码已识别"
,
...
@@ -69,8 +70,8 @@ Page({
...
@@ -69,8 +70,8 @@ Page({
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
}
}
});
});
}
else
if
(
res
.
action
==
ACTION_DIRECT_PAYMENT
)
{
}
else
if
(
res
.
action
==
ACTION_DIRECT_PAYMENT
)
{
//直接收款
//直接收款
my
.
ix
.
sendBuddyMessage
({
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
backScreenAppId
,
target
:
getApp
().
globalData
.
backScreenAppId
,
...
@@ -89,13 +90,14 @@ Page({
...
@@ -89,13 +90,14 @@ Page({
console
.
log
(
"通知后屏小程序跳转到结算页面 失败 ===》 "
+
JSON
.
stringify
(
fres
));
console
.
log
(
"通知后屏小程序跳转到结算页面 失败 ===》 "
+
JSON
.
stringify
(
fres
));
}
}
})
})
}
else
if
(
res
.
action
==
ACTION_CONVERT_COUPON
)
{
}
else
if
(
res
.
action
==
ACTION_CONVERT_COUPON
)
{
//兑换券
//兑换券
this
.
setData
({
scanDialogDisplay
:
res
.
data
})
this
.
setData
({
scanDialogDisplay
:
res
.
data
})
}
else
if
(
res
.
action
==
ACTION_REFUND
)
{
}
else
if
(
res
.
action
==
ACTION_REFUND
)
{
//显示弹窗
//显示弹窗
context
.
setData
({
context
.
setData
({
scanDialogDisplay
:
1
,
scanDialogDisplay
:
1
,
dialogShowType
:
"refund"
,
dialogRemindText
:
"请扫描订单编码"
,
dialogRemindText
:
"请扫描订单编码"
,
dialogLoadingText
:
"识别中"
,
dialogLoadingText
:
"识别中"
,
dialogResultSuccessRemind
:
"退款成功"
,
dialogResultSuccessRemind
:
"退款成功"
,
...
@@ -106,18 +108,24 @@ Page({
...
@@ -106,18 +108,24 @@ Page({
}
else
if
(
res
.
action
==
ACTION_GO_HOME
)
{
}
else
if
(
res
.
action
==
ACTION_GO_HOME
)
{
//home界面收到,则返回界面上
//home界面收到,则返回界面上
context
.
setData
({
context
.
setData
({
scanDialogDisplay
:
0
scanDialogDisplay
:
0
,
dialogShowType
:
""
,
//重置类型
})
})
}
}
}
}
});
});
},
},
//外接扫码枪事件
//外接扫码枪事件
onKeyPress
(
r
)
{
onKeyPress
(
r
)
{
console
.
log
(
"scan onKeyPress==>"
+
r
);
console
.
log
(
"scan onKeyPress==>"
+
r
);
if
(
this
.
data
.
scanDialogDisplay
!=
0
){
if
(
this
.
data
.
scanDialogDisplay
!=
0
)
{
this
.
verifyCoupon
(
r
);
if
(
this
.
data
.
dialogShowType
==
"refund"
)
{
refund
(
r
);
}
else
{
this
.
verifyCoupon
(
r
);
}
}
}
},
},
...
@@ -136,7 +144,7 @@ Page({
...
@@ -136,7 +144,7 @@ Page({
//核销券
//核销券
verifyCoupon
(
code
)
{
verifyCoupon
(
code
)
{
this
.
setData
({
scanDialogDisplay
:
2
})
this
.
setData
({
scanDialogDisplay
:
2
})
var
commonRequest
=
{};
var
commonRequest
=
{};
commonRequest
.
state
=
2
commonRequest
.
state
=
2
this
.
sendConvertCouponToBack
(
commonRequest
)
this
.
sendConvertCouponToBack
(
commonRequest
)
...
@@ -151,19 +159,19 @@ Page({
...
@@ -151,19 +159,19 @@ Page({
timeout
:
30000
,
timeout
:
30000
,
data
:
couponRequest
,
data
:
couponRequest
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
if
(
res
.
data
.
success
!=
true
)
{
if
(
res
.
data
.
success
!=
true
)
{
var
commonRequest
=
{};
var
commonRequest
=
{};
commonRequest
.
state
=
4
commonRequest
.
state
=
4
commonRequest
.
msg
=
res
.
data
.
errorMsg
commonRequest
.
msg
=
res
.
data
.
errorMsg
context
.
sendConvertCouponToBack
(
commonRequest
)
context
.
sendConvertCouponToBack
(
commonRequest
)
this
.
setData
({
scanDialogDisplay
:
4
})
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"核销券失败 ==>"
+
res
.
data
.
errorMsg
);
console
.
log
(
"核销券失败 ==>"
+
res
.
data
.
errorMsg
);
}
else
{
}
else
{
var
commonRequest
=
{};
var
commonRequest
=
{};
commonRequest
.
state
=
3
commonRequest
.
state
=
3
context
.
sendConvertCouponToBack
(
commonRequest
)
context
.
sendConvertCouponToBack
(
commonRequest
)
this
.
setData
({
scanDialogDisplay
:
3
})
this
.
setData
({
scanDialogDisplay
:
3
})
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
}
}
},
},
...
@@ -172,7 +180,7 @@ Page({
...
@@ -172,7 +180,7 @@ Page({
commonRequest
.
state
=
4
commonRequest
.
state
=
4
commonRequest
.
msg
=
"网络异常"
commonRequest
.
msg
=
"网络异常"
context
.
sendConvertCouponToBack
(
commonRequest
)
context
.
sendConvertCouponToBack
(
commonRequest
)
this
.
setData
({
scanDialogDisplay
:
4
})
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"核销券失败 ==>"
+
JSON
.
stringify
(
res
));
console
.
log
(
"核销券失败 ==>"
+
JSON
.
stringify
(
res
));
my
.
showToast
({
my
.
showToast
({
type
:
'exception'
,
type
:
'exception'
,
...
@@ -183,14 +191,6 @@ Page({
...
@@ -183,14 +191,6 @@ Page({
});
});
},
},
//增加扫码内容,以及退款等操作的内容
onKeyPress
(
r
)
{
//只有在弹窗出现时才扫码
if
(
this
.
data
.
scanDialogDisplay
>
0
)
{
refund
(
r
);
}
},
refund
(
barcode
)
{
refund
(
barcode
)
{
this
.
setData
({
scanDialogDisplay
:
2
})
this
.
setData
({
scanDialogDisplay
:
2
})
var
request
=
api
.
createCommonRequest
();
var
request
=
api
.
createCommonRequest
();
...
@@ -203,10 +203,14 @@ Page({
...
@@ -203,10 +203,14 @@ Page({
timeout
:
30000
,
timeout
:
30000
,
data
:
request
,
data
:
request
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
if
(
res
.
data
.
success
!=
true
||
res
.
data
.
data
==
null
)
{
if
(
res
.
data
.
success
!=
true
||
res
.
data
.
data
==
null
)
{
this
.
setData
({
scanDialogDisplay
:
4
})
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"退款失败 ==>"
+
JSON
.
stringify
(
res
.
data
));
console
.
log
(
"退款失败 ==>"
+
JSON
.
stringify
(
res
.
data
));
this
.
refundCallback
(
ACTION_REFUND_FAILED
,
null
);
var
message
=
res
.
data
.
message
;
if
(
message
==
null
)
{
message
=
"退款失败,请检查退款订单号,稍后再试"
;
}
this
.
refundCallback
(
ACTION_REFUND_FAILED
,
message
);
}
else
{
}
else
{
this
.
setData
({
scanDialogDisplay
:
3
})
this
.
setData
({
scanDialogDisplay
:
3
})
console
.
log
(
"退款成功 ==>"
+
JSON
.
stringify
(
res
.
data
));
console
.
log
(
"退款成功 ==>"
+
JSON
.
stringify
(
res
.
data
));
...
@@ -216,12 +220,16 @@ Page({
...
@@ -216,12 +220,16 @@ Page({
fail
:
(
res
)
=>
{
fail
:
(
res
)
=>
{
this
.
setData
({
scanDialogDisplay
:
4
})
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"退款失败 ==>"
+
JSON
.
stringify
(
res
.
data
));
console
.
log
(
"退款失败 ==>"
+
JSON
.
stringify
(
res
.
data
));
this
.
refundCallback
(
ACTION_REFUND_FAILED
,
null
);
var
message
=
res
.
data
.
message
;
if
(
message
==
null
)
{
message
=
"退款失败,请检查退款订单号,稍后再试"
;
}
this
.
refundCallback
(
ACTION_REFUND_FAILED
,
message
);
}
}
});
});
},
},
refundCallback
(
action
,
data
)
{
refundCallback
(
action
,
data
)
{
my
.
ix
.
sendBuddyMessage
({
my
.
ix
.
sendBuddyMessage
({
// 填入目标小程序的 AppID
// 填入目标小程序的 AppID
target
:
getApp
().
globalData
.
backScreenAppId
,
target
:
getApp
().
globalData
.
backScreenAppId
,
...
@@ -241,23 +249,23 @@ Page({
...
@@ -241,23 +249,23 @@ Page({
},
},
//同步兑换券到后台
//同步兑换券到后台
sendConvertCouponToBack
(
e
){
sendConvertCouponToBack
(
e
)
{
my
.
ix
.
sendBuddyMessage
({
my
.
ix
.
sendBuddyMessage
({
// 填入目标小程序的 AppID
// 填入目标小程序的 AppID
target
:
getApp
().
globalData
.
backScreenAppId
,
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
{
data
:
{
action
:
ACTION_CONVERT_COUPON
,
action
:
ACTION_CONVERT_COUPON
,
data
:
e
data
:
e
},
},
success
:
(
sres
)
=>
{
success
:
(
sres
)
=>
{
},
},
fail
:
(
fres
)
=>
{
fail
:
(
fres
)
=>
{
sendConvertCouponToBack
(
e
)
sendConvertCouponToBack
(
e
)
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
}
}
});
});
}
}
...
...
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