Commit da16d384 authored by gaodapeng's avatar gaodapeng

fix bugs

parent 7debfeaa
...@@ -10,5 +10,5 @@ export const API_CREATE_ORDER = "order/create"; ...@@ -10,5 +10,5 @@ export const API_CREATE_ORDER = "order/create";
export const API_PAY = "pay/micropay"; export const API_PAY = "pay/micropay";
//查询支付结果 //查询支付结果
export const API_QUERY = "order/query"; export const API_QUERY = "order/query";
//退款接口
export const API_REFUND = "order/refund"; export const API_REFUND = "order/refund";
\ No newline at end of file
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_GO_SCAN, ACTION_GO_HOME } from '../../const/actioncmd'
import { ACTION_ON_PAY_SUCCESS } from '../../const/actioncmd' import { ACTION_ON_PAY_SUCCESS } from '../../const/actioncmd'
import { ACTION_ON_PAY_FAILED } from '../../const/actioncmd' import { ACTION_ON_PAY_FAILED } from '../../const/actioncmd'
Page({ Page({
data: { data: {
goodsNum:0, goodsNum: 0,
payPrice:0.00, payPrice: 0.00,
totalPrice:0.00, totalPrice: 0.00,
couponPrice:0.00, couponPrice: 0.00,
qrPayShow:false, qrPayShow: false,
list:[], list: [],
orderNo:"", orderNo: "",
isCashierClosed:false, isCashierClosed: false,
isPaying: false, isPaying: false,
}, },
onLoad(options) { onLoad(options) {
...@@ -21,7 +21,7 @@ Page({ ...@@ -21,7 +21,7 @@ Page({
var totalPrice = options.totalPrice var totalPrice = options.totalPrice
var totalDisc = options.totalDisc var totalDisc = options.totalDisc
this.setData({ this.setData({
list:options.goods, list: options.goods,
}); });
if (totalQuantity != null) { if (totalQuantity != null) {
...@@ -46,7 +46,7 @@ Page({ ...@@ -46,7 +46,7 @@ Page({
success: function (res) { success: function (res) {
console.log("商品信息 ===》 " + JSON.stringify(res)); console.log("商品信息 ===》 " + JSON.stringify(res));
context.setData({ context.setData({
list:res.data list: res.data
}) })
}, },
fail: function (res) { fail: function (res) {
...@@ -59,15 +59,18 @@ Page({ ...@@ -59,15 +59,18 @@ Page({
}, },
onShow(){ onShow() {
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_GO_SCAN){//返回扫码页 if (res.action == ACTION_GO_SCAN) {//返回扫码页
//增加跳转回去的内容 //增加跳转回去的内容
my.navigateBack(); my.navigateBack();
} else { } else if (res.action == ACTION_GO_HOME) {
//未知指令 //去首页
my.reLaunch({
url: "/pages/home/home",
});
} }
} }
}); });
...@@ -83,19 +86,19 @@ Page({ ...@@ -83,19 +86,19 @@ Page({
* @todo 支付结果的获取 * @todo 支付结果的获取
* @todo 跳转数据的保存 * @todo 跳转数据的保存
*/ */
startPay(){ startPay() {
//开始loading //开始loading
my.showLoading({}); my.showLoading({});
//获取order //获取order
var payAmount = payUtils.yuan2Fen(this.data.payPrice); var payAmount = payUtils.yuan2Fen(this.data.payPrice);
payUtils.getOrder(/*payAmount*/1,this.data.list, function(res){ payUtils.getOrder(/*payAmount*/1, this.data.list, function (res) {
if(res != null){ if (res != null) {
console.log("callback调用,res=" + JSON.stringify(res)); console.log("callback调用,res=" + JSON.stringify(res));
if(res.resultCode ==1){ if (res.resultCode == 1) {
this.setData({ this.setData({
orderNo:res.data orderNo: res.data
}); });
this.payWithOpenCashier(res.data); this.payWithOpenCashier(res.data);
} }
...@@ -106,8 +109,8 @@ Page({ ...@@ -106,8 +109,8 @@ Page({
/** /**
* 打开收银台,进行扫码收款 * 打开收银台,进行扫码收款
*/ */
payWithOpenCashier(){ payWithOpenCashier() {
try{ try {
console.info("收银台版本" + my.ix.getVersionSync({ console.info("收银台版本" + my.ix.getVersionSync({
packageName: 'zoloz.phone.android.alipay.com.dragonfly' packageName: 'zoloz.phone.android.alipay.com.dragonfly'
}).versionName); }).versionName);
...@@ -125,7 +128,7 @@ Page({ ...@@ -125,7 +128,7 @@ Page({
this.data.isCashierClosed = true; this.data.isCashierClosed = true;
this.doPay(this.data.orderNo, res.barCode); this.doPay(this.data.orderNo, res.barCode);
} }
},fail:(res) => { }, fail: (res) => {
my.showToast({ my.showToast({
type: 'exception', type: 'exception',
content: api.decodeErrorMessage(res.error), content: api.decodeErrorMessage(res.error),
...@@ -166,29 +169,29 @@ Page({ ...@@ -166,29 +169,29 @@ Page({
else else
console.log('RESULT: ' + res.bizType); console.log('RESULT: ' + res.bizType);
}); });
} catch(err) { } catch (err) {
console.log("收银台启动回调 异常==>" + JSON.stringify(err)); console.log("收银台启动回调 异常==>" + JSON.stringify(err));
} }
}, },
//调用收款接口 //调用收款接口
doPay(orderNo, payCode) { doPay(orderNo, payCode) {
console.log("doPay调用"); console.log("doPay调用");
this.setData({isPaying:true}); this.setData({ isPaying: true });
//使用barCode来当面付 //使用barCode来当面付
var payAmount = payUtils.yuan2Fen(this.data.payPrice); var payAmount = payUtils.yuan2Fen(this.data.payPrice);
payUtils.startPay(orderNo, payCode, /*payAmount*/1, this.data.list, function(res){ payUtils.startPay(orderNo, payCode, /*payAmount*/1, this.data.list, function (res) {
my.hideLoading(); my.hideLoading();
console.log("支付回调 ===>" + JSON.stringify(res)); console.log("支付回调 ===>" + JSON.stringify(res));
this.setData({isPaying:false}); this.setData({ isPaying: false });
if(res == null){ if (res == null) {
return; return;
} }
if(res.resultCode == 1){ if (res.resultCode == 1) {
//成功 //成功
console.log("支付回调成功,跳转 " ); console.log("支付回调成功,跳转 ");
// if(data.isCashierClosed == true){ // if(data.isCashierClosed == true){
my.ix.offCashierEventReceive(); my.ix.offCashierEventReceive();
this.saveData(this.data.list, res.data); this.saveData(this.data.list, res.data);
......
var api = require("../../utils/api.js"); var api = require("../../utils/api.js");
import { Page } from '../../utils/scan'; import { Page } from '../../utils/scan';
import { API_USE_COUPON } from '../../const/apiurl' import { API_USE_COUPON } from '../../const/apiurl'
import { API_REFUND } from '../../const/apiurl'
import { ACTION_GO_SCAN } from '../../const/actioncmd' import { ACTION_GO_SCAN } from '../../const/actioncmd'
import { ACTION_GET_ACCOUNT } from '../../const/actioncmd' import { ACTION_GET_ACCOUNT } from '../../const/actioncmd'
import { ACTION_DIRECT_PAYMENT } from '../../const/actioncmd' import { ACTION_DIRECT_PAYMENT } from '../../const/actioncmd'
...@@ -10,7 +11,6 @@ import { ACTION_REFUND } from '../../const/actioncmd' ...@@ -10,7 +11,6 @@ import { ACTION_REFUND } from '../../const/actioncmd'
import { ACTION_REFUND_FAILED } from '../../const/actioncmd' import { ACTION_REFUND_FAILED } from '../../const/actioncmd'
import { ACTION_REFUND_SUCCESS } from '../../const/actioncmd' import { ACTION_REFUND_SUCCESS } from '../../const/actioncmd'
import { ACTION_PRINT_LAST_ORDER } from '../../const/actioncmd' import { ACTION_PRINT_LAST_ORDER } from '../../const/actioncmd'
import { API_REFUND } from '../../const/apiurl'
Page({ Page({
...@@ -118,6 +118,7 @@ Page({ ...@@ -118,6 +118,7 @@ Page({
dialogResultFailureRemind: "退款失败", dialogResultFailureRemind: "退款失败",
dialogResultFailureText: "退款失败!无效的订单码", dialogResultFailureText: "退款失败!无效的订单码",
}); });
console.log("ACTION_REFUND");
} else if (res.action == ACTION_GO_HOME) { } else if (res.action == ACTION_GO_HOME) {
//home界面收到,则返回界面上 //home界面收到,则返回界面上
...@@ -315,13 +316,7 @@ Page({ ...@@ -315,13 +316,7 @@ Page({
}); });
}, },
//增加扫码内容,以及退款等操作的内容
onKeyPress(r) {
//只有在弹窗出现时才扫码
if (this.data.scanDialogDisplay > 0) {
this.refund(r);
}
},
//退款 //退款
refund(barcode) { refund(barcode) {
...@@ -402,4 +397,5 @@ Page({ ...@@ -402,4 +397,5 @@ Page({
}); });
var api = require("../../utils/api.js"); var api = require("../../utils/api.js");
import { Page } from '../../utils/scan'; import { Page } from '../../utils/scan';
import {API_SCAN} from '../../const/apiurl' import { API_SCAN } from '../../const/apiurl'
import {API_USE_COUPON} from '../../const/apiurl' import { API_USE_COUPON } from '../../const/apiurl'
import { ACTION_GOODS } from '../../const/actioncmd' import { ACTION_GOODS } from '../../const/actioncmd'
import { ACTION_REQUEST_GOOD_INFO } from '../../const/actioncmd' import { ACTION_REQUEST_GOOD_INFO } from '../../const/actioncmd'
import { ACTION_GO_BALANCE } from '../../const/actioncmd' import { ACTION_GO_BALANCE } from '../../const/actioncmd'
...@@ -13,14 +13,14 @@ Page({ ...@@ -13,14 +13,14 @@ Page({
//单位是元 //单位是元
totalPrice: 0.00, totalPrice: 0.00,
totalQuantity: 0, totalQuantity: 0,
totalDisc:0.00, totalDisc: 0.00,
memberPhone:'', memberPhone: '',
memberPoint:0 memberPoint: 0
}, },
onLoad: function (options) { onLoad: function (options) {
var barcode = options.barcode var barcode = options.barcode
if(barcode != null){ if (barcode != null) {
console.log("首页传递过来的商品条码是 " + barcode); console.log("首页传递过来的商品条码是 " + barcode);
this.getGoodInfoByBarcode(barcode) this.getGoodInfoByBarcode(barcode)
} }
...@@ -45,24 +45,10 @@ Page({ ...@@ -45,24 +45,10 @@ Page({
} else if (res.action == ACTION_GO_BALANCE) { } else if (res.action == ACTION_GO_BALANCE) {
//去结算页面 //去结算页面
context.goBalance(); context.goBalance();
my.ix.sendBuddyMessage({ } else if (res.action == ACTION_REQUEST_GOOD_INFO) {
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){
//去结算页面 //去结算页面
context.getGoodInfoByBarcode(res.data); context.getGoodInfoByBarcode(res.data);
}else if(res.action == ACTION_GO_HOME){ } else if (res.action == ACTION_GO_HOME) {
//去首页 //去首页
my.reLaunch({ my.reLaunch({
url: "/pages/home/home", url: "/pages/home/home",
...@@ -140,9 +126,9 @@ Page({ ...@@ -140,9 +126,9 @@ Page({
//价格 分转元 //价格 分转元
goodinfo.quantity = 1; goodinfo.quantity = 1;
goodinfo.price = goodinfo.price/100 goodinfo.price = goodinfo.price / 100
goodinfo.salePrice = goodinfo.salePrice/100 goodinfo.salePrice = goodinfo.salePrice / 100
goodinfo.discnt = goodinfo.discnt/100 goodinfo.discnt = goodinfo.discnt / 100
//总数量 //总数量
let totalQuantityTemp = 0 let totalQuantityTemp = 0
...@@ -155,27 +141,27 @@ Page({ ...@@ -155,27 +141,27 @@ Page({
let goodstemp = [] let goodstemp = []
let goodtemp let goodtemp
lastgoods.forEach(function (item, index, array) { lastgoods.forEach(function (item, index, array) {
if(item.barcode == goodinfo.barcode){ if (item.barcode == goodinfo.barcode) {
let quantitytemp = item.quantity let quantitytemp = item.quantity
item.quantity = quantitytemp+1 item.quantity = quantitytemp + 1
isHasSame = true isHasSame = true
goodtemp = item goodtemp = item
}else{ } else {
totalQuantityTemp = totalQuantityTemp + item.quantity totalQuantityTemp = totalQuantityTemp + item.quantity
totalPriceTemp = totalPriceTemp + item.price*item.quantity totalPriceTemp = totalPriceTemp + item.price * item.quantity
goodstemp.push(item) goodstemp.push(item)
} }
}) })
if(isHasSame){ if (isHasSame) {
totalQuantityTemp = totalQuantityTemp + goodtemp.quantity totalQuantityTemp = totalQuantityTemp + goodtemp.quantity
totalPriceTemp = totalPriceTemp + goodtemp.price*goodtemp.quantity totalPriceTemp = totalPriceTemp + goodtemp.price * goodtemp.quantity
let nowgoods = [] let nowgoods = []
nowgoods.push(goodtemp); nowgoods.push(goodtemp);
var newgoods = nowgoods.concat(goodstemp) var newgoods = nowgoods.concat(goodstemp)
this.setData({ goods: newgoods }) this.setData({ goods: newgoods })
}else{ } else {
totalQuantityTemp = totalQuantityTemp + 1 totalQuantityTemp = totalQuantityTemp + 1
totalPriceTemp = totalPriceTemp + goodinfo.price totalPriceTemp = totalPriceTemp + goodinfo.price
let nowgoods = [] let nowgoods = []
...@@ -185,7 +171,8 @@ Page({ ...@@ -185,7 +171,8 @@ Page({
} }
//汇总 //汇总
this.setData({ totalQuantity: totalQuantityTemp, this.setData({
totalQuantity: totalQuantityTemp,
totalPrice: totalPriceTemp, totalPrice: totalPriceTemp,
}) })
...@@ -197,18 +184,18 @@ Page({ ...@@ -197,18 +184,18 @@ Page({
sendGoodInfoToBack() { sendGoodInfoToBack() {
let context = this; let context = this;
var commonRequest = { var commonRequest = {
action:ACTION_GOODS, action: ACTION_GOODS,
data:this.data data: this.data
}; };
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.sendGoodInfoToBack(); context.sendGoodInfoToBack();
} }
......
This diff is collapsed.
...@@ -9,16 +9,16 @@ export default class scan { ...@@ -9,16 +9,16 @@ export default class scan {
if (!page._keyEventListener) { if (!page._keyEventListener) {
my.ix.onKeyEventChange(page._keyEventListener = (r) => { my.ix.onKeyEventChange(page._keyEventListener = (r) => {
let cur = getCurrentPages().slice(-1)[0]; let cur = getCurrentPages().slice(-1)[0];
if (cur && cur.onKeyPress){ if (cur && cur.onKeyPress) {
if (isScaning == false) { if (isScaning == false) {
isScaning = true isScaning = true
code = (r.keyCode - 7)+'' code = (r.keyCode - 7) + ''
setTimeout(() => { setTimeout(() => {
cur.onKeyPress.call(cur, code); cur.onKeyPress.call(cur, code);
isScaning = false isScaning = false
}, 500); }, 700);
}else{ } else {
//特殊处理 keycode需要减7 //特殊处理 keycode需要减7
code = code + (r.keyCode - 7) code = code + (r.keyCode - 7)
} }
......
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