添加预约时间

This commit is contained in:
2025-05-17 15:15:11 +08:00
parent 7ae003c61f
commit cdf7e721c5
7 changed files with 101 additions and 39 deletions

View File

@ -7,7 +7,7 @@
<view class="aside">
<scroll-view style="height: 100%;" scroll-y="true" scroll-with-animation="true">
<view style="padding-bottom: 200rpx;">
<block v-for="(item, index) in cateList" :key="index">
<block v-for="(item, index) in dateList" :key="index">
<view :class="'one-item sm ' + (index == selectIndex ? 'active bg-white' : '')" @click="changeActive(index)">
<text class="name">{{ item.name }}</text>
<view v-if="index == selectIndex" class="active-line bg-default"></view>
@ -20,8 +20,8 @@
<view class="main">
<scroll-view style="height: 100%" scroll-y="true" scroll-with-animation="true">
<view class="main-wrap u-m-t-32">
<view class="bg-white br16 row u-col-top u-m-b-24" v-for="(item, index) in 20" :key="index">
<view>900 - 930</view>
<view class="bg-white br16 row u-col-top u-m-b-24 nr" v-for="(item, index) in timeList" :key="index" @click="selectTime(index)">
<view>{{ item.start_time }}-{{ item.end_time }}</view>
</view>
</view>
</scroll-view>
@ -33,9 +33,11 @@
</template>
<script>
import {getCatrgory} from '@/api/store'
import {yuyueTime} from '@/api/order'
export default {
name: "appointment-time",
props: {
value: {
type: Boolean,
@ -46,25 +48,44 @@
return {
mobile: '',
selectIndex: 0,
cateList: []
cateList: [],
dateList: [],
timeList: []
};
},
created() {
this.getCatrgoryFun()
this.dateList = [
{'name': '今天'},
{'name': '明天'}
]
this.getYuYueTime()
},
methods: {
getCatrgoryFun() {
getCatrgory().then(res => {
if (res.code == 1) {
this.cateList = res.data
}
});
// 获取预约时间
getYuYueTime() {
const store_id = 1
yuyueTime({store_id}).then((res) => {
this.timeList = res.data
})
},
changeActive(index) {
const {cateList} = this
this.selectIndex = index
},
// 选择时间
selectTime(index) {
const day = this.dateList[this.selectIndex].name
const time_id = this.timeList[index].id
const time = this.timeList[index].start_time + '-' + this.timeList[index].end_time
this.$emit('update', {
day,
time_id,
time
})
},
// 提交数据
handleSubmit(e) {
@ -96,7 +117,7 @@
this.$emit('input', val)
}
}
}
},
};
</script>