diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index 153f578..0e0ad4a 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -25,11 +25,13 @@ Page({ }); //获得优惠券的详情 - if ( - options.quancode != null && - (options.quancode != "" && options.quancode) != undefined - ) { - that.data.setInter = setInterval(function(){ + that.data.setInter = setInterval(function() { + if ( + options.quancode != null && + options.quancode != "" && + options.quancode != undefined && + options.couponorderstatus == 0 + ) { Http.get({ url: config.api.couponOrderDetail, data: { @@ -46,10 +48,29 @@ Page({ createDate: util.fmtDate(that.data.data.createDate) }); }); - }, 200); - } - util.barcode("barcode", options.quancode, 510, 100); - util.qrcode("qrcode", options.quancode, 350, 350); + } + }, 2000); + + // if (options.couponorderstatus != "0") { + Http.get({ + url: config.api.couponOrderDetail, + data: { + couponOrderId: options.quancode + } + }).then(res => { + console.log(res); + that.setData({ + data: res.data + }); + that.setData({ + expiredTime: util.fmtDate(that.data.data.expiredTime), + updateDate: util.fmtDate(that.data.data.updateDate), + createDate: util.fmtDate(that.data.data.createDate) + }); + util.barcode("barcode", options.quancode, 510, 100); + util.qrcode("qrcode", options.quancode, 350, 350); + }); + // } }, phone: function() { let that = this; diff --git a/pages/couponorder/index/index.js b/pages/couponorder/index/index.js index b718208..814bf38 100644 --- a/pages/couponorder/index/index.js +++ b/pages/couponorder/index/index.js @@ -35,12 +35,11 @@ Page({ //点击跳转到券详情页面 gotouse: function(e) { - console.log(e.currentTarget.dataset.quancode); + console.log(e.currentTarget.dataset.couponorderstatus); console.log("点击跳转到券详情"); wx.navigateTo({ url: `/pages/couponorder/detail/index?quancode=${ - e.currentTarget.dataset.quancode - }` + e.currentTarget.dataset.quancode}&couponorderstatus=${e.currentTarget.dataset.couponorderstatus}` }); }, getList(key, pageNum) { diff --git a/pages/couponorder/index/index.wxml b/pages/couponorder/index/index.wxml index 340a8ec..8525e4d 100644 --- a/pages/couponorder/index/index.wxml +++ b/pages/couponorder/index/index.wxml @@ -12,7 +12,7 @@ - + - 立即使用 - 查看 + 立即使用 + 查看 diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index 5316b27..bc70beb 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -29,7 +29,7 @@ Page({ // 2 已过期 // 3 已经退款 console.log(e); - if (that.data.mystatus == null || that.data.mystatus == undefined) { + if (that.data.mystatus == "" || that.data.mystatus == undefined) { wx.navigateTo({ url: `/pages/orderquanma/index?quancode=${ e.currentTarget.dataset.quancode @@ -213,7 +213,6 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onShow: function() { - console.log(this.data.mystatus) }, /** diff --git a/pages/orderquanma/index.js b/pages/orderquanma/index.js index 3bce14b..4f70f7e 100644 --- a/pages/orderquanma/index.js +++ b/pages/orderquanma/index.js @@ -11,6 +11,8 @@ Page({ let that = this; util.barcode("barcode", options.quancode, 500, 100); util.qrcode("qrcode", options.quancode, 350, 350); + + console.log("zhuangtai"); that.setData({ code: options.quancode, title: options.title, @@ -18,6 +20,12 @@ Page({ remark: options.remark, couponorderstatus: options.couponorderstatus }); + + console.log(options.couponorderstatus); + console.log("我是状态"); + /** + * 如果没有核销 + */ that.data.setInter = setInterval(function() { if (that.data.couponorderstatus == 0) { Http.get({ @@ -30,20 +38,38 @@ Page({ that.setData({ couponorderstatus: res.data.CouponOrderStatus }); - - /** - * 动态改变上一级页面的核销状态 - */ - var pages = getCurrentPages(); - var currPage = pages[pages.length - 1]; //当前页面 - var prevPage = pages[pages.length - 2]; //上一个页面 - //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 - prevPage.setData({ - mystatus:res.data.CouponOrderStatus - }); + if (res.data.CouponOrderStatus == 1) { + /** + * 动态改变上一级页面的核销状态 + */ + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 + prevPage.setData({ + mystatus: res.data.CouponOrderStatus + }); + } }); } }, 2000); + + if (that.data.couponorderstatus == 1) { + /** + * 如果已经核销 + * 不需要循环 + */ + Http.get({ + url: config.api.getStatus, + data: { + couponOrderId: options.quancode + } + }).then(res => { + console.log(res); + that.setData({ + couponorderstatus: res.data.CouponOrderStatus + }); + }); + } /** * couponorderstatus * 0 没有核销 diff --git a/project.config.json b/project.config.json index e71147c..9232e07 100644 --- a/project.config.json +++ b/project.config.json @@ -1,5 +1,5 @@ { - "description": "项目配置文件。", + "description": "项目配置文件, "packOptions": { "ignore": [] }, @@ -11,7 +11,7 @@ "newFeature": true }, "compileType": "miniprogram", - "libVersion": "2.2.4", + "libVersion": "2.2.5", "appid": "wxb11603577a84a86d", "projectname": "%E5%AF%8C%E8%8C%82%E9%93%BE%E5%AE%A2%E6%B5%8B%E8%AF%95", "isGameTourist": false,