Commit c4f9beb1 authored by pengguangpu's avatar pengguangpu

编写优惠券布局;添加打印逻辑;添加前后屏交互逻辑;

parents 5ce79ab9 5ec20fe2
.tea .tea
.tea/*
.DS_Store .DS_Store
/.tea /.tea
.tea/layout.json .tea/layout.json
...@@ -8,7 +8,7 @@ App({ ...@@ -8,7 +8,7 @@ App({
TEST_URL: "https://cashier.test.miyahub.net/", TEST_URL: "https://cashier.test.miyahub.net/",
RELEASE_URL: "https://cashier.miyahub.com/", RELEASE_URL: "https://cashier.miyahub.com/",
BASE_URL: null, BASE_URL: null,
appId:"1542075029346", appId: "1542075029346",
//小程序容器版本 //小程序容器版本
containerVersionCode: null containerVersionCode: null
}, },
...@@ -19,6 +19,25 @@ App({ ...@@ -19,6 +19,25 @@ App({
console.info('App onLaunch'); console.info('App onLaunch');
//初始化baseUrl //初始化baseUrl
this.globalData.BASE_URL = this.globalData.TEST_URL; this.globalData.BASE_URL = this.globalData.TEST_URL;
//获取容器版本信息
my.ix.getVersion({
success: (r) => {
console.log("getVersion success==>" + JSON.stringify(r));
getApp().globalData.containerVersionCode = r.versionCode;
}
});
//添加后屏小程序
my.ix.addExtensionApp({
appId: "****************",
// 填入后屏小程序的 AppID
type: "screen",
success: (res) => {
console.log("addExtensionApp success:", res)
},
fail: (res) => {
console.log("addExtensionApp fail:", res)
},
})
}, },
onShow(options) { onShow(options) {
// 从后台被 scheme 重新打开 // 从后台被 scheme 重新打开
......
...@@ -78,13 +78,12 @@ page { ...@@ -78,13 +78,12 @@ page {
/* border: 2px solid red; */ /* border: 2px solid red; */
} }
.voucher{ .voucher {
display: flex; display: absolute;
position: fixed; position: fixed;
flex-direction: column;
width: 662rpx; width: 662rpx;
align-content: center; align-content: center;
height: 100%; height: 100%;
margin-bottom: 0rpx; margin-top: 43rpx;
/* border: 2px solid red; */ /* border: 2px solid red; */
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<text style="font-weight:bold;float:right;">-¥{{couponPriceYuan}}</text> <text style="font-weight:bold;float:right;">-¥{{couponPriceYuan}}</text>
</view> </view>
<view class="payPrice"> <view class="payPrice">
<text style="float:left;" decode=true>共计 {{}} 件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;实付:</text> <text style="float:left;" decode=true>共计 {{totalCount}} 件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;实付:</text>
<text style="font-weight:bold;float:right;color:#F72911;">-¥{{payPriceYuan}}</text> <text style="font-weight:bold;float:right;color:#F72911;">-¥{{payPriceYuan}}</text>
</view> </view>
</view> </view>
...@@ -28,11 +28,30 @@ ...@@ -28,11 +28,30 @@
<i-spin></i-spin> <i-spin></i-spin>
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;color:#000000;font-weight:bold;"> <view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;color:#000000;font-weight:bold;">
<view style="display: absolute;margin:0 auto;align-content: center;align-items: center;text-align:center;line-height:186rpx;"> <view style="display: absolute;margin:0 auto;align-content: center;align-items: center;text-align:center;line-height:186rpx;">
<text>{{}}</text> <text>{{printerStatus}}</text>
</view> </view>
</view> </view>
</view> </view>
<view class="voucher"> <view class="voucher" hidden="{{!isShowCoupon}}">
<image mode="aspectFit" style="width:100%;height:229rpx;" src="/images/bg_coupon.png"/>
<view style="display: absolute;position: absolute;left:0rpx;top:0rpx;width:209rpx;height:229rpx;">
<view style="position: absolute;color:#ffffff;left:10rpx;top:103rpx;font-size:43rpx;">
<text >¥</text>
</view>
<view style="position: absolute;color:#ffffff;text-align:center;left:68rpx;font-weight:bold;top:80rpx;font-size:66rpx;">
<text>{{couponPriceYuan}}</text>
</view>
<view style="position: absolute;color:#ffffff;text-align:center;left:23rpx;top:145rpx;font-size:23rpx;">
<text>{{couponHint}}</text>
</view>
</view>
<view style="position: absolute;left:209rpx;top:0rpx;width:453rpx;height:229rpx;">
<view style="position: absolute;color:#ffffff;left:32rpx;top:32rpx;font-size:34rpx;width:352rpx;">
<text >{{couponName}}</text>
</view>
<view style="position: absolute;color:#ffffff;left:32rpx;bottom:32rpx;font-size:34rpx;width:352rpx;">
<text >{{couponDateDuration}}</text>
</view>
</view>
</view> </view>
</view> </view>
\ No newline at end of file
Page({ Page({
data: { data: {
orderPriceYuan:"--.--", orderPriceYuan: "--.--",
couponPriceYuan:"--.--", couponPriceYuan: "--.--",
payPriceYuan:"--.--" payPriceYuan: "--.--",
totalCount: "0",
printerStatus: "小票打印中",
couponPriceYuan: "--.--",
couponHint: "xxxxxx",
couponName: "xxxxxxxx",
couponDateDuration: "xxxx.xx.xx-xxxx.xx.xx",
isShowCoupon: true
}, },
onLoad() {}, onLoad(query) {
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
},
print() {
//发起打印
var printer = require("../../utils/printer.js");
var printCallbackTemp = this.printCallback.bind(this);
var cmds = [
printer.setAlign(printer.ALIGN_CENTER),
printer.printText("storeName"),
printer.printDivide("-"),
printer.setAlign(printer.ALIGN_LEFT),
printer.printText("门店号:"),
printer.printText("收银员账号:"),
printer.printText("订单号:"),
printer.printNowDate(),
printer.printDivide("-"),
printer.printText("活动商品"),
printer.printText("活动名称 " + " 编码 " + " 数量"),
];
for (var i = 0; i < 10; i++) {
//循环取出商品数据
// cmds.push();
}
cmds.push(printer.printDivide("-"));
cmds.push(printer.printText("应收金额:"));
cmds.push(printer.printText("支付方式实付:"));
for (var i = 0; i < 4; i++) {
cmds.push(printer.feedPaper());
}
printer.print({
isCheckStatus: getApp().globalData.containerVersionCode > 20,
cmds: cmds,
callback: printCallbackTemp
});
},
printCallback(res) {
//通知后屏打印结果
my.ix.sendBuddyMessage({
target: "****************",
// 填入目标小程序的 AppID
data: res,
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
},
onShow() {
//开启后屏监听
my.ix.onBuddyMessage({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if ("") {
//重新打印
} else {
//未知指令
}
}
});
},
onHide() {
//关闭后屏监听
my.ix.offBuddyMessage();
}
}); });
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