From bcbbcc43ad54d6e69b7543b831c06218c4689096 Mon Sep 17 00:00:00 2001 From: jiazhipeng Date: Sat, 14 Sep 2024 11:54:55 +0800 Subject: [PATCH] 1 --- pages/index/index.vue | 1 + static/js/CommonFunction.js | 12 ++--- subPackages/food/foodOrder.vue | 58 +++++++++++++++---------- subPackages/hotelHomestay/order.vue | 31 ++++++++++++- subPackages/techan/order.vue | 4 +- subPackages/ticketBooking/order.vue | 55 +++++++++++++---------- subPackages/travelGuide/travelGuide.vue | 1 + 7 files changed, 105 insertions(+), 57 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 7fee848..4cfa440 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -299,6 +299,7 @@ }, // 游记攻略、线路详情 goCalendarDetail(item,type) { + this.Post({id: item.id},'/api/article/getArticleById') this.goOtherDetail(item) if(!item.link_type) { if(type) { diff --git a/static/js/CommonFunction.js b/static/js/CommonFunction.js index e0acd60..f412397 100644 --- a/static/js/CommonFunction.js +++ b/static/js/CommonFunction.js @@ -231,8 +231,9 @@ Date.prototype.Format = function(fmt) return fmt; } -// 获取最大优惠券 params:{money:100,sku_ids:1,2} +// 获取最大优惠券 params:{money:100,sku_ids:1,2} money单位分 Vue.prototype.getMaxCoupon = async function (param) { + param.money = (param.money||0)/100 let res = await this.Post(param, "/api/coupon/use_max_coupon_list") if (res.code == 1 && res.data.id) { this.$store.commit("choseCoupon",res.data); @@ -258,7 +259,9 @@ Vue.prototype.goOtherDetail = (item,type) => { } // 根据类型判断详情页 -Vue.prototype.goDetailByType=(item)=>{ +Vue.prototype.goDetailByType= function(item){ + this.goOtherDetail(item) + let urlData = [ {name:'景区门票', url: '/subPackages/ticketBooking/detail',genre:'ticket'}, {name:'酒店民宿',url:'/subPackages/hotelHomestay/detail',genre:'hotel'}, @@ -269,11 +272,10 @@ Vue.prototype.goDetailByType=(item)=>{ // {name:'游玩公告',url:'/subPackages/notice/noticeDetail'}, {name:'活动日历',url:'/subPackages/eventCalendar/detail',genre:'activity'} ] - + let detailData = urlData.find(v=>v.genre == item.genre) if (detailData) { - let param = "" - + if (detailData.genre == 'article') {this.Post({id: item.id},'/api/article/getArticleById')} uni.navigateTo({ url: `${detailData.url}?id=${(['ticket','hotel'].includes(detailData.genre)?item.scenic_id:item.id)}` }) diff --git a/subPackages/food/foodOrder.vue b/subPackages/food/foodOrder.vue index 03ce0b0..e525a05 100644 --- a/subPackages/food/foodOrder.vue +++ b/subPackages/food/foodOrder.vue @@ -22,9 +22,10 @@
优惠券
-
- 请选择 -
+ + 请选择 + +
-¥{{coupon.discounts/100}} -{{coupon.percent}}% @@ -54,7 +55,7 @@ 合计: - ¥{{ allprice }} + ¥{{ total() }} @@ -71,7 +72,7 @@ coupon:"", reserve_name: '', reserve_phone: '', - info:null, + info:{}, detail:null,//商品的信息 allprice: 0, num:0, @@ -93,7 +94,9 @@ } console.log(this.info); this.reserve_phone = JSON.parse(uni.getStorageSync('userInfo')).mobile - this.total() + + + this.getMaxCouponData() }, methods: { cha() { @@ -182,18 +185,29 @@ // 总价 total() { let price = 0 + this.allprice = this.info.money * this.num if (this.coupon) { if (this.coupon.percent == 0) { price = this.info.money * this.num - this.coupon.discounts } else{ - price = this.info.money * this.num - ((this.info.money * this.num + this.post) * this.coupon.percent) + price = this.info.money * this.num - ((this.info.money * this.num ) * this.coupon.percent/100) } } else{ price = this.info.money * this.num } price < 0 ? 0 : price - this.allprice = price / 100 + return (price / 100).toFixed(2) }, + + // 获取最大优惠券 + async getMaxCouponData () { + let param = {money:this.info.money * this.num,sku_ids:this.info.id} + let res = await this.getMaxCoupon(param) + if (res.id) { + this.coupon = res + } + this.total() + } } } @@ -391,24 +405,20 @@ } .coupon-btn { - width: 140rpx; - height: 57rpx; - border: 1px solid #333333; - border-radius: 29rpx; - font-size: 28rpx; - font-family: PingFangSC; - font-weight: 400; - color: #000000; - text-align: center; - line-height: 57rpx; - + color: #999999;; + display: flex; + align-items: center; .select { - padding: 10rpx 18rpx; - background: #ED9230; - border-radius: 10rpx; - font-size: 28rpx; + display: block; + width: 140rpx; + height: 58rpx; + text-align: right; + line-height: 58rpx; + font-size: 31rpx; + font-family: PingFang SC; font-weight: 400; - color: #fff; + margin-right: 20rpx; + } } diff --git a/subPackages/hotelHomestay/order.vue b/subPackages/hotelHomestay/order.vue index 56dfb81..6eecd18 100644 --- a/subPackages/hotelHomestay/order.vue +++ b/subPackages/hotelHomestay/order.vue @@ -156,7 +156,9 @@ buyNum: 1, roomUser: [{ name: '' - }] + }], + + allSeldDate: [] } @@ -195,6 +197,8 @@ this.phone = '' } + this.getPriceCal(this.skuInfo.id, this.skuInfo.goods_id) + }, // 查看房型 viewDetail () { @@ -214,7 +218,13 @@ }, total () { - return this.skuInfo.money/100 * this.buyNum * this.selectDate.differDays || 0 + + let disfferMoney = 0 + this.allSeldDate.forEach(v=>{ + disfferMoney+=(v.money||0) + }) + + return (disfferMoney/100 * this.buyNum * this.selectDate.differDays || 0).toFixed(2) }, order () { @@ -300,6 +310,23 @@ this.$refs.popupRule.open() }, + + getPriceCal(skuId,goodId) { + this.Post({ + specifications_id: skuId, + goods_id: goodId, + start_date: this.selectDate.startDay, + end_date:this.selectDate.endDay, + }, '/api/goods/getPriceCalendarListBySpecifications').then(res => { + this.allSeldDate = res.data || [] + + if (this.allSeldDate.length>0) { + this.allSeldDate.pop() + } + + }) + }, + } } diff --git a/subPackages/techan/order.vue b/subPackages/techan/order.vue index 36bac6c..3743aa8 100644 --- a/subPackages/techan/order.vue +++ b/subPackages/techan/order.vue @@ -419,12 +419,12 @@ export default { } else{ // 有bug折扣券不加邮费 - price = ((this.info.money) * this.info.buyNum + postPrice) - (((this.info.money) * this.info.buyNum + postPrice) * this.coupon.percent/100) + price = ((this.info.money) * this.info.buyNum + postPrice) - (((this.info.money) * this.info.buyNum) * this.coupon.percent/100) } } else { price = (this.info.money) * this.info.buyNum + postPrice } - return price < 0 ? 0 : price/100 + return price < 0 ? 0 : (price/100).toFixed(2) }, // 预定 order() { diff --git a/subPackages/ticketBooking/order.vue b/subPackages/ticketBooking/order.vue index 86b9250..737e468 100644 --- a/subPackages/ticketBooking/order.vue +++ b/subPackages/ticketBooking/order.vue @@ -17,12 +17,15 @@ {{skuItem.title}} {{skuItem.price / 100}} - + - {{ skuItem.buyNum }} + + + 无库存 + @@ -357,11 +360,12 @@ }, onLoad(options) { // this.getList(); + this.$store.commit("choseCoupon", ""); this.initPageData() }, onShow() { - + this.coupon = this.$store.state.user.coupon }, onUnload () { @@ -395,15 +399,15 @@ }, // 获取sku价格日历money - async initPriceCal(skuId, goodsId,date) { + async initPriceCal(skuId) { let res = await this.Post({ specifications_id: skuId, - goods_id: goodsId, - end_date:date, - start_date:date - }, '/api/goods/getPriceCalendarListBySpecifications') + date: this.showDate.date, + start_time:this.showDate.startTime, + end_time:this.showDate.endTime + }, '/api/goods/getSpecificationsPriceCalendarAndTime') if (res.code == 1) { - return {code:1,money: res.data[0].money, store: ''} + return {code:1,...res.data} } return {code:2} }, @@ -448,18 +452,8 @@ let is_time_stock = data.sInfo.is_time_stock let is_price_calendar = data.sInfo.is_price_calendar data.pInfo.specifications = data.pInfo.specifications.filter(v=>v.is_time_stock==is_time_stock && v.is_price_calendar==is_price_calendar) - let date = data.allSeldDate[data.seldDateIndex].date - let time = data.timesArr[data.seldTimeIndex] - for(let sku of data.pInfo.specifications) { - let res = await this.initPriceCal(sku.id, sku.goods_id, date) - if (res.code === 1) { - sku.price = res.money - } - } - this.pInfo = data.pInfo - this.sInfo = data.sInfo this.minSeldDate=data.minSeldDate this.maxSeldDate = data.maxSeldDate this.calendarParam = data.calendarParam @@ -475,6 +469,19 @@ } + for(let sku of data.pInfo.specifications) { + let res = await this.initPriceCal(sku.id) + if (res.code === 1) { + sku.price = res.money + sku.store = res.store + } + } + + this.pInfo = data.pInfo + this.sInfo = data.sInfo + + + } catch(e){ console.log(e) } @@ -498,10 +505,9 @@ result = personAge>=age_limit.start } if (age_limit.end&&result) { - result = personAge<=age_limit.start + result = personAge<=age_limit.end } } - return result }, @@ -782,7 +788,7 @@ } else { price = allPrice } - return price < 0 ? 0 : price/100 + return price < 0 ? 0 : (price/100).toFixed(2) }, // 判断是否买多个sku @@ -907,9 +913,10 @@ sku.selPerson = { id:null,id_number:null,name:null,tel:null,user_id:null,age:null, } - let res = this.initPriceCal(sku.id, sku.goods_id, date) + let res = this.initPriceCal(sku.id) if (res.code === 1) { sku.price = res.money + sku.store = res.store } } }, @@ -1021,10 +1028,10 @@ method: 'POST', data: JSON.stringify(data) }, '/api/order/place').then(res => { - if (res.code == 200) { + if (res.code == 1) { + uni.removeStorageSync('ticketOrder') console.log(res.data.order_id); let order_id = res.data.order_id - this.$store.commit("changeOrderInfo", null); this.$store.commit("choseCoupon", ""); this.Post({ order_id: order_id, diff --git a/subPackages/travelGuide/travelGuide.vue b/subPackages/travelGuide/travelGuide.vue index 2356171..a6532ad 100644 --- a/subPackages/travelGuide/travelGuide.vue +++ b/subPackages/travelGuide/travelGuide.vue @@ -112,6 +112,7 @@ this.getArticleByType() }, viewDetail (item) { + this.Post({id: item.id},'/api/article/getArticleById') this.goOtherDetail(item) if(!item.link_type) { uni.navigateTo({