From c0c6714242f624019ab4e6aed7f6d193db0cc68f Mon Sep 17 00:00:00 2001 From: 396316021 <396316021@qq.com> Date: Thu, 14 Sep 2023 13:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A1=B5=E9=9D=A2=E7=BB=84?= =?UTF-8?q?=E4=BB=B6,=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/order.js | 29 +++++++++++++++ pages/OrderPage/index.vue | 71 ++++++++++++++++++++++++++++++++++--- pages/UserCoupons/index.vue | 4 +++ 3 files changed, 99 insertions(+), 5 deletions(-) diff --git a/api/order.js b/api/order.js index bc59297..9d303c1 100644 --- a/api/order.js +++ b/api/order.js @@ -50,4 +50,33 @@ export function getStoreService(data = { method: 'post', data:data }) +} + +/** + * 获取价格 + * @param data + * @returns {Promise} + */ +export function getOrderPrice(data = { + "address_id":"" +}){ + return request({ + url:"order/get-petorderprice", + method: 'post', + data:data + }) +} +/** + * 创建订单 + * @param data + * @returns {Promise} + */ +export function createOrderPrice(data = { + "address_id":"" +}){ + return request({ + url:"order/create-petorder", + method: 'post', + data:data + }) } \ No newline at end of file diff --git a/pages/OrderPage/index.vue b/pages/OrderPage/index.vue index b09c28c..4c7899a 100644 --- a/pages/OrderPage/index.vue +++ b/pages/OrderPage/index.vue @@ -183,11 +183,21 @@ 费用共计 - ¥58.8 + ¥{{price.all_price}} - + + + 阅读并同意《上门喂养协议》 @@ -199,6 +209,7 @@ button-color="#4DC3B8" font-color="#FFFFFF" button-width="200rpx" + @click="readInfo ? orderPay() :$u.toast('请先同意协议')" > @@ -340,9 +351,14 @@ import {cardDetail} from "@/api/card"; import {getAddressList} from "@/api/address"; import image from "@/config/image"; - import {getStoreService} from "@/api/order"; + import {createOrderPrice, getOrderPrice, getStoreService} from "@/api/order"; import pet from "@/pages/Pet/index.vue"; export default { + computed: { + api() { + return api + } + }, components: { HeaderNav, FooterNav, @@ -352,6 +368,12 @@ }, data() { return { + readInfo:false, + price:{ + all_price:0, + price:0, + quan_reduce:0, + }, radioValue1:[], list: ['未付款', '待评价', '已付款'], curNow: 0, @@ -415,13 +437,36 @@ this.id = options.id; }, updated() { - this.checkOrderData(); + }, onShow(){ this.getDefaultAddress(); this.getUserCoupons(); }, methods: { + orderPay(){ + + if( + this.address + &&this.timeList.length>0 + &&this.petChecked.length>0 + &&this.basicServiceChecked!=='' + ){ + console.log(this.basicServiceChecked) + createOrderPrice({ + address_id: this.address.id, + do_date: this.timeList.map(res => [res.date,res.time]), + services: this.addServiceList.map(res => res.id).join(','), + basic_service:this.basicServiceChecked, + pet_ids: this.petChecked.map(res => res.id).join(','), + store_id:this.addServiceList[0].store_id, + user_coupon_id:this.coupons.id || 0 + }).then(res => { + console.log(res) + this.price = res.data; + }); + } + }, checkOrderData(){ if( this.address @@ -429,14 +474,28 @@ &&this.petChecked.length>0 &&this.basicServiceChecked!=='' ){ - console.log('formDone') + console.log(this.basicServiceChecked) + getOrderPrice({ + address_id: this.address.id, + do_date: this.timeList.map(res => [res.date,res.time]), + services: this.addServiceList.map(res => res.id).join(','), + basic_service:this.basicServiceChecked, + pet_ids: this.petChecked.map(res => res.id).join(','), + store_id:this.addServiceList[0].store_id, + user_coupon_id:this.coupons.id || 0 + }).then(res => { + console.log(res) + this.price = res.data; + }); } }, selectPet(petList){ this.petChecked = petList; + this.checkOrderData(); }, delPet(index){ this.petChecked.splice(index,1); + this.checkOrderData(); }, doDatePopupConfirm(){ this.timeListTemp.forEach(item => { @@ -451,6 +510,7 @@ doTimeSelect(value){ this.timeListTemp[this.vTabCurrent].time = value console.log(this.timeListTemp) + this.checkOrderData(); }, changeVTab(index){ console.log(index) @@ -539,6 +599,7 @@ radioChange(n) { this.basicServiceChecked = n.id console.log('radioChange', n); + this.checkOrderData(); }, groupChange(n) { console.log('radioChange', n); diff --git a/pages/UserCoupons/index.vue b/pages/UserCoupons/index.vue index 452e351..f1a6d2b 100644 --- a/pages/UserCoupons/index.vue +++ b/pages/UserCoupons/index.vue @@ -31,6 +31,9 @@ + + + 查看使用规则 @@ -89,6 +92,7 @@ couponsBackground: imghost + '/static/image/coupons-bg.png', couponsGrayBackground: imghost + '/static/image/coupons-gray-bg.png', couponsGQ: imghost + '/static/image/coupons-gq.png', + couponsUse: imghost + '/static/image/coupons-use.png', }, indexBanner: [{ image: imghost + '/static/image/banner.png',