From b1411a3dcaaf8cbfbaf12fe935a3c48e0041bca0 Mon Sep 17 00:00:00 2001 From: meo <958484406@qq.com> Date: Sat, 1 Sep 2018 16:46:49 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=A0=B8=E9=94=80=E7=8A=B6=E6=80=81][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:=E6=A0=B8=E9=94=80=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=E7=9A=84=E7=8A=B6=E6=80=81=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.js | 6 +- pages/couponorder/detail/index.js | 44 ++++++----- pages/order/detail/index.js | 67 ++++++++++------- pages/order/index/index.wxml | 3 +- pages/orderquanma/index.js | 121 ++++++++++++------------------ 5 files changed, 122 insertions(+), 119 deletions(-) diff --git a/config/config.js b/config/config.js index 5e5a995..c44c050 100755 --- a/config/config.js +++ b/config/config.js @@ -123,7 +123,11 @@ var config = { * 和login页面 * 页面的图标 */ - marketicon:'/mall/getAppIcon' + marketicon:'/mall/getAppIcon', + /** + * 检查核销的状态 + */ + getStatus:"/couponOrder/getStatus" }, weapp: { diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index 45fa3ed..153f578 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -9,7 +9,13 @@ Page({ data: {}, createDate: "", expiredTime: "", - updateDate:'' + updateDate: "", + //存储计时器 + setInter: "" + }, + onUnload: function() { + let that = this; + clearInterval(that.data.setInter); }, onLoad: function(options) { console.log(options); @@ -23,32 +29,34 @@ Page({ options.quancode != null && (options.quancode != "" && options.quancode) != undefined ) { - Http.get({ - url: config.api.couponOrderDetail, - data: { - couponOrderId: options.quancode - } - }).then(res => { - console.log(res); - that.setData({ - data: res.data + that.data.setInter = setInterval(function(){ + 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) + }); }); - that.setData({ - expiredTime: util.fmtDate(that.data.data.expiredTime), - updateDate: util.fmtDate(that.data.data.updateDate), - createDate: util.fmtDate(that.data.data.createDate) - }); - }); + }, 200); } util.barcode("barcode", options.quancode, 510, 100); - util.qrcode("qrcode", options.quancode,350, 350); + util.qrcode("qrcode", options.quancode, 350, 350); }, phone: function() { let that = this; console.log(that.data); if (that.data.data.merchantLinkPhone) { wx.makePhoneCall({ - phoneNumber: that.data.data.merchantLinkPhone + phoneNumber: that.data.data.merchantLinkPhone }); } } diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index d172b34..5316b27 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -10,7 +10,10 @@ Page({ showModalStatus: false, flag: 0, order: null, - orderId: null + orderId: null, + //存储计时器 + setInter: "", + mystatus:'' }, /** @@ -19,36 +22,51 @@ Page({ */ powerDrawer: function(e) { + let that = this; // couponOrderStatus // 0 未使用 // 1 已使用 // 2 已过期 // 3 已经退款 console.log(e); - - wx.navigateTo({ - url: `/pages/orderquanma/index?quancode=${ - e.currentTarget.dataset.quancode - }&title=${e.currentTarget.dataset.title}&subtitle=${ - e.currentTarget.dataset.subtitle - }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${ - e.currentTarget.dataset.couponorderstatus - }` - }); - console.log(e.currentTarget.dataset.quancode); - console.log(e.currentTarget.dataset.couponorderstatus); + if (that.data.mystatus == null || that.data.mystatus == undefined) { + wx.navigateTo({ + url: `/pages/orderquanma/index?quancode=${ + e.currentTarget.dataset.quancode + }&title=${e.currentTarget.dataset.title}&subtitle=${ + e.currentTarget.dataset.subtitle + }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${ + e.currentTarget.dataset.couponorderstatus + }` + }); + console.log(e.currentTarget.dataset.couponorderstatus); + } else { + wx.navigateTo({ + url: `/pages/orderquanma/index?quancode=${ + e.currentTarget.dataset.quancode + }&title=${e.currentTarget.dataset.title}&subtitle=${ + e.currentTarget.dataset.subtitle + }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${ + that.data.mystatus + }` + }); + } }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let that = this; - console.log(options.orderId); - console.log(options.flag + "我是付款的标识"); - this.setData({ orderId: options.orderId }); + wx.showLoading({ + title: "加载中" + }); + setTimeout(function() { + wx.hideLoading(); + }, 500); + // that.data.setInter = setInterval(function() { Http.get({ url: config.api.orderDetail, @@ -64,12 +82,13 @@ Page({ //createDate 创建时间 var createDate = util.fmtDate(res.data.createDate); - console.log(createDate); that.setData({ createDate: createDate }); }); + + // }, 100); }, /** @@ -193,23 +212,15 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function() {}, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function(options) {}, + onShow: function() { + console.log(this.data.mystatus) + }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() {}, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() {}, - /** * 页面相关事件处理函数--监听用户下拉动作 */ diff --git a/pages/order/index/index.wxml b/pages/order/index/index.wxml index a7495f2..313090e 100644 --- a/pages/order/index/index.wxml +++ b/pages/order/index/index.wxml @@ -12,7 +12,8 @@ {{item.title}} 待付款 - 已付款 + 免费领取 + 已付款 已过期 {{item.subTitle}} diff --git a/pages/orderquanma/index.js b/pages/orderquanma/index.js index bd233f7..3bce14b 100644 --- a/pages/orderquanma/index.js +++ b/pages/orderquanma/index.js @@ -1,78 +1,57 @@ let util = require("../../utils/util"); +let Http = require("../../utils/HttpBasics"); +let config = require("../../config/config.js"); Page({ - - /** - * 页面的初始数据 - */ data: { - code:'' + code: "", + //存储计时器 + setInter: "" }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - console.log(options.quancode); - console.log(options); - console.log(options.subtitle); - + onLoad: function(options) { + let that = this; util.barcode("barcode", options.quancode, 500, 100); util.qrcode("qrcode", options.quancode, 350, 350); - this.setData({ - code:options.quancode, - title:options.title, - subtitle:options.subtitle, - remark:options.remark, - couponorderstatus:options.couponorderstatus - }) - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + that.setData({ + code: options.quancode, + title: options.title, + subtitle: options.subtitle, + remark: options.remark, + couponorderstatus: options.couponorderstatus + }); + that.data.setInter = setInterval(function() { + if (that.data.couponorderstatus == 0) { + Http.get({ + url: config.api.getStatus, + data: { + couponOrderId: options.quancode + } + }).then(res => { + console.log(res); + 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 + }); + }); + } + }, 2000); + /** + * couponorderstatus + * 0 没有核销 + * 1 已经核销成功 + */ + }, + onUnload: function() { + let that = this; + clearInterval(that.data.setInter); } -}) \ No newline at end of file +});