<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef MP-WEIXIN
			this.handleWxLogin()
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			async handleWxLogin() {
				// #ifdef MP-WEIXIN
				try {
					// 1. 获取code
					const loginRes = await new Promise((resolve, reject) => {
						uni.login({
							success: resolve,
							fail: reject
						});
					});

					// 2. 获取用户信息
					// const userInfo = await new Promise((resolve, reject) => {
					//   uni.getUserProfile({
					//     desc: '用于登录',
					//     success: resolve,
					//     fail: reject
					//   });
					// });

					console.log('登录成功:', {
						code: loginRes.code,
						// userInfo: userInfo.userInfo
					});

				} catch (err) {
					console.error('登录失败:', err);
				}
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/uni_modules/uview-plus/index.scss";
	@import "@/static/style/common.scss"
</style>