|
|
@ -1,6 +1,6 @@ |
|
|
|
<script setup> |
|
|
|
import { onLoad, onReady } from '@dcloudio/uni-app'; |
|
|
|
import { reactive, ref, computed, watch, nextTick } from 'vue'; |
|
|
|
import { reactive, ref, computed, watch, nextTick, onMounted, getCurrentInstance } from 'vue'; |
|
|
|
import { stadiumBookList } from "@/api"; |
|
|
|
import { venueTypes, bookDate, bookList } from '../api'; |
|
|
|
import { getNodeMes, showModal } from "@/utils/polish"; |
|
|
@ -15,6 +15,8 @@ const currentVenueType = ref({}); // 当前场地类型 |
|
|
|
const bookDateData = ref([]); // 日期列表 |
|
|
|
const currentBookDate = ref({}); // 当前选中日期 |
|
|
|
const isShowTypeRuleTxt = ref(false); |
|
|
|
const stadiumInfo = ref({}); // 场馆信息 |
|
|
|
const ticketInfo = null; // 票券信息 |
|
|
|
|
|
|
|
const selectedData = computed(_=>{ // 已选中场地 |
|
|
|
let _temArr = []; |
|
|
@ -34,10 +36,18 @@ const selectedData = computed(_=>{ // 已选中场地 |
|
|
|
|
|
|
|
watch(selectedData, val=>nextTick(setScrollViewSize)); |
|
|
|
|
|
|
|
onLoad(async (opts) => { |
|
|
|
onMounted(() =>{ |
|
|
|
const instance = getCurrentInstance().proxy |
|
|
|
const eventChannel = instance.getOpenerEventChannel(); |
|
|
|
eventChannel.on('dataFromGrouponStadiums', data => { |
|
|
|
ticketInfo = data?.ticket || {}; |
|
|
|
stadiumInfo.value = data?.stadium || {}; |
|
|
|
if(!stadiumInfo.value?.id)return showModal({ content: '无效的场馆信息' }); |
|
|
|
initPage(data?.stadium?.id); |
|
|
|
}) |
|
|
|
}) |
|
|
|
async function initPage(stadium_id){ |
|
|
|
try{ |
|
|
|
const stadium_id = 167; |
|
|
|
optQuery.value.stadium_id = stadium_id; |
|
|
|
let _vtLs = await getTypeLs(stadium_id); |
|
|
|
if(_vtLs?.length <=0)return showModal({ content: '没有场地类型!' }); |
|
|
|
let _cvt = currentVenueType.value = _vtLs[0]; |
|
|
@ -49,7 +59,7 @@ onLoad(async (opts) => { |
|
|
|
}catch(err){ |
|
|
|
console.warn(`site select onload err-->`, err); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// 类型切换 |
|
|
|
async function venueTypeChange(e){ |
|
|
|
let _cvt = venueTypeData.value[e.detail.value]; |
|
|
@ -58,7 +68,7 @@ async function venueTypeChange(e){ |
|
|
|
currentBookDate.value = {}; |
|
|
|
siteData.value = []; |
|
|
|
try{ |
|
|
|
let stadium_id = optQuery?.value?.stadium_id ?? ''; |
|
|
|
let stadium_id = stadiumInfo?.value?.id ?? ''; |
|
|
|
let _dateLs = await getDateLs({ stadium_id, type_key: _cvt?.key ?? '', }); |
|
|
|
if(_dateLs?.length <= 0)return showModal({ content: '没有日期列表!' }); |
|
|
|
let _curDate = currentBookDate.value = _dateLs[0]; |
|
|
@ -73,7 +83,7 @@ async function bookDateChange(_date){ |
|
|
|
currentBookDate.value = _date; |
|
|
|
siteData.value = []; |
|
|
|
try{ |
|
|
|
let stadium_id = optQuery?.value?.stadium_id ?? ''; |
|
|
|
let stadium_id = stadiumInfo?.value?.id ?? ''; |
|
|
|
let _cvt = currentVenueType.value ?? {} |
|
|
|
getBookList({ stadium_id, type_key: _cvt?.key ?? '', date: _date?._date ?? '' }); |
|
|
|
}catch(err){ |
|
|
@ -82,7 +92,7 @@ async function bookDateChange(_date){ |
|
|
|
} |
|
|
|
// 清除已选 |
|
|
|
function clearSelectedData(){ |
|
|
|
let stadium_id = optQuery?.value?.stadium_id ?? ''; |
|
|
|
let stadium_id = stadiumInfo?.value?.id ?? ''; |
|
|
|
let _key = currentVenueType.value?.key ?? ''; |
|
|
|
let _date = currentBookDate.value?._date ?? ''; |
|
|
|
getBookList({ stadium_id, type_key: _key, date: _date }); |
|
|
@ -124,21 +134,14 @@ function getDateLs({ stadium_id, type_key, num = 8 }){ |
|
|
|
} |
|
|
|
// 可预订场馆,矩阵图 时间+场馆 |
|
|
|
function getBookList({ |
|
|
|
app_id = 'wxc141a743225e7885', |
|
|
|
brand_id = 63, |
|
|
|
stadium_id, |
|
|
|
date = '', |
|
|
|
type_key = `` |
|
|
|
}){ |
|
|
|
return bookList({ data: { |
|
|
|
app_id, |
|
|
|
brand_id, |
|
|
|
stadium_id, |
|
|
|
date, |
|
|
|
type_key, |
|
|
|
token: `dbce2d0c-ce5d-11ef-9e0f-5254005df464`, |
|
|
|
enable_show_terminal: 1, |
|
|
|
from_platform: `weixin`, |
|
|
|
} }) |
|
|
|
.then(res=>{ |
|
|
|
return siteData.value = res?.data; |
|
|
@ -163,8 +166,8 @@ async function setScrollViewSize(){ |
|
|
|
<view class="site-select"> |
|
|
|
<view class="ss-header" id="ssHeader"> |
|
|
|
<view class="sh-stadium"> |
|
|
|
<view class="ss-logo"></view> |
|
|
|
<view class="ss-name">MJ体育(天空篮球从云店)</view> |
|
|
|
<image v-if="stadiumInfo?.logo" mode="aspectFit" class="ss-logo" :src="stadiumInfo.logo"></image> |
|
|
|
<view class="ss-name">{{ stadiumInfo?.name ?? '-' }}</view> |
|
|
|
</view> |
|
|
|
<view class="sh-bottom"> |
|
|
|
<picker class="sb-classify" mode='selector' :range="venueTypeData" range-key="name" @change="venueTypeChange"> |
|
|
@ -217,7 +220,6 @@ async function setScrollViewSize(){ |
|
|
|
margin-right: 20upx; |
|
|
|
width: 36upx; |
|
|
|
height: 36upx; |
|
|
|
background: skyblue; |
|
|
|
} |
|
|
|
.ss-name{ |
|
|
|
flex-grow: 1; |
|
|
|