|
|
<template> <view v-if="$isRight(goods_details)"> <view class="bg-white" v-if="enter_type!=1"> <view class="cu-bar1 padding-lr"> <text class="lf-color-555 lf-font-28">联系人</text> <input type="text" v-model="contact" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入联系人" /> </view> <view class="cu-bar1 padding-lr"> <text class="lf-color-555 lf-font-28">联系方式</text> <view class="lf-row-between"> <input type="text" v-model="phone" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入联系电话" maxlength="11" /> </view> <button style="position: absolute;right: 0rpx;" class="lf-bg-white" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"> <u-icon name="phone"></u-icon> </button> </view> <view class="cu-bar1 padding-lr" v-if="goods_type!=3"> <text class="lf-color-555 lf-font-28">身份证号码</text> <input type="text" v-model="vertify_code" @blur="computedAge()" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入身份证号码"/> </view> <view class="cu-bar1 padding-lr" v-if="goods_type!=3"> <text class="lf-color-555 lf-font-28">性别</text> <input type="text" v-model="sex" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入性别"/> </view> <view class="cu-bar1 padding-lr" v-if="goods_type!=3"> <text class="lf-color-555 lf-font-28">年龄</text> <input type="number" v-model="age" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入年龄"/> </view> </view> <self-line/> <view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32"> <view class="lf-row-between"> <image :src="goods_details.picture" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 20rpx;"></image> <view class="flex-sub padding-left-sm"> <view class="bref-box lf-font-32 lf-color-333 lf-line-2" style="height: 88rpx;line-height: 44rpx;"> {{goods_details.title}} </view> <view class="flex lf-m-t-25 align-center text-center"> <text class="block lf-color-gray lf-font-24" style="line-height: 40rpx;">数量</text> <text class="lf-m-l-10 lf-color-gray lf-font-24">x {{goods_details.num}}</text> </view> <view class="flex align-center text-center lf-m-t-25"> <lf-price :price="goods_details.price" /> <view class="lf-m-l-20 lf-line-through lf-color-gray"> {{goods_details.original_price}} </view> </view> </view> </view> </view> <!-- <self-line/> <view class="bg-white"> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">优惠</text> <view v-if="goods_details.coupon != ''"> <text class="lf-color-price lf-font-28 lf-m-l-10" v-for="(item,index) of goods_details.coupon">{{item.tag}}</text> </view> <view v-else> <text class="lf-color-price lf-font-28 lf-m-l-10">暂无优惠</text> </view> </view> </view> --> <self-line/> <view class="bg-white" v-if="enter_type!=1"> <!-- 酒店 --> <view v-if="goods_type == 1"> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">套餐类型</text> <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text> </view> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">酒店住房日期</text> <text class="lf-font-28" style="color: #131315;">{{check_in_time}}-{{check_out_time}} 共{{totalLive}}晚</text> </view> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">到店时间</text> <text class="lf-font-28" style="color: #131315;">{{arrival_time}}</text> </view> </view> <!-- 景区 --> <view v-if="goods_type == 2"> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">套餐类型</text> <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text> </view> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">开始时间</text> <text class="lf-font-28" style="color: #131315;">{{enter_time}}</text> </view> </view> <!-- 旅游路线 --> <view v-if="goods_type == 0"> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">套餐类型</text> <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text> </view> <view class="cu-bar padding-lr"> <text class="lf-color-555 lf-font-28">开始时间</text> <text class="lf-font-28" style="color: #131315;">{{departure_time}}</text> </view> </view> </view> <self-line/> <view class="bg-white" v-if="enter_type!=1"> <view class="lf-p-t-30 lf-p-l-32 lf-p-b-36"> <view class="lf-font-28 lf-color-555">支付方式</view> </view> <view class="lf-p-r-32 lf-p-l-32"> <button class="cu-btn bg-white margin-self" :class="pay_type==0?'border-green':'border'" @tap="payStatus(0)"> <text class="lf-iconfont lf-icon-weixin text-green lf-font-44 lf-m-r-23"></text> <text class="lf-font-32" :class="pay_type==0?'text-green':'lf-color-333'">微信支付</text> <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==0" style="position: absolute;right: 22rpx;"></text> </button> </view> <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30"> <button class="cu-btn bg-white margin-self" :class="pay_type==1?'border-green':'border'" @tap="payStatus(1)"> <text class="lf-font-32" :class="pay_type==1?'text-green':'lf-color-333'">线下支付</text> <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==1" style="position: absolute;right: 22rpx;"></text> </button> </view> <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30" v-if="goods_details.deposit != '0.00'"> <button class="cu-btn bg-white margin-self" :class="pay_type==2?'border-green':'border'" @tap="payStatus(2)"> <text class="lf-font-32" :class="pay_type==2?'text-green':'lf-color-333'">订金支付</text> <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==2" style="position: absolute;right: 22rpx;"></text> </button> </view> <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30"> <button class="cu-btn bg-white margin-self" v-if="goods_details.earnest != '0.00'" :class="pay_type==3?'border-green':'border'" @tap="payStatus(3)"> <text class="lf-font-32" :class="pay_type==3?'text-green':'lf-color-333'">定金支付</text> <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==3" style="position: absolute;right: 22rpx;"></text> </button> </view> <!-- <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30"> <button class="cu-btn bg-white margin-self" :class="pay_type==4?'border-green':'border'" @tap="payStatus(4)"> <text class="lf-font-32" :class="pay_type==4?'text-green':'lf-color-333'">首款支付</text> <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==4" style="position: absolute;right: 22rpx;"></text> </button> </view> --> </view> <view style="height: 200rpx;"></view> <view class="btn-bottom solid-top1"> <view class="padding-lr lf-p-t-10 lf-p-b-10 bg-white flex justify-between align-center shadow"> <view class="flex align-center"> <text class="lf-font-24 lf-font-555">应付款:</text> <lf-price :price="goods_details.final_price" /> </view> <button class="btn" @tap="submit"> <text class="lf-font-32 text-white" v-if="btn_type == 1">下单付款</text> <text class="lf-font-32 text-white" v-else>支付尾款</text> </button> </view> </view> </view></template>
<script> export default { data() { return { goods_id: 0, goods_details: {}, contact: '', phone: '', pay_type: 0, btn_type: 1, ifPay: true, order_id: 0, enter_type: 0, payState: true, pay_order_id: 0, vertify_code: '', sex: '', 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列表执行') this.payOnce() } }, onShow(e) { let that = this uni.$on('payState',(data) => { that.payState = data.msg; that.pay_order_id = data.payorder_id; console.log('传来的订单id',that.pay_order_id) if(that.payState == true) { that.$url('/pages/payState/paystate?ifSuccess=1&order_id='+that.pay_order_id,{type: 'redirect'}) }else { that.$url('/pages/payState/paystate?ifSuccess=2&order_id='+that.pay_order_id,{type: 'redirect'}) } }) }, onUnload() { uni.$off('payState'); }, methods: { computedAge() { this.$check(this.vertify_code,'card'); let judge_sex = this.vertify_code[16]; let judge_birthday = this.vertify_code.substring(6,14); let now_date = new Date(); let now_date1 = this.$shared.recordTime(now_date, '-', 'date').replace(/-/g, ""); let age1 = now_date1-judge_birthday; this.age = JSON.stringify(age1).substring(0,2) if(judge_sex%2) { this.sex = '男'; }else { this.sex = '女'; } }, getPhoneNumber(event){ if(event.detail.errMsg == 'getPhoneNumber:ok'){ let encryptedData = event.detail.encryptedData; let iv = event.detail.iv; this.$http(this.API.API_WECHAT_SETPHONE, { encryptedData, iv, // token: userInfo.token // 已在公共参数传
}).then(res => { this.phone = res.data.mobile; }) } }, payStatus(type) { if(type == this.pay_type) { this.pay_type = type; return }else { this.pay_type = type; this.getGoodsData(type); } }, getGoodsData(type){ this.$http(this.API.API_CONFIRMDETAILS,{id: this.goods_id,num: 1,pay_type: type}).then(res => { this.goods_details = res.data; console.log('数据',res) }) }, submit() { if(this.order_id && this.enter_type == 1) { this.payOnce() return } if(!this.contact) { this.$msg('请输入联系人!'); return; } if(!this.phone) { 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, 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) { this.ifPay = true this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+res.data.id,{type: 'redirect'}) }else if(res.data.jump == true) { let that = this; wx.navigateToMiniProgram({ appId: res.data.jump_appid, path: '/pages/order/confirm_atonce', envVersion: 'release', extraData: { order_id: res.data.id }, success(res) { console.log('---res---'); that.ifPay = true; console.log(res); }, fail(err) { console.log('---err---'); console.log(err); that.ifPay = true; } }) } }).catch(err => { this.ifPay = true }) }, payOnce() { this.$http(this.API.API_ORDERPAY,{id: this.order_id}).then(res => { if(res.data.jump) { wx.navigateToMiniProgram({ appId: res.data.jump_appid, path: '/pages/order/confirm_atonce', envVersion: 'release', extraData: { order_id: res.data.id }, success(res) { console.log('---res---') console.log(res) }, fail(err) { console.log('---err---') console.log(err) } }) } }).catch(err => {}) } } }</script>
<style scoped lang="scss"> .cu-bar1 { display: flex; position: relative; align-items: center; min-height: 100rpx; } .btn{ margin: 0; padding: 0; width: 212rpx; height: 82rpx; background-color: #1998FE; color: #FFFFFF; line-height: 80rpx; font-size: 32rpx; border-radius: 41rpx; } .bref-box { text-overflow: -o-ellipsis-lastline; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }</style>
|