Commit 7974e4e2 authored by jiangjiantao's avatar jiangjiantao

增加交互逻辑

parent d33fa4e8
...@@ -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 重新打开
......
...@@ -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";
...@@ -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"
}); });
}, },
......
...@@ -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">
......
...@@ -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();
}
})
}, },
//跳转结算页面 //跳转结算页面
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment