AssetManager.UniApp/App.vue
fanfpy bc48e8f7a3 feat: 初始化项目并添加基础功能
- 添加uni-ui组件库依赖
- 实现微信静默登录功能
- 创建资产、策略、我的等核心页面
- 添加策略组合配置功能
- 实现持仓详情展示
- 完善用户信息展示
- 添加全局样式和工具类
- 配置小程序项目设置
2026-02-18 20:51:42 +08:00

71 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
import api from './utils/api'
export default {
onLaunch: function() {
console.log('App Launch')
// 执行微信静默登录
this.wechatSilentLogin()
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods: {
// 微信静默登录
wechatSilentLogin() {
// 检查是否在微信小程序环境中
if (uni.getSystemInfoSync().platform === 'devtools' || uni.getSystemInfoSync().platform === 'mp-weixin') {
// 调用微信登录API获取code
uni.login({
provider: 'weixin',
success: (loginRes) => {
if (loginRes.code) {
// 将code发送到后端进行登录
api.auth.wechatLogin(loginRes.code)
.then(res => {
if (res.code === 200) {
// 登录成功存储token
uni.setStorageSync('token', res.data.token)
uni.setStorageSync('userInfo', res.data.userInfo)
console.log('微信静默登录成功')
} else {
console.log('微信静默登录失败:', res.message)
}
})
.catch(err => {
console.log('微信登录API调用失败:', err)
})
} else {
console.log('获取微信登录code失败:', loginRes.errMsg)
}
},
fail: (err) => {
console.log('微信登录失败:', err)
}
})
}
}
}
}
</script>
<style>
/* 每个页面公共css */
page {
background-color: #F3F4F6;
font-family: 'Inter', 'Noto Sans SC', sans-serif;
--brand-color: #064e3b;
--brand-light: #10B981;
}
/* 通用工具类 */
.bg-white { background-color: #ffffff; }
.rounded-2xl { border-radius: 32rpx; }
.shadow-sm { box-shadow: 0 2rpx 6rpx rgba(0,0,0,0.05); }
.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
</style>