From 740c83bb4ad4c66b5bdb822f83b8876f704b6641 Mon Sep 17 00:00:00 2001 From: duan <1004387497@qq.com> Date: Mon, 13 May 2024 16:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/api.js | 4 + .../group_order/components/groupOrderInfo.vue | 2 +- pages/product/placeOrder.vue | 151 ++++++++++++++++-- 3 files changed, 146 insertions(+), 11 deletions(-) diff --git a/common/js/api.js b/common/js/api.js index 02ab0fd..15cfb52 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -12,6 +12,10 @@ export default { getproductorderConfirm(data) { return uni.api.get("/product/orderConfirm", data); }, + // 下单 + creatGroupOrder(data) { + return uni.api.post("/groupOrderInfo/creatGroupOrder", data); + }, cartadd(data) { //添加到购物车 return uni.api.post("/cart/add", data); }, diff --git a/pages/group_order/components/groupOrderInfo.vue b/pages/group_order/components/groupOrderInfo.vue index 42cb46c..d2f3553 100644 --- a/pages/group_order/components/groupOrderInfo.vue +++ b/pages/group_order/components/groupOrderInfo.vue @@ -21,7 +21,7 @@ 间: - {{info.payTime}} + {{info.payTime==null?'':info.payTime}} diff --git a/pages/product/placeOrder.vue b/pages/product/placeOrder.vue index 56694eb..3534acb 100644 --- a/pages/product/placeOrder.vue +++ b/pages/product/placeOrder.vue @@ -13,8 +13,8 @@ - ¥12 - ¥13 + ¥{{info.originPrice}} + ¥{{info.salePrice}} @@ -28,15 +28,36 @@ - + + 红包/低佣券 - - 有20张优惠券可选择 + + {{info.couponDetail.name}} + + + + 优惠¥{{info.save * Quantity}} + + + 小计¥{{info.salePrice * Quantity}} + + + + + + 合计 ¥{{info.salePrice * Quantity}} + 含优惠卷包¥0 + + + 共{{Quantity}}件 已优惠¥{{info.save * Quantity}} + + - @@ -52,8 +73,53 @@ } }, methods: { - valChange(e) { - console.log('当前值为: ' + e.value) + async sumbitFrom() { + let payMoney = this.info.salePrice * this.Quantity + let res = await this.api.creatGroupOrder({ + num: this.Quantity, + proId: this.info.proId, + shopId: this.info.shopId, + payAmount: payMoney, + orderAmount: payMoney + }) + if (res.code == 0) { + // 调用支付接口 + this.payEvent(res.data.id) + } + }, + async payEvent(id) { + let res = await this.api.payOrderPay({ + payType:'wechatPay', + orderId:id, + }) + if (res) { + return + uni.requestPayment({ + provider: 'wxpay', //支付类型-固定值 + partnerid: res.data.payAppId, // 微信支付商户号 + timeStamp: res.data.payTimeStamp, // 时间戳(单位:秒) + nonceStr: res.data.paynonceStr, // 随机字符串 + package: res.data.payPackage, // 固定值 + signType: res.data.paySignType, //固定值 + paySign: res.data.paySign, //签名 + success: (res) => { + uni.showToast({ + title: "支付成功" + }) + uni.navigateBack() + }, + fail: (err) => { + setTimeout(res => { + uni.showToast({ + icon: 'none', + title: '支付失败' + }) + uni.hideLoading() + }, 2000) + } + }); + } + }, async getInfo(id) { let res = await this.api.getproductorderConfirm({ @@ -61,7 +127,6 @@ }) if (res.code == 0) { this.info = res.data - console.log(this.info, 'tiaoshi1') } } } @@ -126,8 +191,74 @@ .m(30rpx); >view:first-child { - .df + .df; + font-weight: 400; + font-size: 28rpx; + color: #333333; } + + >view:last-child { + background: #FFE9E9; + border-radius: 16rpx 16rpx 16rpx 16rpx; + font-weight: 400; + font-size: 28rpx; + color: #FF3333; + text-align: center; + padding: 9rpx 13rpx; + } + } + + .jiesuanmoney { + height: 112rpx; + line-height: 112rpx; + text-align: right; + + >text:first-child { + font-size: 24rpx; + + + } + + >text:last-child { + font-size: 32rpx; + margin-left: 20rpx; + + + } + } + + } + + .placeBottom { + position: fixed; + bottom: 0%; + left: 0; + width: 100%; + height: 148rpx; + background-color: #fff; + padding: 16rpx 34rpx; + + >view:last-child { + margin-top: 16rpx; + font-weight: 400; + font-size: 24rpx; + color: #666666; + + } + + .btnStyle { + width: 302rpx; + height: 72rpx; + line-height: 72rpx; + text-align: center; + background: linear-gradient(110deg, #F1A666 0%, #FF4C11 100%); + border-radius: 48rpx 48rpx 48rpx 48rpx; + font-weight: bold; + font-size: 36rpx; + color: #FFFFFF; + position: absolute; + right: 58rpx; + top: 30rpx; } } }