Commit d67d90b2 authored by pengguangpu's avatar pengguangpu

添加前后屏交互指令常量js文件;添加支付结果页的指令监听&发送;

parent 6808a2e0
{
"pages": [
"pages/landscan/landscan",
"pages/payresult/payresult",
"pages/landscan/landscan",
"pages/index/index"
],
"window": {
......
//发送打印结果
export const ACTION_PRINT_RESULT = "ACTION_PRINT_RESULT";
//发送重打印指令
export const ACTION_REPRINT = "ACTION_REPRINT";
\ No newline at end of file
......@@ -37,7 +37,7 @@
</block>
<block a:else>
<view hidden="{{isPrinting}}">
<button type="ghost" style="height:40rpx;margin:0 auto;border-radius:20rpx;border-color:#FF7F19;color:#FF7F19;width:166rpx;" hover-class="loginButtonHover" onTap="">重新打印</button>
<button type="ghost" style="height:40rpx;margin:0 auto;border-radius:20rpx;border-color:#FF7F19;color:#FF7F19;width:166rpx;" hover-class="loginButtonHover" onTap="onReprint">重新打印</button>
</view>
</block>
</view>
......
import { ACTION_PRINT_RESULT } from '../../const/actioncmd'
import { ACTION_REPRINT } from '../../const/actioncmd'
Page({
data: {
payFailedReason:"xxxxxxxxxxx",
isPaySuccess:true,
payPriceYuan:"--.--",
printResult:"正在打印小票...",
isPrinting:false,
isPrintSuccess:true,
payFailedReason: "xxxxxxxxxxx",
isPaySuccess: true,
payPriceYuan: "--.--",
printResult: "正在打印小票...",
isPrinting: false,
isPrintSuccess: true,
},
onLoad() {},
onLoad() { },
onShow() {
//开启后屏监听
my.ix.onBuddyMessage({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_PRINT_RESULT) {
//获取到打印结果
var printResult = res.data;
} else {
//未知指令
}
}
});
},
onReprint() {
//通知前屏重新打印
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: "****************",
data: {
action: ACTION_REPRINT,
data: null
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
},
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