Commit d404843d authored by gaodapeng's avatar gaodapeng

增加系统设置事件的处理

parent 672554e8
......@@ -31,9 +31,6 @@ export const ACTION_ON_PAY_FAILED = "ACTION_ON_PAY_FAILED";
//去首页
export const ACTION_GO_HOME = "ACTION_GO_HOME";
//获取账户信息
export const ACTION_GET_ACCOUNT = "ACTION_GET_ACCOUNT";
//直接收款
export const ACTION_DIRECT_PAYMENT = "ACTION_DIRECT_PAYMENT";
......@@ -63,3 +60,6 @@ export const ACTION_GET_CUR_AD = "ACTION_GET_CUR_AD";
//发送选中的广告url给前屏
export const ACTION_SEND_SEL_AD = "ACTION_SEND_SEL_AD";
//系统设置
export const ACTION_SYSTEM_SETTING = "ACTION_SYSTEM_SETTING";
\ No newline at end of file
......@@ -6,9 +6,10 @@ import { API_REFUND } from '../../const/apiurl'
//ACTION
import {
ACTION_GO_SCAN, ACTION_GET_CUR_AD, ACTION_SEND_SEL_AD,
ACTION_GET_ACCOUNT, ACTION_DIRECT_PAYMENT, ACTION_CONVERT_COUPON,
ACTION_DIRECT_PAYMENT, ACTION_CONVERT_COUPON,
ACTION_GO_HOME, ACTION_REFUND, ACTION_REFUND_FAILED,
ACTION_REFUND_SUCCESS, ACTION_PRINT_LAST_ORDER
ACTION_REFUND_SUCCESS, ACTION_PRINT_LAST_ORDER,
ACTION_SYSTEM_SETTING,
} from '../../const/actioncmd'
......@@ -23,7 +24,8 @@ Page({
dialogResultSuccessText: "恭喜您!兑换成功",
dialogResultFailureRemind: "兑换码未识别",
dialogResultFailureText: "兑换失败,请稍后重试!",
adUrl: "/images/img_ad1.png"
adUrl: "/images/img_ad1.png",
toSetting: false,
},
onLoad() {
......@@ -36,6 +38,13 @@ Page({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_GO_SCAN) {
if (res.data.printEnabled != null) {
my.setStorageSync({
key: 'printEnabled',
data: { enabled: res.data.printEnabled }
})
}
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
......@@ -54,26 +63,6 @@ Page({
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
} else if (res.action == ACTION_GET_ACCOUNT) {
var message = {
data: getApp().globalData.localAccountInfo,
action: ACTION_GET_ACCOUNT
}
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_GET_ACCOUNT,
data: message
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
} else if (res.action == ACTION_DIRECT_PAYMENT) {
//直接收款
my.ix.sendBuddyMessage({
......@@ -176,9 +165,38 @@ Page({
context.setData({
adUrl: selectAdUrl
});
} else if (res.action == ACTION_SYSTEM_SETTING) {
console.log("启动系统设置");
my.ix.startApp({
appName: 'settings',
});
context.setData({
toSetting: true,
})
}
}
});
if (context.data.toSetting == true) {
context.setData({
toSetting: false,
});
//让后屏回到首页上
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_GO_HOME,
data: null
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
}
},
/**返回当前选中广告 */
......
......@@ -4,6 +4,7 @@ Page({
name: "",
password: "",
sn: "",
containerVersion: "",
//按钮是否可点击
loginDisabled: true,
//错误提示是否可见
......@@ -28,6 +29,13 @@ Page({
getApp().globalData.sn = serialno.value;
}
var r = my.ix.getVersionSync();
if (r) {
this.setData({
containerVersion: r.versionName//r.versionCode
})
}
//获取下本地登录数据
var localLoginInfo = my.getStorageSync({
key: 'localLoginInfo', // 缓存数据的key
......@@ -182,21 +190,25 @@ Page({
},
// 登录完成通知后屏
sendLoginOkToBackScreen(){
sendLoginOkToBackScreen() {
let context = this;
var commonRequest = {
action:ACTION_LOGIN_OK,
data:getApp().globalData.localAccountInfo.storeName
action: ACTION_LOGIN_OK,
data: {
account: getApp().globalData.localAccountInfo,
sn: context.data.sn,
containerVersion: context.data.containerVersion
}
};
console.log("登录成功,发送数据:" + commonRequest);
my.ix.sendBuddyMessage({
target: getApp().globalData.backScreenAppId,
data: commonRequest,
success: (res) => {
console.log("登录成功通知后屏 成功 ===》"+JSON.stringify(res));
console.log("登录成功通知后屏 成功 ===》" + JSON.stringify(res));
},
fail: (res) => {
console.log("登录成功通知后屏 失败 ===》 "+JSON.stringify(res));
console.log("登录成功通知后屏 失败 ===》 " + JSON.stringify(res));
//发送失败重试
context.sendLoginOkToBackScreen();
}
......
......@@ -119,14 +119,20 @@ Page({
},
onShow() {
var printEnabledLocal = my.getStorageSync({ key: 'printEnabled' }).data.enabled;
if (printEnabledLocal == null) {
printEnabledLocal = true;
}
//开启后屏监听
my.ix.onBuddyMessage({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_REPRINT) {
//重新打印
if (printEnabledLocal == true) {
this.print();
} else if(res.action == ACTION_GO_HOME) {
}
} else if (res.action == ACTION_GO_HOME) {
//去首页
my.reLaunch({
url: "/pages/home/home",
......@@ -134,7 +140,9 @@ Page({
}
}
});
if (printEnabledLocal == true) {
this.print();
}
},
onHide() {
......
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