Maryam Ilka commited on
Commit
0db1c6d
·
verified ·
1 Parent(s): 06dac0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -31
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
- .ride-header {
33
- background-color: #3d5a80;
34
  padding: 15px;
35
  border-radius: 10px;
36
  color: white;
37
  margin-bottom: 20px;
 
38
  }
39
 
40
- .price-box {
41
- border: 2px solid #3d5a80;
42
  border-radius: 10px;
43
  padding: 15px;
44
  margin: 15px 0;
45
- text-align: center;
46
- font-size: 24px;
 
 
 
 
47
  font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  .explanation-title {
51
- color: #3d5a80;
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 #3d5a80;
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.7368, 51.4036] # میدان ولیعصر
77
 
78
- m = folium.Map(location=[35.75, 51.41], zoom_start=14)
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="blue",
97
- weight=2.5,
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.markdown("<p class='explanation-title'>علت قیمت گذاری:</p>", unsafe_allow_html=True)
121
- for item in explanations.get(exp_type, []):
122
- st.markdown(f"<p class='explanation-item'>{item}</p>", unsafe_allow_html=True)
 
123
 
124
  # ========== توابع مدیریت داده‌ها ==========
125
  def get_credentials():
@@ -223,9 +257,9 @@ def main():
223
 
224
  # نمایش هدر
225
  st.markdown("""
226
- <div class="ride-header">
227
- <h2>تحلیل انصاف قیمتی در پلتفرم‌های اشتراک سفر</h2>
228
- <p>این تحقیق به بررسی تأثیر توضیحات قیمت بر ادراک انصاف می‌پردازد</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.markdown(f"""
248
- <div class="price-box">
249
- قیمت پیشنهادی: {st.session_state.price:,} تومان
250
- </div>
251
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
252
 
253
- # نمایش توضیحات (بر اساس نوع سناریو)
254
- show_explanation(st.session_state.scenario_type)
 
 
 
 
 
 
 
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():