diff --git a/assets/images/QRCODE.png b/assets/images/QRCODE.png new file mode 100644 index 0000000..fd29c53 Binary files /dev/null and b/assets/images/QRCODE.png differ diff --git a/pages/cardorder/cardUse/cardUse.js b/pages/cardorder/cardUse/cardUse.js index 2813982..e18e5e0 100644 --- a/pages/cardorder/cardUse/cardUse.js +++ b/pages/cardorder/cardUse/cardUse.js @@ -4,14 +4,22 @@ const config = require("../../../config/config.js"); const Http = require("../../../utils/HttpBasics"); let app = getApp(); const imgurl = require("../../../utils/imgurl"); +const QR = require("../../../utils/memberqrcode.js"); Page({ - + // https://formall.oss-accelerate.aliyuncs.com/cimg/wm01.jpg /** * 页面的初始数据 */ data: { navigationBarHeight, - data: {} + topLine: imgurl.topLine.url, + btomLine: imgurl.btomLine.url, + data: {}, + showIdFalg: false, + code: '', + codeS: '', + tempFilePath: '', + isShowQR: true }, cardDetail(couponOrderId) { @@ -19,7 +27,7 @@ Page({ Http.get({ url: config.api.cardDetail, data: { - couponOrderId: couponOrderId + couponOrderId: couponOrderId, } }) .then(res => { @@ -29,20 +37,28 @@ Page({ that.setData({ showPage: true, data: res.data, - supportTransfer: res.data.supportTransfer + supportTransfer: res.data.supportTransfer, + code: res.data.id, + codeS: res.data.id.slice(0, 4) + `******` + res.data.id.slice(14), }) + + if (res.data.wxCardInfo.status) { + this.setData({ + isShowQR: false + }) + } else { + that.getQR(res.data.id, res.data.tenantId) + } + /** * 若可转赠获取用户头像信息 */ - if (res.data.supportTransfer) { - that.getUserInfo() - } - if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length <= 4) { + if (that.data.merchantVoList && that.data.merchantVoList.length <= 4) { that.setData({ - height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx', + height: that.data.merchantVoList.length * 140 + 'rpx', showMore: false }) - } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4) { + } else if (that.data.merchantVoList && that.data.cardDetail.length > 4) { that.setData({ height: 4 * 140 + 'rpx' }) @@ -54,6 +70,124 @@ Page({ }) }, + showId() { + let this_ = this; + if (!this_.data.showIdFalg) { + wx.showModal({ + content: '是否查看完整券码', + success(res) { + if (res.confirm) { + this_.setData({ + showIdFalg: true + }) + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + } else { + this.setData({ + showIdFalg: false + }) + } + }, + + // 获取动态二维码 + getQR(cardId, cardTenantId) { + Http.get({ + url: `/couponOrder/cardDynamicId?cardId=${cardId}&cardTenantId=${cardTenantId}`, + }).then(res => { + console.log(res.data); + this.setData({ + expiredSeconds: res.data.expiredSeconds + }) + let url = JSON.stringify({ + END: "C", + TYPE: "card", + ID: res.data.dynamicRq, + TENANTID: res.data.cardTenantId + }) + this.createQrCode(url, "qrcode", 350, 350); + }).catch(err => { + wx.showToast({ + title: err.message, + icon: none + }) + }) + }, + + goGive() { + wx.navigateTo({ + url: `/pages/ConsumeDetail/ConsumeDetail?cardId=${this.data.data.id}`, + }) + }, + + // 扫一扫去支付 + gotoPay: function () { + app.globalData.previewFlag = true + let that = this; + console.log(that.data.data.id, that.data.data.remainingAmount / 100); + wx.scanCode({ + success: (res) => { + 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, + } + }) + .then(res => { + if (res.code == 200) { + let merChantDetail = JSON.stringify(res.data); + if (merChantDetail && that.data.data.id && that.data.data.remainingamount / 100) { + merChantDetail = encodeURIComponent(merChantDetail) + wx.navigateTo({ + url: `/pages/scanPay/scanPay?merChant=${merChantDetail}&cardid=${that.data.data.id}&remainingAmount=${that.data.data.remainingamount}`, + }) + } + } + }) + .catch(err => { + console.log(err) + }) + } else { + wx.showToast({ + title: "未识别到商户二维码", + icon: "none", + mask: false + }) + } + } else { + wx.showToast({ + title: "未识别到商户二维码", + icon: "none", + mask: false + }) + } + }, + fail: (res) => { + wx.showToast({ + title: "未识别到商户二维码", + icon: "none", + mask: false + }) + } + }) + }, + + createQrCode: function (url, canvasId, cavW, cavH) { + console.log('createQrCode!'); + //调用插件中的draw方法,绘制二维码图片 + let that = this; + QR.api.draw(url, canvasId, cavW, cavH, function (res) { + that.setData({ + tempFilePath: res + }) + }); + }, + /** * 生命周期函数--监听页面加载 */ diff --git a/pages/cardorder/cardUse/cardUse.wxml b/pages/cardorder/cardUse/cardUse.wxml index f3f2f38..2f90b27 100644 --- a/pages/cardorder/cardUse/cardUse.wxml +++ b/pages/cardorder/cardUse/cardUse.wxml @@ -10,9 +10,9 @@ {{data.title}} {{data.subTitle}} - 余额:{{data.couponPrice/100}} - 余额:{{data.salePrice/100}} - 余额:{{data.couponPrice/100}} + 余额:{{data.remainingAmount/100}} + 余额:{{data.salePrice/100}} + 余额:{{data.remainingAmount/100}} 过期不退款 @@ -20,9 +20,9 @@ - + 有效期至: - {{expiredTime}} + {{data.expiredTime}} 有效期: @@ -39,14 +39,21 @@ - + - + + - + + + + + + + 点一点刷新二维码 @@ -87,7 +94,7 @@ {{more}} --> - + - - + 手机号2018.05.25 + --> + + + + - - - - + + + + + + \ No newline at end of file diff --git a/pages/cardorder/cardUse/cardUse.wxss b/pages/cardorder/cardUse/cardUse.wxss index aadeb22..afe2384 100644 --- a/pages/cardorder/cardUse/cardUse.wxss +++ b/pages/cardorder/cardUse/cardUse.wxss @@ -368,4 +368,14 @@ page { height: 40rpx; float: left; margin: 20rpx 0 0 20rpx !important; -} */ \ No newline at end of file +} */ +.bottomBtn { + padding: 50rpx; +} + +.bottomBtn .btn { + color: #fff; + font-weight: 600; + background-color: #ff7e2d; + margin-bottom: 20rpx; +} \ No newline at end of file diff --git a/pages/cardorder/index/index.wxml b/pages/cardorder/index/index.wxml index 91b7009..1a8d65c 100644 --- a/pages/cardorder/index/index.wxml +++ b/pages/cardorder/index/index.wxml @@ -35,8 +35,11 @@ {{item.title}} + + + 再次购买 已过期 余额已用完 diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index 2a93e36..96012dc 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -147,6 +147,7 @@ Page({ }); }) }, + showId() { let this_ = this; if (!this_.data.showIdFalg) { @@ -167,7 +168,6 @@ Page({ showIdFalg: false }) } - }, onLoad: function (options) {