feat(uniapp): 我的页面加入资产卡片并展示余额、马豆与兑换券

这个提交包含在:
wikiboss
2026-09-17 15:58:47 +08:00
父节点 f30c3ff633
当前提交 b771abfb91
共有 5 个文件被更改,包括 110 次插入 和 40 次删除

1
.gitignore vendored
查看文件

@@ -27,3 +27,4 @@ AGENTS.md
/未命名/
.webhook_secret
/.deploy/
unpackage/

查看文件

@@ -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);

查看文件

@@ -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

查看文件

@@ -8,7 +8,7 @@
onShareAppMessage
:showFloatButton="true"
>
<s-block v-for="(item, index) in template.data" :key="index" :styles="item.style">
<s-block v-for="(item, index) in layoutBlocks" :key="index" :styles="item.style">
<s-block-item :type="item.type" :data="item.data" :styles="item.style" />
</s-block>
</s-layout>
@@ -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();
});

查看文件

@@ -1,25 +1,15 @@
<template>
<view class="ss-wallet-menu-wrap">
<view class="wallet-grid ss-flex ss-flex-wrap">
<view class="wallet-grid ss-flex ss-row-around">
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/money')"
>
<view class="value-box ss-flex ss-col-bottom ss-row-center">
<view class="value-text ss-line-1">{{ userInfo.money }}</view>
<view class="value-text ss-line-1">{{ userInfo.money || '0.00' }}</view>
<view class="unit-text ss-m-l-6">元</view>
</view>
<view class="menu-title ss-m-t-16">账户余额</view>
</view>
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/commission')"
>
<view class="value-box ss-flex ss-col-bottom ss-row-center">
<view class="value-text ss-line-1">{{ userInfo?.commission || '0.00' }}</view>
<view class="unit-text ss-m-l-6">元</view>
</view>
<view class="menu-title ss-m-t-16">收益</view>
<view class="menu-title ss-m-t-16">余额</view>
</view>
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
@@ -41,30 +31,6 @@
</view>
<view class="menu-title ss-m-t-16">兑换券</view>
</view>
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/score')"
>
<view class="value-box ss-flex ss-col-bottom ss-row-center">
<view class="value-text">{{ userInfo.score }}</view>
<view class="unit-text ss-m-l-6">个</view>
</view>
<view class="menu-title ss-m-t-16">积分</view>
</view>
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
@tap="
sheep.$router.go('/pages/coupon/list', {
type: 'geted',
})
"
>
<view class="value-box ss-flex ss-col-bottom ss-row-center">
<view class="value-text">{{ numData.coupons_num }}</view>
<view class="unit-text ss-m-l-6">张</view>
</view>
<view class="menu-title ss-m-t-16">优惠券</view>
</view>
</view>
</view>
</template>