Skip to content

Commit 85c12c7

Browse files
lv111101lv111101
authored andcommitted
feat(mini-app): Complete mini-program pages
- Add applications page with progress tracking - Add enterprise page with user profile - Add WeChat login integration - Add application filtering by status - Add statistics display - Add menu for settings, help, and contact Tasks: nearai#3
1 parent 4647732 commit 85c12c7

File tree

8 files changed

+984
-0
lines changed

8 files changed

+984
-0
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
const app = getApp();
2+
3+
Page({
4+
data: {
5+
loading: true,
6+
applications: [],
7+
activeTab: 'active',
8+
enterpriseId: null
9+
},
10+
11+
onLoad() {
12+
this.loadEnterprise();
13+
},
14+
15+
onShow() {
16+
if (this.data.enterpriseId) {
17+
this.loadApplications();
18+
}
19+
},
20+
21+
onPullDownRefresh() {
22+
this.loadApplications().then(() => {
23+
wx.stopPullDownRefresh();
24+
});
25+
},
26+
27+
async loadEnterprise() {
28+
try {
29+
const userInfo = app.globalData.userInfo;
30+
if (!userInfo) {
31+
wx.showToast({
32+
title: '请先登录',
33+
icon: 'none'
34+
});
35+
return;
36+
}
37+
38+
const res = await app.request({
39+
url: `/enterprises/user/${userInfo.id}`
40+
});
41+
42+
if (res.data) {
43+
this.setData({
44+
enterpriseId: res.data.id
45+
});
46+
this.loadApplications();
47+
}
48+
} catch (error) {
49+
console.error('获取企业信息失败:', error);
50+
}
51+
},
52+
53+
async loadApplications() {
54+
if (!this.data.enterpriseId) return;
55+
56+
this.setData({ loading: true });
57+
58+
try {
59+
const res = await app.request({
60+
url: '/applications',
61+
data: {
62+
enterpriseId: this.data.enterpriseId
63+
}
64+
});
65+
66+
const applications = (res.data?.items || []).map(item => {
67+
return {
68+
...item,
69+
progressPercent: this.getProgressPercent(item.status),
70+
statusText: this.getStatusText(item.status),
71+
statusColor: this.getStatusColor(item.status)
72+
};
73+
});
74+
75+
this.setData({
76+
applications: applications,
77+
loading: false
78+
});
79+
} catch (error) {
80+
console.error('获取申报任务失败:', error);
81+
this.setData({ loading: false });
82+
app.showError('加载失败');
83+
}
84+
},
85+
86+
getProgressPercent(status) {
87+
const progressMap = {
88+
'待开始': 0,
89+
'准备中': 25,
90+
'审核中': 50,
91+
'待提交': 75,
92+
'已提交': 80,
93+
'已通过': 100,
94+
'未通过': 100,
95+
'已过期': 100
96+
};
97+
return progressMap[status] || 0;
98+
},
99+
100+
getStatusText(status) {
101+
const textMap = {
102+
'待开始': '待开始',
103+
'准备中': '准备中',
104+
'审核中': '审核中',
105+
'待提交': '待提交',
106+
'已提交': '已提交',
107+
'已通过': '已通过',
108+
'未通过': '未通过',
109+
'已过期': '已过期'
110+
};
111+
return textMap[status] || status;
112+
},
113+
114+
getStatusColor(status) {
115+
const colorMap = {
116+
'待开始': '#999',
117+
'准备中': '#1890ff',
118+
'审核中': '#faad14',
119+
'待提交': '#722ed1',
120+
'已提交': '#13c2c2',
121+
'已通过': '#52c41a',
122+
'未通过': '#ff4d4f',
123+
'已过期': '#bfbfbf'
124+
};
125+
return colorMap[status] || '#999';
126+
},
127+
128+
switchTab(e) {
129+
const tab = e.currentTarget.dataset.tab;
130+
this.setData({ activeTab: tab });
131+
},
132+
133+
getFilteredApplications() {
134+
const { applications, activeTab } = this.data;
135+
if (activeTab === 'active') {
136+
return applications.filter(app =>
137+
app.status !== '已通过' &&
138+
app.status !== '未通过' &&
139+
app.status !== '已过期'
140+
);
141+
} else {
142+
return applications.filter(app =>
143+
app.status === '已通过' ||
144+
app.status === '未通过' ||
145+
app.status === '已过期'
146+
);
147+
}
148+
},
149+
150+
goToDetail(e) {
151+
const { id } = e.currentTarget.dataset;
152+
wx.navigateTo({
153+
url: `/pages/application-detail/application-detail?id=${id}`
154+
});
155+
},
156+
157+
goToPolicy(e) {
158+
const { policyId } = e.currentTarget.dataset;
159+
wx.navigateTo({
160+
url: `/pages/policy-detail/policy-detail?id=${policyId}`
161+
});
162+
}
163+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"navigationBarTitleText": "申报管理",
3+
"enablePullDownRefresh": true
4+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<view class="container">
2+
<!-- Tab切换 -->
3+
<view class="tab-bar">
4+
<view class="tab-item {{activeTab === 'active' ? 'active' : ''}}" data-tab="active" bindtap="switchTab">
5+
进行中
6+
</view>
7+
<view class="tab-item {{activeTab === 'completed' ? 'active' : ''}}" data-tab="completed" bindtap="switchTab">
8+
已结束
9+
</view>
10+
</view>
11+
12+
<!-- 加载中 -->
13+
<view wx:if="{{loading}}" class="loading-state">
14+
<view class="loading-spinner"></view>
15+
<text>加载中...</text>
16+
</view>
17+
18+
<!-- 空状态 -->
19+
<view wx:elif="{{getFilteredApplications().length === 0}}" class="empty-state">
20+
<image src="/images/empty.png" mode="aspectFit" class="empty-icon"/>
21+
<text class="empty-text">暂无{{activeTab === 'active' ? '进行中' : '已结束'}}的申报</text>
22+
<button class="btn-primary" bindtap="goToPolicies">去发现政策</button>
23+
</view>
24+
25+
<!-- 申报列表 -->
26+
<view wx:else class="applications-list">
27+
<view
28+
wx:for="{{getFilteredApplications()}}"
29+
wx:key="id"
30+
class="application-card"
31+
data-id="{{item.id}}"
32+
bindtap="goToDetail"
33+
>
34+
<!-- 头部 -->
35+
<view class="card-header">
36+
<text class="policy-name">{{item.policyName || '政策申报'}}</text>
37+
<view class="status-badge" style="background: {{item.statusColor}};">
38+
{{item.statusText}}
39+
</view>
40+
</view>
41+
42+
<!-- 进度条 -->
43+
<view class="progress-section">
44+
<view class="progress-bar">
45+
<view class="progress-fill" style="width: {{item.progressPercent}}%; background: {{item.statusColor}};"></view>
46+
</view>
47+
<text class="progress-text">{{item.progressPercent}}%</text>
48+
</view>
49+
50+
<!-- 信息 -->
51+
<view class="info-section">
52+
<view class="info-item">
53+
<text class="info-label">创建时间:</text>
54+
<text class="info-value">{{item.createdAt}}</text>
55+
</view>
56+
<view class="info-item" wx:if="{{item.submittedAt}}">
57+
<text class="info-label">提交时间:</text>
58+
<text class="info-value">{{item.submittedAt}}</text>
59+
</view>
60+
<view class="info-item" wx:if="{{item.approvedAmount}}">
61+
<text class="info-label">获批金额:</text>
62+
<text class="info-value highlight">{{item.approvedAmount}}万元</text>
63+
</view>
64+
</view>
65+
66+
<!-- 操作按钮 -->
67+
<view class="action-section" catchtap="stopPropagation">
68+
<button
69+
wx:if="{{item.status === '待开始' || item.status === '准备中'}}"
70+
class="btn-primary small"
71+
data-id="{{item.id}}"
72+
bindtap="goToDetail"
73+
>
74+
继续准备
75+
</button>
76+
<button
77+
wx:elif="{{item.status === '待提交'}}"
78+
class="btn-primary small"
79+
data-id="{{item.id}}"
80+
bindtap="goToDetail"
81+
>
82+
立即提交
83+
</button>
84+
<button
85+
wx:else
86+
class="btn-default small"
87+
data-id="{{item.id}}"
88+
bindtap="goToDetail"
89+
>
90+
查看详情
91+
</button>
92+
</view>
93+
</view>
94+
</view>
95+
</view>

0 commit comments

Comments
 (0)