手持机
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.
 
 
 
 
PDA/pages/shoppingTrolley/shoppingTrolley.vue

1084 lines
32 KiB

<template>
<view class="m-content">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text=""
:showIconText="true" iconText="仅看可售" rightWidth="150rpx" title="手持售票" @clickLeft="back" :right-icon="isChecked?'checkbox':'circle'" @clickRight="toggleCheckbox" />
<z-paging class="z-padding" ref="paging" v-model="dataList" @query="queryList" :style="[{ top: safeHeight() }]">
<!-- 需要固定在顶部不滚动的view放在slot="top"的view中,如果需要跟着滚动,则不要设置slot="top" -->
<!-- 注意!此处的z-tabs为独立的组件,可替换为第三方的tabs,若需要使用z-tabs,请在插件市场搜索z-tabs并引入,否则会报插件找不到的错误 -->
<template #top>
<view class="m-btn-group">
<button >景区门票</button>
<button >游玩套票</button>
</view>
<z-tabs :activeStyle="activeStyle" :list="tabList" @change="tabChange" valueKey="id"
:inactive-color="'rgba(27, 27, 27, 1)'" :bgColor="'transparent'" />
</template>
<!-- 自定义下拉刷新view(如果use-custom-refresher为true且不设置下面的slot="refresher",此时不用获取refresherStatus,会自动使用z-paging自带的下拉刷新view) -->
<!-- 注意注意注意!!字节跳动小程序中自定义下拉刷新不支持slot-scope,将导致custom-refresher无法显示 -->
<!-- 如果是字节跳动小程序,请参照sticky-demo.vue中的写法,此处使用slot-scope是为了减少data中无关变量声明,降低依赖 -->
<template #refresher="{ refresherStatus }">
<!-- 此处的custom-refresh为demo中自定义的组件,非z-paging的内置组件,请在实际项目中自行创建。这里插入什么view,下拉刷新就显示什么view -->
<custom-refresher :status="refresherStatus" />
</template>
<!-- 自定义没有更多数据view -->
<template #loadingMoreNoMore>
<!-- 此处的custom-nomore为demo中自定义的组件,非z-paging的内置组件,请在实际项目中自行创建。这里插入什么view,没有更多数据就显示什么view -->
<custom-nomore></custom-nomore>
</template>
<!-- 如果希望其他view跟着页面滚动,可以放在z-paging标签内 -->
<view class="item" v-for="(item, index) in dataList" :key="index" @click="itemClick(item)">
<view class="item-title">{{ item.ticketname }}</view>
<view class="item-date" v-if="item.datesettings == 1">
<view class="m-date-label">使用有效期:</view>
<view class="m-date-value">
{{ parseArrayTime(item.usevalidityStart) }}
{{ parseArrayTime(item.usevalidityEnd) }}
</view>
</view>
<!-- datesettings=='2' 日期票------------------ -->
<view class="item-date" v-if="item.datesettings == 2">
<view class="m-date-label">使用天数:</view>
<view class="m-date-value">
{{ item.effectivedays }}
<span class="m-l-mini">天</span>
</view>
</view>
<!-- datesettings=='3' 小时票------------------ -->
<view class="item-date" v-if="item.datesettings == 3">
<view class="m-date-label">使用时间段:</view>
<view class="m-date-value">
{{ item.usertimeslotStart }}
{{ item.usertimeslotEnd }}
</view>
</view>
<!-- <view class="item-date">
<view class="m-date-label">有效期:</view>
<view class="m-date-value">
{{ parseTime(item.usevalidityStart) + '至' + parseTime(item.usevalidityEnd) }}
</view>
</view> -->
<view class="footer">
<view class="item-price">¥{{ item.settlementPrice }}</view>
<button v-if="item.islisted == 1" class="m-btn" :loading="item.btnLoading" size="mini"
@click.stop="onPlay($event, item)">
加购
</button>
<button class="m-btn disble" v-else disabled size="mini">已下架</button>
</view>
</view>
</z-paging>
<view class="m-botom fixed-botom">
<view class="m-botm-left">
<view class="m-b-l-t">
合计:
<span class="m-red">
¥
<span class="m-price">{{ ticketSumPrice }}</span>
</span>
</view>
<view class="m-b-l-b">
已选门票
<span class="m-red">{{ ticketSumNum }}</span>
</view>
</view>
<view class="m-botm-right">
<button class="m-prime" size="mini" @click="goShopCar">去购物车</button>
</view>
</view>
<cart-animation ref="cartAnimation"></cart-animation>
<wu-calendar @monthSwitch="changeMonth" :startDate="startDate" :selected="selected" ref="calendar"
@confirm="calendarConfirm" :insert="false"></wu-calendar>
</view>
</template>
<script>
import customNomore from '@/components/custom-nomore/custom-nomore.vue';
import customRefresher from '@/components/custom-refresher/custom-refresher.vue';
import cartAnimation from '@/components/f-cartAnimation/f-cartAnimation';
import {
parseTime,
parseArrayTime
} from '@/utils/ruoyi.js';
import {
getTicketSortList,
getTicketList,
getTicketDateInventory
} from '@/api/seal/seal.js';
import {
date
} from '../../uni_modules/wu-ui-tools/libs/function/test';
export default {
components: {
customNomore,
customRefresher,
cartAnimation
},
data() {
return {
//v-model绑定的这个变量不要在分页请求结束中自己赋值!!!
dataList: [],
tabList: [],
car: [],
ticketsort: null,
queryStatus: 1,
ticketSumNum: 0,
ticketSumPrice: 0,
activeStyle: {
'font-family': 'Source Han Sans SC',
'font-weight': 'bold',
'font-size': '32upx',
color: '#2277F0'
},
busPos: {
x: uni.getSystemInfoSync().windowWidth - 350,
y: uni.getSystemInfoSync().windowHeight + 100
},
startDate: parseTime(new Date()),
selected: [],
selectItem: null,
event: null,
ITEM: null, //日期模式选中的item在切换日期时用到
isChecked: true, // 新增的复选框状态
};
},
watch: {
car: {
handler(val) {
console.log(val, 'car变化了');
this.ticketSumNum = 0;
this.ticketSumPrice = 0;
if (Array.isArray(val) && val.length > 0) {
// 使用reduce代替forEach,减少副作用操作
const {
totalCents,
totalNum
} = val.reduce((acc, item) => {
const price = Number(item.settlementPrice);
const quantity = Number(item.num);
// 转换为分并四舍五入
const priceInCents = Math.round(price * 100);
acc.totalCents += priceInCents * quantity;
acc.totalNum += quantity;
return acc;
}, {
totalCents: 0,
totalNum: 0
});
console.log('totalNum',totalNum,totalCents)
// 结果处理(分转元+保留两位小数)
this.ticketSumNum = parseFloat(totalNum.toFixed(2));
this.ticketSumPrice = parseFloat((totalCents / 100).toFixed(2));
}
}
},
isChecked:{
handler(val){
if(val){
this.changeStatus()
}else{
this.clearStatus()
}
},
immediate:true
}
},
onShow() {
//debugger
const allTicket = uni.getStorageSync('ALL_TICKET');
if (allTicket && Array.isArray(allTicket) && allTicket.length > 0) {
this.car = allTicket
} else {
this.car = []
this.ticketSumNum = 0;
this.ticketSumPrice = 0;
}
},
onReady() {
const eve = uni.getStorageSync('EVENT');
if (eve && eve != null && eve != '') {
const event = JSON.parse(eve)
this.$refs.cartAnimation.touchOnGoods(event, this.busPos);
uni.removeStorageSync('EVENT')
}
},
onLoad() {
this.getTicketSortList();
},
mounted() {},
methods: {
//切换月份
changeMonth(e) {
console.log(e)
let that = this
let fullDate = e.fullDate + '-01'
if (fullDate < that.parseTime(new Date())) {
fullDate = that.parseTime(new Date())
}
if (this.ITEM.inventorySettings == 1 || this.ITEM.inventorySettings == 2) {
const params = {
ticketId: this.ITEM.id,
date: fullDate
};
getTicketDateInventory(params)
.then((res) => {
that.selected = []
res.data.forEach((items) => {
const obj = {
date: items.date,
info: '库存:' + that.ITEM.currentinventory,
infoColor: '#666',
topInfo: '',
topInfoColor: '',
badgeColor: '',
disable: !items.isAvailable // 禁用
};
that.selected.push(obj);
});
that.$forceUpdate()
console.log(that.selected)
})
.catch((err) => {
console.log(err);
});
}
//日库存
if (this.ITEM.inventorySettings == 3) {
const params = {
ticketId: this.ITEM.id,
date: fullDate
};
getTicketDateInventory(params)
.then((res) => {
that.selected = [];
res.data.forEach((items) => {
const obj = {
date: items.date,
info: '库存:' + items.inventory,
infoColor: '#666',
topInfo: '',
topInfoColor: '',
badgeColor: '',
disable: !items.isAvailable || items.inventory == 0 // 禁用
};
that.selected.push(obj);
});
that.$forceUpdate()
console.log(that.selected)
})
.catch((err) => {
console.log(err);
});
}
}, //日历操作
calendarConfirm(e) {
let that = this;
console.log(e);
//debugger;
//不限库存
if (that.selectItem.inventorySettings == 1) {
let index;
//无需游客信息,直接添加到购物车
if (that.selectItem.touristInformation == 1) {
if (that.car.length > 0) {
console.log(that.car, '已有购物车')
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) && items
.date == e.fulldate);
console.log(index, '获取到的index')
if (index != -1) {
const currentNum = that.car[index].num;
// 创建一个新的对象,并设置num为当前值加1
let newItem = {
...that.selectItem,
date: e.fulldate,
num: currentNum + 1
};
// 使用 Vue.set 或 that.$set 来保证响应式
that.$set(that.car, index, newItem);
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
} else {
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate
};
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
uni.setStorageSync('ALL_TICKET', that.car)
}
} else {
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate
};
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
}
//需要一个游客信息/需要全部游客信息
if (that.selectItem.touristInformation == 2 || that.selectItem.touristInformation == 3) {
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate
};
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
}
//总库存
if (that.selectItem.inventorySettings == 2) {
let index;
//无需游客信息,直接添加到购物车
if (that.selectItem.touristInformation == 1) {
if (that.car.length > 0) {
//debugger;
console.log(that.car, 'car里的数据');
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) && items
.date == e.fulldate);
if (index != -1) {
//debugger;
const currentNum = that.car[index].num;
if (Number(that.selectItem.currentinventory) - currentNum >= 1) {
// 创建一个新的对象,并设置num为当前值加1
let newItem = {
...that.selectItem,
date: e.fulldate,
num: currentNum + 1,
zkc: that.selectItem.currentinventory
};
// 使用 Vue.set 或 that.$set 来保证响应式
that.$set(that.car, index, newItem); //可以购买
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
} else {
// 超过库存
uni.showToast({
icon: 'none',
title: '库存不足'
});
}
} else {
let newItem = {
...that.selectItem,
date: e.fulldate,
num: 1,
zkc: that.selectItem.currentinventory
};
// 使用 Vue.set 或 that.$set 来保证响应式
that.car.push(newItem);; //可以购买
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
} else {
//debugger;
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate,
zkc: that.selectItem.currentinventory
};
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
}
//需要一个游客信息/需要全部游客信息
if (that.selectItem.touristInformation == 2 || that.selectItem.touristInformation == 3) {
if (that.car.length > 0) {
//debugger;
console.log('that.selectItem.id:', that.selectItem.id);
console.log('e.fulldate:', e.fulldate);
console.log('that.car:', that.car);
index = that.car.findIndex((items) => {
console.log('Checking item:', items); // 打印每个检查的元素
return Number(items.id) == Number(that.selectItem.id) && items.date == e.fulldate;
});
console.log('Found index:', index); // 打印找到的索引
if (index != -1) {
const currentNum = that.car[index].num;
if (Number(that.selectItem.currentinventory) - currentNum >= 1) {
let newItem = {
...that.selectItem,
date: e.fulldate,
num: currentNum + 1,
zkc: that.selectItem.currentinventory
};
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' +
eve
})
} else {
// 超过库存
uni.showToast({
icon: 'none',
title: '库存不足'
});
}
} else {
let newItem = {
...that.selectItem,
date: e.fulldate,
num: 1,
zkc: that.selectItem.currentinventory
};
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
} else {
let newItem = {
...that.selectItem,
date: e.fulldate,
num: 1,
zkc: that.selectItem.currentinventory
};
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
}
}
//日库存
if (that.selectItem.inventorySettings == 3) {
let index;
//debugger
const cartItem = that.car.find((item) => Number(item.id) == Number(that.selectItem.id) && item.date ==
e.fulldate);
const cartQuantity = cartItem ? cartItem.num : 0;
// 获取当天的日库存
const inventoryItem = that.selected.find((item) => item.date == e.fulldate);
const inventory = inventoryItem ? parseInt(inventoryItem.info.split(':')[1], 10) : 0;
// 判断是否超出库存
if (cartItem) {
if (cartQuantity >= inventory) {
uni.showToast({
icon: 'none',
title: '当日库存不足'
});
} else {
//无需游客信息,直接添加到购物车
if (that.selectItem.touristInformation == 1) {
// 执行其他逻辑,例如添加到购物车
console.log('可以添加到购物车');
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) &&
items.date == e.fulldate);
console.log('index:', index);
if (index != -1) {
//debugger;
const currentNum = that.car[index].num;
// 创建一个新的对象,并设置num为当前值加1
let newItem = {
...that.selectItem,
date: e.fulldate,
num: currentNum + 1,
rkc: inventory
};
// 使用 Vue.set 或 that.$set 来保证响应式
that.$set(that.car, index, newItem);
uni.setStorageSync('ALL_TICKET', that.car)
} else {
//debugger;
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate,
rkc: inventory
};
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
uni.setStorageSync('ALL_TICKET', that.car)
}
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
//需要一个游客信息/需要全部游客信息
if (that.selectItem.touristInformation == 2 || that.selectItem.touristInformation == 3) {
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) &&
items.date == e.fulldate);
console.log('index:', index);
if (index != -1) {
//debugger;
const currentNum = that.car[index].num;
// 创建一个新的对象,并设置num为当前值加1
let newItem = {
...that.selectItem,
date: e.fulldate,
num: currentNum + 1,
rkc: inventory
};
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' +
eve
})
} else {
//debugger;
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate,
rkc: inventory
};
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' +
eve
})
}
}
}
} else {
//无需游客信息,直接添加到购物车
if (that.selectItem.touristInformation == 1) {
const newItem = {
...that.selectItem,
num: 1,
date: e.fulldate,
rkc: inventory
};
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
uni.setStorageSync('ALL_TICKET', that.car)
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
//需要一个游客信息/需要全部游客信息
if (that.selectItem.touristInformation == 2 || that.selectItem.touristInformation == 3) {
let newItem = {
...that.selectItem,
date: e.fulldate,
num: 1,
rkc: inventory
};
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
that.selectItem.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
}
}
},
// 打开日历
open() {
this.$refs.calendar.open();
},
//可售门票
changeStatus() {
this.queryStatus = 1;
this.$refs.paging.reload(true);
},
//全部门票
clearStatus() {
this.queryStatus = null;
this.$refs.paging.reload(true);
},
//门票分类
getTicketSortList() {
getTicketSortList()
.then((res) => {
res.data.forEach((item) => {
item.name = item.sortName;
});
res.data.unshift({
id: null,
name: '全部'
});
this.tabList = res.data;
})
.catch((err) => {
console.log(err);
});
},
goShopCar() {
const data = JSON.stringify(this.car);
uni.navigateTo({
url: '/pages/shoppingCar/shoppingCar?sum=' + this.ticketSumNum + '&price=' + this
.ticketSumPrice
});
},
//加购
onPlay(event, item) {
this.ITEM = item,
console.log(item, '点击加购的item');
this.event = event;
item.btnLoading = true;
let that = this;
//有效期模式,
//debugger;
if (item.datesettings == 1) {
const date = this.parseTime(new Date(), '{y}-{m}-{d}')
item.date = date
// 不限库存
if (item.inventorySettings == 1) {
//无需游客信息
if (item.touristInformation == 1) {
if (that.car.length > 0) {
const index = that.car.findIndex((items) => Number(items.id) == Number(item.id));
if (index !== -1) {
that.car[index].num += 1
item.num = that.car[index].num
// 使用 Vue.set 或 that.$set 来保证响应式
that.$set(that.car, index, item);
uni.setStorageSync('ALL_TICKET', that.car)
} else {
item.num = 1;
// that.$set(that.car, that.car.length, item);
that.car.push(item);
uni.setStorageSync('ALL_TICKET', that.car)
}
} else {
item.num = 1;
// that.$set(that.car, that.car.length, item);
that.car.push(item);
uni.setStorageSync('ALL_TICKET', that.car)
}
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
}
// //需要游客信息一个
// if (item.touristInformation == 2) {
// let index,
// if (that.car.length > 0) {
// index = that.car.findIndex(items=>Number(items.id) == Number(item.id)&&items.date == item.date)
// if(index!=-1){
// that.car[index].num++
// uni.setStorageSync('ALL_TICKET', that.car)
// }else{
// uni.setStorageSync('ALL_TICKET', that.car)
// const data = JSON.stringify(item)
// const eve = JSON.stringify(event)
// item.btnLoading = false;
// uni.navigateTo({
// url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
// })
// }
// }else{
// uni.setStorageSync('ALL_TICKET', that.car)
// const data = JSON.stringify(item)
// const eve = JSON.stringify(event)
// item.btnLoading = false;
// uni.navigateTo({
// url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
// })
// }
// }
//需要游客信息全部
if (item.touristInformation == 2 || item.touristInformation == 3) {
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(item)
const eve = JSON.stringify(event)
item.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
item.btnLoading = false;
}
//总库存
if (item.inventorySettings == 2) {
//无需游客信息
if (item.touristInformation == 1) {
if (Number(item.currentinventory) > item.num) {
//没超过总库存
if (that.car.length > 0) {
const index = that.car.findIndex((items) => Number(items.id) == Number(item.id));
if (index !== -1) {
that.car[index].num += 1
item.num = that.car[index].num
// 使用 Vue.set 或 that.$set 来保证响应式
that.$set(that.car, index, item);
uni.setStorageSync('ALL_TICKET', that.car)
} else {
item.num = 1;
// that.$set(that.car, that.car.length, item);
that.car.push(item);
uni.setStorageSync('ALL_TICKET', that.car)
}
} else {
item.num = 1;
// that.$set(that.car, that.car.length, item);
that.car.push(item);
uni.setStorageSync('ALL_TICKET', that.car)
}
that.$refs.cartAnimation.touchOnGoods(that.event, that.busPos);
} else {
//等于总库存后
uni.showToast({
icon: 'none',
title: '库存不足'
});
}
item.btnLoading = false;
}
//需要游客信息一个或全部
if (item.touristInformation == 2 || item.touristInformation == 3) {
const choseItemIndex = that.car.findIndex((items) => items.id == item.id)
if (choseItemIndex !== -1) {
if (Number(item.currentinventory) > that.car[choseItemIndex].num) {
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(item)
const eve = JSON.stringify(event)
item.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' +
eve
})
} else {
//等于总库存后
uni.showToast({
icon: 'none',
title: '库存不足'
});
}
} else {
uni.setStorageSync('ALL_TICKET', that.car)
const data = JSON.stringify(item)
const eve = JSON.stringify(event)
item.btnLoading = false;
uni.navigateTo({
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
}
item.btnLoading = false;
}
}
}
//日期模式
if (item.datesettings == 2 || item.datesettings == 3) {
//使用日期和使用小时模式:单日,这里使用日期设置不论星期还是多日都不影响返回的日期了
//不限库存/总库存
if (item.inventorySettings == 1 || item.inventorySettings == 2) {
that.selectItem = item;
const params = {
ticketId: item.id,
date: that.parseTime(new Date())
};
getTicketDateInventory(params)
.then((res) => {
that.selected = [];
res.data.forEach((items) => {
const obj = {
date: items.date,
info: '库存:' + item.currentinventory,
infoColor: '#666',
topInfo: '',
topInfoColor: '',
badgeColor: '',
disable: !items.isAvailable // 禁用
};
that.selected.push(obj);
});
that.open();
})
.catch((err) => {
console.log(err);
});
}
//日库存
if (item.inventorySettings == 3) {
that.selectItem = item;
const params = {
ticketId: item.id,
date: that.parseTime(new Date())
};
getTicketDateInventory(params)
.then((res) => {
that.selected = [];
res.data.forEach((items) => {
const obj = {
date: items.date,
info: '库存:' + items.inventory,
infoColor: '#666',
topInfo: '',
topInfoColor: '',
badgeColor: '',
disable: !items.isAvailable || items.inventory == 0 // 禁用
};
that.selected.push(obj);
});
that.open();
})
.catch((err) => {
console.log(err);
});
}
item.btnLoading = false;
}
// that.ticketSumNum = nums;
// that.ticketSumPrice = price;
},
parseTime(val) {
return parseTime(val, '{y}-{m}-{d}');
},
parseArrayTime(val) {
return parseArrayTime(val);
},
back() {
uni.navigateBack({
delta: 1
});
},
safeHeight() {
return uni.getSystemInfoSync().safeArea.top + 44 + 'px';
},
//门票分类切换
tabChange(index, value) {
this.ticketsort = value;
//当切换tab或搜索时请调用组件的reload方法,请勿直接调用:queryList方法!!
//调用reload时参数传true则代表reload时触发下拉刷新效果,不传或false则代表取消此效果
this.$refs.paging.reload(true);
},
queryList(pageNo, pageSize) {
//组件加载时会自动触发此方法,因此默认页面加载时会自动触发,无需手动调用
//这里的pageNo和pageSize会自动计算好,直接传给服务器即可
//模拟请求服务器获取分页数据,请替换成自己的网络请求
const params = {
pageNo: pageNo,
pageSize: pageSize,
ticketsort: this.ticketsort,
queryStatus: this.queryStatus,
distributionChannel: 3
};
getTicketList(params)
.then((res) => {
res.data.list.forEach((item) => {
item.num = 0;
item.sumPrice = 0;
item.date = null;
item.currentinventory = item.inventorySettings == 1 ? '不限' : item.currentinventory;
item.btnLoading = false;
item.visitorInfoList = [];
});
//将请求的结果数组传递给z-paging
this.$refs.paging.complete(res.data.list);
})
.catch((res) => {
//如果请求失败写this.$refs.paging.complete(false);
//注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
//在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
this.$refs.paging.complete(false);
});
},
itemClick(item) {},
toggleCheckbox() {
this.isChecked = !this.isChecked;
console.log('Checkbox is now:', this.isChecked);
},
},
onHide() {
this.$refs.calendar.close();
}
};
</script>
<style lang="scss" scoped>
.m-btn-group {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
padding: 0 0 10upx 0;
button {
width: 50%;
}
}
.item {
position: relative;
height: 150upx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30upx;
}
.item-detail {
padding: 5upx 15upx;
border-radius: 10upx;
font-size: 28upx;
color: white;
background-color: #007aff;
}
.item-line {
position: absolute;
bottom: 0px;
left: 0rpx;
height: 1upx;
width: 100%;
background-color: #eeeeee;
}
::v-deep .z-padding .zp-paging-container-content {
margin: 10upx 34upx 136upx;
.item {
background: #ffffff;
border-radius: 20upx;
margin-bottom: 20upx;
display: flex;
flex-direction: column;
align-items: start;
height: fit-content;
padding: 20upx;
.item-title {
font-family: Source Han Sans SC;
font-weight: 500;
margin-bottom: 22upx;
font-size: 32upx;
color: #1b1b1b;
}
.item-date {
display: flex;
align-items: center;
font-size: 26upx;
.m-date-label {
font-family: Source Han Sans SC;
font-weight: 400;
color: #666666;
}
.m-date-value {
color: rgba(34, 119, 240, 1);
}
}
.footer {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
margin-top: 44upx;
.item-price {
font-family: DIN Alternate;
font-weight: bold;
font-size: 38upx;
color: #ff5400;
}
.m-btn {
display: block;
margin: 0;
background: rgba(34, 119, 240, 0.1);
border-radius: 12Upx;
color: rgba(34, 119, 240, 1);
}
.disble {
background: rgba(153, 157, 157, 0.1);
border-radius: 12Upx;
color: #acacac;
}
}
}
}
.m-botom {
width: 100%;
height: 136upx;
background: #ffffff;
position: fixed;
bottom: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 40upx;
z-index: 99;
.m-botm-left {
.m-red {
color: #ff5400;
.m-price {
font-size: 48upx;
}
}
}
.m-botm-right {
.m-prime {
height: 80upx;
line-height: 80upx;
background: linear-gradient(90deg, #5097fa 0%, #2277f0 100%);
border-radius: 16upx;
font-family: Source Han Sans SC;
font-weight: 500;
font-size: 32upx;
color: #ffffff;
}
}
}
</style>