Commit 93544b52 authored by gaodapeng's avatar gaodapeng

增加跳转到结算页面的内容。增加支付成功失败的状态

parent ee0f3a2e
...@@ -17,4 +17,10 @@ export const ACTION_REQUEST_GOOD_INFO = "ACTION_REQUEST_GOOD_INFO"; ...@@ -17,4 +17,10 @@ export const ACTION_REQUEST_GOOD_INFO = "ACTION_REQUEST_GOOD_INFO";
export const ACTION_GO_SCAN = "ACTION_GO_SCAN"; export const ACTION_GO_SCAN = "ACTION_GO_SCAN";
//获取店铺信息 //获取店铺信息
export const ACTION_STORE_INFO = "ACTION_STORE_INFO"; export const ACTION_STORE_INFO = "ACTION_STORE_INFO";
\ No newline at end of file
//支付成功
export const ACTION_ON_PAY_SUCCESS = "ACTION_ON_PAY_SUCCESS";
//支付失败
export const ACTION_ON_PAY_FAILED = "ACTION_ON_PAY_FAILED";
var api = require("../../utils/api.js"); var api = require("../../utils/api.js");
var payUtils = require("../../utils/payUtils.js"); var payUtils = require("../../utils/payUtils.js");
import { ACTION_GO_SCAN } from '../../const/actioncmd'
import { ACTION_ON_PAY_SUCCESS } from '../../const/actioncmd'
import { ACTION_ON_PAY_FAILED } from '../../const/actioncmd'
Page({ Page({
data: { data: {
...@@ -55,6 +58,26 @@ Page({ ...@@ -55,6 +58,26 @@ Page({
}, },
onshow(){
my.ix.onBuddyMessage({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if(res.action == ACTION_GO_SCAN){
//增加跳转回去的内容
} else {
//未知指令
}
}
});
},
onHide() {
// 页面隐藏
//关闭后屏监听
my.ix.offBuddyMessage();
},
/** /**
* @todo 支付结果的获取 * @todo 支付结果的获取
* @todo 跳转数据的保存 * @todo 跳转数据的保存
...@@ -171,6 +194,22 @@ Page({ ...@@ -171,6 +194,22 @@ Page({
my.redirectTo({ my.redirectTo({
url: '/pages/paysuccess/paysuccess', url: '/pages/paysuccess/paysuccess',
}); });
//发送支付成功到后屏
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_ON_PAY_SUCCESS,
data: res.data
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
// } // }
} else { } else {
console.log("支付回调失败,toast提示 "); console.log("支付回调失败,toast提示 ");
...@@ -180,6 +219,21 @@ Page({ ...@@ -180,6 +219,21 @@ Page({
content: res.message, content: res.message,
duration: 2000 duration: 2000
}); });
//发送支付失败到后屏
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_ON_PAY_FAILED,
data: null
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
} }
}.bind(this)); }.bind(this));
}, },
......
...@@ -49,9 +49,23 @@ Page({ ...@@ -49,9 +49,23 @@ Page({
}) })
} }
}else if(res.action == ACTION_GO_BALANCE){ } else if (res.action == ACTION_GO_BALANCE) {
//去结算页面 //去结算页面
context.goBalance(); context.goBalance();
my.ix.sendBuddyMessage({
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_GO_BALANCE,
data:null
},
success: (res) => {
console.log("发送商品数据到后屏小程序成功 ===》"+JSON.stringify(res));
},
fail: (res) => {
console.log("发送商品数据到后屏小程序 失败 ===》 "+JSON.stringify(res));
//发送失败重试
}
})
}else if(res.action == ACTION_REQUEST_GOOD_INFO){ }else if(res.action == ACTION_REQUEST_GOOD_INFO){
//去结算页面 //去结算页面
context.getGoodInfoByBarcode(res.data); context.getGoodInfoByBarcode(res.data);
......
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