perf: 支持约课以及消息推送能力

This commit is contained in:
richarjiang
2026-04-12 21:44:44 +08:00
parent 9639f44698
commit c60821c5ff
28 changed files with 963 additions and 86 deletions

View File

@@ -105,13 +105,13 @@
<view class="btn-outline" @tap="handleCancel">
<text class="btn-outline-text">取消</text>
</view>
<view
<button
class="btn-confirm"
:class="{ disabled: !selectedMembershipId }"
@tap="handleConfirm"
>
<text class="btn-confirm-text">确认预约</text>
</view>
</button>
</view>
</view>
</view>
@@ -120,6 +120,7 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import type { TimeSlotWithBookingStatus, MembershipWithCardType } from '@mp-pilates/shared'
import { requestBookingCreatedSubscriptionMessage } from '../utils/wechat-subscription'
const props = defineProps<{
visible: boolean
@@ -134,6 +135,7 @@ const emit = defineEmits<{
}>()
const selectedMembershipId = ref<string>('')
const requestingSubscribe = ref(false)
// Auto-select the first membership when popup opens or memberships list changes
watch(
@@ -150,8 +152,22 @@ const selectedMembership = computed(() =>
props.memberships.find((m) => m.id === selectedMembershipId.value) ?? null,
)
function handleConfirm() {
async function handleConfirm() {
if (!props.timeSlot || !selectedMembershipId.value) return
if (requestingSubscribe.value) return
requestingSubscribe.value = true
try {
await requestBookingCreatedSubscriptionMessage()
} catch (err: unknown) {
const message = err instanceof Error ? err.message : '订阅消息授权失败'
uni.showToast({ title: message, icon: 'none' })
return
} finally {
requestingSubscribe.value = false
}
emit('confirm', {
timeSlotId: props.timeSlot.id,
membershipId: selectedMembershipId.value,

View File

@@ -58,6 +58,7 @@
import { computed, ref } from 'vue'
import { useUserStore } from '../stores/user'
import { CardTypeCategory } from '@mp-pilates/shared'
import { getErrorMessage } from '../utils/auth'
const emit = defineEmits<{
(e: 'scroll-to-card-shop'): void
@@ -71,8 +72,8 @@ async function handleLogin() {
loading.value = true
try {
await userStore.loginWithSetup()
} catch {
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
} catch (err: unknown) {
uni.showToast({ title: getErrorMessage(err, '登录失败,请重试'), icon: 'none' })
} finally {
loading.value = false
}