From 396122fb83c60edc8da176544b72c840a85b7cd9 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Thu, 1 Nov 2018 15:52:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BA=91=E7=AB=AF=E6=94=AF=E4=BB=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9][=E4=BF=AE=E6=94=B9]:=E4=BA=91=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.js | 6 +-- pages/coupon/detail/index.js | 65 ++++++++++++++++---------------- pages/order/detail/index.js | 72 ++++++++++++------------------------ project.config.json | 2 +- 4 files changed, 58 insertions(+), 87 deletions(-) diff --git a/config/config.js b/config/config.js index 245a24b..ed3d2c8 100755 --- a/config/config.js +++ b/config/config.js @@ -1,8 +1,8 @@ var config = { // url: "http://10.11.205.51:7000/C/api", // url: "https://ciformall.youlane.cn/C/api", - url:"https://c.malls.iformall.com/C/api", - // url: "http://31adc9ce.ngrok.io/C/api", + // url:"https://c.malls.iformall.com/C/api", + url: "http://81be62f2.ngrok.io/C/api", api: { /** * 接口用途:login @@ -161,7 +161,7 @@ var config = { }, weapp: { - AppId: "wx026ee7f6290aa336" + AppId: "wx649b3be73c1afe47" }, ErrorCode: { NICK_NOT_AUTH: 11004, diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 851f70b..cb21584 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -24,7 +24,6 @@ Page({ phone: function () { let that = this; - console.log(that.data); if (that.data.data.merchantLinkPhone) { wx.makePhoneCall({ phoneNumber: that.data.data.merchantLinkPhone @@ -99,7 +98,6 @@ Page({ } }; Http.get(parmer).then(res => { - console.log(res.data); if (res.data.endTime){ that.countdown(res.data.endTime); //当前时间与优惠券下架时间做计算 @@ -121,8 +119,8 @@ Page({ }); if (res.data.validType == 1) { that.setData({ - validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dddd"), - validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dddd"), + validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"), + validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"), }); } else { that.setData({ @@ -134,7 +132,8 @@ Page({ /** * 支付订单更新 */ - payOrderUpdate: (orderId, payOrderId, status, reason) => { + payOrderUpdate: (orderId, payOrderId, status, reason,type) => { + let that=this; // 支付成功 Http.post({ url: config.api.payOrderUpdate, @@ -145,12 +144,22 @@ Page({ reason: reason } }) - .then(res => { - console.log("payOrderUpdate then", res); - }) - .catch(err => { - console.log("payOrderUpdate catch", err); - }); + .then(res => { + console.log(that.payOrderUpdate()); + console.log("成功"); + if(!type){ + setTimeout(() => { + wx.navigateTo({ + url: `/pages/order/detail/index?orderId=${ + orderId + }` + }); + }, 1000) + } + }) + .catch(err => { + + }); }, /** * 发起支付 @@ -166,7 +175,6 @@ Page({ data: {} }) .then(res => { - console.log(res); var data = { couponChannelId: "" + that.data.couponChannelId, couponId: "" + that.data.couponId @@ -185,7 +193,6 @@ Page({ }); }) .catch(err => { - console.log(err); if (err.code == "2011") { wx.showToast({ title: "商户信息没找到", @@ -272,10 +279,7 @@ Page({ } }) .then(res => { - console.log(res); - console.log("点击领取卡券一直在loading"); if (typeof (res) != "undefined") { - console.log("", res); let orderId = "" + res.data.id; that.setData({ orderId: orderId @@ -291,7 +295,6 @@ Page({ orderId: orderId } }).then(res => { - console.log(res); /// Begin payment ---- var payOrderId = "" + res.data.payOrderId; wx.hideLoading(); @@ -302,19 +305,20 @@ Page({ signType: (res.data.signType) ? res.data.signType : "MD5", paySign: res.data.paySign, success: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 - console.log(res); + + var timesRun = 0; + var interval = setInterval(function () { + timesRun += 1; + if (timesRun === 3) { + clearInterval(interval); + } + that.payOrderUpdate(that.data.orderId, payOrderId, 1, ); + }, 2000); + if (res.errMsg == "requestPayment:ok") { setTimeout(function () { wx.hideLoading(); }, 2000); - setTimeout(() => { - wx.navigateTo({ - url: `/pages/order/detail/index?orderId=${ - that.data.orderId - }` - }); - }, 1000) /** * 用户支付成功以后跳转到券包列表 */ @@ -336,8 +340,7 @@ Page({ }, fail: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 2); // 支付失败 - console.log(res); + that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); // 支付失败 return; }, complete: res => { @@ -364,8 +367,6 @@ Page({ }` }); }, 1000) - //////////////////////////停车券 - console.log(that.data.data.type) if (that.data.data.type == 5) { setTimeout(() => { wx.switchTab({ @@ -388,20 +389,16 @@ Page({ path: '/pages/index/index', success: function (res) { if (res.errMsg == 'shareAppMessage:ok') { - console.log(res) } }, fail: function (error) { if (res.errMsg == 'shareAppMessage:fail cancel') { - console.log(error) } else if (res.errMsg == 'shareAppMessage:fail') { - console.log(error) } } }; // 来自页面内的按钮的转发 if (options.from == 'button') { - console.log(options) var eData = options.target.dataset.id; var couponId = options.target.dataset.couponid; // shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`; diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index 3e02bea..bee8b73 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -119,54 +119,12 @@ Page({ console.log(res); that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 console.log(res); - if (res.errMsg == "requestPayment:ok") { - wx.showToast({ - title: "购买成功", - duration: 2000, - image: "./../../../assets/img/success.png", - mask: false, - success: function () { - wx.showLoading({ - title: "加载中..." - }); - - setTimeout(function () { - wx.hideLoading(); - }, 1600); - setTimeout(() => { - wx.navigateTo({ - url: `/pages/order/detail/index?orderId=${ - that.data.orderId - }` - }); - }, 1600); - } - }); - } }, fail: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 2); + that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); console.log(res); - // wx.showToast({ - // title: "支付失败", - // image: "./../../../assets/img/fail.png", - // duration: 2000, - // mask: false - // }); return; }, - // complete: res => { - // console.log(res); - // if (res.errMsg == "requestPayment:ok") {} else { - // wx.showToast({ - // title: "支付失败", - // image: "./../../../assets/img/fail.png", - // duration: 2000, - // mask: false - // }); - // } - // return; - // } }); /// End payment -------- }); @@ -183,7 +141,7 @@ Page({ /** * 支付订单更新 */ - payOrderUpdate: (orderId, payOrderId, status, reason) => { + payOrderUpdate: (orderId, payOrderId, status, reason,type) => { // 支付成功 Http.post({ url: config.api.payOrderUpdate, @@ -195,11 +153,27 @@ Page({ } }) .then(res => { - console.log("payOrderUpdate then", res); - // wx.showToast({ - // title: "购买成功", - // duration: 2500 - // }); + if (!type) { + wx.showToast({ + title: "购买成功", + duration: 2000, + image: "./../../../assets/img/success.png", + mask: false, + success: function () { + wx.showLoading({ + title: "加载中..." + }); + setTimeout(function () { + wx.hideLoading(); + }, 1600); + setTimeout(() => { + wx.navigateTo({ + url: `/pages/order/detail/index?orderId=${orderId}` + }); + }, 1600); + } + }); + } }) .catch(err => { console.log("payOrderUpdate catch", err); diff --git a/project.config.json b/project.config.json index 3b57d21..ccbb80a 100644 --- a/project.config.json +++ b/project.config.json @@ -12,7 +12,7 @@ }, "compileType": "miniprogram", "libVersion": "2.0.9", - "appid": "wx026ee7f6290aa336", + "appid": "wx649b3be73c1afe47", "projectname": "C", "isGameTourist": false, "condition": {