Spaces:
Running
Running
Maryam Ilka commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import json
|
|
| 9 |
import random
|
| 10 |
|
| 11 |
# تنظیمات اولیه
|
| 12 |
-
st.set_page_config(layout="wide", page_title="تحلیل انصاف قیمتی", page_icon="
|
| 13 |
|
| 14 |
# ========== تنظیمات دیتا ==========
|
| 15 |
SHEET_ID = "1mmdWAyOCYq4yXMgP53Duq712AnlqZWLkfIo76JqM7wM"
|
|
@@ -29,26 +29,50 @@ st.markdown("""
|
|
| 29 |
direction: rtl !important;
|
| 30 |
}
|
| 31 |
|
| 32 |
-
.
|
| 33 |
-
background-color: #
|
| 34 |
padding: 15px;
|
| 35 |
border-radius: 10px;
|
| 36 |
color: white;
|
| 37 |
margin-bottom: 20px;
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
-
.price-
|
| 41 |
-
|
| 42 |
border-radius: 10px;
|
| 43 |
padding: 15px;
|
| 44 |
margin: 15px 0;
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
font-weight: bold;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
.explanation-title {
|
| 51 |
-
color: #
|
| 52 |
font-weight: bold;
|
| 53 |
margin-top: 20px;
|
| 54 |
}
|
|
@@ -56,7 +80,7 @@ st.markdown("""
|
|
| 56 |
.explanation-item {
|
| 57 |
margin: 10px 0;
|
| 58 |
padding-right: 15px;
|
| 59 |
-
border-right: 3px solid #
|
| 60 |
}
|
| 61 |
|
| 62 |
.survey-section {
|
|
@@ -65,17 +89,27 @@ st.markdown("""
|
|
| 65 |
padding: 20px;
|
| 66 |
margin-top: 30px;
|
| 67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
</style>
|
| 69 |
""", unsafe_allow_html=True)
|
| 70 |
|
| 71 |
# ========== توابع اصلی ==========
|
| 72 |
def create_ride_map():
|
| 73 |
"""ایجاد نقشه سفر با Folium"""
|
| 74 |
-
# مختصات تهران (میدان ونک تا میدان
|
| 75 |
start_point = [35.7698, 51.4116] # میدان ونک
|
| 76 |
-
end_point = [35.
|
| 77 |
|
| 78 |
-
m = folium.Map(location=[35.
|
| 79 |
|
| 80 |
# اضافه کردن مبدأ و مقصد
|
| 81 |
folium.Marker(
|
|
@@ -86,15 +120,15 @@ def create_ride_map():
|
|
| 86 |
|
| 87 |
folium.Marker(
|
| 88 |
end_point,
|
| 89 |
-
popup="<b>مقصد:</b> میدان
|
| 90 |
icon=folium.Icon(color="red", icon="flag", prefix="fa")
|
| 91 |
).add_to(m)
|
| 92 |
|
| 93 |
# خط مسیر
|
| 94 |
folium.PolyLine(
|
| 95 |
[start_point, end_point],
|
| 96 |
-
color="
|
| 97 |
-
weight=
|
| 98 |
opacity=1
|
| 99 |
).add_to(m)
|
| 100 |
|
|
@@ -103,7 +137,6 @@ def create_ride_map():
|
|
| 103 |
def show_explanation(exp_type):
|
| 104 |
"""نمایش توضیحات قیمت"""
|
| 105 |
explanations = {
|
| 106 |
-
"control": [],
|
| 107 |
"input": [
|
| 108 |
"سطح تقاضا در منطقه: زیاد",
|
| 109 |
"تعداد رانندگان فعال: کم",
|
|
@@ -117,9 +150,10 @@ def show_explanation(exp_type):
|
|
| 117 |
}
|
| 118 |
|
| 119 |
if exp_type != "control":
|
| 120 |
-
st.
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 123 |
|
| 124 |
# ========== توابع مدیریت دادهها ==========
|
| 125 |
def get_credentials():
|
|
@@ -223,9 +257,9 @@ def main():
|
|
| 223 |
|
| 224 |
# نمایش هدر
|
| 225 |
st.markdown("""
|
| 226 |
-
<div class="
|
| 227 |
-
<h2>
|
| 228 |
-
<p>این
|
| 229 |
</div>
|
| 230 |
""", unsafe_allow_html=True)
|
| 231 |
|
|
@@ -240,18 +274,33 @@ def main():
|
|
| 240 |
# اگر پرسشنامه تکمیل نشده
|
| 241 |
if not st.session_state.survey_completed:
|
| 242 |
# نمایش سناریو
|
| 243 |
-
st.markdown("###
|
| 244 |
folium_static(create_ride_map(), width=800, height=400)
|
| 245 |
|
| 246 |
-
# نمایش قیمت
|
| 247 |
-
st.
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
# پرسشنامه
|
| 257 |
with st.container():
|
|
|
|
| 9 |
import random
|
| 10 |
|
| 11 |
# تنظیمات اولیه
|
| 12 |
+
st.set_page_config(layout="wide", page_title="راهیار - تحلیل انصاف قیمتی", page_icon="🚖")
|
| 13 |
|
| 14 |
# ========== تنظیمات دیتا ==========
|
| 15 |
SHEET_ID = "1mmdWAyOCYq4yXMgP53Duq712AnlqZWLkfIo76JqM7wM"
|
|
|
|
| 29 |
direction: rtl !important;
|
| 30 |
}
|
| 31 |
|
| 32 |
+
.rahyar-header {
|
| 33 |
+
background-color: #6a0dad;
|
| 34 |
padding: 15px;
|
| 35 |
border-radius: 10px;
|
| 36 |
color: white;
|
| 37 |
margin-bottom: 20px;
|
| 38 |
+
text-align: center;
|
| 39 |
}
|
| 40 |
|
| 41 |
+
.price-container {
|
| 42 |
+
background-color: #f8f9fa;
|
| 43 |
border-radius: 10px;
|
| 44 |
padding: 15px;
|
| 45 |
margin: 15px 0;
|
| 46 |
+
border-right: 5px solid #6a0dad;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.rahyar-price {
|
| 50 |
+
color: #6a0dad;
|
| 51 |
+
font-size: 28px;
|
| 52 |
font-weight: bold;
|
| 53 |
+
text-align: center;
|
| 54 |
+
margin: 10px 0;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.rahyar-btn {
|
| 58 |
+
background-color: #6a0dad !important;
|
| 59 |
+
color: white !important;
|
| 60 |
+
border: none !important;
|
| 61 |
+
padding: 10px 20px !important;
|
| 62 |
+
border-radius: 8px !important;
|
| 63 |
+
font-weight: bold !important;
|
| 64 |
+
margin: 5px 0 !important;
|
| 65 |
+
width: 100% !important;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.rahyar-btn-secondary {
|
| 69 |
+
background-color: white !important;
|
| 70 |
+
color: #6a0dad !important;
|
| 71 |
+
border: 2px solid #6a0dad !important;
|
| 72 |
}
|
| 73 |
|
| 74 |
.explanation-title {
|
| 75 |
+
color: #6a0dad;
|
| 76 |
font-weight: bold;
|
| 77 |
margin-top: 20px;
|
| 78 |
}
|
|
|
|
| 80 |
.explanation-item {
|
| 81 |
margin: 10px 0;
|
| 82 |
padding-right: 15px;
|
| 83 |
+
border-right: 3px solid #6a0dad;
|
| 84 |
}
|
| 85 |
|
| 86 |
.survey-section {
|
|
|
|
| 89 |
padding: 20px;
|
| 90 |
margin-top: 30px;
|
| 91 |
}
|
| 92 |
+
|
| 93 |
+
.rahyar-badge {
|
| 94 |
+
background-color: #e6e6fa;
|
| 95 |
+
color: #6a0dad;
|
| 96 |
+
padding: 5px 10px;
|
| 97 |
+
border-radius: 15px;
|
| 98 |
+
font-size: 14px;
|
| 99 |
+
display: inline-block;
|
| 100 |
+
margin-left: 10px;
|
| 101 |
+
}
|
| 102 |
</style>
|
| 103 |
""", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
# ========== توابع اصلی ==========
|
| 106 |
def create_ride_map():
|
| 107 |
"""ایجاد نقشه سفر با Folium"""
|
| 108 |
+
# مختصات تهران (میدان ونک تا میدان تجریش)
|
| 109 |
start_point = [35.7698, 51.4116] # میدان ونک
|
| 110 |
+
end_point = [35.8044, 51.4258] # میدان تجریش
|
| 111 |
|
| 112 |
+
m = folium.Map(location=[35.7871, 51.4187], zoom_start=13)
|
| 113 |
|
| 114 |
# اضافه کردن مبدأ و مقصد
|
| 115 |
folium.Marker(
|
|
|
|
| 120 |
|
| 121 |
folium.Marker(
|
| 122 |
end_point,
|
| 123 |
+
popup="<b>مقصد:</b> میدان تجریش",
|
| 124 |
icon=folium.Icon(color="red", icon="flag", prefix="fa")
|
| 125 |
).add_to(m)
|
| 126 |
|
| 127 |
# خط مسیر
|
| 128 |
folium.PolyLine(
|
| 129 |
[start_point, end_point],
|
| 130 |
+
color="#6a0dad",
|
| 131 |
+
weight=3,
|
| 132 |
opacity=1
|
| 133 |
).add_to(m)
|
| 134 |
|
|
|
|
| 137 |
def show_explanation(exp_type):
|
| 138 |
"""نمایش توضیحات قیمت"""
|
| 139 |
explanations = {
|
|
|
|
| 140 |
"input": [
|
| 141 |
"سطح تقاضا در منطقه: زیاد",
|
| 142 |
"تعداد رانندگان فعال: کم",
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
if exp_type != "control":
|
| 153 |
+
with st.expander("🔍 مشاهده توضیحات قیمت", expanded=False):
|
| 154 |
+
st.markdown("<p class='explanation-title'>علت قیمت گذاری:</p>", unsafe_allow_html=True)
|
| 155 |
+
for item in explanations.get(exp_type, []):
|
| 156 |
+
st.markdown(f"<p class='explanation-item'>• {item}</p>", unsafe_allow_html=True)
|
| 157 |
|
| 158 |
# ========== توابع مدیریت دادهها ==========
|
| 159 |
def get_credentials():
|
|
|
|
| 257 |
|
| 258 |
# نمایش هدر
|
| 259 |
st.markdown("""
|
| 260 |
+
<div class="rahyar-header">
|
| 261 |
+
<h2>راهیار 🚖</h2>
|
| 262 |
+
<p>سفرهای درون شهری سریع و مطمئن</p>
|
| 263 |
</div>
|
| 264 |
""", unsafe_allow_html=True)
|
| 265 |
|
|
|
|
| 274 |
# اگر پرسشنامه تکمیل نشده
|
| 275 |
if not st.session_state.survey_completed:
|
| 276 |
# نمایش سناریو
|
| 277 |
+
st.markdown("### مسیر سفر شما")
|
| 278 |
folium_static(create_ride_map(), width=800, height=400)
|
| 279 |
|
| 280 |
+
# نمایش قیمت و دکمهها
|
| 281 |
+
col1, col2 = st.columns([3, 2])
|
| 282 |
+
with col1:
|
| 283 |
+
st.markdown(f"""
|
| 284 |
+
<div class="price-container">
|
| 285 |
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
| 286 |
+
<span>راهیار <span class="rahyar-badge">به صرفه</span></span>
|
| 287 |
+
<span class="rahyar-price">{st.session_state.price:,} تومان</span>
|
| 288 |
+
</div>
|
| 289 |
+
</div>
|
| 290 |
+
""", unsafe_allow_html=True)
|
| 291 |
+
|
| 292 |
+
if st.session_state.scenario_type != "control":
|
| 293 |
+
show_explanation(st.session_state.scenario_type)
|
| 294 |
|
| 295 |
+
with col2:
|
| 296 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 297 |
+
if st.button("درخواست راهیار", key="request_btn", type="primary"):
|
| 298 |
+
pass
|
| 299 |
+
|
| 300 |
+
if st.session_state.scenario_type != "control":
|
| 301 |
+
if st.button("مشاهده توضیحات", key="explanation_btn",
|
| 302 |
+
help="توضیحات قیمت گذاری این سفر"):
|
| 303 |
+
pass
|
| 304 |
|
| 305 |
# پرسشنامه
|
| 306 |
with st.container():
|