|
|
|
@ -11,9 +11,14 @@ Component({ |
|
|
|
addGlobalClass: true |
|
|
|
}, |
|
|
|
properties: { |
|
|
|
product:{ |
|
|
|
type:Object, |
|
|
|
default:{} |
|
|
|
product: { |
|
|
|
type: Object, |
|
|
|
default: {} |
|
|
|
}, |
|
|
|
// 是否是团体预约的场馆
|
|
|
|
isTeam: { |
|
|
|
type: Number, |
|
|
|
default: 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
@ -21,81 +26,81 @@ Component({ |
|
|
|
* 组件的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
threeDays:[], |
|
|
|
activeDate:"", |
|
|
|
datelist:[], |
|
|
|
showMoreDateFlag:false, |
|
|
|
moreFlag:true, |
|
|
|
timelist:[], |
|
|
|
timeIndex:0, |
|
|
|
isSzMuseum:false, |
|
|
|
kjIdCom:null, |
|
|
|
gpIdCom:null |
|
|
|
threeDays: [], |
|
|
|
activeDate: "", |
|
|
|
datelist: [], |
|
|
|
showMoreDateFlag: false, |
|
|
|
moreFlag: true, |
|
|
|
timelist: [], |
|
|
|
timeIndex: 0, |
|
|
|
isSzMuseum: false, |
|
|
|
kjIdCom: null, |
|
|
|
gpIdCom: null |
|
|
|
}, |
|
|
|
lifetimes: { |
|
|
|
attached: function() { |
|
|
|
attached: function () { |
|
|
|
this.setData({ |
|
|
|
kjIdCom:app.globalData.kjId, |
|
|
|
gpIdCom:app.globalData.gp_id || app.globalData.team_id |
|
|
|
kjIdCom: app.globalData.kjId, |
|
|
|
gpIdCom: app.globalData.gp_id || app.globalData.team_id |
|
|
|
}) |
|
|
|
// 在组件实例进入页面节点树时执行
|
|
|
|
let product = app.globalData.product,today = util.formatDate(new Date()),end_date = util.formatDate(new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000)); |
|
|
|
if(product.product.title.indexOf("苏州博物馆")!=-1){ |
|
|
|
let product = app.globalData.product, today = util.formatDate(new Date()), end_date = util.formatDate(new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000)); |
|
|
|
if (product.product.title.indexOf("苏州博物馆") != -1) { |
|
|
|
this.setData({ |
|
|
|
isSzMuseum:true |
|
|
|
isSzMuseum: true |
|
|
|
}) |
|
|
|
} |
|
|
|
commonApi.user_post("token/check").then(res=>{ |
|
|
|
if(res.code==1){ |
|
|
|
commonApi.user_post("token/check").then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
// 获取价格日历
|
|
|
|
commonApi.user_post("product/product_date_price",{ |
|
|
|
start_date:today, |
|
|
|
end_date:end_date, |
|
|
|
sku_id:product.sku.id |
|
|
|
}).then(res=>{ |
|
|
|
commonApi.user_post("product/product_date_price", { |
|
|
|
start_date: today, |
|
|
|
end_date: end_date, |
|
|
|
sku_id: product.sku.id |
|
|
|
}).then(res => { |
|
|
|
// 如果之前已经在详情页面选择了日期的话 默认日期不能是第一个有库存的日期了
|
|
|
|
if(app.globalData.product.infoDate){ |
|
|
|
let dateIndex = res.data.slice(0,3).findIndex(item=>item.date==app.globalData.product.infoDate.date) |
|
|
|
if (app.globalData.product.infoDate) { |
|
|
|
let dateIndex = res.data.slice(0, 3).findIndex(item => item.date == app.globalData.product.infoDate.date) |
|
|
|
// if(!app.globalData.product.infoDate.short_date){
|
|
|
|
// app.globalData.product.infoDate.short_date = app.globalData.product.infoDate.date.split("-").splice(1,2).join("-")
|
|
|
|
// }
|
|
|
|
this.setData({ |
|
|
|
activeDate:app.globalData.product.infoDate, |
|
|
|
moreFlag:dateIndex!=-1 |
|
|
|
activeDate: app.globalData.product.infoDate, |
|
|
|
moreFlag: dateIndex != -1 |
|
|
|
}) |
|
|
|
this.getTimeStock() |
|
|
|
this.triggerEvent("onChangeDate",app.globalData.product.infoDate) |
|
|
|
this.triggerEvent("onChangeDate", app.globalData.product.infoDate) |
|
|
|
} |
|
|
|
else { |
|
|
|
for(let i=0;i<res.data.length;i++){ |
|
|
|
if(res.data[i].stock>0){ |
|
|
|
res.data[i].short_date = res.data[i].date.split("-").splice(1,2).join("-") |
|
|
|
for (let i = 0; i < res.data.length; i++) { |
|
|
|
if (res.data[i].stock > 0) { |
|
|
|
res.data[i].short_date = res.data[i].date.split("-").splice(1, 2).join("-") |
|
|
|
this.setData({ |
|
|
|
activeDate:res.data[i] |
|
|
|
activeDate: res.data[i] |
|
|
|
}) |
|
|
|
this.getTimeStock() |
|
|
|
this.triggerEvent("onChangeDate",this.data.activeDate) |
|
|
|
this.triggerEvent("onChangeDate", this.data.activeDate) |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.data.gpIdCom){ |
|
|
|
if (this.data.gpIdCom) { |
|
|
|
// 拼团的话 价格日历无效 所有价格都是sku里面的event_price
|
|
|
|
res.data.map(item=>{ |
|
|
|
res.data.map(item => { |
|
|
|
item.price = product.sku.event_price |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
datelist:res.data |
|
|
|
datelist: res.data |
|
|
|
}) |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
threeDays:res.data.slice(0,3) |
|
|
|
threeDays: res.data.slice(0, 3) |
|
|
|
}) |
|
|
|
let index = this.data.threeDays.findIndex(item=>item.date==this.data.activeDate.date) |
|
|
|
let index = this.data.threeDays.findIndex(item => item.date == this.data.activeDate.date) |
|
|
|
this.setData({ |
|
|
|
moreFlag:index!=-1 |
|
|
|
moreFlag: index != -1 |
|
|
|
}) |
|
|
|
console.log(res) |
|
|
|
}) |
|
|
|
@ -103,15 +108,15 @@ Component({ |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
detached: function() { |
|
|
|
detached: function () { |
|
|
|
// 在组件实例被从页面节点树移除时执行
|
|
|
|
}, |
|
|
|
}, |
|
|
|
pageLifetimes:{ |
|
|
|
show:function(){ |
|
|
|
pageLifetimes: { |
|
|
|
show: function () { |
|
|
|
this.setData({ |
|
|
|
kjIdCom:app.globalData.kjId, |
|
|
|
gpIdCom:app.globalData.gp_id || app.globalData.team_id |
|
|
|
kjIdCom: app.globalData.kjId, |
|
|
|
gpIdCom: app.globalData.gp_id || app.globalData.team_id |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -119,80 +124,80 @@ Component({ |
|
|
|
* 组件的方法列表 |
|
|
|
*/ |
|
|
|
methods: { |
|
|
|
showMoreDate:function(){ |
|
|
|
showMoreDate: function () { |
|
|
|
this.setData({ |
|
|
|
showMoreDateFlag:true |
|
|
|
showMoreDateFlag: true |
|
|
|
}) |
|
|
|
}, |
|
|
|
hideCalendar:function(){ |
|
|
|
hideCalendar: function () { |
|
|
|
this.setData({ |
|
|
|
showMoreDateFlag:false |
|
|
|
showMoreDateFlag: false |
|
|
|
}) |
|
|
|
}, |
|
|
|
changeDate:function(e){ |
|
|
|
changeDate: function (e) { |
|
|
|
let date = e.currentTarget.dataset.date; |
|
|
|
if(date.stock<=0) return; |
|
|
|
if(date.stock==null) return; |
|
|
|
if(date.price==null) return; |
|
|
|
if (date.stock <= 0) return; |
|
|
|
if (date.stock == null) return; |
|
|
|
if (date.price == null) return; |
|
|
|
this.setData({ |
|
|
|
activeDate:date, |
|
|
|
moreFlag:true |
|
|
|
activeDate: date, |
|
|
|
moreFlag: true |
|
|
|
}) |
|
|
|
this.triggerEvent("onChangeDate",this.data.activeDate) |
|
|
|
this.triggerEvent("onChangeDate", this.data.activeDate) |
|
|
|
this.getTimeStock() |
|
|
|
}, |
|
|
|
// 修改日期
|
|
|
|
onTapDay:function(e){ |
|
|
|
let threeDays = this.data.threeDays,flag=false; |
|
|
|
threeDays.map(item=>{ |
|
|
|
if(item.date==e.detail.date){ |
|
|
|
onTapDay: function (e) { |
|
|
|
let threeDays = this.data.threeDays, flag = false; |
|
|
|
threeDays.map(item => { |
|
|
|
if (item.date == e.detail.date) { |
|
|
|
flag = true |
|
|
|
} |
|
|
|
}) |
|
|
|
e.detail.short_date = e.detail.date.substr(5,5); |
|
|
|
e.detail.short_date = e.detail.date.substr(5, 5); |
|
|
|
this.setData({ |
|
|
|
activeDate:e.detail, |
|
|
|
showMoreDateFlag:false, |
|
|
|
moreFlag:flag |
|
|
|
activeDate: e.detail, |
|
|
|
showMoreDateFlag: false, |
|
|
|
moreFlag: flag |
|
|
|
}) |
|
|
|
this.triggerEvent("onChangeDate",this.data.activeDate) |
|
|
|
this.triggerEvent("onChangeDate", this.data.activeDate) |
|
|
|
this.getTimeStock() |
|
|
|
}, |
|
|
|
getTimeStock:function(){ |
|
|
|
if(this.data.activeDate.is_time_stock!=true) return; |
|
|
|
commonApi.user_post("product/product_timestock_price",{ |
|
|
|
date:this.data.activeDate.date, |
|
|
|
sku_id:this.data.activeDate.sku_id?this.data.activeDate.sku_id:app.globalData.product.sku.id |
|
|
|
}).then(res=>{ |
|
|
|
getTimeStock: function () { |
|
|
|
if (this.data.activeDate.is_time_stock != true) return; |
|
|
|
commonApi.user_post("product/product_timestock_price", { |
|
|
|
date: this.data.activeDate.date, |
|
|
|
sku_id: this.data.activeDate.sku_id ? this.data.activeDate.sku_id : app.globalData.product.sku.id |
|
|
|
}).then(res => { |
|
|
|
let timeIndex = -1; |
|
|
|
if(app.globalData.product.infoTime){ |
|
|
|
this.triggerEvent("onChangeTime",app.globalData.product.infoTime); |
|
|
|
timeIndex = res.data.findIndex(item=>item.start_time==app.globalData.product.infoTime.start_time) |
|
|
|
if (app.globalData.product.infoTime) { |
|
|
|
this.triggerEvent("onChangeTime", app.globalData.product.infoTime); |
|
|
|
timeIndex = res.data.findIndex(item => item.start_time == app.globalData.product.infoTime.start_time) |
|
|
|
this.setData({ |
|
|
|
timelist:res.data, |
|
|
|
timeIndex:timeIndex |
|
|
|
timelist: res.data, |
|
|
|
timeIndex: timeIndex |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
for(let i=0;i<res.data.length;i++){ |
|
|
|
if(res.data[i].stock_number>0){ |
|
|
|
for (let i = 0; i < res.data.length; i++) { |
|
|
|
if (res.data[i].stock_number > 0) { |
|
|
|
timeIndex = i; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
timelist:res.data, |
|
|
|
timeIndex:timeIndex |
|
|
|
timelist: res.data, |
|
|
|
timeIndex: timeIndex |
|
|
|
}) |
|
|
|
this.triggerEvent("onChangeTime",this.data.timelist[this.data.timeIndex]) |
|
|
|
this.triggerEvent("onChangeTime", this.data.timelist[this.data.timeIndex]) |
|
|
|
}) |
|
|
|
}, |
|
|
|
selectTime:function(e){ |
|
|
|
if(this.data.timelist[e.currentTarget.dataset.index].stock_number!=0){ |
|
|
|
selectTime: function (e) { |
|
|
|
if (this.data.timelist[e.currentTarget.dataset.index].stock_number != 0) { |
|
|
|
this.setData({ |
|
|
|
timeIndex:e.currentTarget.dataset.index |
|
|
|
timeIndex: e.currentTarget.dataset.index |
|
|
|
}) |
|
|
|
this.triggerEvent("onChangeTime",this.data.timelist[this.data.timeIndex]) |
|
|
|
this.triggerEvent("onChangeTime", this.data.timelist[this.data.timeIndex]) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|