Commit 28abb413 authored by gaodapeng's avatar gaodapeng

对首页的按钮加了loading和互斥逻辑

parent d79d95af
...@@ -162,7 +162,6 @@ Page({ ...@@ -162,7 +162,6 @@ Page({
onLoad(query) { onLoad(query) {
console.info(a);
// 页面加载 // 页面加载
console.info(`Page onLoad with query: ${JSON.stringify(query)}`); console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
}, },
...@@ -507,6 +506,9 @@ Page({ ...@@ -507,6 +506,9 @@ Page({
/**首页相关 */ /**首页相关 */
/**立即收款 */ /**立即收款 */
onHomeCashierImmediatelyClicked: throttle(2000, function () { onHomeCashierImmediatelyClicked: throttle(2000, function () {
if (this.showLoading == true) {
return
}
this.setData({ scene: 3, flowType: FLOW_DIRECT_PAYMENT }) this.setData({ scene: 3, flowType: FLOW_DIRECT_PAYMENT })
}), }),
...@@ -515,6 +517,10 @@ Page({ ...@@ -515,6 +517,10 @@ Page({
* 兑换 * 兑换
*/ */
onHomeExchangeClicked: throttle(2000, function () { onHomeExchangeClicked: throttle(2000, function () {
if (this.showLoading == true) {
return
}
this.setData({ convertCouponState: 1 }) this.setData({ convertCouponState: 1 })
this.sendConvertCouponToFront(1) this.sendConvertCouponToFront(1)
}), }),
...@@ -524,6 +530,10 @@ Page({ ...@@ -524,6 +530,10 @@ Page({
*/ */
onHomePosterClicked: throttle(2000, function () { onHomePosterClicked: throttle(2000, function () {
//发送指令至前屏,获取当前正在显示的广告页面 //发送指令至前屏,获取当前正在显示的广告页面
if (this.showLoading == true) {
return
}
this.showLoading();
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
data: { data: {
...@@ -531,9 +541,11 @@ Page({ ...@@ -531,9 +541,11 @@ Page({
data: null data: null
}, },
success: (res) => { success: (res) => {
this.hideLoading()
console.log("sendBuddyMessage success:" + JSON.stringify(res)); console.log("sendBuddyMessage success:" + JSON.stringify(res));
}, },
fail: (res) => { fail: (res) => {
this.hideLoading()
console.log("sendBuddyMessage fail:" + JSON.stringify(res)); console.log("sendBuddyMessage fail:" + JSON.stringify(res));
}, },
}); });
...@@ -543,6 +555,9 @@ Page({ ...@@ -543,6 +555,9 @@ Page({
* 退款 * 退款
*/ */
onHomeRefundClicked: throttle(2000, function () { onHomeRefundClicked: throttle(2000, function () {
if(this.showLoading){
return
}
this.setData({ this.setData({
flowType: FLOW_REFUND, flowType: FLOW_REFUND,
scene: 4 scene: 4
...@@ -557,6 +572,9 @@ Page({ ...@@ -557,6 +572,9 @@ Page({
if (this.data.printEnabled != true) { if (this.data.printEnabled != true) {
return; return;
} }
if(this.showLoading){
return
}
let context = this; let context = this;
//发送指令至前屏 //发送指令至前屏
//通知前屏重新打印 //通知前屏重新打印
...@@ -568,11 +586,13 @@ Page({ ...@@ -568,11 +586,13 @@ Page({
data: null data: null
}, },
success: (res) => { success: (res) => {
context.hideLoading()
console.info(`onHomePrintLastOrderClicked sendBuddyMessage success: ${JSON.stringify(res)}`); console.info(`onHomePrintLastOrderClicked sendBuddyMessage success: ${JSON.stringify(res)}`);
//跳转至打印上一单页面 //跳转至打印上一单页面
context.goPage('printlastorder'); context.goPage('printlastorder');
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
context.showToast("发送指令失败"); context.showToast("发送指令失败");
} }
...@@ -583,6 +603,10 @@ Page({ ...@@ -583,6 +603,10 @@ Page({
* 核验 * 核验
*/ */
onHomeVerifyClicked: throttle(2000, function () { onHomeVerifyClicked: throttle(2000, function () {
if(this.showLoading){
return
}
this.showLoading()
this.setData({ this.setData({
flowType: FLOW_VERIFY, flowType: FLOW_VERIFY,
}) })
...@@ -593,6 +617,7 @@ Page({ ...@@ -593,6 +617,7 @@ Page({
waitOperateCancelText: "关闭", waitOperateCancelText: "关闭",
waitOperateHideLeft: true, waitOperateHideLeft: true,
}) })
let context = this
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID // 填入目标小程序的 AppID
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
...@@ -601,9 +626,11 @@ Page({ ...@@ -601,9 +626,11 @@ Page({
data: null data: null
}, },
success: (res) => { success: (res) => {
context.hideLoading()
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
} }
}); });
...@@ -613,6 +640,10 @@ Page({ ...@@ -613,6 +640,10 @@ Page({
* 提货 * 提货
*/ */
onHomePickUpGoodsClicked: throttle(2000, function () { onHomePickUpGoodsClicked: throttle(2000, function () {
if(this.showLoading){
return
}
this.showLoading()
let context = this; let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
...@@ -621,10 +652,12 @@ Page({ ...@@ -621,10 +652,12 @@ Page({
data: 1 data: 1
}, },
success: (sres) => { success: (sres) => {
context.hideLoading()
context.setData({ pickGoodsState: 1 }) context.setData({ pickGoodsState: 1 })
console.log("提货通知前屏 成功 ===》" + JSON.stringify(sres)); console.log("提货通知前屏 成功 ===》" + JSON.stringify(sres));
}, },
fail: (fres) => { fail: (fres) => {
context.hideLoading()
console.log("提货通知前屏 失败 ===》 " + JSON.stringify(fres)); console.log("提货通知前屏 失败 ===》 " + JSON.stringify(fres));
} }
}) })
...@@ -632,6 +665,10 @@ Page({ ...@@ -632,6 +665,10 @@ Page({
/**日结 */ /**日结 */
onHomeDayCheckClicked: throttle(2000, function () { onHomeDayCheckClicked: throttle(2000, function () {
if(this.showLoading){
return
}
this.showLoading()
//发送打印日结订单到前屏 //发送打印日结订单到前屏
let context = this; let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
...@@ -642,11 +679,13 @@ Page({ ...@@ -642,11 +679,13 @@ Page({
data: null data: null
}, },
success: (res) => { success: (res) => {
context.hideLoading()
context.showToast('已发送日结打印请求...'); context.showToast('已发送日结打印请求...');
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
context.showToast('发送失败'); context.showToast('发送失败');
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
} }
...@@ -737,6 +776,10 @@ Page({ ...@@ -737,6 +776,10 @@ Page({
//跳转到收银页面 //跳转到收银页面
sendGoToCollections: throttle(2000, function () { sendGoToCollections: throttle(2000, function () {
if (this.showLoading == true) {
return
}
this.showLoading();
//首先清除数据 //首先清除数据
this.setData({ this.setData({
totalQuantity: 0, totalQuantity: 0,
...@@ -760,6 +803,7 @@ Page({ ...@@ -760,6 +803,7 @@ Page({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
data: commonRequest, data: commonRequest,
success: (res) => { success: (res) => {
context.hideLoading()
context.setData({ context.setData({
flowType: FLOW_COLLECTIONS flowType: FLOW_COLLECTIONS
}) })
...@@ -767,6 +811,7 @@ Page({ ...@@ -767,6 +811,7 @@ Page({
console.log("发送收银事件到前屏小程序 成功 ===》" + JSON.stringify(res)); console.log("发送收银事件到前屏小程序 成功 ===》" + JSON.stringify(res));
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
context.setData({ context.setData({
flowType: FLOW_IDLE flowType: FLOW_IDLE
}) })
...@@ -785,6 +830,7 @@ Page({ ...@@ -785,6 +830,7 @@ Page({
action: ACTION_DIRECT_PAYMENT, action: ACTION_DIRECT_PAYMENT,
data: payment data: payment
}; };
this.showLoading()
let context = this; let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
...@@ -792,6 +838,7 @@ Page({ ...@@ -792,6 +838,7 @@ Page({
success: (res) => { success: (res) => {
console.log("发送直接收款事件到前屏小程序 成功 ===》" + JSON.stringify(res)); console.log("发送直接收款事件到前屏小程序 成功 ===》" + JSON.stringify(res));
//直接收款 //直接收款
context.hideLoading()
context.clearGood(); context.clearGood();
if (payment != null) { if (payment != null) {
context.setData({ context.setData({
...@@ -807,6 +854,7 @@ Page({ ...@@ -807,6 +854,7 @@ Page({
context.goPage('waitoperate'); context.goPage('waitoperate');
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
console.log("发送收款事件到前屏小程序 失败 ===》 " + JSON.stringify(res)); console.log("发送收款事件到前屏小程序 失败 ===》 " + JSON.stringify(res));
context.showToast("操作失败"); context.showToast("操作失败");
}, },
...@@ -853,7 +901,6 @@ Page({ ...@@ -853,7 +901,6 @@ Page({
//把手输条码发生到前屏 //把手输条码发生到前屏
sendGoodsInfoToFront(barcode) { sendGoodsInfoToFront(barcode) {
let context = this; let context = this;
this.showLoading();
var commonRequest = { var commonRequest = {
action: ACTION_REQUEST_GOOD_INFO, action: ACTION_REQUEST_GOOD_INFO,
data: barcode data: barcode
...@@ -1137,6 +1184,7 @@ Page({ ...@@ -1137,6 +1184,7 @@ Page({
//发生兑换券到前屏 //发生兑换券到前屏
sendConvertCouponToFront(res) { sendConvertCouponToFront(res) {
let context = this; let context = this;
context.showLoading()
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
data: { data: {
...@@ -1144,9 +1192,11 @@ Page({ ...@@ -1144,9 +1192,11 @@ Page({
data: res data: res
}, },
success: (sres) => { success: (sres) => {
context.hideLoading()
console.log("兑换券通知前屏 成功 ===》" + JSON.stringify(sres)); console.log("兑换券通知前屏 成功 ===》" + JSON.stringify(sres));
}, },
fail: (fres) => { fail: (fres) => {
context.hideLoading()
console.log("兑换券通知前屏 失败 ===》 " + JSON.stringify(fres)); console.log("兑换券通知前屏 失败 ===》 " + JSON.stringify(fres));
} }
}) })
...@@ -1186,6 +1236,8 @@ Page({ ...@@ -1186,6 +1236,8 @@ Page({
object.refundAmount = amount; object.refundAmount = amount;
} }
this.showLoading()
this.goPage('waitoperate'); this.goPage('waitoperate');
this.setData({ this.setData({
waitOperateMoneyRemind: "应退款:", waitOperateMoneyRemind: "应退款:",
...@@ -1207,10 +1259,12 @@ Page({ ...@@ -1207,10 +1259,12 @@ Page({
data: refundAmount data: refundAmount
}, },
success: (res) => { success: (res) => {
context.hideLoading()
//成功发送则 //成功发送则
console.log("发送退款金额到前屏小程序成功 ===》" + JSON.stringify(res)); console.log("发送退款金额到前屏小程序成功 ===》" + JSON.stringify(res));
}, },
fail: (res) => { fail: (res) => {
context.hideLoading()
context.showToast("操作失败"); context.showToast("操作失败");
} }
}) })
......
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