Commit d404843d authored by gaodapeng's avatar gaodapeng

增加系统设置事件的处理

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