diff --git a/.gitignore b/.gitignore index 1913808..38c21fb 100755 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ AGENTS.md /未命名/ .webhook_secret /.deploy/ +unpackage/ diff --git a/tests/verify_user_wallet_card_spec.js b/tests/verify_user_wallet_card_spec.js new file mode 100644 index 0000000..b57efb9 --- /dev/null +++ b/tests/verify_user_wallet_card_spec.js @@ -0,0 +1,65 @@ +const fs = require('fs'); +const path = require('path'); + +let passed = 0; +let failed = 0; + +function assert(condition, testName, detail = '') { + if (condition) { + console.log(` [PASS] ${testName}`); + passed++; + } else { + console.error(` [FAIL] ${testName} - ${detail}`); + failed++; + } +} + +console.log("========================================================"); +console.log(" 我的页面资产卡片(余额、马豆、兑换券)功能规格测试"); +console.log("========================================================\n"); + +// 1. 验证 pages/index/user.vue +const userVuePath = path.resolve(__dirname, '../uniapp/pages/index/user.vue'); +assert(fs.existsSync(userVuePath), 'user.vue 文件存在'); +const userVueContent = fs.readFileSync(userVuePath, 'utf-8'); + +assert( + userVueContent.includes('walletCard') && (userVueContent.includes('layoutBlocks') || userVueContent.includes('walletBlock')), + 'user.vue 中包含 walletCard 资产卡片的保底注入机制', + '未在 user.vue 中检测到 walletCard 逻辑' +); + +assert( + !userVueContent.includes('v-for="(item, index) in template.data"'), + 'user.vue 模板遍历已升级为支持动态补充资产卡片的 blocks 计算列表', + '仍直接遍历未补充 walletCard 的 template.data' +); + +// 2. 验证 sheep/components/s-wallet-card/s-wallet-card.vue +const walletCardPath = path.resolve(__dirname, '../uniapp/sheep/components/s-wallet-card/s-wallet-card.vue'); +assert(fs.existsSync(walletCardPath), 's-wallet-card.vue 文件存在'); +const walletCardContent = fs.readFileSync(walletCardPath, 'utf-8'); + +assert( + walletCardContent.includes('userInfo.money') && walletCardContent.includes('/pages/user/wallet/money') && (walletCardContent.includes('余额') || walletCardContent.includes('账户余额')), + 's-wallet-card.vue 包含余额项、正确数据绑定与跳转路由', + '缺少余额配置或路由不正确' +); + +assert( + walletCardContent.includes('displayMadow') && walletCardContent.includes('/pages/commission/madow') && walletCardContent.includes('马豆'), + 's-wallet-card.vue 包含马豆项、正确数据绑定与跳转路由', + '缺少马豆配置或路由不正确' +); + +assert( + walletCardContent.includes('voucher_available') && walletCardContent.includes('/pages/commission/voucher') && (walletCardContent.includes('兑换券') || walletCardContent.includes('兑换卷')), + 's-wallet-card.vue 包含兑换券(卷)项、正确数据绑定与跳转路由', + '缺少兑换券配置或路由不正确' +); + +console.log("\n--------------------------------------------------------"); +console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`); +console.log("========================================================"); + +process.exit(failed === 0 ? 0 : 1); diff --git a/uniapp/env b/uniapp/env index 4060a84..e669358 100644 --- a/uniapp/env +++ b/uniapp/env @@ -1,8 +1,8 @@ # 正式环境接口域名 -SHOPRO_BASE_URL = https://v3.shopro.top +SHOPRO_BASE_URL = https://henglian.gynhc.com # 开发环境接口域名 -SHOPRO_DEV_BASE_URL = https://v3.shopro.top +SHOPRO_DEV_BASE_URL = https://henglian.gynhc.com # 开发环境运行端口 SHOPRO_DEV_PORT = 3000 diff --git a/uniapp/pages/index/user.vue b/uniapp/pages/index/user.vue index 206a6b4..5495a46 100644 --- a/uniapp/pages/index/user.vue +++ b/uniapp/pages/index/user.vue @@ -8,7 +8,7 @@ onShareAppMessage :showFloatButton="true" > - + @@ -27,6 +27,44 @@ const template = computed(() => sheep.$store('app').template.user); const isLogin = computed(() => sheep.$store('user').isLogin); + const defaultWalletStyle = { + background: { + type: 'color', + bgImage: '', + bgColor: '#FFFFFF', + }, + marginLeft: 10, + marginRight: 10, + marginTop: 0, + marginBottom: 8, + borderRadiusTop: 8, + borderRadiusBottom: 8, + padding: 0, + }; + + const layoutBlocks = computed(() => { + const list = template.value?.data || []; + if (!Array.isArray(list) || list.length === 0) return list; + + const hasWallet = list.some((item) => item.type === 'walletCard'); + if (hasWallet) return list; + + const blocks = [...list]; + const userCardIndex = blocks.findIndex((item) => item.type === 'userCard'); + const walletBlock = { + type: 'walletCard', + data: {}, + style: defaultWalletStyle, + }; + + if (userCardIndex !== -1) { + blocks.splice(userCardIndex + 1, 0, walletBlock); + } else { + blocks.unshift(walletBlock); + } + return blocks; + }); + onShow(() => { sheep.$store('user').updateUserData(); }); diff --git a/uniapp/sheep/components/s-wallet-card/s-wallet-card.vue b/uniapp/sheep/components/s-wallet-card/s-wallet-card.vue index abd8e6f..29b718a 100644 --- a/uniapp/sheep/components/s-wallet-card/s-wallet-card.vue +++ b/uniapp/sheep/components/s-wallet-card/s-wallet-card.vue @@ -1,25 +1,15 @@