重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
|
||||
/**
|
||||
* Purpose: money supports index.js by holding or executing the money page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function money(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatTime supports index.js by holding or executing the format time page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function formatTime(value) {
|
||||
return value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function sceneText(scene) {
|
||||
const map = {
|
||||
MANUAL_RECHARGE: '手工充值',
|
||||
MANUAL_DEDUCT: '手工扣减',
|
||||
ORDER_PAY: '订单消费',
|
||||
ORDER_REFUND: '订单退款',
|
||||
RECHARGE: '充值',
|
||||
CONSUME: '消费'
|
||||
}
|
||||
return map[scene] || scene || '余额变动'
|
||||
}
|
||||
|
||||
/**
|
||||
* vip-center page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
asset: {
|
||||
/**
|
||||
* Purpose: vipLevel supports index.js by holding or executing the vip level page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipLevel: '普通',
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
balanceText: '0.00',
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
totalRechargeText: '0.00',
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
lastRechargeText: '--',
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipStartText: '--',
|
||||
/**
|
||||
* Purpose: manualOverride supports index.js by holding or executing the manual override page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
manualOverride: false
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
history: [],
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePlans: [],
|
||||
/**
|
||||
* Purpose: rechargePanelVisible supports index.js by holding or executing the recharge panel visible page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePanelVisible: false
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('查看 VIP 中心')) {
|
||||
return
|
||||
}
|
||||
this.loadData()
|
||||
},
|
||||
|
||||
async loadData() {
|
||||
try {
|
||||
const [asset, history, plans] = await Promise.all([
|
||||
userApi.getMyAsset(),
|
||||
userApi.getMyBalanceHistory(),
|
||||
userApi.listMyVipRechargePlans().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
asset: {
|
||||
...asset,
|
||||
/**
|
||||
* Purpose: balanceText supports index.js by holding or executing the balance text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
balanceText: money(asset && asset.balance),
|
||||
/**
|
||||
* Purpose: totalRechargeText supports index.js by holding or executing the total recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
totalRechargeText: money(asset && asset.totalRechargeAmount),
|
||||
/**
|
||||
* Purpose: lastRechargeText supports index.js by holding or executing the last recharge text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
lastRechargeText: formatTime(asset && asset.lastRechargeTime),
|
||||
/**
|
||||
* Purpose: vipStartText supports index.js by holding or executing the vip start text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
vipStartText: formatTime(asset && asset.vipStartTime)
|
||||
},
|
||||
/**
|
||||
* Purpose: history supports index.js by holding or executing the history page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
history: (Array.isArray(history) ? history : []).map(item => {
|
||||
const amountNumber = Number(item.amount || 0)
|
||||
return {
|
||||
...item,
|
||||
amountNumber,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
amountText: `${amountNumber > 0 ? '+' : ''}¥${money(amountNumber)}`,
|
||||
/**
|
||||
* Purpose: sceneText supports index.js by holding or executing the scene text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
sceneText: sceneText(item.changeScene || item.type),
|
||||
/**
|
||||
* Purpose: changeTimeText supports index.js by holding or executing the change time text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
changeTimeText: formatTime(item.changeTime)
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* Purpose: rechargePlans supports index.js by holding or executing the recharge plans page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
rechargePlans: (Array.isArray(plans) ? plans : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: amountText supports index.js by holding or executing the amount text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
amountText: `充 ${money(item.rechargeAmount)} 送 ${money(item.giftAmount)}`
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || 'VIP 信息加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `openRechargePanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
openRechargePanel() {
|
||||
this.setData({ rechargePanelVisible: true })
|
||||
},
|
||||
|
||||
/**
|
||||
* `closeRechargePanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
closeRechargePanel() {
|
||||
this.setData({ rechargePanelVisible: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* `noop` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
noop() {
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<navigation-bar title="VIP 中心" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
||||
<view class="vip-page">
|
||||
<view class="vip-hero">
|
||||
<text class="vip-kicker">会员等级</text>
|
||||
<text class="vip-level">{{asset.vipLevel || '普通'}}</text>
|
||||
<text class="vip-benefit">{{asset.benefitInfo || '暂无额外权益说明'}}</text>
|
||||
</view>
|
||||
|
||||
<view class="metric-grid">
|
||||
<view class="metric">
|
||||
<text>余额</text>
|
||||
<text class="metric-value">¥{{asset.balanceText}}</text>
|
||||
</view>
|
||||
<view class="metric">
|
||||
<text>累计充值</text>
|
||||
<text class="metric-value">¥{{asset.totalRechargeText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="recharge-entry" bindtap="openRechargePanel">去充值 / 查看充值说明</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">会员信息</view>
|
||||
<view class="info-row"><text>最近充值</text><text>{{asset.lastRechargeText}}</text></view>
|
||||
<view class="info-row"><text>生效时间</text><text>{{asset.vipStartText}}</text></view>
|
||||
<view class="info-row"><text>等级来源</text><text>{{asset.manualOverride ? '后台指定' : '自动计算'}}</text></view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">余额变动</view>
|
||||
<block wx:if="{{history.length}}">
|
||||
<view wx:for="{{history}}" wx:key="id" class="history-row">
|
||||
<view>
|
||||
<text class="history-title">{{item.sceneText}}</text>
|
||||
<text class="history-time">{{item.changeTimeText}}</text>
|
||||
<text wx:if="{{item.remark}}" class="history-remark">{{item.remark}}</text>
|
||||
</view>
|
||||
<text class="history-amount {{item.amountNumber > 0 ? 'income' : ''}}">{{item.amountText}}</text>
|
||||
</view>
|
||||
</block>
|
||||
<view wx:else class="empty">暂无余额变动</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{rechargePanelVisible}}" class="recharge-mask" bindtap="closeRechargePanel">
|
||||
<view class="recharge-panel" catchtap="noop">
|
||||
<view class="section-title">充值档位展示</view>
|
||||
<block wx:if="{{rechargePlans.length}}">
|
||||
<view wx:for="{{rechargePlans}}" wx:key="id" class="recharge-plan">
|
||||
<view class="plan-head">
|
||||
<text>{{item.title}}</text>
|
||||
<text>{{item.vipLevel}}</text>
|
||||
</view>
|
||||
<text class="plan-amount">{{item.amountText}}</text>
|
||||
<text class="plan-desc">{{item.description || '该档位仅展示,暂不发起支付。'}}</text>
|
||||
</view>
|
||||
</block>
|
||||
<view wx:else class="empty">暂无可展示充值档位</view>
|
||||
<view class="recharge-close" bindtap="closeRechargePanel">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,162 @@
|
||||
.vip-page {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx;
|
||||
background: #f7f4f1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.vip-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
padding: 36rpx;
|
||||
border-radius: 16rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #2b2522, #8a704e);
|
||||
}
|
||||
|
||||
.vip-kicker, .vip-benefit {
|
||||
color: rgba(255,255,255,.76);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.vip-level {
|
||||
font-size: 56rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.metric, .section {
|
||||
padding: 28rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
color: #7f7470;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
color: #2d2927;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin-bottom: 20rpx;
|
||||
color: #2d2927;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.info-row, .history-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid #f0ece8;
|
||||
}
|
||||
|
||||
.info-row:last-child, .history-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.history-title, .history-time, .history-remark {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.history-title {
|
||||
color: #2d2927;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.history-time, .history-remark, .empty {
|
||||
margin-top: 6rpx;
|
||||
color: #9a918d;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.history-amount {
|
||||
color: #2d2927;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.history-amount.income {
|
||||
color: #0f8f63;
|
||||
}
|
||||
|
||||
.recharge-entry {
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fff7ed;
|
||||
color: #9a5b2e;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.recharge-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
z-index: 30;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.recharge-panel {
|
||||
width: 100%;
|
||||
max-height: 75vh;
|
||||
overflow: auto;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
background: #fff;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.recharge-plan {
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid #f0ece8;
|
||||
}
|
||||
|
||||
.plan-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 18rpx;
|
||||
color: #2d2927;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.plan-amount {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
color: #9a5b2e;
|
||||
}
|
||||
|
||||
.plan-desc {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: #9a918d;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.recharge-close {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f4f0eb;
|
||||
text-align: center;
|
||||
}
|
||||
Reference in New Issue
Block a user