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
ed3b2e9c
Commit
ed3b2e9c
authored
Feb 24, 2020
by
pengguangpu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
home页添加打印上一单逻辑;
parent
bfeefbf3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
3 deletions
+116
-3
actioncmd.js
const/actioncmd.js
+3
-0
home.js
pages/home/home.js
+113
-3
No files found.
const/actioncmd.js
View file @
ed3b2e9c
...
@@ -48,3 +48,6 @@ export const ACTION_REFUND_FAILED = "ACTION_REFUND_FAILED";
...
@@ -48,3 +48,6 @@ export const ACTION_REFUND_FAILED = "ACTION_REFUND_FAILED";
//登录完成
//登录完成
export
const
ACTION_LOGIN_OK
=
"ACTION_LOGIN_OK"
;
export
const
ACTION_LOGIN_OK
=
"ACTION_LOGIN_OK"
;
//打印上一单
export
const
ACTION_PRINT_LAST_ORDER
=
"ACTION_PRINT_LAST_ORDER"
;
pages/home/home.js
View file @
ed3b2e9c
...
@@ -10,6 +10,7 @@ import { ACTION_REFUND } from '../../const/actioncmd'
...
@@ -10,6 +10,7 @@ import { ACTION_REFUND } from '../../const/actioncmd'
import
{
ACTION_REFUND_FAILED
}
from
'../../const/actioncmd'
import
{
ACTION_REFUND_FAILED
}
from
'../../const/actioncmd'
import
{
ACTION_REFUND_SUCCESS
}
from
'../../const/actioncmd'
import
{
ACTION_REFUND_SUCCESS
}
from
'../../const/actioncmd'
import
{
API_REFUND
}
from
'../../const/apiurl'
import
{
API_REFUND
}
from
'../../const/apiurl'
import
{
ACTION_PRINT_LAST_ORDER
}
from
'../../const/apiurl'
Page
({
Page
({
...
@@ -104,7 +105,7 @@ Page({
...
@@ -104,7 +105,7 @@ Page({
dialogResultFailureRemind
:
"兑换码未识别"
,
dialogResultFailureRemind
:
"兑换码未识别"
,
dialogResultFailureText
:
"兑换失败,请稍后重试!"
,
dialogResultFailureText
:
"兑换失败,请稍后重试!"
,
})
})
}
else
if
(
res
.
action
==
ACTION_REFUND
)
{
}
else
if
(
res
.
action
==
ACTION_REFUND
)
{
//显示弹窗
//显示弹窗
context
.
setData
({
context
.
setData
({
...
@@ -124,11 +125,120 @@ Page({
...
@@ -124,11 +125,120 @@ Page({
scanDialogDisplay
:
0
,
scanDialogDisplay
:
0
,
dialogShowType
:
""
,
//重置类型
dialogShowType
:
""
,
//重置类型
})
})
}
else
if
(
res
.
action
==
ACTION_PRINT_LAST_ORDER
)
{
//打印上一单
//商品列表
var
printLastOrder_goodsList
=
my
.
getStorageSync
({
key
:
'paySuccessGoodsList'
}).
data
;
var
printLastOrder_paySuccessResp
=
my
.
getStorageSync
({
key
:
'paySuccessResponse'
}).
data
;
if
(
printLastOrder_paySuccessResp
==
null
)
{
//本地没有上一单信息
my
.
ix
.
sendBuddyMessage
({
// 填入目标小程序的 AppID
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
{
action
:
ACTION_PRINT_LAST_ORDER
,
data
:
{
code
:
-
1
,
data
:
"本地没有上一单信息"
}
},
success
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
},
fail
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
}
});
return
;
}
//去打印
context
.
printLastOrder
(
printLastOrder_goodsList
,
printLastOrder_paySuccessResp
)
}
}
}
}
});
});
},
},
/**打印上一单 */
printLastOrder
(
printLastOrder_goodsList
,
printLastOrder_paySuccessResp
)
{
var
printLastOrder_orderPriceFen
=
printLastOrder_paySuccessResp
.
tradeAmount
;
var
printLastOrder_couponPriceFen
=
printLastOrder_paySuccessResp
.
mdiscount
+
printLastOrder_paySuccessResp
.
discount
;
var
printLastOrder_payPriceFen
=
printLastOrder_paySuccessResp
.
tradeAmount
-
(
printLastOrder_paySuccessResp
.
mdiscount
+
printLastOrder_paySuccessResp
.
discount
);
var
printLastOrder_totalCount
=
context
.
caculateTotalCountFromGoodsList
(
printLastOrder_goodsList
);
//分转元
var
miyapay
=
require
(
"../../utils/miyapay4.js"
);
var
printLastOrder_orderPriceYuan
=
miyapay
.
fen2Yuan
(
printLastOrder_orderPriceFen
);
var
printLastOrder_couponPriceYuan
=
miyapay
.
fen2Yuan
(
printLastOrder_couponPriceFen
);
var
printLastOrder_payPriceYuan
=
miyapay
.
fen2Yuan
(
printLastOrder_payPriceFen
);
//支付渠道
var
payChannel
=
"未知"
;
if
(
printLastOrder_paySuccessResp
.
channel
==
1
)
{
payChannel
=
"微信"
;
}
else
if
(
printLastOrder_paySuccessResp
.
channel
==
3
)
{
payChannel
=
"支付宝"
;
}
var
printer
=
require
(
"../../utils/printer.js"
);
var
cmds
=
[
printer
.
setAlign
(
printer
.
ALIGN_CENTER
),
printer
.
printText
(
getApp
().
globalData
.
localAccountInfo
.
storeName
),
printer
.
setAlign
(
printer
.
ALIGN_LEFT
),
printer
.
printDivide
(
"-"
),
printer
.
printText
(
"门店号:"
+
printLastOrder_paySuccessResp
.
storeId
),
printer
.
printText
(
"收银员账号:"
+
printLastOrder_paySuccessResp
.
operatorId
),
printer
.
printText
(
"订单号:"
+
printLastOrder_paySuccessResp
.
tradeNo
),
printer
.
printNowDate
(),
printer
.
printDivide
(
"-"
),
printer
.
printText
(
"活动商品"
),
printer
.
printText
(
"商品名称 "
+
" 编码 "
+
" 数量"
),
];
for
(
var
i
=
0
;
i
<
printLastOrder_goodsList
.
length
;
i
++
)
{
//循环取出商品数据
cmds
.
push
(
printer
.
setAlign
(
printer
.
ALIGN_LEFT
));
cmds
.
push
(
printer
.
printText
(
printLastOrder_goodsList
[
i
].
name
));
cmds
.
push
(
printer
.
printTwoText
(
printLastOrder_goodsList
[
i
].
barcode
,
printLastOrder_goodsList
[
i
].
quantity
+
""
));
}
cmds
.
push
(
printer
.
setAlign
(
printer
.
ALIGN_LEFT
));
cmds
.
push
(
printer
.
printDivide
(
"-"
));
cmds
.
push
(
printer
.
printText
(
"应收金额:"
+
printLastOrder_orderPriceYuan
));
cmds
.
push
(
printer
.
printText
(
payChannel
+
":"
+
printLastOrder_payPriceYuan
));
for
(
var
i
=
0
;
i
<
4
;
i
++
)
{
cmds
.
push
(
printer
.
feedPaper
());
}
printer
.
print
({
isCheckStatus
:
getApp
().
globalData
.
containerVersionCode
>
20
,
cmds
:
cmds
,
callback
:
(
res
)
=>
{
//发送给后屏,告知打印结果
my
.
ix
.
sendBuddyMessage
({
// 填入目标小程序的 AppID
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
{
action
:
ACTION_PRINT_LAST_ORDER
,
data
:
res
},
success
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
},
fail
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
}
});
}
});
},
//计算件数
caculateTotalCountFromGoodsList
(
goodsList
)
{
if
(
goodsList
==
null
||
goodsList
.
length
==
0
)
{
return
0
;
}
var
totalCount
=
0
;
for
(
var
i
=
0
;
i
<
goodsList
.
length
;
i
++
)
{
totalCount
=
totalCount
+
goodsList
[
i
].
quantity
;
}
return
totalCount
;
},
//外接扫码枪事件
//外接扫码枪事件
onKeyPress
(
r
)
{
onKeyPress
(
r
)
{
console
.
log
(
"scan onKeyPress==>"
+
r
);
console
.
log
(
"scan onKeyPress==>"
+
r
);
...
@@ -136,7 +246,7 @@ Page({
...
@@ -136,7 +246,7 @@ Page({
if
(
this
.
data
.
dialogShowType
==
"refund"
)
{
if
(
this
.
data
.
dialogShowType
==
"refund"
)
{
//退款
//退款
this
.
refund
(
r
);
this
.
refund
(
r
);
}
else
if
(
this
.
data
.
dialogShowType
==
"coupon"
)
{
}
else
if
(
this
.
data
.
dialogShowType
==
"coupon"
)
{
// 兑换券
// 兑换券
this
.
verifyCoupon
(
r
);
this
.
verifyCoupon
(
r
);
}
}
...
@@ -212,7 +322,7 @@ Page({
...
@@ -212,7 +322,7 @@ Page({
this
.
refund
(
r
);
this
.
refund
(
r
);
}
}
},
},
//退款
//退款
refund
(
barcode
)
{
refund
(
barcode
)
{
this
.
setData
({
scanDialogDisplay
:
2
})
this
.
setData
({
scanDialogDisplay
:
2
})
...
...
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