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
7974e4e2
Commit
7974e4e2
authored
Feb 14, 2020
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加交互逻辑
parent
d33fa4e8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
20 deletions
+76
-20
app.js
app.js
+12
-11
actioncmd.js
const/actioncmd.js
+7
-1
home.js
pages/home/home.js
+1
-3
scan.axml
pages/scan/scan.axml
+0
-5
scan.js
pages/scan/scan.js
+56
-0
No files found.
app.js
View file @
7974e4e2
...
@@ -9,6 +9,7 @@ App({
...
@@ -9,6 +9,7 @@ App({
RELEASE_URL
:
"https://cashier.miyahub.com/"
,
RELEASE_URL
:
"https://cashier.miyahub.com/"
,
BASE_URL
:
null
,
BASE_URL
:
null
,
appId
:
"2021001107603212"
,
appId
:
"2021001107603212"
,
backScreenAppId
:
"2021001107617164"
,
//小程序容器版本
//小程序容器版本
containerVersionCode
:
null
,
containerVersionCode
:
null
,
localAccountInfo
:
null
,
localAccountInfo
:
null
,
...
@@ -30,17 +31,17 @@ App({
...
@@ -30,17 +31,17 @@ App({
}
}
});
});
//添加后屏小程序
//添加后屏小程序
//
my.ix.addExtensionApp({
my
.
ix
.
addExtensionApp
({
// appId: "2021001107617164"
,
appId
:
this
.
globalData
.
backScreenAppId
,
//
// 填入后屏小程序的 AppID
// 填入后屏小程序的 AppID
//
type: "screen",
type
:
"screen"
,
//
success: (res) => {
success
:
(
res
)
=>
{
//
console.log("addExtensionApp success:", res)
console
.
log
(
"addExtensionApp success:"
,
res
)
//
},
},
//
fail: (res) => {
fail
:
(
res
)
=>
{
//
console.log("addExtensionApp fail:", res)
console
.
log
(
"addExtensionApp fail:"
,
res
)
//
},
},
//
})
})
},
},
onShow
(
options
)
{
onShow
(
options
)
{
// 从后台被 scheme 重新打开
// 从后台被 scheme 重新打开
...
...
const/actioncmd.js
View file @
7974e4e2
...
@@ -3,3 +3,9 @@ export const ACTION_PRINT_RESULT = "ACTION_PRINT_RESULT";
...
@@ -3,3 +3,9 @@ export const ACTION_PRINT_RESULT = "ACTION_PRINT_RESULT";
//发送重打印指令
//发送重打印指令
export
const
ACTION_REPRINT
=
"ACTION_REPRINT"
;
export
const
ACTION_REPRINT
=
"ACTION_REPRINT"
;
//商品信息
export
const
ACTION_GOODS
=
"ACTION_GOODS"
;
//去结算页面
export
const
ACTION_GOODS
=
"ACTION_GO_BALANCE"
;
pages/home/home.js
View file @
7974e4e2
...
@@ -18,9 +18,7 @@ Page({
...
@@ -18,9 +18,7 @@ Page({
},
},
homeTap
()
{
homeTap
()
{
my
.
redirectTo
({
//FIXME 这里是跳转到新的界面
my
.
navigateTo
({
url
:
"/pages/scan/scan"
url
:
"/pages/scan/scan"
});
});
},
},
...
...
pages/scan/scan.axml
View file @
7974e4e2
...
@@ -33,11 +33,6 @@
...
@@ -33,11 +33,6 @@
<view class="scan-price-quantity-propmt">
<view class="scan-price-quantity-propmt">
(共{{totalQuantity}}件)
(共{{totalQuantity}}件)
</view>
</view>
<button style="margin-left:120rpx;padding-left:20rpx;padding-right:20rpx;" size="default" type="primary" onTap="goBalance">
去支付
</button>
</view>
</view>
<!-- <view class="scan-bottom-item">
<!-- <view class="scan-bottom-item">
<view class="scan-price-total-propmt">
<view class="scan-price-total-propmt">
...
...
pages/scan/scan.js
View file @
7974e4e2
...
@@ -2,6 +2,7 @@ var api = require("../../utils/api.js");
...
@@ -2,6 +2,7 @@ var api = require("../../utils/api.js");
import
{
Page
}
from
'../../utils/scan'
;
import
{
Page
}
from
'../../utils/scan'
;
import
{
API_SCAN
}
from
'../../const/apiurl'
import
{
API_SCAN
}
from
'../../const/apiurl'
import
{
API_USE_COUPON
}
from
'../../const/apiurl'
import
{
API_USE_COUPON
}
from
'../../const/apiurl'
import
{
ACTION_GOODS
}
from
'../../const/actioncmd'
Page
({
Page
({
...
@@ -23,6 +24,42 @@ Page({
...
@@ -23,6 +24,42 @@ Page({
}
}
},
},
onShow
()
{
//开启后屏监听
let
context
=
this
;
my
.
ix
.
onBuddyMessage
({
success
:
(
res
)
=>
{
console
.
info
(
`onBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
if
(
res
.
action
==
ACTION_GOODS
)
{
//商品信息同步
let
viewGoodsInfo
=
res
.
data
.
viewGoodsInfo
if
(
viewGoodsInfo
.
goods
==
null
||
viewGoodsInfo
.
goods
.
length
==
0
){
my
.
redirectTo
({
url
:
"/pages/home/home"
});
}
else
{
//空列表就回到首页
context
.
setData
({
goods
:
viewGoodsInfo
.
goods
,
totalPrice
:
viewGoodsInfo
.
totalPrice
,
totalQuantity
:
viewGoodsInfo
.
totalQuantity
,
totalDisc
:
viewGoodsInfo
.
totalDisc
,
})
}
}
else
if
(
res
.
action
==
ACTION_GO_BALANCE
){
//去结算页面
context
.
goBalance
();
}
}
});
},
onHide
()
{
//关闭后屏监听
my
.
ix
.
offBuddyMessage
();
},
//外接扫码枪事件
//外接扫码枪事件
onKeyPress
(
r
)
{
onKeyPress
(
r
)
{
console
.
log
(
"scan onKeyPress==>"
+
r
);
console
.
log
(
"scan onKeyPress==>"
+
r
);
...
@@ -134,6 +171,25 @@ Page({
...
@@ -134,6 +171,25 @@ Page({
totalPrice
:
totalPriceTemp
,
totalPrice
:
totalPriceTemp
,
})
})
//同步信息到后端
this
.
sendGoodInfoToBack
();
},
//把所有的商品数据发送到后屏
sendGoodInfoToBack
()
{
let
context
=
this
;
my
.
ix
.
sendBuddyMessage
({
target
:
getApp
().
globalData
.
backScreenAppId
,
data
:
context
.
data
,
success
:
(
res
)
=>
{
console
.
log
(
"发送商品数据到后屏小程序成功 ===》"
+
JSON
.
stringify
(
res
));
},
fail
:
(
res
)
=>
{
console
.
log
(
"发送商品数据到后屏小程序 失败 ===》 "
+
JSON
.
stringify
(
res
));
//发送失败重试
context
.
sendGoodInfoToBack
();
}
})
},
},
//跳转结算页面
//跳转结算页面
...
...
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