feat: 套餐按钮根据用户会员状态显示

- 当前套餐:绿色disabled按钮
- 已升级:灰色disabled按钮
- 未登录/低等级:显示购买按钮
- pricing路由传递user对象
This commit is contained in:
2026-04-14 18:18:42 +08:00
parent c1e929fc8a
commit 81c4965ded
2 changed files with 24 additions and 1 deletions

3
app.py
View File

@@ -206,7 +206,8 @@ def history():
@app.route('/pricing') @app.route('/pricing')
def pricing(): def pricing():
"""会员定价页""" """会员定价页"""
return render_template('pricing.html', plans=MEMBERSHIP_PLANS) user = get_current_user()
return render_template('pricing.html', plans=MEMBERSHIP_PLANS, user=user)
# ==================== 路由: API ==================== # ==================== 路由: API ====================

View File

@@ -40,7 +40,13 @@
<li class="text-muted">❌ 批量翻译</li> <li class="text-muted">❌ 批量翻译</li>
</ul> </ul>
{% if user and user.user_type in ['free', 'vip_basic', 'vip_pro', 'vip_enterprise', 'admin'] %}
<span class="btn btn-secondary w-100 mt-3 disabled">
{% if user.user_type == 'free' %}当前套餐{% else %}已升级{% endif %}
</span>
{% else %}
<a href="/register" class="btn btn-outline-secondary w-100 mt-3">免费注册</a> <a href="/register" class="btn btn-outline-secondary w-100 mt-3">免费注册</a>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@@ -62,7 +68,13 @@
<li>✅ 优先处理队列</li> <li>✅ 优先处理队列</li>
</ul> </ul>
{% if user and user.user_type == 'vip_basic' %}
<span class="btn btn-success w-100 mt-3 disabled">当前套餐</span>
{% elif user and user.user_type in ['vip_pro', 'vip_enterprise', 'admin'] %}
<span class="btn btn-secondary w-100 mt-3 disabled">已升级</span>
{% else %}
<button class="btn btn-outline-primary w-100 mt-3">立即购买</button> <button class="btn btn-outline-primary w-100 mt-3">立即购买</button>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@@ -86,7 +98,13 @@
<li>✅ 自定义术语库</li> <li>✅ 自定义术语库</li>
</ul> </ul>
{% if user and user.user_type == 'vip_pro' %}
<span class="btn btn-success w-100 mt-3 disabled">当前套餐</span>
{% elif user and user.user_type in ['vip_enterprise', 'admin'] %}
<span class="btn btn-secondary w-100 mt-3 disabled">已升级</span>
{% else %}
<button class="btn btn-primary w-100 mt-3">立即购买</button> <button class="btn btn-primary w-100 mt-3">立即购买</button>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@@ -106,7 +124,11 @@
<li>✅ API接口调用</li> <li>✅ API接口调用</li>
</ul> </ul>
{% if user and user.user_type in ['vip_enterprise', 'admin'] %}
<span class="btn btn-success w-100 mt-3 disabled">当前套餐</span>
{% else %}
<button class="btn btn-outline-primary w-100 mt-3">联系购买</button> <button class="btn btn-outline-primary w-100 mt-3">联系购买</button>
{% endif %}
</div> </div>
</div> </div>
</div> </div>