From 9bb5a6cb2795ec9717fba558df5e9bf9cfaf1dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=96?= Date: Tue, 5 Mar 2019 15:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=82=E7=94=A8=E9=97=A8=E5=BA=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/getphoneInfo/index.js | 9 + pages/phoneinput/phoneinput.js | 9 + pages/spellGroup/mySpellGroup/index.js | 258 ++++++++++++++++++++++- pages/spellGroup/mySpellGroup/index.wxml | 34 ++- pages/spellGroup/mySpellGroup/index.wxss | 87 +++++++- 5 files changed, 373 insertions(+), 24 deletions(-) diff --git a/pages/getphoneInfo/index.js b/pages/getphoneInfo/index.js index a85319e..b3985f4 100755 --- a/pages/getphoneInfo/index.js +++ b/pages/getphoneInfo/index.js @@ -59,6 +59,15 @@ Page({ }).then( function (res) { app.globalData.phone = res.data.phone; + /** + * 来自拼团详情 + */ + if (that.path == 'spell') { + wx.redirectTo({ + url: "pages/spellGroup/mySpellGroup/index?couponChannelId=" + that.data.paramData.couponChannelId + "&couponId" + that.data.paramData.couponId + }) + return; + } /** * fromId若存在来自卡转赠 */ diff --git a/pages/phoneinput/phoneinput.js b/pages/phoneinput/phoneinput.js index fd40441..e637aa0 100644 --- a/pages/phoneinput/phoneinput.js +++ b/pages/phoneinput/phoneinput.js @@ -45,6 +45,15 @@ Page({ } }) .then(res => { + /** + * 来自拼团详情 + */ + if (that.path == 'spell'){ + wx.redirectTo({ + url: "pages/spellGroup/mySpellGroup/index?couponChannelId=" + that.data.paramData.couponChannelId + "&couponId" + that.data.paramData.couponId + }) + return; + } if (that.path != 'index'){ wx.redirectTo({ url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, diff --git a/pages/spellGroup/mySpellGroup/index.js b/pages/spellGroup/mySpellGroup/index.js index 0d3a003..ad03f00 100644 --- a/pages/spellGroup/mySpellGroup/index.js +++ b/pages/spellGroup/mySpellGroup/index.js @@ -8,10 +8,13 @@ Page({ * 页面的初始数据 */ data: { + teljpgUrl: imgurl.teljpg.url, couponChannelId:'', couponId:'', - detailData:[], - spellData:null + data:[], + spellData:null, + canSpell:true, + canBuyIf:true }, /** @@ -25,6 +28,34 @@ Page({ this.getDetail(options.couponChannelId); this.getOneSpell(options.couponId) }, + /** + * 拨打电话 + */ + phone: function (e) { + let that = this; + wx.makePhoneCall({ + phoneNumber: e.target.dataset.merchantlinkphone + }); + }, + /** + * 直接购买 + */ + gotoBuy(){ + console.log(22222) + this.setData({ + canBuyIf: false + }) + }, + /** + * 发起拼团 + */ + gotoSpell(){ + console.log(111111111) + this.setData({ + canSpell:false + }) + this.orderFunc() + }, /** * 获取一个拼团信息 */ @@ -58,10 +89,219 @@ Page({ data.price = (data.price / 100).toFixed(2) data.salePrice = (data.salePrice / 100).toFixed(2) that.setData({ - detailData: data + data }); }); }, + /** + * 发起支付 + */ + orderFunc(discount) { + var that = this; + Http.post({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(res => { + /** + * orderSave 下单 + */ + debugger + // return Http.post({ + // url: config.api.orderSave, + // data: data + // }); + }) + .catch(err => { + console.log(err); + that.setData({ + showbutton: false, + showbutton1: false + }) + if (err.code == 2011) { + wx.showToast({ + title: "商户信息没找到", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 2013) { + wx.showToast({ + title: "商户信息禁用", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 3000) { + wx.showToast({ + title: "库存不足", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 3001) { + wx.showToast({ + title: "超过限购条件", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 3002) { + wx.showToast({ + title: "订单失败", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 3003) { + wx.showToast({ + title: "订单不存在", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 3004) { + wx.showToast({ + title: "订单不存在", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 4003) { + wx.showToast({ + title: "卡券已作废", + image: './../../../assets/images/fail.png', + duration: 2000, + mask: false + }); + } else if (err.code == 11005) { + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index?path=spell&couponChannelId=" + + that.data.couponChannelId + '&couponId=' + that.data.couponId + }); + } else if (err.code == 11006) { + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput?path=spell&couponChannelId=" + + that.data.couponChannelId + '&couponId=' + that.data.couponId + }); + } else { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) + .then(res => { + console.log(res) + if (discount != 'discount') { + if (typeof (res) != "undefined") { + let orderId = "" + res.data.id; + that.setData({ + 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" + }) + } else if (that.data.data.type != "5") { + wx.setStorage({ + key: 'couponNum', + data: "couponNum" + }) + } + } + } + } else { + if (res) { + wx.navigateTo({ + url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`, + }) + } + } + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ @@ -73,7 +313,10 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - + this.setData({ + canSpell:true, + canBuyIf:true + }) }, /** @@ -102,12 +345,5 @@ Page({ */ onReachBottom: function () { - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - } }) \ No newline at end of file diff --git a/pages/spellGroup/mySpellGroup/index.wxml b/pages/spellGroup/mySpellGroup/index.wxml index 5c6dbe9..2cebbc7 100644 --- a/pages/spellGroup/mySpellGroup/index.wxml +++ b/pages/spellGroup/mySpellGroup/index.wxml @@ -1,14 +1,14 @@ - + - {{detailData.title}} + {{data.title}} - {{detailData.subTitle}} + {{data.subTitle}} - 【拼团购】{{detailData.pressLimitNum}}人拼团成功,单价仅需 - {{detailData.salePriceStr}}元 + 【拼团购】{{data.pressLimitNum}}人拼团成功,单价仅需 + {{data.salePriceStr}}元 @@ -26,19 +26,33 @@ 商品详情: - {{detailData.remark}} + {{data.remark}} + + + 适用门店 + - + - {{detailData.price}} + {{data.price}} 立即购买 - + + - {{detailData.salePrice}} + {{data.salePrice}} 发起拼团 diff --git a/pages/spellGroup/mySpellGroup/index.wxss b/pages/spellGroup/mySpellGroup/index.wxss index f40f22c..a13261b 100644 --- a/pages/spellGroup/mySpellGroup/index.wxss +++ b/pages/spellGroup/mySpellGroup/index.wxss @@ -171,6 +171,7 @@ float: right; width: 330rpx; height: 95rpx; + line-height: 46rpx; background:linear-gradient(90deg,rgba(236,59,45,1) 0%,rgba(248,98,52,1) 100%); box-shadow:0px 8rpx 8rpx 1rpx rgba(246,93,51,0.32); border-radius:48rpx; @@ -207,17 +208,16 @@ } .edit-right-top{ - height: 46rpx; + line-height: 32rpx; text-align: center; + margin-top: 13rpx; } .real-price{ display: inline; font-size:32rpx; - line-height: 32rpx; font-family:PingFang-SC-Medium; font-weight:500; color:rgba(254,254,254,1); - margin-top: 6rpx; } .real-price-unit{ display: inline; @@ -235,4 +235,85 @@ font-family:PingFang-SC-Medium; font-weight:500; color:rgba(254,254,254,1); +} +.posi { + position: relative; +} +.applyshop{ + font-size:32rpx; + font-family:PingFang-SC-Bold; + font-weight:bold; + color:rgba(51,51,51,1); + margin: 10rpx 0 20rpx 0; +} + +.posi>view:nth-child(2) { + width: 100%; + height: 87rpx; + display: flex; + justify-content: space-between; + line-height: 87rpx; +} + +.posi>view:nth-child(2) text:nth-child(1) { + font-size: 30rpx; + color: #a9a9a9; +} + +.posi>view:nth-child(2) text:nth-child(2) { + font-size: 30rpx; + color: #a9a9a9; +} + +.posi_logo { + width: 100%; + display: flex; + padding: 20rpx 0; + background: #fff; + height: 100rpx; + margin-bottom: 20rpx; +} + +.posi_logo view:nth-child(1) { + width: 100rpx; + height: 100rpx; + border-radius: 16rpx; +} + +.posi_logo view:nth-child(1) image { + display: block; + width: 100rpx; + height: 100rpx; + border-radius: 16rpx; + border: 1px solid #e5e5e5; +} + +.posi_logo view:nth-child(2) { + display: flex; + flex-direction: column; + flex: 8; + padding-left: 30rpx; +} + +.posi_logo view:nth-child(2) text:nth-child(1) { + font-size: 32rpx; + color: #333; + letter-spacing: 0; +} + +.posi_logo view:nth-child(2) text:nth-child(2) { + font-size: 24rpx; + color: #b8b8b8; + padding-top: 3rpx; + width: 450rpx; + height: 36rpx; + overflow: hidden; +} +.tel { + right: 0; + top: 0; + bottom: 0; + margin: auto; + width: 50rpx; + height: 50rpx; } \ No newline at end of file