From f9c8ce1f041e8e4226cc588d9871547b69f73747 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Thu, 23 Sep 2021 15:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=A7=84=E6=A0=BC=E4=B8=8B=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api.js | 4 +- pages/goodsDetail/index.vue | 173 ++++++++++++++++++++++++++-------- pages/order/confirm_order.vue | 116 +++++++++++++++++++---- 3 files changed, 236 insertions(+), 57 deletions(-) diff --git a/common/api.js b/common/api.js index 2855811..47f4c8b 100644 --- a/common/api.js +++ b/common/api.js @@ -1,7 +1,7 @@ // appId: 正式 null | 测试 wxeb58570b5e04d147 -export const DEV = "prod"; // dev 测试 | prod 正式 +export const DEV = "dev"; // dev 测试 | prod 正式 export const VERSION = '1.0.0'; // 版本号 -export const DEVURL = 'https://hainan.lanzulive.com'; // 测试服请求地址 +export const DEVURL = 'https://yytx.eugyl.com'; // 测试服请求地址 // export const DEVURL = 'http://hainan.com'; // 测试服请求地址 export const PRODURL = 'https://yytx.eugyl.com'; // 正式服请求地址 diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index bed8c7c..0f58b7c 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -38,7 +38,7 @@ - + {{goods_detail.product.extends.field_2_name}} {{goods_detail.product.extends.field_2_address}} @@ -77,23 +77,23 @@ - - ¥{{ goods_detail.original_price }} + + ¥{{ goods_detail.product.spec[type_index].original_price }} - 入园时间:09月23日 + 开始时间:{{ choose_date }} 套餐类型 - 大床房 + {{item.name}} - 入园时间 + 开始时间 - 入园时间 + 开始时间 @@ -105,7 +105,7 @@ - + @@ -166,22 +166,22 @@ - - ¥{{ goods_detail.original_price }} + + ¥{{ goods_detail.product.spec[type_index].original_price }} - 酒店住房日期:09月22日-09月27日 + 酒店住房日期:{{live_date}}~{{leave_date}} 套餐类型 - 大床房 + {{item.name}} 酒店住房日期 - 共6晚 + 共{{totalLive}}晚 @@ -233,7 +233,7 @@ - + @@ -270,26 +270,25 @@ - - ¥{{ goods_detail.original_price }} + + ¥{{ goods_detail.product.spec[type_index].original_price }} - 套餐类型:奢玩云南6天|出行日期:09月22日-09月27日 + 套餐类型:{{goods_detail.product.spec[type_index].name}} 套餐类型 - 潮玩云南游6天 + {{item.name}} 出行日期 - 共6晚 - 出发时间 + 开始时间 @@ -299,21 +298,9 @@ - - - 回程时间 - - - - - {{ back_date }} - - - - - + @@ -350,7 +337,7 @@ 分享 - + @@ -375,16 +362,17 @@ //景区类型相关 scenic_spot: false, type_index: 0, - choose_date: '请选择入园时间', + choose_date: '请选择开始时间', //酒店相关 hotel: false, live_date: '请选择入住日期', leave_date: '请选择离店日期', arrive_date: '请选择到店日期', arrive_time: '请选择到店时间', + totalLive: '',//住宿时间 //旅游路线相关 travel_route: false, - go_date: '请选择出发日期', + go_date: '请选择开始时间', back_date: '请选择回程日期', //餐厅 canteen: false @@ -405,6 +393,15 @@ } }, methods: { + compareDate(val) { + var nowTime = new Date(new Date().toLocaleDateString()).getTime(); + let oldTime = new Date(new Date(val).toLocaleDateString()).getTime(); + if(nowTime>oldTime) { + return false; + }else { + return true; + } + }, pickerChange(e) { this.choose_date = e.detail.value; console.log(e) @@ -426,6 +423,9 @@ }, leaveChange(e) { this.leave_date = e.detail.value; + let live_date = new Date(new Date(this.live_date).toLocaleDateString()).getTime(); + let leave_date = new Date(new Date(this.leave_date).toLocaleDateString()).getTime(); + this.totalLive = parseInt(Math.abs(leave_date - live_date) / 1000 / 60 / 60 / 24); }, chooseType(index) { this.type_index = index; @@ -498,8 +498,105 @@ }, // 跳转到确认下单页面 toAddOrder(){ - let goods_id = this.goods_detail.id; - this.$url('/pages/order/confirm_order?goods_id='+ goods_id); + //0旅游路线1酒店2景区3餐厅 + if(this.goods_detail.product.type == 2) { + //景区 + if(this.choose_date != '请选择开始时间') { + let date_compare = this.compareDate(this.choose_date); + console.log(date_compare) + if(date_compare){ + let goods_id = this.goods_detail.id; + let godds_type = this.goods_detail.product.type; + let enter_time = this.choose_date; + let spec_id = this.goods_detail.product.spec[this.type_index].id; + let type_text = this.goods_detail.product.spec[this.type_index].name; + this.$url('/pages/order/confirm_order?goods_id='+ goods_id+ '&spec_id='+ spec_id +'&goods_type='+godds_type+'&enter_time='+enter_time+'&goods_typetext='+type_text); + }else { + this.$msg('请选择正确的开始时间!'); + } + }else { + this.$msg('请选择开始时间!'); + } + }else if(this.goods_detail.product.type == 1) { + let date1 = false; + let date2 = false; + let date3 = false; + if(this.live_date != '请选择入住日期') { + let date_compare = this.compareDate(this.live_date); + if(date_compare){ + date1 = true; + }else { + this.$msg('请选择正确的入住日期!'); + return + } + }else { + this.$msg('请选择入住日期!'); + return + } + if(this.leave_date != '请选择离店日期') { + let date_compare = this.compareDate(this.leave_date); + if(date_compare){ + date2 = true; + }else { + this.$msg('请选择正确的离店日期!'); + return + } + }else { + this.$msg('请选择离店日期!'); + return + } + if(this.arrive_date != '请选择到店日期') { + let date_compare = this.compareDate(this.arrive_date); + if(date_compare){ + date3 = true; + }else { + this.$msg('请选择正确的到店日期!'); + return + } + }else { + this.$msg('请选择到店日期!'); + return + } + if(this.arrive_time == '请选择到店时间') { + this.$msg('请选择到店时间!'); + return + } + if(date1&&date2&&date3) { + let arrival_timedate = this.arrive_date + ' ' + this.arrive_time + console.log(arrival_time) + let goods_id = this.goods_detail.id; + let godds_type = this.goods_detail.product.type; + let spec_id = this.goods_detail.product.spec[this.type_index].id; + let type_text = this.goods_detail.product.spec[this.type_index].name; + //酒店 + let check_in_time = this.live_date; + let check_out_time = this.leave_date; + let totalLive = this.totalLive; + let arrival_time = arrival_timedate; + this.$url('/pages/order/confirm_order?goods_id='+ goods_id+ '&spec_id='+ spec_id +'&goods_type='+godds_type+'&check_in_time='+check_in_time+'&goods_typetext='+type_text+'&check_out_time='+check_out_time+'&arrival_time='+arrival_time+'&totalLive='+totalLive); + } + }else if(this.goods_detail.product.type == 0) { + if(this.go_date != '请选择开始时间') { + let date_compare = this.compareDate(this.go_date); + console.log(date_compare) + if(date_compare){ + let goods_id = this.goods_detail.id; + let godds_type = this.goods_detail.product.type; + let departure_time = this.go_date; + let spec_id = this.goods_detail.product.spec[this.type_index].id; + let type_text = this.goods_detail.product.spec[this.type_index].name; + this.$url('/pages/order/confirm_order?goods_id='+ goods_id+ '&spec_id='+ spec_id +'&goods_type='+godds_type+'&departure_time='+departure_time+'&goods_typetext='+type_text); + }else { + this.$msg('请选择正确的开始时间!'); + } + }else { + this.$msg('请选择开始时间!'); + } + } + + + // let goods_id = this.goods_detail.id; + // this.$url('/pages/order/confirm_order?goods_id='+ goods_id); }, // 预览图片 lookImg(index){ diff --git a/pages/order/confirm_order.vue b/pages/order/confirm_order.vue index 130e8ba..48dfea5 100644 --- a/pages/order/confirm_order.vue +++ b/pages/order/confirm_order.vue @@ -14,17 +14,17 @@ - + 身份证号码 - + 性别 - + 年龄 - + @@ -63,17 +63,42 @@ --> - - 套餐类型 - 大床房 + + + + 套餐类型 + {{goods_typetext}} + + + 酒店住房日期 + {{check_in_time}}-{{check_out_time}} 共{{totalLive}}晚 + + + 到店时间 + {{arrival_time}} + - - 酒店住房日期 - 09月22日-09月27日 共6晚 + + + + 套餐类型 + {{goods_typetext}} + + + 开始时间 + {{enter_time}} + - - 到店时间 - 09月22日 16:00 + + + + 套餐类型 + {{goods_typetext}} + + + 开始时间 + {{departure_time}} + @@ -153,16 +178,44 @@ pay_order_id: 0, vertify_code: '', sex: '', - age: '' + age: '', + goods_type: 0, + spec_id: 0, + goods_typetext: '', + //景区 + enter_time: '', + //旅游路线 + departure_time: '', + return_time: '', + //酒店 + check_in_time: '', + check_out_time: '', + arrival_time: '', + totalLive: '' } }, onLoad(e) { + //0旅游路线1酒店2景区3餐厅 this.goods_id = e.goods_id; + this.goods_type = e.goods_type; this.btn_type = e.btn_type; this.order_id = e.order_id; + this.spec_id = e.spec_id; this.enter_type = e.enter_type; + this.goods_typetext = e.goods_typetext; if(this.goods_id) { this.getGoodsData(this.pay_type); + if(this.goods_type == 2) { + this.enter_time = e.enter_time; + }else if(this.goods_type == 0) { + this.departure_time = e.departure_time; + }else if(this.goods_type == 1) { + this.check_in_time = e.check_in_time; + this.check_out_time = e.check_out_time; + this.arrival_time = e.arrival_time; + this.totalLive = e.totalLive; + console.log(this.check_in_time,this.check_out_time,this.arrival_time) + } } if(this.order_id && this.enter_type == 1) { console.log('con列表执行') @@ -195,8 +248,7 @@ iv, // token: userInfo.token // 已在公共参数传 }).then(res => { - this.$msg('更新成功', {icon: 'success'}); - console.log(res) + this.phone = res.data.mobile; }) } }, @@ -228,10 +280,40 @@ this.$msg('请输入联系电话!'); return; } + if(this.goods_type != 3) { + if(!this.vertify_code) { + this.$msg('请输入身份证号!'); + return; + } + if(!this.sex) { + this.$msg('请输入性别!'); + return; + } + if(!this.age) { + this.$msg('请输入年龄!'); + return; + } + } if(!this.ifPay) return; this.ifPay = false; - this.$http(this.API.API_CREATEORDER,{id: this.goods_id,num: 1,pay_type: this.pay_type,name:this.contact,mobile:this.phone}).then(res => { + this.$http(this.API.API_CREATEORDER,{ + id: this.goods_id, + num: 1, + pay_type: this.pay_type, + name:this.contact, + mobile:this.phone, + spec_id: this.spec_id, + enter_time: this.enter_time, + sex: this.sex, + age: this.age, + id_card: this.vertify_code, + departure_time: this.departure_time, + return_time: this.return_time, + check_in_time: this.check_in_time, + check_out_time: this.check_out_time, + arrival_time: this.arrival_time + }).then(res => { this.pay_order_id = res.data.id if(this.pay_type == 1) {