Browse Source

add logic

dev
刘嘉炜 2 weeks ago
parent
commit
25f770b33a
  1. 10
      src/subpackage/groupon/components/site/footer.vue
  2. 72
      src/subpackage/groupon/components/venue_info.vue
  3. 39
      src/subpackage/groupon/pages/confirm_order/venue.vue
  4. 34
      src/subpackage/groupon/pages/site_select.vue

10
src/subpackage/groupon/components/site/footer.vue

@ -1,8 +1,8 @@
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref, computed } from 'vue';
import { reactive, ref, computed, toRaw } from 'vue';
import { accAdd } from "@/utils/calculation";
const emits = defineEmits([ 'click:clear' ]);
const emits = defineEmits([ 'click:clear', 'click:submit' ]);
const props = defineProps({
selectedData: { default: [] },
})
@ -10,6 +10,11 @@ const totalAmount = computed(_=>{
let _sData = props.selectedData ?? [];
return _sData?.length ? _sData.reduce((num, e, i) => accAdd(num, e?.price ?? 0), 0) : 0;
})
function submitBtnClick() {
if (props.selectedData.length <= 0) return;
emits('click:submit', toRaw(props.selectedData));
}
</script>
<template>
@ -54,6 +59,7 @@ const totalAmount = computed(_=>{
<view
class="ssb-btn"
:class="{ 'un-active': selectedData.length <=0 }"
@click="submitBtnClick"
>{{ selectedData.length ? '确定' : '请选择场地' }}</view>
</view>
</view>

72
src/subpackage/groupon/components/venue_info.vue

@ -1,26 +1,82 @@
<script setup>
import { reactive, ref } from "vue";
import { reactive, ref, computed } from "vue";
import { accAdd } from "@/utils/calculation";
import textLine from "./text_line.vue";
const isShowSpecificTime = ref(false);
const props = defineProps({
typeName: {
type: String,
default: ''
},
dateStr: {
type: String,
default: ''
},
dayStr: {
type: String,
default: ''
},
venueLs: {
type: Array,
default: []
}
})
const gatherList = computed({
get(){
return formatVenueLs(props.venueLs);
}
})
const totalAmount = computed(_=> (props.venueLs || []).reduce((res, item, idx)=>accAdd(res, item.price), 0));
function formatVenueLs(list){
//
let _tempMap = new Map();
list.forEach(e=>(_tempMap.get(e.venue_id) || _tempMap.set(e.venue_id, []).get(e.venue_id)).push(e));
let showArr = [];
_tempMap.forEach(v=>{
//
v.sort((a, b)=>a.index - b.index);
if(!v?.length)return;
let _name, start, end, lastIdx;
v.forEach(ele=>{
let [ _st, _et ] = (ele.time).split('-');
if(_name&&ele.index !== (lastIdx + 1)){
showArr.push({ name: _name, duration: `${start}-${end}` });
start = _st;
}else if(!_name){
_name = ele.venue_name, start = _st;
}
lastIdx = ele.index;
end = _et;
});
if(_name&&start&&end){
showArr.push({ name: _name, duration: `${start}-${end}` });
_name = undefined, start = undefined, end = undefined, lastIdx = 0;
}
})
return showArr
}
</script>
<template>
<slot name="title"></slot>
<text-line label="预定项目:">羽毛球</text-line>
<text-line label="预定日期:">2019年05月17日(周五)</text-line>
<text-line label="预定项目:">{{ typeName ?? '' }}</text-line>
<text-line label="预定日期:">{{ dateStr ?? '' }}{{ dayStr ?? '' }}</text-line>
<view class="soi-booking-info">
<view class="sbi-name">预定场次</view>
<view class="sbi-time-range">
<block v-for="(e, i) in 3" :key=i>
<view class="str-item">{{ e.name || '几号馆' }} {{ e.time || '时间段' }}</view>
<block v-for="(e, i) in gatherList" :key=i>
<view class="str-item">{{ e.name || '几号馆' }} {{ e.duration || '时间段' }}</view>
</block>
</view>
</view>
<view class="vmm-line" v-if='isShowSpecificTime'>
<view>具体场次</view>
<view>
<view v-for="(e,i) in 3" :key="i">{{ 'venue_name' }} {{ 'duration' }} ({{ 0 }})</view>
<view v-for="(e,i) in venueLs" :key="i">{{ e.venue_name ?? '' }} {{ e.time ?? '' }} ({{ e?.price ?? 0 }})</view>
</view>
</view>
<view class="soi-fold-btn" @click="isShowSpecificTime = !isShowSpecificTime">
@ -28,8 +84,8 @@ const isShowSpecificTime = ref(false);
<text class="sfb-icon" :class="[ isShowSpecificTime ? 'rotate' :'' ]">&#xe695;</text>
</view>
<view class="vvm-total">
<view>小计{{0}}</view>
<view>{{ 0}}</view>
<view>小计{{ venueLs?.length }}</view>
<view>{{ totalAmount }}</view>
</view>
</template>

39
src/subpackage/groupon/pages/confirm_order/venue.vue

@ -1,27 +1,46 @@
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref } from "vue";
import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import confirmTemplate from "../../components/confirm_template.vue";
import ticketItem from "../../components/ticket_item.vue";
import venueInfo from "../../components/venue_info.vue";
onLoad(() => {
});
const stadiumInfo = ref({});
const ticketInfo = ref({});
const venueData = ref({});
onMounted(() =>{
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel();
eventChannel.on('dataFromGrouponSiteSelect', data => {
stadiumInfo.value = data?.stadium ?? {};
ticketInfo.value = data?.ticket ?? {};
venueData.value = data?.venueInfo ?? {};
})
})
</script>
<template>
<confirm-template>
<confirm-template
:stadiumLogo="stadiumInfo?.logo || ''"
:stadiumName="stadiumInfo?.name || ''"
:stadiumAddress="stadiumInfo?.address || ''"
>
<view class="venue-confirm">
<view class="vc-box">
<venue-info>
<venue-info
:typeName="venueData.typeName"
:dateStr="venueData.date"
:dayStr="venueData.zh_day"
:venueLs="venueData.venues"
>
<template #title>
<view class="vc-title">产品信息</view>
</template>
</venue-info>
</view>
<view class="vc-box vc-groupon-show">
<view class="tti-icon"></view>
<image class="tti-icon" mode="aspectFit" src="@/subpackage/groupon/static/images/ticket_icon.png"></image>
<view class="tti-right">
<view class="tr-txt">团购券 <text class="tt-orange">已选1张</text> </view>
<view class="tr-price">团购券抵扣6小时-¥600.00</view>
@ -29,7 +48,10 @@ onLoad(() => {
</view>
<view class="vc-box vc-groupon">
<view class="vc-title">团购券信息</view>
<ticket-item></ticket-item>
<ticket-item
:ticketName="ticketInfo?.dy_title ?? '-'"
:orderId="ticketInfo?.order_id ?? ''"
></ticket-item>
<view class="vc-txt">温馨提示团购券需一次性使用完一经使用不退不换</view>
</view>
<view class="vc-box vc-contact">
@ -73,7 +95,6 @@ onLoad(() => {
flex-shrink: 0;
width: 40upx;
height: 40upx;
background: skyblue;
}
.tti-right{
flex-grow: 1;

34
src/subpackage/groupon/pages/site_select.vue

@ -15,6 +15,7 @@ const currentVenueType = ref({}); // 当前场地类型
const bookDateData = ref([]); //
const currentBookDate = ref({}); //
const isShowTypeRuleTxt = ref(false);
const stadiumInfo = ref({}); //
const ticketInfo = null; //
@ -40,6 +41,7 @@ onMounted(() =>{
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel();
eventChannel.on('dataFromGrouponStadiums', data => {
console.log(`site select onload dataFromGrouponStadiums-->`, data);
ticketInfo = data?.ticket || {};
stadiumInfo.value = data?.stadium || {};
if(!stadiumInfo.value?.id)return showModal({ content: '无效的场馆信息' });
@ -160,6 +162,32 @@ async function setScrollViewSize(){
let _otherHeight = _headerInfo?.height + _footerInfo?.height + _dateBarInfo?.height;
scrollHeight.value = _sysInfo?.windowHeight - (_otherHeight || 0);
}
function submitClick(venues){
uni.navigateTo({
url: `/subpackage/groupon/pages/confirm_order/venue`,
success: res => {
res.eventChannel.emit('dataFromGrouponSiteSelect', {
stadium: stadiumInfo.value,
ticket: ticketInfo,
venueInfo: {
typeName: currentVenueType.value?.name ?? '',
date: (currentBookDate.value?.date ?? '').slice(0, 10),
zh_day: currentBookDate.value?._zh_day,
venues: venues.map(e=>({
time: e?.time ?? '',
venue_name: e?._venue_name ?? '',
venue_id: e?._venue_id ?? '',
price: e?.price ?? '',
date: e?.date ?? '',
index: e?.index ?? '',
}))
},
})
}
});
}
</script>
<template>
@ -201,7 +229,11 @@ async function setScrollViewSize(){
></site-table>
</view>
<view class="ss-footer" id="ssFooter">
<site-footer :selected-data="selectedData" @click:clear="clearSelectedData"></site-footer>
<site-footer
:selected-data="selectedData"
@click:clear="clearSelectedData"
@click:submit="submitClick"
></site-footer>
</view>
</view>
</template>

Loading…
Cancel
Save