Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
U
uni-pdtravel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
panyongping
uni-pdtravel
Commits
e93cc300
Commit
e93cc300
authored
Dec 18, 2023
by
潘永坪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
组合下单和单产品下单优化
parent
38e2578c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
339 additions
and
318 deletions
+339
-318
request.js
common/request.js
+2
-1
main.js
main.js
+1
-1
scenicCombiOrder.vue
pages/scenic/scenicCombiOrder/scenicCombiOrder.vue
+105
-86
scenicOrder.vue
pages/scenic/scenicOrder/scenicOrder.vue
+231
-230
No files found.
common/request.js
View file @
e93cc300
var
baseUrl
=
''
var
baseUrl
=
''
if
(
process
.
env
.
NODE_ENV
===
'development'
){
//开发环境
if
(
process
.
env
.
NODE_ENV
===
'development'
){
//开发环境
baseUrl
=
'http://pay.tuyoyoo.com/'
// baseUrl= 'http://pay.tuyoyoo.com/'
baseUrl
=
'http://192.168.0.213:7888/'
}
else
{
}
else
{
baseUrl
=
'https://manager.pangdly.com/'
baseUrl
=
'https://manager.pangdly.com/'
}
}
...
...
main.js
View file @
e93cc300
...
@@ -8,7 +8,7 @@ import commonjs from 'common/common.js'
...
@@ -8,7 +8,7 @@ import commonjs from 'common/common.js'
Vue
.
prototype
.
$commonjs
=
commonjs
Vue
.
prototype
.
$commonjs
=
commonjs
Vue
.
prototype
.
$request
=
request
Vue
.
prototype
.
$request
=
request
Vue
.
prototype
.
$wxurl
=
'https://
w
x.pangdly.com/#/'
Vue
.
prototype
.
$wxurl
=
'https://
l
x.pangdly.com/#/'
Vue
.
prototype
.
imageError
=
'@/static/img/common/pangdingLogo.png'
Vue
.
prototype
.
imageError
=
'@/static/img/common/pangdingLogo.png'
Vue
.
use
(
uView
)
Vue
.
use
(
uView
)
uni
.
$u
.
config
.
unit
=
'rpx'
uni
.
$u
.
config
.
unit
=
'rpx'
...
...
pages/scenic/scenicCombiOrder/scenicCombiOrder.vue
View file @
e93cc300
...
@@ -262,7 +262,10 @@
...
@@ -262,7 +262,10 @@
<view
class=
"bottom-btn"
:style=
"{ background: payBackground }"
>
<view
class=
"bottom-btn"
:style=
"{ background: payBackground }"
>
<text
v-if=
"orderStatus == 1"
>
已下架
</text>
<text
v-if=
"orderStatus == 1"
>
已下架
</text>
<text
v-if=
"orderStatus!= 1"
@
click=
"goPay()"
>
去支付
</text>
<
template
v-else
>
<text
v-if=
"parseInt(maxBookNum)
<1
"
>
暂无库存
</text>
<text
v-if=
"parseInt(maxBookNum)>0"
@
click=
"goPay()"
>
去支付
</text>
</
template
>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -384,6 +387,7 @@ export default {
...
@@ -384,6 +387,7 @@ export default {
contactTotal
:
[],
//所有联系人列表
contactTotal
:
[],
//所有联系人列表
originalTotal
:
0
,
//原价总价
originalTotal
:
0
,
//原价总价
sellTotal
:
0
,
//卖价总价
sellTotal
:
0
,
//卖价总价
maxBookNum
:
999
,
//最大购买数量
}
}
},
},
onLoad
(
option
)
{
onLoad
(
option
)
{
...
@@ -417,29 +421,12 @@ export default {
...
@@ -417,29 +421,12 @@ export default {
this
.
productIdList
=
this
.
productList
.
map
((
item
)
=>
{
//id集合用于请求价格库存列表接口
this
.
productIdList
=
this
.
productList
.
map
((
item
)
=>
{
//id集合用于请求价格库存列表接口
return
item
.
id
return
item
.
id
})
})
for
(
let
i
=
0
;
i
<
this
.
productList
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
productList
.
length
;
i
++
){
let
item
=
this
.
productList
[
i
]
let
item
=
this
.
productList
[
i
]
//任何一个产品需要填写游客信息,下面的联系电话必须填写
//任何一个产品需要填写游客信息,下面的联系电话必须填写
if
(
item
.
tripTemplateFlag
!=
2
){
if
(
item
.
tripTemplateFlag
!=
2
){
this
.
showTelephone
=
true
this
.
showTelephone
=
true
}
}
//需要优化
// if(item.defaultAreaCode){
// item.areaObj={}
// item.areaObj.areaCode=item.areaCode
// item.areaObj.areaName=item.areaName
// }else{
// item.areaObj={}
// }
// if(item.isFetch==1&&item.productAreaList.length>1){
// //多个排号点
// this.areaIndex=index
// this.sortUpDown(item.merchantVo.code)
// }else if(item.isFetch==1&&item.productAreaList.length==1){
// //只有一个排号点
// item.areaObj=item.productAreaList[0]
// }
item
.
dateActive
=
0
//默认选中第一个日期
item
.
dateActive
=
0
//默认选中第一个日期
item
.
buyNum
=
1
,
//默认为1
item
.
buyNum
=
1
,
//默认为1
item
.
chooseContact
=
[]
//选中的游客信息列表
item
.
chooseContact
=
[]
//选中的游客信息列表
...
@@ -455,11 +442,6 @@ export default {
...
@@ -455,11 +442,6 @@ export default {
}
}
}
}
this
.
getPriceList
()
this
.
getPriceList
()
// this.getDiscountPrice() //获取优惠价格
if
(
this
.
showTelephone
)
{
//需要填写联系人信息和手机号码
this
.
getContactList
()
}
}
else
{
}
else
{
uni
.
showToast
({
uni
.
showToast
({
title
:
res
.
message
,
title
:
res
.
message
,
...
@@ -488,64 +470,79 @@ export default {
...
@@ -488,64 +470,79 @@ export default {
let
today
=
this
.
$commonjs
.
today
()
//今天
let
today
=
this
.
$commonjs
.
today
()
//今天
let
tomorrow
=
this
.
$commonjs
.
tomorrow
()
//明天
let
tomorrow
=
this
.
$commonjs
.
tomorrow
()
//明天
let
afterTomorrow
=
this
.
$commonjs
.
afterTomorrow
()
//后天
let
afterTomorrow
=
this
.
$commonjs
.
afterTomorrow
()
//后天
this
.
productList
.
forEach
(
item
=>
{
for
(
let
index
=
0
;
index
<
this
.
productList
.
length
;
index
++
){
if
(
item
.
priceStockList
.
length
>
0
){
let
item
=
this
.
productList
[
index
]
//获取价格列表的第一个日期+预订最晚时间
if
(
item
.
priceStockList
.
length
>
0
){
let
time1
=
item
.
priceStockList
[
0
].
startTime
.
substr
(
0
,
10
)
+
item
.
bookTime
//获取价格列表的第一个日期+预订最晚时间
let
timeNum1
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time1
))
let
time1
=
item
.
priceStockList
[
0
].
startTime
.
substr
(
0
,
10
)
+
item
.
bookTime
let
time2
=
new
Date
().
Format
(
'yyyy-MM-dd hh:mm:ss'
)
let
timeNum1
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time1
))
let
timeNum2
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time2
))
//将当前时间转化为数字
let
time2
=
new
Date
().
Format
(
'yyyy-MM-dd hh:mm:ss'
)
if
(
timeNum2
>
timeNum1
){
let
timeNum2
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time2
))
//将当前时间转化为数字
//如果当前时间大于价格列表第一个日期+预订最晚时间,第一个价格不显示
if
(
timeNum2
>
timeNum1
){
item
.
priceStockList
.
splice
(
0
,
1
)
//如果当前时间大于价格列表第一个日期+预订最晚时间,第一个价格不显示
}
item
.
priceStockList
.
splice
(
0
,
1
)
item
.
priceStockList
.
forEach
((
item2
,
index
)
=>
{
}
//价格上面时间小于当前时间加上需预定天数之后的需删除
item
.
priceStockList
.
forEach
((
item2
,
index
)
=>
{
let
date
=
new
Date
()
//价格上面时间小于当前时间加上需预定天数之后的需删除
date
.
setDate
(
date
.
getDate
()
+
item
.
beforeBookDays
)
let
date
=
new
Date
()
let
newDate
=
date
.
Format
(
'yyyy-MM-dd'
)
date
.
setDate
(
date
.
getDate
()
+
item
.
beforeBookDays
)
let
priceTime
=
this
.
$commonjs
.
changeTime
(
item2
.
endTime
.
substr
(
0
,
10
))
let
newDate
=
date
.
Format
(
'yyyy-MM-dd'
)
let
newTime
=
this
.
$commonjs
.
changeTime
(
newDate
)
let
priceTime
=
this
.
$commonjs
.
changeTime
(
item2
.
endTime
.
substr
(
0
,
10
))
if
(
priceTime
<
newTime
)
{
let
newTime
=
this
.
$commonjs
.
changeTime
(
newDate
)
delete
item
.
priceStockList
[
index
]
if
(
priceTime
<
newTime
)
{
}
delete
item
.
priceStockList
[
index
]
})
}
item
.
priceStockList
=
item
.
priceStockList
.
filter
(
val
=>
{
})
return
val
item
.
priceStockList
=
item
.
priceStockList
.
filter
(
val
=>
{
})
return
val
if
(
item
.
priceStockList
.
length
==
0
){
})
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
if
(
item
.
priceStockList
.
length
==
0
){
this
.
payBackground
=
'#C0C0C0'
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
return
this
.
payBackground
=
'#C0C0C0'
}
this
.
maxBookNum
=
0
//下面参数是默认选择每个产品第一个日期的值
return
item
.
chooseDate
=
item
.
priceStockList
[
0
].
startTime
.
substr
(
0
,
10
)
//日历选中的日期
}
item
.
startDate
=
item
.
priceStockList
[
0
].
startTime
//开始日期
//下面参数是默认选择每个产品第一个日期的值
item
.
endDate
=
item
.
priceStockList
[
0
].
endTime
//结束日期
item
.
chooseDate
=
item
.
priceStockList
[
0
].
startTime
.
substr
(
0
,
10
)
//日历选中的日期
item
.
originalPrice
=
item
.
priceStockList
[
0
].
originalPrice
//原价
item
.
startDate
=
item
.
priceStockList
[
0
].
startTime
//开始日期
item
.
sellingPrice
=
item
.
priceStockList
[
0
].
sellingPrice
//卖价
item
.
endDate
=
item
.
priceStockList
[
0
].
endTime
//结束日期
item
.
maxBookNum
=
Math
.
min
(
item
.
priceStockList
[
0
].
surplus
,
item
.
maxBookNum
)
//最大购买数量
item
.
originalPrice
=
item
.
priceStockList
[
0
].
originalPrice
//原价
item
.
priceStockList
.
forEach
(
item2
=>
{
//循环单个产品的价格列表
item
.
sellingPrice
=
item
.
priceStockList
[
0
].
sellingPrice
//卖价
item2
.
week
=
'日一二三四五六'
.
charAt
(
new
Date
(
item2
.
startTime
.
substr
(
0
,
10
)).
getDay
())
item
.
maxBookNum
=
Math
.
min
(
item
.
priceStockList
[
0
].
surplus
,
item
.
maxBookNum
)
//最大购买数量
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
today
){
item
.
priceStockList
.
forEach
(
item2
=>
{
//循环单个产品的价格列表
item2
.
week
=
'今天'
item2
.
week
=
'日一二三四五六'
.
charAt
(
new
Date
(
item2
.
startTime
.
substr
(
0
,
10
)).
getDay
())
}
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
today
){
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
tomorrow
){
item2
.
week
=
'今天'
item2
.
week
=
'明天'
}
}
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
tomorrow
){
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
afterTomorrow
){
item2
.
week
=
'明天'
item2
.
week
=
'后天'
}
}
if
(
item2
.
startTime
.
substr
(
0
,
10
)
==
afterTomorrow
){
})
item2
.
week
=
'后天'
//如果是班次票,并且班次票价格列表不为空
}
if
(
item
.
productType
==
3
&&
item
.
priceStockList
.
length
>
0
){
})
//如果是班次票,并且班次票价格列表不为空
if
(
item
.
productType
==
3
&&
item
.
priceStockList
.
length
>
0
){
this
.
getTimeStock
(
item
)
this
.
getTimeStock
(
item
)
}
}
}
else
{
//获取优惠券
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
initCoupon
(
item
)
this
.
payBackground
=
'#C0C0C0'
//需要排号
}
if
(
item
.
isFetch
==
1
){
})
this
.
areaIndex
=
index
this
.
sortUpDown
(
item
.
merchantVo
.
code
)
}
}
else
{
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
payBackground
=
'#C0C0C0'
this
.
maxBookNum
=
0
return
}
}
if
(
this
.
showTelephone
)
{
//需要填写联系人信息和手机号码
this
.
getContactList
()
}
this
.
computedPrice
()
//计算价格
this
.
computedPrice
()
//计算价格
//解决初始化日期不显示的情况
//解决初始化日期不显示的情况
this
.
$forceUpdate
()
this
.
$forceUpdate
()
...
@@ -575,18 +572,28 @@ export default {
...
@@ -575,18 +572,28 @@ export default {
//有库存并且需要选择两个站点以上的票种,显示区域组件
//有库存并且需要选择两个站点以上的票种,显示区域组件
for
(
let
item2
in
data
.
main
)
{
for
(
let
item2
in
data
.
main
)
{
if
(
data
.
main
[
item2
].
sceneSortStatus
==
'1'
){
if
(
data
.
main
[
item2
].
sceneSortStatus
==
'1'
){
//暂时下面只适应长江索道
this
.
showChooseArea
=
true
//上架
//上架
item
.
areaUp
=
true
item
.
areaUp
=
true
if
(
item
.
defaultAreaCode
){
//有默认的站点
item
.
areaObj
=
{}
item
.
areaObj
.
areaCode
=
item
.
areaCode
item
.
areaObj
.
areaName
=
item
.
areaName
}
else
{
item
.
areaObj
=
{}
}
//暂时下面只适应长江索道
this
.
showChooseArea
=
true
}
}
}
}
}
else
if
(
item
.
productAreaList
.
length
==
1
)
{
}
else
if
(
item
.
productAreaList
.
length
==
1
)
{
//只有一个站点时,直接选中站点(现目前还没有一个站点的景区)
//只有一个站点时,直接选中站点(现目前还没有一个站点的景区)
for
(
let
item
in
data
.
main
)
{
for
(
let
item
in
data
.
main
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
)
{
item
.
areaObj
=
item
.
productAreaList
[
0
]
//上架
item
.
areaUp
=
true
item
.
areaUp
=
true
item
.
areaObj
.
areaCode
=
item
.
productAreaList
[
0
].
areaCode
item
.
areaObj
.
areaName
=
item
.
productAreaList
[
0
].
areaName
}
}
}
}
}
}
...
@@ -1017,12 +1024,24 @@ export default {
...
@@ -1017,12 +1024,24 @@ export default {
let
item
=
this
.
productList
[
i
]
let
item
=
this
.
productList
[
i
]
//没有库存情况
//没有库存情况
if
(
!
item
.
priceStockList
||
item
.
priceStockList
.
length
==
0
){
if
(
!
item
.
priceStockList
||
item
.
priceStockList
.
length
==
0
){
uni
.
showToast
({
title
:
item
.
merchantName
+
'没有库存'
,
icon
:
'none'
})
return
return
}
}
//由于默认购买数量为1,没有判断产品的最大购买数量是否大于等于1,故下单的时候需要判断产品的最大购买数量大于1,才可以下单
if
(
parseFloat
(
item
.
maxBookNum
)
<
1
){
uni
.
showToast
({
title
:
item
.
merchantName
+
'没有库存'
,
icon
:
'none'
})
return
}
}
}
if
(
this
.
showTelephone
)
{
if
(
this
.
showTelephone
)
{
//需要填写电话号码
//需要填写电话号码
if
(
!
this
.
$commonjs
.
phoneReg
().
test
(
this
.
ticketPhone
)
&&
this
.
productIfo
.
tripTemplateFlag
!=
2
)
{
if
(
!
this
.
$commonjs
.
phoneReg
().
test
(
this
.
ticketPhone
))
{
//未填写正确手机号码
//未填写正确手机号码
uni
.
showToast
({
uni
.
showToast
({
title
:
'请填写正确的手机号码'
,
title
:
'请填写正确的手机号码'
,
...
@@ -1031,9 +1050,9 @@ export default {
...
@@ -1031,9 +1050,9 @@ export default {
return
return
}
}
}
}
// if (!
this.startDate || !this
.endDate) {
// if (!
item.startDate || !item
.endDate) {
// uni.showToast({
// uni.showToast({
// title:
'请选择游玩日期',
// title:
item.merchantName+
'请选择游玩日期',
// icon: 'none'
// icon: 'none'
// })
// })
// return
// return
...
...
pages/scenic/scenicOrder/scenicOrder.vue
View file @
e93cc300
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
</view>
</view>
</view>
</view>
<!--需要排队并且站点数大于1-->
<!--需要排队并且站点数大于1-->
<view
class=
"middle-place"
@
click=
"openArea()"
v-if=
"productIfo.isFetch == 1 && productIfo.productAreaList.length > 1 &&
showOpenArea
"
>
<view
class=
"middle-place"
@
click=
"openArea()"
v-if=
"productIfo.isFetch == 1 && productIfo.productAreaList.length > 1 &&
areaUp
"
>
<view>
出发站点
</view>
<view>
出发站点
</view>
<view>
<view>
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
</view>
</view>
</view>
</view>
<!--需要排队并且为一个站点-->
<!--需要排队并且为一个站点-->
<!--
<view
class=
"middle-place"
v-if=
"productIfo.isFetch == 1 && productIfo.productAreaList.length == 1 &&
showOpenArea
"
@
click=
"getSortInfor()"
>
<!--
<view
class=
"middle-place"
v-if=
"productIfo.isFetch == 1 && productIfo.productAreaList.length == 1 &&
areaUp
"
@
click=
"getSortInfor()"
>
<view>
获取排队信息
</view>
<view>
获取排队信息
</view>
<view>
<view>
...
@@ -304,8 +304,11 @@
...
@@ -304,8 +304,11 @@
<view
class=
"bottom-btn"
:style=
"{ background: payBackground }"
>
<view
class=
"bottom-btn"
:style=
"{ background: payBackground }"
>
<text
v-if=
"productIfo.status == 1"
>
已下架
</text>
<text
v-if=
"productIfo.status == 1"
>
已下架
</text>
<text
v-if=
"parseInt(maxBookNum) <1"
style=
"background: #c0c0c0"
>
暂无库存
</text>
<
template
v-else
>
<text
v-if=
"productIfo.status != 1 && parseInt(maxBookNum) >= 1"
@
click=
"goPay()"
>
去支付
</text>
<text
v-if=
"parseInt(maxBookNum)
<1
"
>
暂无库存
</text>
<text
v-if=
"parseInt(maxBookNum) >0"
@
click=
"goPay()"
>
去支付
</text>
</
template
>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -397,7 +400,7 @@ export default {
...
@@ -397,7 +400,7 @@ export default {
sortInforPop
:
false
,
//一个站点时获取排队信息弹窗
sortInforPop
:
false
,
//一个站点时获取排队信息弹窗
showErmai
:
true
,
//临时的,选择了南站不显示耳麦
showErmai
:
true
,
//临时的,选择了南站不显示耳麦
showArea
:
false
,
//控制选择站点显示隐藏
showArea
:
false
,
//控制选择站点显示隐藏
showOpenArea
:
false
,
//是否可以显示选择站点
areaUp
:
false
,
//排号是否上架
chooseDate
:
''
,
//选择的日期
chooseDate
:
''
,
//选择的日期
active
:
10000
,
//日期下标
active
:
10000
,
//日期下标
timeActive
:
10000
,
//时间下标,默认不选中
timeActive
:
10000
,
//时间下标,默认不选中
...
@@ -425,7 +428,7 @@ export default {
...
@@ -425,7 +428,7 @@ export default {
endDate
:
''
,
//结束日期
endDate
:
''
,
//结束日期
startPlayTime
:
''
,
//开始时间
startPlayTime
:
''
,
//开始时间
endPlayTime
:
''
,
//结束时间
endPlayTime
:
''
,
//结束时间
areaObj
:
''
,
//区域组件的传值
areaObj
:
{}
,
//区域组件的传值
templateList
:
[],
//该产品联系人必须要填写的信息
templateList
:
[],
//该产品联系人必须要填写的信息
timeFlag
:
''
,
//setTimeout函数
timeFlag
:
''
,
//setTimeout函数
savedMoney
:
0
,
//优惠价格
savedMoney
:
0
,
//优惠价格
...
@@ -508,6 +511,226 @@ export default {
...
@@ -508,6 +511,226 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
//---页面初始化数据,获取产品基本信息
initData
()
{
let
data
=
{
id
:
this
.
productId
//产品id
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'scenic/groupGood/loadProduct'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
productIfo
=
res
.
data
this
.
defaultAreaCode
=
this
.
productIfo
.
defaultAreaCode
||
''
this
.
merchantCode
=
this
.
productIfo
.
merchantVo
.
code
,
//商户code
this
.
productId
=
res
.
data
.
id
//产品id变化,重新赋值产品id
this
.
merchantId
=
res
.
data
.
merchantId
//重新赋值商户id
this
.
beforeBookDays
=
res
.
data
.
beforeBookDays
||
0
//提前预定天数
this
.
buyKnowData
=
res
.
data
//购买须知,传给子组件
this
.
serviceList
=
res
.
data
.
loadProductResVoList
//额外服务
//this.chooseService=res.data.data.loadProductResVoList//默认全部选中
if
(
this
.
productIfo
.
status
==
1
)
{
//下架状态
this
.
payBackground
=
'#C0C0C0'
return
}
if
(
this
.
productIfo
.
productType
!=
3
)
{
//不为班次票时,开始时间为当前时间,结束时间为23:59:59
this
.
startPlayTime
=
new
Date
().
Format
(
'hh:mm:ss'
)
this
.
endPlayTime
=
'23:59:59'
}
this
.
getPriceList
()
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---获取产品价格库存列表
getPriceList
()
{
let
data
=
{
productId
:
this
.
productId
//产品id
}
this
.
$request
(
'scenic/user/product/priceStockList'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
dateList
=
res
.
data
//日期列表
if
(
this
.
dateList
.
length
>
0
)
{
let
time1
=
this
.
dateList
[
0
].
startTime
.
substr
(
0
,
10
)
+
this
.
productIfo
.
bookTime
//获取价格列表的第一个日期+预订最晚时间
let
timeNum1
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time1
))
let
time2
=
new
Date
().
Format
(
'yyyy-MM-dd hh:mm:ss'
)
let
timeNum2
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time2
))
//将当前时间转化为数字
if
(
timeNum2
>
timeNum1
)
{
//如果当前时间大于价格列表第一个日期+预订最晚时间,第一个价格不显示
this
.
dateList
.
splice
(
0
,
1
)
}
this
.
dateList
.
forEach
((
item
,
index
)
=>
{
//价格上面时间小于当前时间加上需预定天数之后的需删除
let
date
=
new
Date
()
date
.
setDate
(
date
.
getDate
()
+
this
.
beforeBookDays
)
let
newDate
=
date
.
Format
(
'yyyy-MM-dd'
)
let
priceTime
=
this
.
$commonjs
.
changeTime
(
item
.
endTime
.
substr
(
0
,
10
))
let
newTime
=
this
.
$commonjs
.
changeTime
(
newDate
)
if
(
priceTime
<
newTime
)
{
delete
this
.
dateList
[
index
]
}
})
this
.
dateList
=
this
.
dateList
.
filter
(
val
=>
{
return
val
})
if
(
this
.
dateList
.
length
==
0
)
{
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
payBackground
=
'#C0C0C0'
this
.
maxBookNum
=
0
return
}
if
(
this
.
dateList
.
length
==
1
&&
this
.
beforeBookDays
==
0
)
{
//长度为1而且只能预订当天,默认选中第一个日期
//真机模拟的时候手机端不显示今天,明天后天,延迟执行
setTimeout
(
item
=>
{
this
.
$refs
.
calendar
.
defaultDate
=
this
.
dateList
[
0
].
startTime
.
substr
(
0
,
10
)
},
1000
)
this
.
maxBookNum
=
Math
.
min
(
this
.
dateList
[
0
].
surplus
,
this
.
productIfo
.
maxBookNum
)
//剩余量
this
.
startDate
=
this
.
dateList
[
0
].
startTime
//开始日期
this
.
endDate
=
this
.
dateList
[
0
].
endTime
//结束日期
this
.
originalPrice
=
this
.
dateList
[
0
].
originalPrice
//原价
this
.
sellingPrice
=
this
.
dateList
[
0
].
sellingPrice
//卖价
this
.
active
=
0
if
(
this
.
productIfo
.
productType
==
3
)
{
//如果为班次票,请求班次票接口
this
.
getTimeStock
()
}
//获取优惠券
this
.
initCoupon
()
}
if
(
this
.
productIfo
.
isFetch
==
1
)
{
this
.
sortUpDown
()
}
if
(
this
.
productIfo
.
tripTemplateFlag
!=
2
)
{
//等于2时不需要填写联系人信息和手机号码
this
.
getContactList
()
}
}
else
{
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
payBackground
=
'#C0C0C0'
this
.
maxBookNum
=
0
return
}
let
today
=
this
.
$commonjs
.
today
()
//今天
let
tomorrow
=
this
.
$commonjs
.
tomorrow
()
//明天
let
afterTomorrow
=
this
.
$commonjs
.
afterTomorrow
()
//后天
this
.
dateList
.
forEach
((
item
,
index
)
=>
{
item
.
week
=
'日一二三四五六'
.
charAt
(
new
Date
(
item
.
startTime
.
substr
(
0
,
10
)).
getDay
())
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
today
)
{
item
.
week
=
'今天'
}
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
tomorrow
)
{
item
.
week
=
'明天'
}
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
afterTomorrow
)
{
item
.
week
=
'后天'
}
})
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---排号是否上下架
sortUpDown
()
{
let
data
=
{
merchantCode
:
this
.
merchantCode
//商户code
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'distribution/distribution/findNewFetchInfoFromSceinc'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
sortArr
=
res
.
data
.
data
let
data
=
res
.
data
let
areaList
=
this
.
productIfo
.
productAreaList
if
(
areaList
.
length
>
1
)
{
//有库存并且需要选择两个站点以上的票种,显示区域组件
for
(
let
item
in
data
.
main
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
){
//上架
this
.
areaUp
=
true
this
.
showArea
=
true
//通过默认站点找到站点数据
if
(
this
.
defaultAreaCode
)
{
areaList
.
forEach
(
item
=>
{
if
(
item
.
areaCode
==
this
.
defaultAreaCode
)
{
this
.
areaObj
.
areaCode
=
item
.
areaCode
this
.
areaObj
.
areaName
=
item
.
areaName
}
})
}
}
}
}
else
if
(
areaList
.
length
==
1
)
{
//只有一个站点时,直接选中站点(现目前还没有一个站点的景区)
for
(
let
item
in
data
.
main
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
)
{
//上架
this
.
areaUp
=
true
this
.
areaObj
.
areaCode
=
areaList
[
0
].
areaCode
this
.
areaObj
.
areaName
=
areaList
[
0
].
areaName
}
}
}
}
})
},
//---获取班次票
getTimeStock
()
{
let
data
=
{
endDate
:
this
.
endDate
,
//结束日期
startDate
:
this
.
startDate
,
//开始日期
interfaceCode
:
this
.
productIfo
.
merchantVo
.
interfaceCompanyId
,
//接口编号
merchantCode
:
this
.
merchantCode
,
//商户code
productCode
:
this
.
productIfo
.
code
//产品code
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'distribution/distribution/getTimeStock'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
timeList
=
res
.
data
this
.
timeList
.
forEach
((
item
,
index
)
=>
{
//增加一个时间Number字段,用于判断当前时间大于班次结束时间时,显示售罄
let
text
=
parseFloat
((
item
.
last
/
item
.
total
).
toFixed
(
2
))
||
0
if
(
text
>
0.4
){
item
.
copyLast
=
'余票充足'
}
else
{
item
.
copyLast
=
item
.
last
}
item
.
timeNumber
=
parseInt
(
this
.
$commonjs
.
changeTime
(
item
.
planDate
.
substr
(
0
,
10
)
+
item
.
endPlanTime
))
if
(
this
.
timeNumber
>
item
.
timeNumber
||
item
.
last
<=
0
)
{
item
.
copyLast
=
'售罄'
}
})
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---获取排号信息
//---获取排号信息
getSortInfor
()
{
getSortInfor
()
{
let
data
=
{
let
data
=
{
...
@@ -693,228 +916,6 @@ export default {
...
@@ -693,228 +916,6 @@ export default {
showBuyKnow
()
{
showBuyKnow
()
{
this
.
$refs
.
buyKnow
.
showPop
=
true
this
.
$refs
.
buyKnow
.
showPop
=
true
},
},
//---页面初始化数据,获取产品基本信息
initData
()
{
let
data
=
{
id
:
this
.
productId
//产品id
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'scenic/groupGood/loadProduct'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
productIfo
=
res
.
data
this
.
defaultAreaCode
=
this
.
productIfo
.
defaultAreaCode
||
''
//通过默认站点找到站点数据
if
(
this
.
defaultAreaCode
)
{
this
.
productIfo
.
productAreaList
.
forEach
(
item
=>
{
if
(
item
.
areaCode
==
this
.
defaultAreaCode
)
{
this
.
areaObj
=
{}
this
.
areaObj
.
areaCode
=
item
.
areaCode
this
.
areaObj
.
areaName
=
item
.
areaName
}
})
}
this
.
merchantCode
=
this
.
productIfo
.
merchantVo
.
code
,
//商户code
this
.
productId
=
res
.
data
.
id
//产品id变化,重新赋值产品id
this
.
merchantId
=
res
.
data
.
merchantId
//重新赋值商户id
this
.
beforeBookDays
=
res
.
data
.
beforeBookDays
||
0
//提前预定天数
this
.
buyKnowData
=
res
.
data
//购买须知,传给子组件
this
.
serviceList
=
res
.
data
.
loadProductResVoList
//额外服务
//this.chooseService=res.data.data.loadProductResVoList//默认全部选中
if
(
this
.
productIfo
.
status
==
1
)
{
//下架状态
this
.
payBackground
=
'#C0C0C0'
}
if
(
this
.
productIfo
.
productType
!=
3
)
{
//不为班次票时,开始时间为当前时间,结束时间为23:59:59
this
.
startPlayTime
=
new
Date
().
Format
(
'hh:mm:ss'
)
this
.
endPlayTime
=
'23:59:59'
}
if
(
this
.
productIfo
.
tripTemplateResList
.
length
>
0
)
{
//用于判断选中的联系人信息是否填写完善
this
.
productIfo
.
tripTemplateResList
.
forEach
(
item
=>
{
this
.
templateList
.
push
(
item
.
enumKey
)
})
}
this
.
getPriceList
()
this
.
getDiscountPrice
()
//获取优惠价格
if
(
this
.
productIfo
.
tripTemplateFlag
!=
2
)
{
//等于2时不需要填写联系人信息和手机号码
this
.
getContactList
()
}
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---获取产品价格库存列表
getPriceList
()
{
let
data
=
{
productId
:
this
.
productId
//产品id
}
this
.
$request
(
'scenic/user/product/priceStockList'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
dateList
=
res
.
data
//日期列表
if
(
this
.
dateList
.
length
>
0
)
{
let
time1
=
this
.
dateList
[
0
].
startTime
.
substr
(
0
,
10
)
+
this
.
productIfo
.
bookTime
//获取价格列表的第一个日期+预订最晚时间
let
timeNum1
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time1
))
let
time2
=
new
Date
().
Format
(
'yyyy-MM-dd hh:mm:ss'
)
let
timeNum2
=
parseInt
(
this
.
$commonjs
.
changeTime
(
time2
))
//将当前时间转化为数字
if
(
timeNum2
>
timeNum1
)
{
//如果当前时间大于价格列表第一个日期+预订最晚时间,第一个价格不显示
this
.
dateList
.
splice
(
0
,
1
)
}
this
.
dateList
.
forEach
((
item
,
index
)
=>
{
//价格上面时间小于当前时间加上需预定天数之后的需删除
let
date
=
new
Date
()
date
.
setDate
(
date
.
getDate
()
+
this
.
beforeBookDays
)
let
newDate
=
date
.
Format
(
'yyyy-MM-dd'
)
let
priceTime
=
this
.
$commonjs
.
changeTime
(
item
.
endTime
.
substr
(
0
,
10
))
let
newTime
=
this
.
$commonjs
.
changeTime
(
newDate
)
if
(
priceTime
<
newTime
)
{
delete
this
.
dateList
[
index
]
}
})
this
.
dateList
=
this
.
dateList
.
filter
(
val
=>
{
return
val
})
if
(
this
.
dateList
.
length
==
0
)
{
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
showArea
=
false
this
.
payBackground
=
'#C0C0C0'
return
}
if
(
this
.
productIfo
.
isFetch
==
1
)
{
this
.
sortUpDown
()
}
if
(
this
.
dateList
.
length
==
1
&&
this
.
beforeBookDays
==
0
)
{
//长度为1而且只能预订当天,默认选中第一个日期
//真机模拟的时候手机端不显示今天,明天后天,延迟执行
setTimeout
(
item
=>
{
this
.
$refs
.
calendar
.
defaultDate
=
this
.
dateList
[
0
].
startTime
.
substr
(
0
,
10
)
},
1000
)
this
.
maxBookNum
=
Math
.
min
(
this
.
dateList
[
0
].
surplus
,
this
.
productIfo
.
maxBookNum
)
//剩余量
this
.
startDate
=
this
.
dateList
[
0
].
startTime
//开始日期
this
.
endDate
=
this
.
dateList
[
0
].
endTime
//结束日期
this
.
originalPrice
=
this
.
dateList
[
0
].
originalPrice
//原价
this
.
sellingPrice
=
this
.
dateList
[
0
].
sellingPrice
//卖价
this
.
active
=
0
if
(
this
.
productIfo
.
productType
==
3
)
{
//如果为班次票,请求班次票接口
this
.
getTimeStock
()
}
this
.
initCoupon
()
//获取优惠券
}
}
else
{
uni
.
showToast
({
title
:
'没有库存'
,
icon
:
'none'
})
this
.
showArea
=
false
this
.
payBackground
=
'#C0C0C0'
}
let
today
=
this
.
$commonjs
.
today
()
//今天
let
tomorrow
=
this
.
$commonjs
.
tomorrow
()
//明天
let
afterTomorrow
=
this
.
$commonjs
.
afterTomorrow
()
//后天
this
.
dateList
.
forEach
((
item
,
index
)
=>
{
item
.
week
=
'日一二三四五六'
.
charAt
(
new
Date
(
item
.
startTime
.
substr
(
0
,
10
)).
getDay
())
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
today
)
{
item
.
week
=
'今天'
}
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
tomorrow
)
{
item
.
week
=
'明天'
}
if
(
item
.
startTime
.
substr
(
0
,
10
)
==
afterTomorrow
)
{
item
.
week
=
'后天'
}
})
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---排号是否上下架
sortUpDown
()
{
let
data
=
{
merchantCode
:
this
.
merchantCode
//商户code
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'distribution/distribution/findNewFetchInfoFromSceinc'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
sortArr
=
res
.
data
.
data
let
data
=
res
.
data
if
(
this
.
productIfo
.
productAreaList
.
length
>
1
)
{
//有库存并且需要选择两个站点以上的票种,显示区域组件
for
(
let
item
in
data
.
main
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
){
this
.
showArea
=
true
this
.
showOpenArea
=
true
}
}
}
else
if
(
this
.
productIfo
.
productAreaList
.
length
==
1
)
{
//只有一个站点时,直接选中站点(现目前还没有一个站点的景区)
for
(
let
item
in
data
.
main
)
{
if
(
data
.
main
[
item
].
sceneSortStatus
==
'1'
)
{
this
.
areaObj
=
this
.
productIfo
.
productAreaList
[
0
]
this
.
showOpenArea
=
true
}
}
}
}
})
},
//---获取班次票
getTimeStock
()
{
let
data
=
{
endDate
:
this
.
endDate
,
//结束日期
startDate
:
this
.
startDate
,
//开始日期
interfaceCode
:
this
.
productIfo
.
merchantVo
.
interfaceCompanyId
,
//接口编号
merchantCode
:
this
.
merchantCode
,
//商户code
productCode
:
this
.
productIfo
.
code
//产品code
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
'distribution/distribution/getTimeStock'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
)
{
this
.
timeList
=
res
.
data
this
.
timeList
.
forEach
((
item
,
index
)
=>
{
//增加一个时间Number字段,用于判断当前时间大于班次结束时间时,显示售罄
let
text
=
parseFloat
((
item
.
last
/
item
.
total
).
toFixed
(
2
))
||
0
if
(
text
>
0.4
){
item
.
copyLast
=
'余票充足'
}
else
{
item
.
copyLast
=
item
.
last
}
item
.
timeNumber
=
parseInt
(
this
.
$commonjs
.
changeTime
(
item
.
planDate
.
substr
(
0
,
10
)
+
item
.
endPlanTime
))
if
(
this
.
timeNumber
>
item
.
timeNumber
||
item
.
last
<=
0
)
{
item
.
copyLast
=
'售罄'
}
})
}
else
{
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
})
}
})
},
//---初始化联系人列表
//---初始化联系人列表
getContactList
()
{
getContactList
()
{
let
data
=
{
let
data
=
{
...
@@ -1134,7 +1135,7 @@ export default {
...
@@ -1134,7 +1135,7 @@ export default {
return
return
}
}
}
}
if
(
this
.
productIfo
.
isFetch
==
1
&&
this
.
showOpenArea
)
{
if
(
this
.
productIfo
.
isFetch
==
1
&&
this
.
areaUp
)
{
//需要选择站点的票种,必须选择站点
//需要选择站点的票种,必须选择站点
if
(
!
this
.
areaObj
.
areaCode
)
{
if
(
!
this
.
areaObj
.
areaCode
)
{
uni
.
showToast
({
uni
.
showToast
({
...
@@ -1211,7 +1212,7 @@ export default {
...
@@ -1211,7 +1212,7 @@ export default {
return
return
}
}
}
}
if
(
this
.
productIfo
.
isFetch
==
1
&&
this
.
showOpenArea
)
{
if
(
this
.
productIfo
.
isFetch
==
1
&&
this
.
areaUp
)
{
//需要选择站点的票种,必须选择站点
//需要选择站点的票种,必须选择站点
if
(
!
this
.
areaObj
.
areaCode
)
{
if
(
!
this
.
areaObj
.
areaCode
)
{
uni
.
showToast
({
uni
.
showToast
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment