diff --git a/pages/cardorder/index/index.js b/pages/cardorder/index/index.js
index de6b3df..255759d 100644
--- a/pages/cardorder/index/index.js
+++ b/pages/cardorder/index/index.js
@@ -54,28 +54,36 @@ Page({
let that = this;
wx.scanCode({
success: (res) => {
- let value = JSON.parse(res.result);
- if (value.END == 'B' && value.TYPE == 'merchant' && value.ID){
- Http.get({
- url: config.api.findByCode,
- data: {
- merchantCode:value.ID,
- }
- })
- .then(res => {
- if (res.code == 200) {
- let merChantDetail = JSON.stringify(res.data);
- if (merChantDetail && e.currentTarget.dataset.cardid && e.currentTarget.dataset.remainingamount) {
- wx.navigateTo({
- url: `/pages/scanPay/scanPay?merChant=${merChantDetail}&cardid=${e.currentTarget.dataset.cardid}&remainingAmount=${e.currentTarget.dataset.remainingamount}`,
- })
+ if (util.isJSON(res.result)) {
+ let value = JSON.parse(res.result);
+ if (value.END == 'B' && value.TYPE == 'merchant' && value.ID) {
+ Http.get({
+ url: config.api.findByCode,
+ data: {
+ merchantCode: value.ID,
}
- }
- })
- .catch(err => {
- console.log(err)
+ })
+ .then(res => {
+ if (res.code == 200) {
+ let merChantDetail = JSON.stringify(res.data);
+ if (merChantDetail && e.currentTarget.dataset.cardid && e.currentTarget.dataset.remainingamount) {
+ wx.navigateTo({
+ url: `/pages/scanPay/scanPay?merChant=${merChantDetail}&cardid=${e.currentTarget.dataset.cardid}&remainingAmount=${e.currentTarget.dataset.remainingamount}`,
+ })
+ }
+ }
+ })
+ .catch(err => {
+ console.log(err)
+ })
+ } else {
+ wx.showToast({
+ title: "未识别到商户二维码",
+ icon: "none",
+ mask: false
})
- }else{
+ }
+ } else {
wx.showToast({
title: "未识别到商户二维码",
icon: "none",
@@ -84,7 +92,11 @@ Page({
}
},
fail: (res) => {
- console.log(res);
+ wx.showToast({
+ title: "未识别到商户二维码",
+ icon: "none",
+ mask: false
+ })
}
})
},
diff --git a/pages/orderquanma/index.js b/pages/orderquanma/index.js
index a453146..72a8ba1 100644
--- a/pages/orderquanma/index.js
+++ b/pages/orderquanma/index.js
@@ -51,8 +51,8 @@ Page({
onLoad: function (options) {
let that = this;
let value = JSON.stringify({ END: "C", TYPE: "couponorder", ID: options.quancode})
- util.barcode("barcode", value.ID, 500, 100);
- util.qrcode("qrcode", options.quancode, 350, 350);
+ // util.barcode("barcode", value, 500, 100);
+ util.qrcode("qrcode", value, 350, 350);
that.setData({
code: options.quancode,
title: options.title,
diff --git a/pages/orderquanma/index.wxml b/pages/orderquanma/index.wxml
index 55cff2b..e977290 100644
--- a/pages/orderquanma/index.wxml
+++ b/pages/orderquanma/index.wxml
@@ -15,9 +15,9 @@
-
+
diff --git a/pages/orderquanma/index.wxss b/pages/orderquanma/index.wxss
index 5c3d007..e0b71d4 100644
--- a/pages/orderquanma/index.wxss
+++ b/pages/orderquanma/index.wxss
@@ -40,7 +40,7 @@ page {
width:600rpx;
display:block;
border-radius:10rpx;
-margin:38rpx auto 0;
+margin:0 auto;
padding:0;
z-index:10000000000;
diff --git a/utils/util.js b/utils/util.js
index 742b373..9e1caf4 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -114,11 +114,37 @@ function timecha(endTime,startTime) {
var second = runTime;
return (month+"月"+day+"天"+hour+"小时"+minute+"分钟")
}
-
+function isJSON(str) {
+ if (typeof str == 'string') {
+ console.log("string")
+ try {
+ var obj = JSON.parse(str);
+ if (typeof obj == 'object' && obj) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (e) {
+ console.log(e);
+ wx.showToast({
+ title: '请扫描正确的二维码',
+ icon: 'none',
+ duration: 1300
+ })
+ }
+ } else {
+ wx.showToast({
+ title: '请扫描正确的二维码',
+ icon: 'none',
+ duration: 1300
+ })
+ }
+}
module.exports = {
formatTime: formatTime,
barcode: barc,
qrcode: qrc,
+ isJSON: isJSON,
fmtDate: fmtDate,
timechuo:timechuo,
timecha:timecha