@@ -54,28 +54,36 @@ Page({ | |||||
let that = this; | let that = this; | ||||
wx.scanCode({ | wx.scanCode({ | ||||
success: (res) => { | 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({ | wx.showToast({ | ||||
title: "未识别到商户二维码", | title: "未识别到商户二维码", | ||||
icon: "none", | icon: "none", | ||||
@@ -84,7 +92,11 @@ Page({ | |||||
} | } | ||||
}, | }, | ||||
fail: (res) => { | fail: (res) => { | ||||
console.log(res); | |||||
wx.showToast({ | |||||
title: "未识别到商户二维码", | |||||
icon: "none", | |||||
mask: false | |||||
}) | |||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
@@ -51,8 +51,8 @@ Page({ | |||||
onLoad: function (options) { | onLoad: function (options) { | ||||
let that = this; | let that = this; | ||||
let value = JSON.stringify({ END: "C", TYPE: "couponorder", ID: options.quancode}) | 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({ | that.setData({ | ||||
code: options.quancode, | code: options.quancode, | ||||
title: options.title, | title: options.title, | ||||
@@ -15,9 +15,9 @@ | |||||
<image wx:if="{{couponorderstatus==2}}" src="{{wm02Url}}" mode='widthFix'></image> | <image wx:if="{{couponorderstatus==2}}" src="{{wm02Url}}" mode='widthFix'></image> | ||||
<image wx:if="{{couponorderstatus==3}}" src="{{wm03Url}}" mode='widthFix'></image> | <image wx:if="{{couponorderstatus==3}}" src="{{wm03Url}}" mode='widthFix'></image> | ||||
<view class="panel" wx:if="{{couponorderstatus==0}}"> | <view class="panel" wx:if="{{couponorderstatus==0}}"> | ||||
<view class="barcode"> | |||||
<!-- <view class="barcode"> | |||||
<canvas canvas-id="barcode" /> | <canvas canvas-id="barcode" /> | ||||
</view> | |||||
</view> --> | |||||
<view class="qrcode"> | <view class="qrcode"> | ||||
<canvas canvas-id="qrcode" /> | <canvas canvas-id="qrcode" /> | ||||
</view> | </view> | ||||
@@ -40,7 +40,7 @@ page { | |||||
width:600rpx; | width:600rpx; | ||||
display:block; | display:block; | ||||
border-radius:10rpx; | border-radius:10rpx; | ||||
margin:38rpx auto 0; | |||||
margin:0 auto; | |||||
padding:0; | padding:0; | ||||
z-index:10000000000; | z-index:10000000000; | ||||
@@ -114,11 +114,37 @@ function timecha(endTime,startTime) { | |||||
var second = runTime; | var second = runTime; | ||||
return (month+"月"+day+"天"+hour+"小时"+minute+"分钟") | 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 = { | module.exports = { | ||||
formatTime: formatTime, | formatTime: formatTime, | ||||
barcode: barc, | barcode: barc, | ||||
qrcode: qrc, | qrcode: qrc, | ||||
isJSON: isJSON, | |||||
fmtDate: fmtDate, | fmtDate: fmtDate, | ||||
timechuo:timechuo, | timechuo:timechuo, | ||||
timecha:timecha | timecha:timecha | ||||