feat: add venue selection shell
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
export const CURRENT_VENUE_KEY = 'CURRENT_VENUE'
|
||||
|
||||
export const VENUE_KEYS = Object.freeze({
|
||||
ICE: 'ice',
|
||||
COMPREHENSIVE: 'comprehensive'
|
||||
})
|
||||
|
||||
export const VENUE_OPTIONS = Object.freeze([
|
||||
{
|
||||
key: VENUE_KEYS.ICE,
|
||||
name: '冰场馆',
|
||||
description: '课程预约、会员卡与滑冰服务',
|
||||
homePath: '/pages/ice/home/index'
|
||||
},
|
||||
{
|
||||
key: VENUE_KEYS.COMPREHENSIVE,
|
||||
name: '综合场馆',
|
||||
description: '课程、包场、门票、订单与余额',
|
||||
homePath: '/pages/comprehensive/home/index'
|
||||
}
|
||||
])
|
||||
|
||||
export const isVenueKey = (value) => {
|
||||
return value === VENUE_KEYS.ICE || value === VENUE_KEYS.COMPREHENSIVE
|
||||
}
|
||||
|
||||
export const getVenueOption = (venueKey) => {
|
||||
return VENUE_OPTIONS.find((item) => item.key === venueKey) || null
|
||||
}
|
||||
|
||||
export const getStoredVenue = () => {
|
||||
const venue = uni.getStorageSync(CURRENT_VENUE_KEY)
|
||||
return isVenueKey(venue) ? venue : ''
|
||||
}
|
||||
|
||||
export const setStoredVenue = (venueKey) => {
|
||||
if (!isVenueKey(venueKey)) {
|
||||
uni.removeStorageSync(CURRENT_VENUE_KEY)
|
||||
return ''
|
||||
}
|
||||
|
||||
uni.setStorageSync(CURRENT_VENUE_KEY, venueKey)
|
||||
return venueKey
|
||||
}
|
||||
|
||||
export const navigateToVenueHome = (venueKey, options = {}) => {
|
||||
const venue = getVenueOption(venueKey)
|
||||
if (!venue) {
|
||||
uni.reLaunch({ url: '/pages/venue-select/index' })
|
||||
return
|
||||
}
|
||||
|
||||
const navigate = options.redirect === true ? uni.redirectTo : uni.reLaunch
|
||||
navigate({ url: venue.homePath })
|
||||
}
|
||||
Reference in New Issue
Block a user