You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
986 lines
30 KiB
986 lines
30 KiB
// pages/order/scene/index.js
|
|
let app = getApp()
|
|
import util from "../../../utils/util"
|
|
import commonApi from "../../../utils/https/common"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
product:null,
|
|
productNum: 1,
|
|
linkmanList: [],
|
|
date: "",
|
|
time: "",
|
|
remark: "",
|
|
singlePrice: 0,
|
|
type: null,
|
|
coupon:null,
|
|
isLogin: false,
|
|
kjId: null,
|
|
gp_id: null,
|
|
groupName: "",
|
|
prizeId: null,
|
|
select_allowance: false,
|
|
showAllowance: false,
|
|
allowance_data: null,
|
|
allowance_price: 0,
|
|
pIndex: 0,
|
|
flag:null,
|
|
ticket_type:1,
|
|
isCar:'single',
|
|
showMask: false,
|
|
price:0,
|
|
is_need_idcard:1,
|
|
is_authentication:1, // 是否实名,0否1是,默认实名
|
|
phone:'', //不实名时传的手机号
|
|
is_real_name:1, // 是否是一证一票,0否1是,
|
|
status:false,
|
|
date: "",
|
|
time: "",
|
|
ydxz:false, //预定须知弹框
|
|
bookingInfo: null,
|
|
bookingInfoTitle: "",
|
|
showDate:false,
|
|
showDate2:false,
|
|
showYhq:null,
|
|
couponFlag:false,
|
|
|
|
skuDays: 30,
|
|
|
|
selectExplain: false,
|
|
explainData: null,
|
|
showContent: false,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
product: app.globalData.product,
|
|
type: options.type,
|
|
kjId: app.globalData.kjId,
|
|
gp_id: app.globalData.gp_id || app.globalData.team_id,
|
|
prizeId: wx.getStorageSync('prizeId'),
|
|
flag:options.flag,
|
|
date:null,
|
|
ticket_type:app.globalData.product.sku.ticket_type || 1,
|
|
isCar:options.isCar,
|
|
is_need_idcard:app.globalData.product.sku.sku_model.is_need_idcard,
|
|
is_authentication:app.globalData.product.sku.sku_model.is_authentication || 0,
|
|
is_real_name:app.globalData.product.sku.sku_model.is_real_name,
|
|
date: app.globalData.product.date,
|
|
time: app.globalData.product.time || {},
|
|
showYhq:app.globalData.listName?false:true
|
|
})
|
|
console.log('-------',this.data.product,this.data.time);
|
|
// debugger
|
|
console.log('-------',app.globalData.product.sku.sku_model.is_need_idcard);
|
|
console.log('---是否实名----',app.globalData.product.sku.sku_model.is_authentication);
|
|
console.log('---一证一票----',app.globalData.product.sku.sku_model.is_real_name);
|
|
console.log(app.globalData.list, app.globalData.index,'list---index')
|
|
if (!app.globalData.product) {
|
|
util.back();
|
|
return;
|
|
}
|
|
if (!app.globalData.product.time) {
|
|
app.globalData.product.time = {}
|
|
}
|
|
if (app.globalData.product.productNum) {
|
|
this.setData({
|
|
productNum: app.globalData.product.productNum < 1 ? 1 : app.globalData.product.productNum
|
|
})
|
|
}else{
|
|
this.setData({
|
|
productNum: app.globalData.product.num == null ? 1 : app.globalData.product.num
|
|
})
|
|
}
|
|
|
|
if (app.globalData.product && app.globalData.product.sku && app.globalData.product.sku.display_tags) {
|
|
try {
|
|
if (Array.isArray(app.globalData.product.sku.display_tags)) {
|
|
app.globalData.product.sku.display_tags_str = app.globalData.product.sku.display_tags.splice(0, 2).join(" | ");
|
|
} else {
|
|
app.globalData.product.sku.display_tags_str = app.globalData.product.sku.display_tags.split(",").splice(0, 2).join(" | ");
|
|
}
|
|
} catch(e) {}
|
|
// app.globalData.product.sku.display_tags_str = app.globalData.product.sku.display_tags.split(",").splice(0, 2).join(" | ");
|
|
}
|
|
if (this.data.product.product.scene_id == 5442) {
|
|
this.setData({skuDays: 7})
|
|
}
|
|
|
|
|
|
this.setData({
|
|
product: app.globalData.product,
|
|
singlePrice: app.globalData.product.date?app.globalData.product.date.price :(this.data.gp_id ? app.globalData.product.sku.event_price : app.globalData.product.sku.price)
|
|
// singlePrice: this.data.gp_id ? app.globalData.product.sku.event_price : app.globalData.product.sku.price
|
|
})
|
|
console.log(this.data.singlePrice);
|
|
|
|
this.getExplain()
|
|
|
|
try {
|
|
this.getNewCoupon()
|
|
} catch (e) {}
|
|
|
|
// this.showAllPrice()
|
|
// console.log('********',this.data.product);
|
|
if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1 && this.data.type!='museum') {
|
|
this.couponCom = this.selectAllComponents("#coupon")[0];
|
|
}
|
|
},
|
|
|
|
initPage () {
|
|
this.setData({
|
|
is_need_idcard:app.globalData.product.sku.sku_model.is_need_idcard,
|
|
is_authentication:app.globalData.product.sku.sku_model.is_authentication,
|
|
is_real_name:app.globalData.product.sku.sku_model.is_real_name,
|
|
})
|
|
},
|
|
|
|
// next: function () {
|
|
// this.setData({
|
|
// showMask:true
|
|
// })
|
|
// },
|
|
// changeDate() {
|
|
// this.setData({
|
|
// showDate: true,
|
|
// })
|
|
// },
|
|
hideDate: function () {
|
|
this.setData({
|
|
showDate: false
|
|
})
|
|
},
|
|
showBookingInfo: function (e) {
|
|
this.setData({
|
|
bookingInfo: this.data.product.sku.sku_model,
|
|
bookingInfoTitle: this.data.product.sku.sku_name
|
|
})
|
|
util.pagePoint({
|
|
event: "scene_notice",
|
|
param: {
|
|
type: this.data.product.type,
|
|
id: this.data.product.id
|
|
}
|
|
}, 1)
|
|
},
|
|
closeMask: function () {
|
|
this.setData({
|
|
bookingInfo: null
|
|
})
|
|
},
|
|
showAllPrice:function () {
|
|
// console.log('detail',app.globalData.product);
|
|
// console.log('singlePrice',this.data.singlePrice);
|
|
// console.log('productNum',this.data.productNum);
|
|
console.log('couponInfo',app.globalData.couponInfo);
|
|
if (this.data.ticket_type != 1) {
|
|
// this.setData({
|
|
// singlePrice:app.globalData.product.product.price
|
|
// })
|
|
let price
|
|
if (this.data.coupon) {
|
|
console.log(app.globalData.couponInfo,this.data.coupon);
|
|
if (this.data.coupon.activity.discount_type == 'pricebreak') {
|
|
price = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
|
|
} else {
|
|
price =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
|
|
}
|
|
} else {
|
|
price = this.data.singlePrice * this.data.productNum
|
|
}
|
|
|
|
if (price >0) {
|
|
this.setData({
|
|
price:price/100
|
|
})
|
|
}else {
|
|
this.setData({
|
|
price:0
|
|
})
|
|
}
|
|
// console.log(this.data.singlePrice);
|
|
}else {
|
|
let price
|
|
if (this.data.coupon) {
|
|
if (this.data.coupon.activity.discount_type == 'pricebreak') {
|
|
price = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
|
|
} else {
|
|
price =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
|
|
}
|
|
} else {
|
|
price = this.data.singlePrice * this.data.productNum
|
|
}
|
|
if (price >0) {
|
|
this.setData({
|
|
price:price/100
|
|
})
|
|
}else {
|
|
this.setData({
|
|
price:0
|
|
})
|
|
}
|
|
}
|
|
// let price = this.data.singlePrice * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0)
|
|
// 多写了一遍
|
|
// let price
|
|
// if (this.data.coupon) {
|
|
// if (this.data.coupon.discount_type == 'pricebreak') {
|
|
// price = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
|
|
// } else {
|
|
// price =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
|
|
// }
|
|
// } else {
|
|
// price = this.data.singlePrice * this.data.productNum
|
|
// }
|
|
// if (price >0) {
|
|
// this.setData({
|
|
// price:price/100
|
|
// })
|
|
// }else {
|
|
// this.setData({
|
|
// price:0
|
|
// })
|
|
// }
|
|
},
|
|
cancel: function () {
|
|
this.setData({
|
|
showMask:false
|
|
})
|
|
},
|
|
changeGroupName: function (e) {
|
|
this.setData({
|
|
groupName: e.detail.value
|
|
})
|
|
},
|
|
setLinkman: function (e) {
|
|
if (e.detail.phone || e.detail.phone=='') {
|
|
this.setData({
|
|
phone:e.detail.phone
|
|
})
|
|
console.log('setphone', e.detail.phone)
|
|
}else {
|
|
console.log(e);
|
|
let linkmanList = e.detail;
|
|
if (this.data.productNum != linkmanList.length && this.data.coupon) {
|
|
wx.showToast({
|
|
title: '订单价格发生变化,请重新选择优惠券',
|
|
icon: 'none'
|
|
})
|
|
// if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1) {
|
|
// this.couponCom.setNullCoupon()
|
|
// }
|
|
// app.globalData.couponInfo = null;
|
|
// this.setData({
|
|
// coupon: null
|
|
// })
|
|
}
|
|
// let productNum = linkmanList.length == 0 ? 1 : this.data.productNum < linkmanList.length ? linkmanList.length : this.data.productNum;
|
|
// if (this.data.gp_id) {
|
|
// productNum = app.globalData.product.maxNum;
|
|
// }
|
|
this.setData({
|
|
// productNum: productNum,
|
|
linkmanList: linkmanList
|
|
})
|
|
console.log(this.data.linkmanList);
|
|
// this.changePrice()
|
|
this.totalPrice(this.data.singlePrice)
|
|
}
|
|
},
|
|
add: function () {
|
|
if (this.data.productNum==undefined) {
|
|
wx.showToast({
|
|
title: '请先添加出行人',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.data.product.sku.sku_model.traveller_limit_num != 0 && this.data.productNum == this.data.product.sku.sku_model.traveller_limit_num) {
|
|
wx.showToast({
|
|
title: '本产品单笔限购' + this.data.product.sku.sku_model.traveller_limit_num + "份",
|
|
icon: 'none'
|
|
})
|
|
return;
|
|
}
|
|
this.setData({
|
|
productNum: this.data.productNum + 1
|
|
})
|
|
this.data.product.num = this.data.productNum
|
|
// this.changePrice()
|
|
// this.showAllPrice()
|
|
this.totalPrice(this.data.singlePrice)
|
|
},
|
|
minus: function () {
|
|
if (this.data.productNum==undefined) {
|
|
wx.showToast({
|
|
title: '请先添加出行人',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.data.productNum == 1) return;
|
|
if (this.data.coupon) {
|
|
wx.showToast({
|
|
title: '订单价格发生变化,请重新选择优惠券',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1 && !this.data.flag && this.data.type!='museum') {
|
|
// this.couponCom.setNullCoupon()
|
|
|
|
}
|
|
app.globalData.couponInfo = null;
|
|
console.log(this.data.couponFlag);
|
|
this.setData({
|
|
productNum: (this.data.productNum - 1),
|
|
coupon: null,
|
|
couponFlag:true
|
|
})
|
|
this.data.product.num = this.data.productNum
|
|
// this.changePrice()
|
|
// this.showAllPrice()
|
|
this.totalPrice(this.data.singlePrice)
|
|
},
|
|
totalPrice(price) {
|
|
this.setData({
|
|
singlePrice:price
|
|
})
|
|
|
|
let allPrice
|
|
if (this.data.coupon) {
|
|
if (this.data.coupon.activity.discount_type == 'pricebreak') {
|
|
allPrice = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
|
|
} else {
|
|
allPrice =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
|
|
}
|
|
} else {
|
|
allPrice = this.data.singlePrice * this.data.productNum
|
|
}
|
|
|
|
// allPrice = price * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0)
|
|
if (allPrice >0) {
|
|
this.setData({
|
|
price:allPrice/100,
|
|
singlePrice:price
|
|
})
|
|
}else {
|
|
this.setData({
|
|
price:0,
|
|
singlePrice:price
|
|
})
|
|
}
|
|
console.log('singlePrice',this.data.singlePrice);
|
|
},
|
|
changeDate: function (e) {
|
|
console.log('打印',e);
|
|
let sku_id = e.detail.sku_id;
|
|
this.setData({
|
|
showDate:true
|
|
})
|
|
// debugger
|
|
// this.showAllPrice()
|
|
this.totalPrice(e.detail.price)
|
|
if (e.detail.price != this.data.singlePrice && this.data.coupon) {
|
|
wx.showToast({
|
|
title: '订单价格发生变化,请重新选择优惠券',
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
coupon: null,
|
|
singlePrice:e.detail.price
|
|
})
|
|
if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1 && this.data.type!='museum') {
|
|
this.couponCom.setNullCoupon()
|
|
}
|
|
app.globalData.couponInfo = null;
|
|
}
|
|
app.globalData.product.changeFlag = true
|
|
this.setData({
|
|
date: e.detail,
|
|
showDate2:true
|
|
})
|
|
// this.changePrice()
|
|
|
|
// 获取sku信息
|
|
commonApi._post("product/get_sku_detail_id", {
|
|
sku_id: sku_id
|
|
}).then(res => {
|
|
this.data.product.sku = res.data
|
|
app.globalData.product.sku = res.data
|
|
this.setData({
|
|
singlePrice: this.data.gp_id ? this.data.product.sku.event_price : e.detail.price,
|
|
product: this.data.product
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
changeTime: function (e) {
|
|
this.setData({
|
|
time: e.detail
|
|
})
|
|
},
|
|
changeAllowance: function () {
|
|
this.setData({
|
|
showAllowance: !this.data.showAllowance
|
|
})
|
|
},
|
|
changeRemark: function (e) {
|
|
this.setData({
|
|
remark: e.detail.value
|
|
})
|
|
},
|
|
/**
|
|
* 补贴价
|
|
*/
|
|
changePrice: function () {
|
|
let product = this.data.product, price = product.sku.price;
|
|
if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) {
|
|
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price);
|
|
price -= this.data.allowance_price < spread_price ? this.data.allowance_price : spread_price
|
|
}
|
|
this.setData({
|
|
singlePrice: app.globalData.kjId ? 0 : price
|
|
})
|
|
|
|
},
|
|
changed() {
|
|
console.log('time---',this.data.date,this.data.time)
|
|
app.globalData.product.date = this.data.date
|
|
app.globalData.product.time = this.data.time
|
|
app.globalData.product.changeFlag = true
|
|
this.hideDate()
|
|
|
|
// this.initPage()
|
|
|
|
},
|
|
order:function() {
|
|
let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product;
|
|
let linkmanIds = [];
|
|
if (linkmanList.length==0 && this.data.is_authentication == 1) {
|
|
wx.showToast({
|
|
title: '请选择出行人',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.data.is_authentication == 1) {
|
|
linkmanList.map(item => {
|
|
linkmanIds.push(item.id)
|
|
})
|
|
}
|
|
if (this.data.is_authentication == 0) { //是否实名:0否1是
|
|
if (this.data.phone == '') {
|
|
wx.showToast({
|
|
title: '请填写手机号',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
}
|
|
// 判断时间日期
|
|
if (!date && this.data.ticket_type == 1) {
|
|
wx.showToast({
|
|
title: '请选择使用日期',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (!time && date && date.is_time_stock == true) {
|
|
wx.showToast({
|
|
title: '请选择使用时间',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
let data = {
|
|
coupon_id: this.data.coupon ? this.data.coupon.id : null,
|
|
source: "WECHATXCX",
|
|
product_list: [{
|
|
type: product.product.type,
|
|
product_id: product.product.id,
|
|
sku_id: (date && date.sku_id) ? date.sku_id : product.sku.id,
|
|
compose_sku_id: product.sku.compose_sku_id,
|
|
start_time: time.start_time,
|
|
end_time: time.end_time,
|
|
use_date: date ? date.date : '',
|
|
visitors: linkmanIds.join(","),
|
|
remark: remark,
|
|
product_num: app.globalData.product.isGroup == 1 ? 1 : productNum,
|
|
phone:this.data.phone,// 不实名的时候传的手机号参数
|
|
// 美食预定
|
|
reserve_mobile: product.product.type=="food"?this.data.phone:"",
|
|
}],
|
|
originate_order_id: this.data.kjId,
|
|
gp_id: app.globalData.gp_id,
|
|
team_id: app.globalData.team_id,
|
|
linkmanList:this.data.is_authentication == 1?this.data.linkmanList:[]
|
|
}
|
|
if (this.data.selectExplain && this.data.explainData) {
|
|
let explainData = this.data.explainData
|
|
let explain_prod = {
|
|
type: explainData.product.type,
|
|
product_id: explainData.product.id,
|
|
sku_id: explainData.sku.id,
|
|
product_num: 1,
|
|
}
|
|
data.product_list.push(explain_prod)
|
|
}
|
|
|
|
if (app.globalData.from) {
|
|
data.system_name = app.globalData.from;
|
|
}
|
|
if (app.globalData.retailId) {
|
|
data.commission_code = app.globalData.retailId;
|
|
app.globalData.retailId = null;
|
|
}
|
|
if (app.globalData.category_id) {
|
|
data.category_id = app.globalData.category_id;
|
|
}
|
|
if (this.data.prizeId) {
|
|
data.lottery_id = this.data.prizeId
|
|
}
|
|
if (this.data.product.product.ZTPoint) {
|
|
data.partner_code = this.data.product.product.ZTPoint
|
|
data.channel = this.data.product.product.ZTPoint
|
|
}
|
|
let service = 'order/create', postData = {
|
|
data: JSON.stringify(data)
|
|
}
|
|
|
|
if (app.globalData.product.isGroup == 1) {
|
|
service = "team_order/appoint"
|
|
postData.member_num = this.data.productNum
|
|
postData.team_name = this.data.groupName
|
|
postData.type = 1;
|
|
}
|
|
if(app.globalData.list){
|
|
app.globalData.list[app.globalData.index] = this.data.product
|
|
// app.globalData.list[app.globalData.index].linkmanList = this.data.linkmanList
|
|
if (!app.globalData.list[app.globalData.index].sku.sku_model.is_authentication) {
|
|
app.globalData.list[app.globalData.index].phone = this.data.phone
|
|
// app.globalData.list[app.globalData.index].reserve_mobile = this.data.phone
|
|
app.globalData.list[app.globalData.index].linkmanList = []
|
|
}else {
|
|
app.globalData.list[app.globalData.index].linkmanList = this.data.linkmanList
|
|
}
|
|
}
|
|
// app.globalData.linkmanList = this.data.linkmanList
|
|
app.globalData.ticketPrice += (this.data.singlePrice * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0))/100;
|
|
console.log(app.globalData);
|
|
if(app.globalData.list && app.globalData.list.length > app.globalData.index + 1 &&this.data.type!='museum'){
|
|
if(app.globalData.createDate){
|
|
app.globalData.createDate.product_list.push(data.product_list[0])
|
|
}else{
|
|
app.globalData.createDate = data
|
|
}
|
|
console.log(app.globalData.createDate);
|
|
app.globalData.index = app.globalData.index + 1
|
|
app.globalData.product = app.globalData.list[app.globalData.index]
|
|
wx.redirectTo({
|
|
url: '/pages/order/scene/index?flag='+ this.data.flag+'&isCar='+this.data.isCar,
|
|
})
|
|
return
|
|
}else{
|
|
if(app.globalData.list && app.globalData.list.length > 1 || app.globalData.postProduct.length>0){
|
|
if(app.globalData.createDate){
|
|
app.globalData.createDate.product_list.push(data.product_list[0])
|
|
}
|
|
wx.redirectTo({
|
|
url: '/pages/order/orderList/index?flag='+ this.data.flag
|
|
})
|
|
}else{
|
|
// 5442拙政园弹弹框
|
|
if (this.data.product.product.scene_id == 5442) {
|
|
wx.showModal({
|
|
content: '节假日期间出票时间可能延迟,请耐心等待,最终出票结果以平台通知为准',
|
|
confirmColor:"#0B898E",
|
|
success: (res)=>{
|
|
if (res.confirm) {
|
|
commonApi.user_post(service, postData).then(res => {
|
|
if (app.globalData.kjId) {
|
|
this.setData({
|
|
kjId: null
|
|
});
|
|
app.globalData.kjId = null;
|
|
}
|
|
if (app.globalData.gp_id) {
|
|
this.setData({
|
|
gp_id: null
|
|
});
|
|
app.globalData.gp_id = null;
|
|
}
|
|
if (res.code == 1 && app.globalData.product.isGroup == 1) {
|
|
// 团购跳转到团购详情
|
|
wx.navigateTo({
|
|
url: '/pages/info/groupOrderInfo/index?id=' + res.data.order_id + '&from=order'
|
|
})
|
|
}
|
|
})
|
|
|
|
} else if (res.cancel) {}
|
|
},
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
commonApi.user_post(service, postData).then(res => {
|
|
if (app.globalData.kjId) {
|
|
this.setData({
|
|
kjId: null
|
|
});
|
|
app.globalData.kjId = null;
|
|
}
|
|
if (app.globalData.gp_id) {
|
|
this.setData({
|
|
gp_id: null
|
|
});
|
|
app.globalData.gp_id = null;
|
|
}
|
|
if (res.code == 1 && app.globalData.product.isGroup == 1) {
|
|
// 团购跳转到团购详情
|
|
wx.navigateTo({
|
|
url: '/pages/info/groupOrderInfo/index?id=' + res.data.order_id + '&from=order'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
},
|
|
next: function () {
|
|
console.log(this.data)
|
|
let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product;
|
|
let linkmanIds = [];
|
|
// if (this.data.is_need_idcard == 1) {
|
|
// if (linkmanList.length < productNum && app.globalData.product.isGroup != 1) {
|
|
// wx.showToast({
|
|
// title: '请添加出行人',
|
|
// icon: "none"
|
|
// })
|
|
// return;
|
|
// }
|
|
// }
|
|
if (!date && this.data.ticket_type == 1) {
|
|
wx.showToast({
|
|
title: '请选择使用日期',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (linkmanList.length!=productNum && this.data.is_authentication == 1 && this.data.is_real_name == 1) {
|
|
wx.showToast({
|
|
title: '购票数量要和出行人数量一致',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (!util.isTel(this.data.phone) &&this.data.is_authentication == 0) {
|
|
wx.showToast({
|
|
title: '请输入正确的手机号',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (!time && date && date.is_time_stock == true) {
|
|
wx.showToast({
|
|
title: '请选择使用时间',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (app.globalData.product.isGroup == 1 && !this.data.groupName) {
|
|
wx.showToast({
|
|
title: '请输入团队主体名称',
|
|
icon: 'none'
|
|
})
|
|
return;
|
|
}
|
|
// if (this.data.phone) {
|
|
// linkmanList.map(item => {
|
|
// linkmanIds.push(item.id)
|
|
// })
|
|
// }
|
|
// console.log(app.globalData);
|
|
// debugger
|
|
this.setData({
|
|
showMask:true
|
|
})
|
|
// linkmanList.map(item => {
|
|
// linkmanIds.push(item.id)
|
|
// })
|
|
// console.log(date)
|
|
// let data = {
|
|
// coupon_id: this.data.coupon ? this.data.coupon.id : null,
|
|
// source: "WECHATXCX",
|
|
// product_list: [{
|
|
// type: product.product.type,
|
|
// product_id: product.product.id,
|
|
// sku_id: (date && date.sku_id) ? date.sku_id : product.sku.id,
|
|
// start_time: time.start_time,
|
|
// end_time: time.end_time,
|
|
// use_date: date ? date.date : '',
|
|
// visitors: linkmanIds.join(","),
|
|
// remark: remark,
|
|
// product_num: app.globalData.product.isGroup == 1 ? 1 : productNum
|
|
// }],
|
|
// originate_order_id: this.data.kjId,
|
|
// gp_id: app.globalData.gp_id,
|
|
// team_id: app.globalData.team_id,
|
|
// linkmanList:this.data.linkmanList
|
|
// }
|
|
// if (app.globalData.from) {
|
|
// data.system_name = app.globalData.from;
|
|
// }
|
|
// if (app.globalData.retailId) {
|
|
// data.commission_code = app.globalData.retailId;
|
|
// app.globalData.retailId = null;
|
|
// }
|
|
// if (app.globalData.category_id) {
|
|
// data.category_id = app.globalData.category_id;
|
|
// }
|
|
// if (this.data.prizeId) {
|
|
// data.lottery_id = this.data.prizeId
|
|
// }
|
|
// let service = 'order/create', postData = {
|
|
// data: JSON.stringify(data)
|
|
// }
|
|
// if (app.globalData.product.isGroup == 1) {
|
|
// service = "team_order/appoint"
|
|
// postData.member_num = this.data.productNum
|
|
// postData.team_name = this.data.groupName
|
|
// postData.type = 1;
|
|
// }
|
|
// if(app.globalData.list){
|
|
// app.globalData.list[app.globalData.index] = this.data.product
|
|
// app.globalData.list[app.globalData.index].linkmanList = this.data.linkmanList
|
|
// }
|
|
// // app.globalData.linkmanList = this.data.linkmanList
|
|
// app.globalData.ticketPrice += (this.data.singlePrice * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0))/100;
|
|
// console.log(app.globalData);
|
|
// if(app.globalData.list && app.globalData.list.length > app.globalData.index + 1 &&this.data.type!='museum'){
|
|
// if(app.globalData.createDate){
|
|
// app.globalData.createDate.product_list.push(data.product_list[0])
|
|
// }else{
|
|
// app.globalData.createDate = data
|
|
// }
|
|
// app.globalData.index = app.globalData.index + 1
|
|
// app.globalData.product = app.globalData.list[app.globalData.index]
|
|
// wx.redirectTo({
|
|
// url: '/pages/order/scene/index?flag='+ this.data.flag+'&isCar='+this.data.isCar,
|
|
// })
|
|
// return
|
|
// }else{
|
|
// if(app.globalData.list && app.globalData.list.length > 1 || app.globalData.postProduct.length>0){
|
|
// if(app.globalData.createDate){
|
|
// app.globalData.createDate.product_list.push(data.product_list[0])
|
|
// }
|
|
// wx.redirectTo({
|
|
// url: '/pages/order/orderList/index?flag='+ this.data.flag
|
|
// })
|
|
// }else{
|
|
// commonApi.user_post(service, postData).then(res => {
|
|
// if (app.globalData.kjId) {
|
|
// this.setData({
|
|
// kjId: null
|
|
// });
|
|
// app.globalData.kjId = null;
|
|
// }
|
|
// if (app.globalData.gp_id) {
|
|
// this.setData({
|
|
// gp_id: null
|
|
// });
|
|
// app.globalData.gp_id = null;
|
|
// }
|
|
// if (res.code == 1 && app.globalData.product.isGroup == 1) {
|
|
// // 团购跳转到团购详情
|
|
// wx.navigateTo({
|
|
// url: '/pages/info/groupOrderInfo/index?id=' + res.data.order_id + '&from=order'
|
|
// })
|
|
// }
|
|
// })
|
|
// }
|
|
// }
|
|
},
|
|
// 活动预约
|
|
activityOrder: function () {
|
|
if (this.data.linkmanList && this.data.linkmanList.length > 0) {
|
|
commonApi.user_post("pbservice/Culture/booking", {
|
|
id: this.data.product.product.id,
|
|
name: this.data.linkmanList[0].name,
|
|
card_number: this.data.linkmanList[0].id_number,
|
|
tel: this.data.linkmanList[0].tel
|
|
}).then(res => {
|
|
if (res.code == 1) {
|
|
wx.showToast({
|
|
title: '预约成功',
|
|
icon: 'success'
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1000)
|
|
return;
|
|
}
|
|
})
|
|
}
|
|
else {
|
|
wx.showToast({
|
|
title: '请选择出行人',
|
|
icon: 'none'
|
|
})
|
|
return;
|
|
}
|
|
|
|
},
|
|
/**
|
|
* 选择补贴
|
|
*/
|
|
selectAllowance: function () {
|
|
this.setData({
|
|
select_allowance: !this.data.select_allowance
|
|
})
|
|
this.changePrice()
|
|
},
|
|
//获取最高优惠券
|
|
getNewCoupon(e){
|
|
this.setData({
|
|
coupon:e.detail
|
|
})
|
|
this.showAllPrice()
|
|
},
|
|
|
|
// 讲解
|
|
getExplain () {
|
|
console.log(this.data.product)
|
|
commonApi._post("product/get_product_compose_list", {
|
|
product_id: this.data.product.product.id
|
|
}).then(res => {
|
|
if (res.data && res.data.length>0) {
|
|
this.setData({
|
|
explainData: res.data[0]
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
changeSeletExplain (e) {
|
|
let val = e.currentTarget.dataset.val;
|
|
this.setData({
|
|
selectExplain: val
|
|
})
|
|
},
|
|
|
|
changeContent (e) {
|
|
let val = e.currentTarget.dataset.val;
|
|
this.setData({
|
|
showContent: val
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
// this.setData({
|
|
// productNum:1
|
|
// })
|
|
// app.globalData.productNum =1
|
|
if(app.globalData.list && app.globalData.list.length != 0 && this.data.type!='museum'){
|
|
app.globalData.product = app.globalData.list[app.globalData.index]
|
|
}
|
|
if (!this.data.isLogin) {
|
|
commonApi.user_post("token/check").then(res => {
|
|
if (res.code == 1) {
|
|
this.setData({
|
|
isLogin: true
|
|
})
|
|
}
|
|
})
|
|
}
|
|
// this.setData({
|
|
// coupon: app.globalData.couponInfo
|
|
// })
|
|
// 获取补贴
|
|
// if (this.data.product) {
|
|
// commonApi.user_post("product/getProductAllowancePrice", {
|
|
// product_code: this.data.product.product.product_code
|
|
// }).then(resTwo => {
|
|
// if (resTwo && resTwo.code == 1) {
|
|
// this.setData({
|
|
// allowance_data: resTwo.data
|
|
// })
|
|
// let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price)
|
|
// let sInfo = this.data.product.sku
|
|
// if (spread_price > 0) {
|
|
// if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) {
|
|
// this.setData({
|
|
// allowance_price: spread_price
|
|
// })
|
|
// } else {
|
|
// this.setData({
|
|
// allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price
|
|
// })
|
|
// }
|
|
// this.changePrice()
|
|
// } else {
|
|
// this.setData({
|
|
// allowance_price: 0
|
|
// })
|
|
// }
|
|
// }
|
|
// })
|
|
// }
|
|
// console.log('-----',app.globalData.product.sku.price);
|
|
// app.globalData.product = delete(app.globalData.product.detail)
|
|
// this.showAllPrice()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
this.setData({
|
|
couponFlag:false
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
this.setData({
|
|
kjId: null,
|
|
gp_id: null
|
|
});
|
|
app.globalData.kjId = null;
|
|
app.globalData.gp_id = null;
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
}
|
|
})
|