Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-back
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-back
Commits
1b2381ea
Commit
1b2381ea
authored
Feb 14, 2020
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后屏互动通信
parent
d67d90b2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
149 additions
and
80 deletions
+149
-80
app.js
app.js
+2
-0
app.json
app.json
+1
-1
actioncmd.js
const/actioncmd.js
+7
-1
landscan.axml
pages/landscan/landscan.axml
+3
-3
landscan.js
pages/landscan/landscan.js
+136
-75
No files found.
app.js
View file @
1b2381ea
...
...
@@ -3,6 +3,8 @@ App({
globalData
:
{
TEST_URL
:
"https://cashier.test.miyahub.net/"
,
RELEASE_URL
:
"https://cashier.miyahub.com/"
,
appId
:
"2021001107617164"
,
frontScreenAppId
:
"2021001107603212"
,
},
onLaunch
(
options
)
{
...
...
app.json
View file @
1b2381ea
{
"pages"
:
[
"pages/payresult/payresult"
,
"pages/landscan/landscan"
,
"pages/payresult/payresult"
,
"pages/index/index"
],
"window"
:
{
...
...
const/actioncmd.js
View file @
1b2381ea
...
...
@@ -2,4 +2,10 @@
export
const
ACTION_PRINT_RESULT
=
"ACTION_PRINT_RESULT"
;
//发送重打印指令
export
const
ACTION_REPRINT
=
"ACTION_REPRINT"
;
\ No newline at end of file
export
const
ACTION_REPRINT
=
"ACTION_REPRINT"
;
//商品信息
export
const
ACTION_GOODS
=
"ACTION_GOODS"
;
//去结算页面
export
const
ACTION_GO_BALANCE
=
"ACTION_GO_BALANCE"
;
pages/landscan/landscan.axml
View file @
1b2381ea
...
...
@@ -44,9 +44,9 @@
<image class="operat-icon" mode="aspectFit" src="/images/clear_shop_list.png" catchTap="clearGood"/>
</view>
<view class="operating-bottom">
<text class="total-num">共{{total
Num
}}件商品,合计金额</text>
<text class="pay-price">¥{{
pay
Price}}</text>
<button class="go-pay" size="default" type="primary">收款</button>
<text class="total-num">共{{total
Quantity
}}件商品,合计金额</text>
<text class="pay-price">¥{{
total
Price}}</text>
<button class="go-pay" size="default" type="primary"
onTap="goPay"
>收款</button>
</view>
</view>
</view>
...
...
pages/landscan/landscan.js
View file @
1b2381ea
var
api
=
require
(
"../../utils/api.js"
);
import
{
API_SCAN
}
from
'../../const/apiurl'
import
{
ACTION_GOODS
}
from
'../../const/actioncmd'
import
{
ACTION_GO_BALANCE
}
from
'../../const/actioncmd'
import
{
ACTION_REQUEST_GOOD_INFO
}
from
'../../const/actioncmd'
Page
({
data
:
{
//是否正在用券
couponUseing
:
false
,
couponUseing
:
false
,
//0代表弹窗关闭 1代表手动输入条码弹窗 2代表会员 3.收款 4.退款
scene
:
0
,
//总数量
totalNum
:
0
,
//应付款
payPrice
:
"0.00"
,
totalQuantity
:
0
,
//折后价格
totalPrice
:
"0.00"
,
//折扣
totalDisc
:
"0.00"
,
goods
:
[
]
},
onLoad
()
{
},
//键盘完成
onKeyBordFinished
(
data
)
{
let
mockdata
=
'{"activityId": "5808753370","activityType": "Skus","activityName": "2020年新活动,中国加油","discnt": 100,"startTime": 1580877000000,"endTime": 1583423999000,"pic": "https://miya-ngm.oss-cn-hangzhou.aliyuncs.com/1560763177031148973127.png?Expires=1876123177&OSSAccessKeyId=LTAItcMpilplOYdV&Signature=9NTSNuDocXKQyr%2FbPlHooey3Vrg%3D","name": "test001","barcode": "09876","price": 100000,"salePrice": 100000,"hasDiscount": true}'
;
onShow
()
{
//开启后屏监听
let
context
=
this
;
my
.
ix
.
onBuddyMessage
({
success
:
(
res
)
=>
{
console
.
info
(
`onBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
if
(
res
.
action
==
ACTION_GOODS
)
{
//商品信息同步
my
.
hideLoading
();
let
viewGoodsInfo
=
res
.
data
.
viewGoodsInfo
if
(
viewGoodsInfo
.
goods
!=
null
&&
viewGoodsInfo
.
goods
.
length
>
0
)
{
context
.
setData
({
goods
:
viewGoodsInfo
.
goods
,
totalPrice
:
viewGoodsInfo
.
totalPrice
,
totalQuantity
:
viewGoodsInfo
.
totalQuantity
,
totalDisc
:
viewGoodsInfo
.
totalDisc
,
})
}
}
}
});
},
onHide
()
{
//关闭后屏监听
my
.
ix
.
offBuddyMessage
();
},
//把所有的商品数据发送到后屏
sendGoodInfoToFront
()
{
let
context
=
this
;
var
commonRequest
=
{
action
:
ACTION_GOODS
,
data
:
this
.
data
};
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
frontScreenAppId
,
data
:
commonRequest
,
success
:
(
res
)
=>
{
console
.
log
(
"发送商品数据到前屏小程序成功 ===》"
+
JSON
.
stringify
(
res
));
},
fail
:
(
res
)
=>
{
console
.
log
(
"发送商品数据到前屏小程序 失败 ===》 "
+
JSON
.
stringify
(
res
));
//发送失败重试
context
.
sendGoodInfoToFront
();
}
})
},
this
.
parseGoodInfo
(
JSON
.
parse
(
mockdata
))
//键盘完成
onKeyBordFinished
(
barcode
)
{
this
.
onKeyBordClose
();
my
.
showLoading
({});
var
commonRequest
=
{
action
:
ACTION_REQUEST_GOOD_INFO
,
data
:
barcode
};
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
frontScreenAppId
,
data
:
commonRequest
,
success
:
(
res
)
=>
{
console
.
log
(
"发送商品条码到前屏小程序成功 ===》"
+
JSON
.
stringify
(
res
));
},
fail
:
(
res
)
=>
{
console
.
log
(
"发送商品条码到前屏小程序 失败 ===》 "
+
JSON
.
stringify
(
res
));
my
.
hideLoading
();
my
.
showToast
({
type
:
'fail'
,
content
:
'发送商品条码到后屏失败'
,
duration
:
3000
,
success
:
()
=>
{
},
});
}
})
},
// 键盘关闭
...
...
@@ -37,70 +114,12 @@ Page({
//清空商品信息
clearGood
(
e
)
{
this
.
setData
({
goods
:
[]
})
},
//转化商品信息
parseGoodInfo
(
goodinfo
)
{
//价格 分转元
goodinfo
.
quantity
=
1
;
goodinfo
.
price
=
goodinfo
.
price
/
100
goodinfo
.
salePrice
=
goodinfo
.
salePrice
/
100
goodinfo
.
discnt
=
goodinfo
.
discnt
/
100
//总数量
let
totalQuantityTemp
=
0
//总价格
let
totalPriceTemp
=
0.00
//数量+1
let
isHasSame
=
false
;
let
lastgoods
=
this
.
data
.
goods
;
let
goodstemp
=
[]
let
goodtemp
lastgoods
.
forEach
(
function
(
item
,
index
,
array
)
{
if
(
item
.
barcode
==
goodinfo
.
barcode
)
{
let
quantitytemp
=
item
.
quantity
item
.
quantity
=
quantitytemp
+
1
isHasSame
=
true
goodtemp
=
item
}
else
{
totalQuantityTemp
=
totalQuantityTemp
+
item
.
quantity
totalPriceTemp
=
totalPriceTemp
+
item
.
price
*
item
.
quantity
goodstemp
.
push
(
item
)
}
})
if
(
isHasSame
)
{
totalQuantityTemp
=
totalQuantityTemp
+
goodtemp
.
quantity
totalPriceTemp
=
totalPriceTemp
+
goodtemp
.
price
*
goodtemp
.
quantity
let
nowgoods
=
[]
nowgoods
.
push
(
goodtemp
);
var
newgoods
=
nowgoods
.
concat
(
goodstemp
)
this
.
setData
({
goods
:
newgoods
})
}
else
{
totalQuantityTemp
=
totalQuantityTemp
+
1
totalPriceTemp
=
totalPriceTemp
+
goodinfo
.
price
let
nowgoods
=
[]
nowgoods
.
push
(
goodinfo
);
var
newgoods
=
nowgoods
.
concat
(
lastgoods
)
this
.
setData
({
goods
:
newgoods
})
}
//汇总
this
.
setData
({
totalNum
:
totalQuantityTemp
,
payPrice
:
totalPriceTemp
,
})
this
.
calculation
([]);
this
.
sendGoodInfoToFront
();
},
//删除商品
deleteGood
(
e
)
{
let
barcode
=
e
.
target
.
id
;
let
lastgoods
=
this
.
data
.
goods
;
let
newGoods
=
[]
...
...
@@ -110,7 +129,8 @@ Page({
}
})
this
.
setData
({
goods
:
newGoods
})
this
.
calculation
(
newGoods
);
},
//减少商品
decreaseGood
(
e
)
{
...
...
@@ -131,13 +151,12 @@ Page({
}
})
this
.
setData
({
goods
:
newGoods
})
this
.
calculation
(
newGoods
);
},
//增加商品
increaseGood
(
e
)
{
console
.
log
(
e
);
let
barcode
=
e
.
target
.
id
;
let
lastgoods
=
this
.
data
.
goods
;
let
newGoods
=
[]
...
...
@@ -151,16 +170,58 @@ Page({
}
})
this
.
setData
({
goods
:
newGoods
})
this
.
calculation
(
newGoods
);
},
//计算总价格 总数量 总优惠
calculation
(
goods
)
{
if
(
null
!=
goods
&&
goods
.
length
>
0
)
{
let
quantitytemp
=
0
;
let
pricetemp
=
0
;
goods
.
forEach
(
function
(
item
,
index
,
array
)
{
quantitytemp
=
quantitytemp
+
item
.
quantity
pricetemp
=
pricetemp
+
item
.
price
})
this
.
setData
({
totalQuantity
:
quantitytemp
,
totalPrice
:
pricetem
+
''
})
//数据同步到前屏
this
.
sendGoodInfoToFront
()
}
},
//跳转到支付结果页面
goPay
(
e
)
{
var
commonRequest
=
{
action
:
ACTION_GO_BALANCE
,
data
:
""
};
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
frontScreenAppId
,
data
:
commonRequest
,
success
:
(
res
)
=>
{
console
.
log
(
"通知前屏跳转到结算页面 成功 ===》"
+
JSON
.
stringify
(
res
));
},
fail
:
(
res
)
=>
{
console
.
log
(
"通知前屏跳转到结算页面 失败 ===》 "
+
JSON
.
stringify
(
res
));
my
.
showToast
({
type
:
'fail'
,
content
:
'结算失败'
,
duration
:
3000
,
success
:
()
=>
{
},
});
}
})
},
//用券返回
couponBack
(
e
){
this
.
setData
({
couponUseing
:
false
})
couponBack
(
e
)
{
this
.
setData
({
couponUseing
:
false
})
},
//使用券
useCoupon
(
e
){
this
.
setData
({
couponUseing
:
true
})
useCoupon
(
e
)
{
this
.
setData
({
couponUseing
:
true
})
}
...
...
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