From e82d76eca6abe6efc905fb5d73a5e98741fbe5f4 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Mon, 5 Nov 2018 18:23:54 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=94=AF=E4=BB=98=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0][=E4=BF=AE=E6=94=B9]:=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coupon/detail/index.js | 146 ++++++++++++++++----------------- pages/index/rushToBuy/index.js | 1 + pages/order/detail/index.js | 11 ++- pages/passCar/passCar.js | 10 ++- utils/util.js | 4 +- 5 files changed, 91 insertions(+), 81 deletions(-) diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index f76b7ca..7ac216f 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -6,11 +6,11 @@ const util = require("../../../utils/util"); Page({ data: { data: { - title:null + title: null }, - questions1:null, - questions2:null, - display:"none", + questions1: null, + questions2: null, + display: "none", carList: [], couponChannelId: null, couponId: null, @@ -26,11 +26,11 @@ Page({ end_time: null, clock: "已经截止", questionnaire: {}, - questionId:null + questionId: null }, - onShow:function(){ + onShow: function () { this.setData({ - display:"none", + display: "none", }) }, phone: function () { @@ -50,59 +50,59 @@ Page({ let that = this; that.setData({ questions1: e.detail, - display:"none" + display: "none" }) }, - formSubmit:function(e){ + formSubmit: function (e) { let that = this; that.setData({ questions2: e.detail, - display:"none" + display: "none" }) }, /** * gotopay */ - gotopay:function(){ + gotopay: function () { let that = this; - if (that.data.questions1 || that.data.questions2){ + if (that.data.questions1 || that.data.questions2) { that.setData({ display: "none", }) that.orderFunc(); - }else{ + } else { Http.get({ url: config.api.getQuestion, data: { couponType: JSON.stringify(that.data.data.type) } }) - .then(res => { - if (res.data == undefined) { + .then(res => { + if (res.data == undefined) { that.setData({ display: "none", }) that.orderFunc(); } - else if (res.data) { - that.setData({ - display: "block", - questionnaire: JSON.parse(res.data.content), - questionId:res.data.id + else if (res.data) { + that.setData({ + display: "block", + questionnaire: JSON.parse(res.data.content), + questionId: res.data.id + }); + } + }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false }); - } - }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + }) } }, - + countdown(end_time) { let that = this; var EndTime = end_time; @@ -110,8 +110,8 @@ Page({ var total_micro_second = EndTime - NowTime || []; // 渲染倒计时时钟 let obj = that.dateformat(total_micro_second); - - if (total_micro_second>0){ + + if (total_micro_second > 0) { that.setData({ clock: obj, day: obj.a1, @@ -119,7 +119,7 @@ Page({ min: obj.c1, sec: obj.d1, }) - }else{ + } else { that.setData({ clock: "00", day: "00", @@ -145,10 +145,10 @@ Page({ // 分钟 var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60); // 秒 - var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60): Math.floor(second % 60); - + var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60); + // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒"; - return { a1: day, b1: hr, c1: min, d1: sec} + return { a1: day, b1: hr, c1: min, d1: sec } }, onLoad(options) { let that = this; @@ -171,7 +171,7 @@ Page({ } }; Http.get(parmer).then(res => { - if (res.data.endTime){ + if (res.data.endTime) { that.countdown(res.data.endTime); //当前时间与优惠券下架时间做计算 var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss"); @@ -185,7 +185,7 @@ Page({ }); } } - + wx.hideLoading(); that.setData({ data: res.data @@ -212,8 +212,8 @@ Page({ /** * 支付订单更新 */ - payOrderUpdate: (orderId, payOrderId, status, reason,type,_this) => { - let that=this; + payOrderUpdate: (orderId, payOrderId, status, reason, type, _this) => { + let that = this; // 支付成功 Http.post({ url: config.api.payOrderUpdate, @@ -225,21 +225,25 @@ Page({ } }) .then(res => { - if(!type){ - setTimeout(() => { - wx.navigateTo({ - url: `/pages/order/detail/index?orderId=${ - orderId - }` - }); + console.log(res); + if (!type) { + setTimeout(() => { + wx.navigateTo({ + url: `/pages/order/detail/index?orderId=${ + orderId + }` + }); }, 1000) - } + } + }) + .catch(err => { + console.log(err); + if (!type) { + setTimeout(function () { + _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this); + }, 2000) + } }) - .catch(err => { - setTimeout(function(){ - _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this); - },2000) - }); }, /** * 发起支付 @@ -330,7 +334,6 @@ Page({ mask: false }); } else if (err.code == 11005) { - // 用户手机未授权 /** * 将值传到用户手机号授权的页面 * @@ -402,33 +405,30 @@ Page({ wx.switchTab({ url: '/pages/passCar/passCar' }); - }, 1600); + }, 1600); } } }, - fail: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); // 支付失败 + /** + * 支付失败,需要更新订单的状态 + */ + that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail',that); return; }, complete: res => { } }); /// End payment -------- - - ///// virtual pay - //var payOrderId = "" + res.data.out_trade_no; - //that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 - ///// end virtual pay - }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) } else { // 免费券 that.payOrderUpdate(orderId, "0", 1, '', 'fail'); @@ -482,10 +482,10 @@ Page({ if (options.from == 'button') { var eData = options.target.dataset.id; var couponId = options.target.dataset.couponid; - // shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`; shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`; } // 返回shareObj return shareObj; - } + }, + }); \ No newline at end of file diff --git a/pages/index/rushToBuy/index.js b/pages/index/rushToBuy/index.js index 785f669..e5d7926 100644 --- a/pages/index/rushToBuy/index.js +++ b/pages/index/rushToBuy/index.js @@ -55,6 +55,7 @@ Component({ }); }) .catch(err => { + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index 1d925ac..20b34d9 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -144,7 +144,7 @@ Page({ that.payOrderUpdate(that.data.orderId, payOrderId, 1,'','',that); // 支付成功 }, fail: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); + that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail',that); return; }, }); @@ -198,9 +198,12 @@ Page({ } }) .catch(err => { - setTimeout(function () { - _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this); - }, 1500) + console.log(err) + if (!type) { + setTimeout(function () { + _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this); + }, 1500) + } }); }, diff --git a/pages/passCar/passCar.js b/pages/passCar/passCar.js index d7135f3..e2e587c 100644 --- a/pages/passCar/passCar.js +++ b/pages/passCar/passCar.js @@ -199,6 +199,7 @@ Page({ url: "/pages/getuserinfo/index" }); }else{ + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -228,6 +229,7 @@ Page({ } }) .catch(err => { + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -294,6 +296,7 @@ Page({ that.initUsrCarList(); }) .catch(err => { + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -335,6 +338,7 @@ Page({ }); }) .catch(err => { + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -395,6 +399,7 @@ Page({ url: "/pages/phoneinput/phoneinput" }); }else{ + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -438,6 +443,7 @@ Page({ }); }) .catch(error => { + console.log(error) wx.showModal({ title: "提示", showCancel: false, @@ -461,6 +467,7 @@ Page({ }) }) .catch(err => { + console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', @@ -481,8 +488,9 @@ Page({ .then(res => { }) .catch(err => { + console.log(err) wx.showToast({ - title: err.errMsg, + title: err.message, icon: 'none', duration: 2000, mask: false diff --git a/utils/util.js b/utils/util.js index e947673..22eafea 100644 --- a/utils/util.js +++ b/utils/util.js @@ -92,7 +92,6 @@ function timechuo(startTime) { var minute = Math.floor(runTime / 60); var runTime = runTime % 60; var second = runTime; - console.log(month, day, hour, minute, second); return (day+"天"+hour+"小时"+minute+"分钟") } @@ -113,8 +112,7 @@ function timecha(endTime,startTime) { var minute = Math.floor(runTime / 60); var runTime = runTime % 60; var second = runTime; - console.log(month, day, hour, minute, second); - return (day+"天"+hour+"小时"+minute+"分钟") + return (month+"月"+day+"天"+hour+"小时"+minute+"分钟") } module.exports = {