feat: 完成喂养计划,宠物信息填充
This commit is contained in:
1 parent
08d03cfbe0
commit
6dfcc0076a
15 files changed
+276
-38
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import right from '@/static/icons/right.svg'
|
||||
|
||||
withDefaults(defineProps<{
|
||||
title: string
|
||||
border?: boolean
|
||||
}>(), {
|
||||
border: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view
|
||||
class="h-[56px] bg-[white] flex items-center p-4 justify-between" :class="{
|
||||
'border-[#E5E5E5] border-b-[0.5px]': border,
|
||||
}"
|
||||
>
|
||||
<view class="text-base">
|
||||
{{ title }}
|
||||
</view>
|
||||
<view class="flex-1 flex justify-center items-center gap-3">
|
||||
<view class="flex-1 flex justify-end">
|
||||
<slot />
|
||||
</view>
|
||||
<image :src="right" class="w-[24px] h-[24px]" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-full bg-[#fff] shadow-cell-group rounded-3 overflow-hidden cell-group">
|
||||
<slot />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
}>()
|
||||
const emits = defineEmits<{
|
||||
'update:modelValue': [string]
|
||||
}>()
|
||||
|
||||
function bindDateChange(e: { detail: { value: string } }) {
|
||||
emits('update:modelValue', e.detail.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<picker mode="date" :value="modelValue" @change="bindDateChange">
|
||||
<view class="">
|
||||
{{ modelValue }}
|
||||
</view>
|
||||
</picker>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
export interface PickerItemOption {
|
||||
label: string
|
||||
value: string | number
|
||||
}
|
||||
const props = defineProps<{
|
||||
modelValue: string | number
|
||||
options: PickerItemOption[]
|
||||
}>()
|
||||
|
||||
const emits = defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
function bindPickerChange(e: { detail: { value: number | string } }) {
|
||||
const currentIndex = e.detail.value as number
|
||||
emits('update:modelValue', props.options[currentIndex].value)
|
||||
}
|
||||
|
||||
const index = ref(0)
|
||||
|
||||
watch(() => props.modelValue, (currentValue) => {
|
||||
const currentIndex = props.options.findIndex(option => option.value === currentValue)
|
||||
index.value = currentIndex === -1 ? 0 : currentIndex
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<picker :value="index" :range="options" range-key="label" @change="bindPickerChange">
|
||||
<view>
|
||||
{{ options[index].label }}
|
||||
</view>
|
||||
</picker>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import type { UniPopupDialogInstance } from '@uni-helper/uni-types'
|
||||
import type { UniPopupInstance } from '@uni-helper/uni-ui-types'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue: string | number
|
||||
placeholder?: string
|
||||
suffix?: string
|
||||
}>(), {
|
||||
placeholder: '请输入内容',
|
||||
})
|
||||
|
||||
const emits = defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
const uniPopupRef = ref<UniPopupInstance | null>(null)
|
||||
const uniPopupDialogRef = ref<UniPopupDialogInstance | null>(null)
|
||||
|
||||
function dialogInputConfirm(value: any) {
|
||||
if (value === '') {
|
||||
uni.showToast({
|
||||
title: props.placeholder,
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
emits('update:modelValue', value as (string | number))
|
||||
if (uniPopupRef.value && uniPopupRef.value.close) {
|
||||
uniPopupRef.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
if (uniPopupRef.value && uniPopupRef.value.open) {
|
||||
uniPopupRef.value.open()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-full" @click="handleClick">
|
||||
{{ modelValue }}
|
||||
<text v-if="suffix">
|
||||
{{ suffix }}
|
||||
</text>
|
||||
</view>
|
||||
<uni-popup ref="uniPopupRef" type="dialog">
|
||||
<uni-popup-dialog
|
||||
ref="uniPopupDialogRef" mode="input" title="输入内容" :value="modelValue" :placeholder="placeholder"
|
||||
@confirm="dialogInputConfirm"
|
||||
/>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in new issue
Block a user