import { getPublicConfig } from '@/api/appUser'

export default {
	onLaunch: function(options) {
		console.log('App Launch', options)
		try { uni.setStorageSync('app_session_id', String(Date.now())) } catch (_) {}
		if (options && options.query && options.query.invite_code) {
			console.log('App Launch captured invite_code:', options.query.invite_code)
			try { uni.setStorageSync('inviter_code', options.query.invite_code) } catch (e) { console.error('Save invite code failed', e) }
		}

		// 加载公开配置 (如订阅消息模板ID)
		getPublicConfig().then(res => {
			if (res && res.subscribe_templates) {
				console.log('Loaded public config:', res)
				try { uni.setStorageSync('subscribe_templates', res.subscribe_templates) } catch (_) {}
			}
		}).catch(err => {
			console.warn('Failed to load public config:', err)
		})
	},
	onShow: function() {
		console.log('App Show')
	},
	onHide: function() {
		console.log('App Hide')
	}
}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni.scss';

	page {
		background-color: $bg-page;
		color: $text-main;
		font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
	}

	.container {
		padding: $spacing-lg;
	}

	/* Global Keyframes */
	@keyframes fadeIn {
		from { opacity: 0; }
		to { opacity: 1; }
	}
	@keyframes fadeInDown {
		from { opacity: 0; transform: translateY(-30rpx); }
		to { opacity: 1; transform: translateY(0); }
	}
	@keyframes fadeInUp {
		from { opacity: 0; transform: translateY(30rpx); }
		to { opacity: 1; transform: translateY(0); }
	}
	@keyframes slideUp {
		from { opacity: 0; transform: translateY(100%); }
		to { opacity: 1; transform: translateY(0); }
	}
	@keyframes zoomIn {
		from { opacity: 0; transform: scale(0.9); }
		to { opacity: 1; transform: scale(1); }
	}
	@keyframes pulse {
		0% { transform: scale(1); }
		50% { transform: scale(1.05); }
		100% { transform: scale(1); }
	}
	@keyframes float {
		0% { transform: translateY(0); }
		50% { transform: translateY(-20rpx); }
		100% { transform: translateY(0); }
	}
</style>
