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.
 

192 lines
4.5 KiB

// pages/order/movie/index.js
import util from "../../../utils/util"
import commonApi from "../../../utils/https/common"
import userApi from "../../../utils/https/user"
let app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
key:"",
tel:'',
product:null,
price:0,
coupon:app.globalData.couponInfo,
prizeId:null,
num:0,
sPrice:0,
hideMx:false,
showModel:false,
agree:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(JSON.parse(options));
app.globalData.couponInfo = null
this.setData({
coupon:app.globalData.couponInfo
})
this.setData({
prizeId:wx.getStorageSync('prizeId')
})
let product = app.globalData.product,price=0,num=0,sPrice=0;
product.info.selectSeatInfo = JSON.parse(options.selectSeatInfo)
product.info.selectSeatInfo.seatPriceInfo.map(item=>{
price =price +Math.ceil(Number(item.split('-')[1])*1.006 * 100) / 100
num = num + 1
sPrice = Math.ceil(Number(item.split('-')[1])*1.006 * 100) / 100
})
console.log(price*100);
this.setData({
product:product,
price:(price*100).toFixed(2),
num:num,
sPrice:sPrice
})
console.log(this.data.price);
userApi.user_post("user/getMyInfo").then(res=>{
this.setData({
tel:res.data.mobile
})
})
},
changeTel:function(e){
this.setData({
tel:e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
order:function(){
if (!this.data.agree) {
wx.showToast({
title: '请您先同意购票退改规则',
icon:'none'
})
return
}
if(!this.data.tel){
wx.showToast({
title: '请输入手机号',
icon:'none'
})
return;
}
let product = this.data.product
// product.info.selectSeatInfo.map(item=>{
// seats_list.push(item.name);
// seats_ids.push({
// ext_id:item.ext_id,
// area:item.area || "",
// flag:Number(item.flag)
// })
// })
let product_list = [{
"type" : "movie",//电影,必填
"product_id": product.product.id,
"sku_id": product.product.sku_info.id,
"product_num": product.info.selectSeatInfo.seatInfo.length,//也就是锁定的座位数,必填
"reserve_mobile": this.data.tel,
"use_date": product.info.show_date,//使用日期,Y-m-d日期格式字符串,必填
"use_time": product.info.show_time+'-'+product.info.close_time,//场次时间,直接传字符串,必填
"show_version": product.info.show_version,//场次版本,必填
"scene_id": product.product.scene_id,//场景id,我方系统的场景id,必填
"schedules_name": product.info.hallName,//放映厅名称,必填
"seats_list": product.info.selectSeatInfo.seatInfo.join(","),//座位中文名称,多个座位逗号分隔,必填
// "key": this.data.key,//锁座返回的key,必填
"schedules_id": product.info.schedule_id,//淘票票场次id,必填
"seats_ids": product.info.selectSeatInfo.seatPriceInfo
}];
let data = {
product_list:product_list,
source:"WECHATXCX",
coupon_id:this.data.coupon?this.data.coupon.id:null
}
if(app.globalData.from){
data.system_name = app.globalData.from;
}
if(this.data.prizeId){
data.lottery_id = this.data.prizeId
}
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;
}
commonApi.user_post("order/create",{
data:JSON.stringify(data)
}).then(res=>{
console.log(res)
})
},
mingxi(){
this.setData({
hideMx:!this.data.hideMx
})
},
closeModel(){
this.setData({
showModel:!this.data.showModel,
agree:false
})
},
changeAgree(){
this.setData({
agree:!this.data.agree
})
},
//获取最高优惠券
getNewCoupon(e){
this.setData({
coupon:e.detail
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}
})