From e48ab17f60346444a98d203462b1eb3f29931ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=96?= Date: Tue, 5 Mar 2019 19:39:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8B=BC=E5=9B=A2=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 3 +- config/config.js | 10 +- pages/spellDetail/index.js | 66 ++++++ pages/spellDetail/index.json | 4 + pages/spellDetail/index.wxml | 2 + pages/spellDetail/index.wxss | 1 + pages/spellGroup/mySpellGroup/index.js | 273 ++++++++++++++--------- pages/spellGroup/mySpellGroup/index.wxss | 2 +- 8 files changed, 255 insertions(+), 106 deletions(-) create mode 100644 pages/spellDetail/index.js create mode 100644 pages/spellDetail/index.json create mode 100644 pages/spellDetail/index.wxml create mode 100644 pages/spellDetail/index.wxss diff --git a/app.json b/app.json index c5c50c2..dbe3321 100644 --- a/app.json +++ b/app.json @@ -49,7 +49,8 @@ "pages/paySuccess/paySuccess", "pages/ConsumeDetail/ConsumeDetail", "pages/externallinks/index", - "pages/czdetail/czdetail" + "pages/czdetail/czdetail", + "pages/spellDetail/index" ], "navigateToMiniProgramAppIdList": [ "wx192b7d2e8dcbefd0", diff --git a/config/config.js b/config/config.js index 0a2ed71..cb5cdf2 100755 --- a/config/config.js +++ b/config/config.js @@ -239,7 +239,15 @@ var config = { /** * *分页列表接口 */ - merchantList:"/merchant/list" + merchantList:"/merchant/list", + /* + * 查询拼团状态 + */ + queryOrderGroupStatus:'/orderGroup/queryOrderGroupStatus', + /** + * 去拼团 + */ + toOrderGroup: '/orderGroup/toOrderGroup' }, weapp: { AppId: weappId diff --git a/pages/spellDetail/index.js b/pages/spellDetail/index.js new file mode 100644 index 0000000..6bdd84b --- /dev/null +++ b/pages/spellDetail/index.js @@ -0,0 +1,66 @@ +// pages/spellDetail/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/spellDetail/index.json b/pages/spellDetail/index.json new file mode 100644 index 0000000..4c7c9fc --- /dev/null +++ b/pages/spellDetail/index.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "拼团详情", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/spellDetail/index.wxml b/pages/spellDetail/index.wxml new file mode 100644 index 0000000..49546b3 --- /dev/null +++ b/pages/spellDetail/index.wxml @@ -0,0 +1,2 @@ + +pages/spellDetail/index.wxml diff --git a/pages/spellDetail/index.wxss b/pages/spellDetail/index.wxss new file mode 100644 index 0000000..062be82 --- /dev/null +++ b/pages/spellDetail/index.wxss @@ -0,0 +1 @@ +/* pages/spellDetail/index.wxss */ \ No newline at end of file diff --git a/pages/spellGroup/mySpellGroup/index.js b/pages/spellGroup/mySpellGroup/index.js index ad03f00..763a944 100644 --- a/pages/spellGroup/mySpellGroup/index.js +++ b/pages/spellGroup/mySpellGroup/index.js @@ -45,6 +45,7 @@ Page({ this.setData({ canBuyIf: false }) + this.orderFunc() }, /** * 发起拼团 @@ -54,7 +55,7 @@ Page({ this.setData({ canSpell:false }) - this.orderFunc() + this.orderFunc(0) }, /** * 获取一个拼团信息 @@ -74,6 +75,35 @@ Page({ } }); }, + countdown(end_time) { + let that = this; + var EndTime = end_time; + var NowTime = new Date().getTime(); + var total_micro_second = EndTime - NowTime || []; + // 渲染倒计时时钟 + let obj = that.dateformat(total_micro_second); + if (total_micro_second > 0) { + that.setData({ + clock: obj, + day: obj.a1, + hour: obj.b1, + min: obj.c1, + sec: obj.d1, + }) + } else { + that.setData({ + clock: "00", + day: "00", + hour: "00", + min: "00", + sec: "00", + }) + } + setTimeout(function () { + total_micro_second -= 1000; + that.countdown(end_time); + }, 1000) + }, /** * 获取券详情信息 */ @@ -93,10 +123,72 @@ Page({ }); }); }, + /** + * 去拼团 + */ + goToOrderGroup(orderId, orderGroupId, _this){ + console.log(22222222) + let that = this; + // 支付成功 + Http.post({ + url: config.api.toOrderGroup, + data: { + id: orderGroupId, + orderId, + couponId: _this.data.data.couponId + } + }) + .then(res => { + + }) + .catch(err => { + console.log(err); + }) + // return; + // wx.navigateTo({ + // url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.data.couponId}` + // }); + }, + /** + * 支付订单更新 + */ + payOrderUpdate: (orderId, payOrderId, status, reason, _this, orderGroupId) => { + let that = this; + // 支付成功 + Http.post({ + url: config.api.payOrderUpdate, + data: { + payOrderId: payOrderId, + orderId: orderId, + status: status, + reason: reason + } + }) + .then(res => { + wx.hideLoading() + _this.goToOrderGroup(orderId, res.data.orderGroupId, _this) + }) + .catch(err => { + console.log(err); + setTimeout(function () { + _this.payOrderUpdate(orderId, payOrderId, status, reason, _this, orderGroupId); + }, 2000) + }) + }, /** * 发起支付 */ - orderFunc(discount) { + orderFunc(orderGroupId) { + let data = { + couponChannelId: this.data.data.id, + couponId: this.data.data.couponId + } + /** + * 拼团订单 + */ + if (orderGroupId==0){ + data.orderGroupId = orderGroupId + } var that = this; Http.post({ url: config.api.checkPhoneStatus, @@ -106,11 +198,10 @@ Page({ /** * orderSave 下单 */ - debugger - // return Http.post({ - // url: config.api.orderSave, - // data: data - // }); + return Http.post({ + url: config.api.orderSave, + data: data + }); }) .catch(err => { console.log(err); @@ -200,106 +291,82 @@ Page({ }) .then(res => { console.log(res) - if (discount != 'discount') { - if (typeof (res) != "undefined") { - let orderId = "" + res.data.id; - that.setData({ + if (typeof (res) != "undefined") { + let orderId = "" + res.data.id; + that.setData({ + orderId: orderId + }); + // 支付金额不为0 + /** + * 支付订单创建 + */ + Http.post({ + url: config.api.payOrderCreate, + data: { orderId: orderId - }); - if (res.data.payment > 0) { - // 支付金额不为0 - /** - * 支付订单创建 - */ - Http.post({ - url: config.api.payOrderCreate, - data: { - orderId: orderId - } - }) - .then(res => { - var payOrderId = "" + res.data.payOrderId; - wx.hideLoading(); - wx.requestPayment({ - timeStamp: res.data.timeStamp, - nonceStr: res.data.nonceStr, - package: res.data.package, - signType: (res.data.signType) ? res.data.signType : "MD5", - paySign: res.data.paySign, - success: res => { - wx.showLoading({ - title: '订单正在处理中...', - }) - setTimeout(function () { - wx.hideLoading() - }, 5000) - that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); - if (res.errMsg == "requestPayment:ok") { - setTimeout(function () { - wx.hideLoading(); - }, 2000); - /** - * 用户支付成功以后跳转到券包列表 - */ - if (that.data.cardType == 100) { - wx.setStorage({ - key: 'couponNum2', - data: "couponNum2" - }) - } else if (that.data.data.type != 5) { - wx.setStorage({ - key: 'couponNum', - data: "couponNum" - }) - } - } - }, - fail: res => { - /** - * 支付失败,需要更新订单的状态 - */ - that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that); - that.setData({ - showbutton: false - }) - return; - }, - complete: res => { } - }); - /// End payment -------- - }) - .catch(err => { - wx.showToast({ - title: err.message, - icon: 'none', - duration: 2000, - mask: false - }); - }) - } else { - console.log(that.data.type) - // 免费券 - that.payOrderUpdate(orderId, "0", 1, '', 'free'); - if (that.data.cardType == 100) { - wx.setStorage({ - key: 'couponNum2', - data: "couponNum2" + } + }) + .then(res => { + var payOrderId = "" + res.data.payOrderId; + wx.hideLoading(); + wx.requestPayment({ + timeStamp: res.data.timeStamp, + nonceStr: res.data.nonceStr, + package: res.data.package, + signType: (res.data.signType) ? res.data.signType : "MD5", + paySign: res.data.paySign, + success: res => { + wx.showLoading({ + title: '订单正在处理中...', }) - } else if (that.data.data.type != "5") { - wx.setStorage({ - key: 'couponNum', - data: "couponNum" + setTimeout(function () { + wx.hideLoading() + }, 5000) + that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId); + if (res.errMsg == "requestPayment:ok") { + setTimeout(function () { + wx.hideLoading(); + }, 2000); + /** + * 用户支付成功以后跳转到券包列表 + */ + if (that.data.cardType == 100) { + wx.setStorage({ + key: 'couponNum2', + data: "couponNum2" + }) + } else if (that.data.data.type != 5) { + wx.setStorage({ + key: 'couponNum', + data: "couponNum" + }) + } + } + }, + fail: res => { + /** + * 支付失败,需要更新订单的状态 + */ + that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', that, orderGroupId); + that.setData({ + showbutton: false }) - } - } - } - } else { - if (res) { - wx.navigateTo({ - url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`, - }) - } + return; + }, + complete: res => { } + }); + /// End payment -------- + }) + .catch(err => { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + }) } + }) }, /** diff --git a/pages/spellGroup/mySpellGroup/index.wxss b/pages/spellGroup/mySpellGroup/index.wxss index a13261b..21b7d6c 100644 --- a/pages/spellGroup/mySpellGroup/index.wxss +++ b/pages/spellGroup/mySpellGroup/index.wxss @@ -62,7 +62,7 @@ font-weight:500; color:rgba(0,0,0,1); line-height:44rpx; - margin-right: 30rpx; + margin-right: 15rpx; } .des-saleprice{ display: inline;