提交 8172142d 编写于 作者: M m0_37786544

Sat Apr 20 19:21:00 CST 2024 inscode

上级 0520122c
import streamlit as st
from streamlit_option_menu import option_menu
# 设置Streamlit应用程序的标题
st.set_page_config(page_title="app name", layout="wide")
# 菜单
menu = {
"牛排": 50,
"鸡肉": 35,
"虾仁": 40,
"炒面": 20,
"饺子": 15
}
menu1="菜单1"
menu2="菜单2"
# 页面标题
st.title("欢迎来到餐厅点餐小程序")
with st.sidebar:
menu = option_menu("菜单", [menu1, menu2],
icons=['house', "list-task"],
menu_icon="cast", default_index=0)
# 商家编辑菜单
if st.sidebar.checkbox("编辑菜单"):
menu = {}
st.write("请编辑菜单:")
while True:
dish_name = st.text_input("请输入菜名")
if not dish_name:
break
price = st.number_input("请输入价格", min_value=0)
if price == 0:
break
menu[dish_name] = price
st.write("已更新菜单:")
st.write(menu)
def main():
# 选择菜品,并提交订单
st.subheader("请选择您需要的菜品及数量")
order_dict = {}
for dish, price in menu.items():
quantity = st.number_input(f"{dish}({price}元)", value=0, step=1)
if quantity > 0:
order_dict[dish] = {"price": price, "quantity": quantity}
if st.button("提交订单"):
if order_dict:
st.success("订单已提交")
if menu == menu1:
st.subheader(f"{menu1}")
# 生成订单号
order_id = "123456789"
st.write(f"订单号:{order_id}")
if menu == menu2:
st.subheader(f"{menu2}")
# 展示订单详情
st.subheader("订单详情")
total_price = 0
for dish, values in order_dict.items():
price = values["price"]
quantity = values["quantity"]
dish_total_price = price*quantity
total_price += dish_total_price
st.write(f"{dish} x {quantity}: {dish_total_price}元")
st.write(f"总价:{total_price}元")
if __name__ == '__main__':
main()
# 支付
payment_method = st.selectbox("请选择支付方式", ["微信支付", "支付宝支付", "银行卡支付"])
if st.button("支付"):
st.success("支付成功")
st.write("请等待配送")
else:
st.warning("您还没有选择任何菜品")
# 商家查看订单
st.subheader("商家查看订单")
if st.button("查看订单"):
st.write("订单详情")
st.write(order_dict)
import streamlit as st
# 菜单
menu = {
"牛排": 50,
"鸡肉": 35,
"虾仁": 40,
"炒面": 20,
"饺子": 15
}
# 页面标题
st.title("欢迎来到餐厅点餐小程序")
# 商家编辑菜单
if st.sidebar.checkbox("编辑菜单"):
menu = {}
st.write("请编辑菜单:")
while True:
dish_name = st.text_input("请输入菜名")
if not dish_name:
break
price = st.number_input("请输入价格", min_value=0)
if price == 0:
break
menu[dish_name] = price
st.write("已更新菜单:")
st.write(menu)
# 选择菜品,并提交订单
st.subheader("请选择您需要的菜品及数量")
order_dict = {}
for dish, price in menu.items():
quantity = st.number_input(f"{dish}({price}元)", value=0, step=1)
if quantity > 0:
order_dict[dish] = {"price": price, "quantity": quantity}
if st.button("提交订单"):
if order_dict:
st.success("订单已提交")
# 生成订单号
order_id = "123456789"
st.write(f"订单号:{order_id}")
# 展示订单详情
st.subheader("订单详情")
total_price = 0
for dish, values in order_dict.items():
price = values["price"]
quantity = values["quantity"]
dish_total_price = price*quantity
total_price += dish_total_price
st.write(f"{dish} x {quantity}: {dish_total_price}元")
st.write(f"总价:{total_price}元")
# 支付
payment_method = st.selectbox("请选择支付方式", ["微信支付", "支付宝支付", "银行卡支付"])
if st.button("支付"):
st.success("支付成功")
st.write("请等待配送")
else:
st.warning("您还没有选择任何菜品")
# 商家查看订单
st.subheader("商家查看订单")
if st.button("查看订单"):
st.write("订单详情")
st.write(order_dict)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册