Commit 470be20f authored by 潘永坪's avatar 潘永坪

订单填写页面开发

parent 3c81b50e
<template>
<u-popup :show="show" :round="20" @close="show = false" closeable>
<u-popup :show="showPop" :round="20" @close="showPop = false" closeable>
<view class="son-wrap">
<view class="detail-title">
订单明细
......@@ -15,7 +15,7 @@
</view>
</view>
<!-- ---------------------------------------额外服务------------------------------------------- -->
<view class="content-box" v-for="(item, index) of choooseServiceData" :key="index">
<view class="content-box" v-for="(item, index) of chooseService" :key="index">
<text>
{{ item.name }}
</text>
......@@ -45,56 +45,19 @@
<script>
export default {
props: ['merchantName', 'name', 'buyNum', 'sellingPrice', 'productDepositTotal', 'chooseCouponObj', 'choooseService'],
watch: {
choooseService: {
handler(newValue, oldValue) {
if (newValue) {
this.choooseServiceData = this.choooseService
}
},
deep: false,
immediate: false
}
},
props: [
'merchantName',
'name',
'buyNum',
'sellingPrice',
'productDepositTotal',
'chooseCouponObj',
'chooseService',
'sellTotal'
],
data() {
return {
show: false, //控制弹窗显示隐藏
extraPrice: 0, //额外服务价格
depositTotal: 0, //额外服务总押金
choooseServiceData: [] //选中的服务
}
},
computed: {
sellTotal() {
//卖价总价
let savedMoney = 0
if (this.chooseCouponObj) {
savedMoney = this.chooseCouponObj.savedMoney
}
if (this.choooseServiceData.length > 0) {
//额外服务价格
let singleMoney = 0 //单个产品总押金,用于算出总押金
this.extraPrice = 0
this.depositTotal = 0 //总押金
for (let i = 0; i < this.choooseServiceData.length; i++) {
this.extraPrice += parseFloat((this.choooseServiceData[i].sellingPrice * this.buyNum).toFixed(2))
if (this.choooseServiceData[i].depositType == 1) {
//等于1,押金金额跟数量没关系
singleMoney = this.choooseServiceData[i].deposit
this.choooseServiceData[i].depositTotal = this.choooseServiceData[i].deposit //单个产品总押金
} else if (this.choooseServiceData[i].depositType == 2) {
//等于2,押金单价乘购买数量
singleMoney = parseFloat((this.choooseServiceData[i].deposit * this.buyNum).toFixed(2))
this.choooseServiceData[i].depositTotal = parseFloat((this.choooseServiceData[i].deposit * this.buyNum).toFixed(2)) //单个产品总押金
}
this.depositTotal += singleMoney
}
} else {
this.extraPrice = 0
this.depositTotal = 0
}
return parseFloat((this.sellingPrice * this.buyNum + this.extraPrice + this.depositTotal + this.productDepositTotal - savedMoney).toFixed(2))
showPop: false, //控制弹窗显示隐藏
}
},
......
......@@ -123,6 +123,55 @@
</view>
</view>
</view>
<!-- -----------------------------有可用优惠券,并且未选中----------------------------------------------------- -->
<!-- <div class="middle1Coupon" v-if="couponData.masterSlaveCouponList&&couponData.masterSlaveCouponList.length>0&&chooseCouponObj==''" @click="showCoupon()">
<span>
</span>
<span>
{{couponData.masterSlaveCouponList[0].couponName}}
</span>
<span>
未选优惠券
<svg class="icon" aria-hidden="true" style="font-size: 0.24rem;color: #666666;">
<use xlink:href="#iconyou"></use>
</svg>
</span>
</div> -->
<!-- -----------------------------有可用优惠券----------------------------------------------------- -->
<!-- <div class="middle1Coupon" v-if="chooseCouponObj!=''&&savedMoney>0" @click="showCoupon()">
<span>
</span>
<span>
<b>{{chooseCouponObj.couponName}}</b>
</span>
<span>
<i></i><i>{{parseFloat(savedMoney.toFixed(2))}}</i>
<svg class="icon" aria-hidden="true" style="font-size: 0.24rem;color: #666666;">
<use xlink:href="#iconyou"></use>
</svg>
</span>
</div> -->
<!-- -----------------------------------------------可用优惠券条件--------------------------------------- -->
<!-- <div class="middle1Coupon" v-if="ableConpon!=''" @click="showCoupon()">
<span>
</span>
<span>
<b>{{ableConpon.couponName}}</b>
</span>
<span>
{{ableConpon.couponRule}}
<svg class="icon" aria-hidden="true">
<use xlink:href="#iconyou"></use>
</svg>
</span>
</div> -->
<!-- --------------------------------------------额外服务部分-------------------------------------------- -->
<view class="extraService" v-if="serviceList.length>0&&showErmai">
<checkbox-group @change="extraChange">
......@@ -136,7 +185,7 @@
<view>
<text style="font-size: 24rpx;">¥</text>
<text style="font-size: 32rpx;margin-right: 20rpx;">{{item.sellingPrice}}</text>
<checkbox class="blue" :value="JSON.stringify(item)" style="transform: scale(0.7);" />
<checkbox class="blue" :value="JSON.stringify(item)" style="transform: scale(0.7);" :checked="item.ifChoose" />
</view>
</label>
</view>
......@@ -265,12 +314,14 @@
<buyKnow ref="buyKnow" :buyKnowData="buyKnowData"></buyKnow>
<detail
ref="detail"
:sellTotal='sellTotal'
:merchantName="productIfo.merchantName"
:name="productIfo.name"
:buyNum="buyNum"
:sellingPrice="sellingPrice"
:choooseService="choooseService"
:chooseService="chooseService"
:productDepositTotal="productDepositTotal"
:chooseCouponObj="chooseCouponObj"
></detail>
<chooseArea
v-if="showArea"
......@@ -287,7 +338,7 @@
:contactTotal="contactTotal"
:contactNum="contactNum"
></contactList>
<orderCoupon :couponData="couponData" ref="orderCoupon" @couponChoose="couponChoose" :chooseCouponObj="chooseCouponObj"></orderCoupon>
<!--一个站点时获取排队信息弹窗-->
<!-- <u-popup :show="sortInforPop" :round="10" closeable @close="sortInforPop = false">
<view style="padding: 40rpx 60rpx">
......@@ -321,6 +372,7 @@
<script>
import calendar from '../scenicComponents/calendar' //日历组件
import buyKnow from '@/components/buyKnow.vue' //购票须知
import orderCoupon from '@/components/orderCoupon' //优惠券
import detail from '../scenicComponents/detail.vue' //明细弹窗
import chooseArea from '../scenicComponents/chooseArea' //选择站点
import contactList from '../scenicComponents/contactList' //联系人弹窗
......@@ -335,7 +387,8 @@ export default {
contactList,
editContacts,
times,
chooseArea
chooseArea,
orderCoupon
},
data() {
return {
......@@ -359,8 +412,8 @@ export default {
merchantId: '', //商户Id
ticketPhone: '', //联系电话
productIfo: '', //初始化产品基本信息
originalPrice: 0, //原价
sellingPrice: 0, //卖价
originalPrice: 0, //原价单价
sellingPrice: 0, //卖价单价
interfaceCode: '', //接口编号
merchantCode: '', //商户code
productCode: '', //产品code
......@@ -379,11 +432,10 @@ export default {
flag: '', //setTimeout函数
savedMoney: 0, //优惠价格
serviceList: [], //所有额外服务
choooseService: [], //选中的额外服务
chooseService: [], //选中的额外服务
extraPrice: 0, //额外服务总价格
showExtraPop: false, //控制支付时有额外服务,没有选中额外服务的弹窗显示隐藏
orderProductList: [], //额外服务,儿童票等入参
extraextraDepositTotal: 0, //额外服务总押金
productDepositTotal: 0, //产品总押金
orderSource: '', //订单来源 1公众号平台、2公众号组合页面1、3公众号组合页面2、4胖丁伙伴app、5第三方自助机、6第三方票房窗口
thirdOpenid: '', //第三方openid
......@@ -392,7 +444,10 @@ export default {
docQuery: '', //元素变量
payBackground: '', //支付按钮背景颜色
dateScroll: '', //日期滚动值
timeScroll: '' //时间滚动值
timeScroll: '' ,//时间滚动值
openid:uni.getStorageSync('openid') || '',//openid
couponData: '', //所有劵数据
chooseCouponObj: '', //默认选中最优价格优惠券
}
},
onLoad(option) {
......@@ -409,19 +464,19 @@ export default {
computed: {
originalTotal() {
//原价总价
if (this.choooseService.length > 0) {
if (this.chooseService.length > 0) {
//额外服务价格和押金总价格
let singleProduct = 0 //单个产品押金
this.extraPrice = 0
this.extraDepositTotal = 0 //总押金
for (let i = 0; i < this.choooseService.length; i++) {
this.extraPrice += parseFloat((this.choooseService[i].sellingPrice * this.buyNum).toFixed(2))
if (this.choooseService[i].depositType == 1) {
for (let i = 0; i < this.chooseService.length; i++) {
this.extraPrice += parseFloat((this.chooseService[i].sellingPrice * this.buyNum).toFixed(2))
if (this.chooseService[i].depositType == 1) {
//等于1,押金金额跟数量没关系
singleProduct = this.choooseService[i].deposit
} else if (this.choooseService[i].depositType == 2) {
singleProduct = this.chooseService[i].deposit
} else if (this.chooseService[i].depositType == 2) {
//等于2,押金单价乘购买数量
singleProduct = parseFloat((this.choooseService[i].deposit * this.buyNum).toFixed(2))
singleProduct = parseFloat((this.chooseService[i].deposit * this.buyNum).toFixed(2))
}
this.extraDepositTotal += singleProduct
}
......@@ -445,7 +500,7 @@ export default {
},
sellTotal() {
//卖价总价
if (this.choooseService.length == 0) {
if (this.chooseService.length == 0) {
this.extraPrice = 0
this.extraDepositTotal = 0
}
......@@ -478,21 +533,13 @@ export default {
}
})
},
//---额外服务多选框变化
extraChange(e) {
this.choooseService=[]
let value=e.detail.value
value.forEach(item=>{
this.choooseService.push(JSON.parse(item))
})
},
//---获取子组件的传值
areaSure(data) {
this.areaObj = data
if (this.areaObj.areaCode == 'cjsd_project_0001') {
//选择了南站不显示耳麦
this.showErmai = false
this.choooseService = []
this.chooseService = []
} else {
this.showErmai = true
}
......@@ -507,7 +554,7 @@ export default {
},
//---展示详情弹窗
showDetail() {
this.$refs.detail.show = true
this.$refs.detail.showPop = true
},
//---展示日历
showCalendar() {
......@@ -672,7 +719,7 @@ export default {
this.beforeBookDays = res.data.beforeBookDays || 0 //提前预定天数
this.buyKnowData = res.data //购买须知,传给子组件
this.serviceList = res.data.loadProductResVoList //额外服务
//this.choooseService=res.data.data.loadProductResVoList//默认全部选中
//this.chooseService=res.data.data.loadProductResVoList//默认全部选中
if (this.productIfo.status == 1) {
//下架状态
this.payBackground = '#C0C0C0'
......@@ -861,7 +908,7 @@ export default {
//---初始化联系人列表
getContactList() {
let data = {
openid: uni.getStorageSync('openid') || ''
openid:this.openid
}
this.$request('wechatUser/contact/findContactList', data).then(res => {
if (res.code == '00') {
......@@ -895,7 +942,7 @@ export default {
//---添加并选中联系人--用于添加联系人之后直接从联系人列表选出需要填写的几位联系人
addChoose() {
let data = {
openid: uni.getStorageSync('openid') || ''
openid:this.openid
}
this.$request('wechatUser/contact/findContactList', data).then(res => {
if (res.code == '00') {
......@@ -915,15 +962,91 @@ export default {
}
})
},
//---加载优惠券(暂未开发)
initCoupon() {
let savedMoneyList = []
this.chooseCouponObj = ''
this.ableConpon = ''
let data = {
productId: this.productId, //产品id
tickets: this.buyNum, //房间数量
singleMoney: this.sellingPrice, //单价
money: parseFloat((this.buyNum * this.sellingPrice).toFixed(2)), //订单总价,不算券,和现金红包
merchantId: this.merchantId, //商户Id
openid:this.$store.state.openId
}
this.axios.post(this.wechatUserJs.usableCouponList(), data).then((res) => {
if (res.data.code == '00') {
this.couponData = res.data.data
let masterSlaveCouponList=res.data.data.masterSlaveCouponList
if (masterSlaveCouponList&&masterSlaveCouponList.length>0) {
masterSlaveCouponList.forEach((item) => { //获取最优券
savedMoneyList.push(item.savedMoney)
})
let maxMoney = Math.max.apply(null, savedMoneyList)
let arr=masterSlaveCouponList.filter((item)=>{//找到最大值的数组
return item.savedMoney==maxMoney
})
if(arr.length==1){
this.chooseCouponObj=arr[0]
}else{
let index=arr.findIndex((item)=>{//如果有多个,找到是否有平台券,平台劵优先
return item.createSource==1
})
if(index>-1){
this.chooseCouponObj=arr[index]
}else{
this.chooseCouponObj=arr[0]
}
}
this.savedMoney=this.chooseCouponObj.savedMoney
} else {
if (res.data.data.unusableCouponList.length > 0) {
res.data.data.unusableCouponList.forEach((item, i) => { //没有可用优惠券,有达到条件可以用的优惠券,先显示条件,达到条件时显示可用优惠券
if (item.isProduct == 1) {
this.ableConpon = item
}
})
}
}
}
})
},
//---获取优惠价格
getDiscountPrice() {
let data = {
productId: this.productId, //产品ID
merchantId: this.merchantId, //商家ID
companyId: this.companyId, //公司ID
openid: uni.getStorageSync('openid') || '' //openid
openid: this.openid //openid
}
this.$request('scenic/user/productRule/getProductRule', data).then(res => {})
},
//---子组件券选择之后触发的事件
couponChoose(data) {
if(data){
this.chooseCouponObj = data
this.savedMoney=this.chooseCouponObj.savedMoney||0
}else{
this.chooseCouponObj = ''
this.savedMoney=0
}
},
//---展示券列表
showCoupon() {
this.$refs.orderCoupon.showCoupon()
},
//---额外服务多选框变化
extraChange(e) {
this.chooseService=[]
//解决数据修改之后,多选框未选中bug
this.serviceList.forEach(item=>{
item.ifChoose=false
})
let value=e.detail.value
value.forEach(item=>{
this.chooseService.push(JSON.parse(item))
})
},
//---不需要享受耳麦服务
extraNo() {
......@@ -933,7 +1056,10 @@ export default {
//---需要享受耳麦服务
extraYes() {
this.showExtraPop = false
this.choooseService = this.serviceList
this.serviceList.forEach(item=>{
item.ifChoose=true
})
this.chooseService = this.serviceList
this.placeOrder()
},
//---点击去支付
......@@ -944,7 +1070,7 @@ export default {
}
if (this.serviceList.length > 0) {
//有额外服务,并且选择了额外服务的,直接支付
if (this.choooseService.length > 0) {
if (this.chooseService.length > 0) {
this.placeOrder()
}
}
......@@ -999,11 +1125,11 @@ export default {
return
}
}
if (this.choooseService.length == 0 && this.showErmai) {
if (this.chooseService.length == 0 && this.showErmai) {
//没有购买额外服务,并且选择的北站,跳出弹窗
this.showExtraPop = true
}
if (this.choooseService.length == 0 && !this.showErmai) {
if (this.chooseService.length == 0 && !this.showErmai) {
//没有购买额外服务,并且选择的南站,直接购买
this.placeOrder()
}
......@@ -1080,94 +1206,112 @@ export default {
},
//---预下单
preOrder() {
//时间戳转化
let bookStartTime = ''
if (this.$commonjs.today() == this.startDate.substr(0, 10)) {
//如果是当天就取当前时间+10秒
bookStartTime = new Date().getTime() + 10 * 1000
} else {
//不是当天就取开始时间
//手机兼容
let startDate = this.startDate.replace(/-/g, '/')
bookStartTime = new Date(startDate).getTime()
}
//手机兼容
let endDate = this.endDate.replace(/-/g, '/')
let bookEndTime = new Date(endDate).getTime()
//参数游客信息组装
let reservationInfoList = []
this.chooseContact.forEach((item, index) => {
reservationInfoList.push({
let orderTouristList = this.contactTotal.map((item) => {
return {
category: 0,
name: item.name,
identificationNumber: item.credentialNumber
})
credentialNumber: item.credentialNumber
}
})
//商品库 spu & 非商品库 sku
tt.createOrder({
skuList: [
{
skuId: this.productIfo.distributionProductId, // sku 商品Id 必传
skuType: 1, // sku 商品类型 必传 1-商品库商品 2-非商品库商品
quantity: this.buyNum, // 数量 必传
price: parseFloat((this.sellingPrice * 100).toFixed(2)), // 价格 非商品库 sku 商品必传
goodsInfo: {
goodsName: this.productIfo.name, // 商品名称
goodsPhoto: 'http://picture.pangdly.com/company/2022-02/2022-02-10/zip/z001644484223062b28c62cc60b0c65e.jpg', // 商品图片链接
goodsId: this.productIfo.distributionProductId, // 商品ID
goodsType: 1, //1-商品库商品2-非商品库商品
GoodsBookInfo: {
bookType: 1 //预约类型:1. 不需要预约 2. 在线预约
}
let couponList = []
if (this.chooseCouponObj) {
if(this.chooseCouponObj.slaveList.length>0){//有从卷取值从卷,没有从卷取值主劵
couponList=[//券列表
{
couponId:this.chooseCouponObj.slaveCouponId,//券id
isMerchant:this.chooseCouponObj.slaveCreateSource,//是否是商户的券
myCouponId:this.chooseCouponObj.slaveId,//领取人编号
couponType:this.chooseCouponObj.couponType,//券类型
couponPrice:this.chooseCouponObj.savedMoney,//券价格
}
// extraInfo: {
// ticketName: '成人票', // 票种,非商品库门票类 sku 必传
// date: '2023-05-16', // 日期,非商品库门票类 sku 必传
// },
}
],
bookInfo: {
itemBookInfoList: [
]
}else{
couponList=[
{
poiId: this.productIfo.poiId, // 预约门店的 poiId,必填
shopName: this.productIfo.merchantName, // 预约店铺名称,必填
outShopId: this.productIfo.merchantId, // 预约门店的外部店铺id,必填
goodsId: this.productIfo.distributionProductId, // 商品id,必填
bookStartTime, // 预定开始时间(ms),13位毫秒时间戳,必填
bookEndTime, //预定结束时间(ms),13位毫秒时间戳,必填
reservationInfoList // 留资信息 非必填
couponId:this.chooseCouponObj.couponId,//券id
isMerchant:this.chooseCouponObj.createSource,//是否是商户的券
myCouponId:this.chooseCouponObj.id,//领取人编号
couponType:this.chooseCouponObj.couponType,//券类型
couponPrice:this.chooseCouponObj.savedMoney,//券价格
}
]
},
payment: {
totalAmount: parseFloat((this.buyNum * this.sellingPrice * 100).toFixed(2)) // 订单总价 必填
},
contactInfo: {
//联系人
phoneNumber: this.ticketPhone // 手机号 非必传
},
callbackData: {
productAreaCode: this.areaObj.areaCode || this.defaultAreaCode //站点信息
},
success: res => {
const { orderId, outOrderNo } = res
uni.navigateTo({
url: '/pages/salePay/paySuccess/paySuccess?orderId=' + outOrderNo
})
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res
if (errLogId) {
console.log('预下单失败', errNo, errMsg, errLogId)
}
}
//额外服务不为空,联票购买不为空,带有儿童票,组合购买不为空,单品购买为空
if (this.chooseService.length > 0) {
this.orderProductList = this.chooseService.map((item) => {
return {
distributionPrice: item.sellingPrice, //临时用
productId: item.id, //产品Id
buyNum: this.buyNum, //购买数量
subOrderType: 0, //产品类型,网络
unitPrice: item.sellingPrice, //产品单价
merchantId: item.merchantId, //商户id
orderTouristList, //游客信息
playDate: this.startDate.substr(0, 10), //开始日期
endPlayDate: this.endDate.substr(0, 10), //结束日期
isMaster: 1, //是否主产品 1 否, 0 是
startPlayTime: this.startPlayTime, //开始时间
endPlayTime: this.endPlayTime, //结束时间
}
if (errMsg || errNo) {
console.log('支付失败', errNo, errMsg, orderId, outOrderNo)
})
}else{
this.orderProductList=[]
}
let data = {
companyId: this.companyId, //公司Id
buyMethod: 1, // 单品购买,2套票、联票购买,3组合购买
userId: this.openid,//用户id
ticketPhone: this.ticketPhone, //联系电话
cash: 0, //现金红包
orderMoney: this.sellTotal, //订单总价 = 订单原价 - 优惠券价格 - 现金抵扣价格
orderType: 1, //订单类型,景区
orderSource:this.orderSource||1, //订单来源 1公众号平台、2公众号组合页面1、3公众号组合页面2、4胖丁伙伴app、5第三方自助机、6第三方票房窗口
orderProductList: this.orderProductList, //额外服务不为空,联票购买不为空,带有儿童票,组合购买不为空,单品购买为空
orderProductVo: //产品信息列表
{
bookTime:this.productIfo.bookTime,//最晚预定时间
earlyBookTime:this.productIfo.earlyBookTime,//最早预定时间
extendContent:'{"openid":'+'"'+this.openid+'"'+','+'"zr":'+'"'+this.thirdOpenid+'"'+'}',
productId: this.productId, //产品Id
buyNum: this.buyNum, //购买数量
subOrderType: 0, //产品类型,网络
cruisePlanId: this.cruisePlanId, //班次id
unitPrice: this.sellingPrice, //产品单价
distributionPrice: this.sellingPrice, //临时用
merchantId: this.merchantId, //商户id
orderTouristList, //游客信息
playDate: this.startDate.substr(0, 10), //开始日期
endPlayDate: this.endDate.substr(0, 10), //结束日期
isMaster: 0, //是否主产品 1 否, 0 是
startPlayTime: this.startPlayTime, //开始时间
endPlayTime: this.endPlayTime, //结束时间
productAreaCode:this.areaObj.areaCode, //选择的站点编码
couponList, //券列表
}
}
uni.showLoading({
title:'加载中',
mask:true
})
this.$request('orderc/order/createOrder', data).then((res) => {
if (res.code == '00') {
if (res.data.id) {
uni.navigateTo({
url: '/pages/payment/orderPayment/orderPayment?orderId='+res.data.id
})
} else {
uni.showToast({
title: '下单失败',
icon: 'none'
})
}
} else {
uni.showToast({
title: errMsg,
icon: 'none',
duration: 3000
title: res.message,
icon: 'none'
})
}
})
......@@ -1628,13 +1772,13 @@ export default {
.bottom-btn {
position: relative;
width: 200rpx;
width: 240rpx;
height: 80rpx;
margin-left: 20rpx;
line-height: 80rpx;
font-size: 32rpx;
font-weight: bolder;
border-radius: 16rpx;
border-radius: 24rpx;
background: $red;
text-align: center;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment