顯示具有 Django 標籤的文章。 顯示所有文章
顯示具有 Django 標籤的文章。 顯示所有文章

2025年6月8日 星期日

尚虎雲產銷平台助水井村智慧減碳節水三生一體

 

國立虎尾科技大學電機資訊學院
113學年度第二學期多媒體應用與實習【創新課程】教學成果


教學目標:

本課程將以先前開發的尚虎雲產銷平台為基礎,著重於前端網站設計及物聯網技術的實踐與應用。課程內容包括強化多媒體應用於產銷平台的功能,提升學生在前端開發、智慧物聯網整合與平台優化方面的能力。本次課程將延續地方場域的實踐,學生將透過實地考察與社區合作,結合所學技能,進一步完善並擴展尚虎雲平台的使用範圍與功能。評量方式涵蓋專案成果展示、技術能力測試及課堂參與,旨在全面提升學生的實務經驗與創新能力。透過此課程,學生將具備更高的實作能力,並能在數位科技及物聯網應用領域展現競爭力。

關鍵詞:多媒體應用、前端網站設計、物聯網、地方場域、尚虎雲產銷平台

場域學習:

  • 114年4月25日 北港高中 第四屆雲林Go科技/國立虎尾科技大學電子工程系吳添全副教授


  • 114年4月25日 水井村 - 生態導覽/水井社區發展協會林文欽總幹事



業師教學:

  • 114年3月14日-「視覺設計的基礎」,盧泰岳品牌主理人/呆尼創意工作室

  • 114年3月21日-「Wireframe(線框圖)」,盧泰岳品牌主理人/呆尼創意工作室


  • 114年3月28日-「網頁基礎架構」,盧泰岳品牌主理人/呆尼創意工作室



  • 114年5月23日-「HUB8735 Ultra」,施朝斌經理/小霸王科技有限公司





  • 114年5月23日-「HUB8735U IOT」,施朝斌經理/小霸王科技有限公司



成果影片:

開源程式碼:


創新教材:

  1. 尚虎雲產銷平台-生產端軟體安裝手冊
  2. 尚虎雲產銷平台-生產端軟體操作手冊
  3. 尚虎雲產銷平台-生產端軟體新增刪除感測器的功能
  4. 尚虎雲產銷平台-銷售端軟體安裝手冊
  5. 善用pythonanywhere開發Django網站
  6. 在Django網站首頁放置樹藝micro:bit的照片
  7. Django Soft UI Dashboard佈署到pythonanywhere
  8. 設計Django網站採用Giftos樣版上傳到pythonanywhere
  9. 在Django網站中採用美食廣場Bootstrap 5 電子商務樣版
  10. 在Django網站中採用美食廣場Bootstrap 5 電子商務樣版(續)
  11. 上傳美食廣場Bootstrap 5 電子商務樣版到pythonanywhere
  12. 下載有機食物樣版實作Django網站
  13. 實作冰淇淋Django網站(一)-首頁
  14. 實作冰淇淋Django網站(二)-關於
  15. 實作冰淇淋Django網站(三)-冰淇淋
  16. 實作冰淇淋Django網站(四)-服務
  17. 實作冰淇淋Django網站(五)-部落格
  18. 實作冰淇淋Django網站(六)-聯絡我們
  19. 實作冰淇淋Django網站(七)-基礎樣版設計
  20. 實作冰淇淋Django網站(八)-輪播迴圈樣版設計
  21. 實作冰淇淋Django網站(九)-建立輪播圖資料庫
  22. 實作冰淇淋Django網站(十)-AI生成輪播圖視域程式
  23. 在pythonanywhere設計Django網站的卡片(Card)功能(新增資料庫)
  24. 在Django中設定和存取Session的內容
  25. 在Django中使用Cookies來計算今天瀏覽次數
  26. 在pythonanywhere設計Django網站的登入功能
  27. 在pythonanywhere設計Django網站的登入功能加上圖形驗證
  28. 用Python/Django/pythonanywhere實作農漁業產品交易行情
  29. 製作水果交易網站(一) -在Django中用pyecharts製作圖表
  30. 尚虎雲產銷平台-銷售端整合市場行情
  31. 尚虎雲產銷平台-銷售端整合商業模式圖
  32. 實作物聯網網站用Django+AJAX+JavaScript整合MQTT
應用範例:

評量工具:




2025年6月7日 星期六

實作物聯網網站用Django+AJAX+JavaScript整合MQTT

 

1.安裝套件

pip install django

pip install paho-mqtt

2.建立mqtttest專案

django-admin startproject mqtttest

3.進入專案

cd mqtttest

4.建立app

python manage.py startapp mqttapp

5.修改mqtttest/mqtttest/settings.py

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"""
Django settings for mqtttest project.

Generated by 'django-admin startproject' using Django 4.2.9.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-q2ia=(7x3d5_mxao#-sl)+)crp9j%e*732fg4jhid-f&sln5k('

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mqttapp',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mqtttest.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mqtttest.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MQTT_SERVER = 'broker.MQTTGO.io'
MQTT_PORT = 1883
MQTT_KEEPALIVE = 60
MQTT_USER = ''
MQTT_PASSWORD = ''

6.修改mqtttest/mqtttest/urls.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
URL configuration for mqtttest project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from mqttapp.views import home, publish_message, mqtt_messages_json

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', home),
    path('publish/', publish_message, name='publish'),
    path('api/messages/', mqtt_messages_json, name='mqtt_messages_json'),
]

7.mqtttest/mqttapp/models.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from django.db import models

# Create your models here.

class MQTTMessage(models.Model):
    received_at = models.DateTimeField(auto_now_add=True)  # 自動紀錄訊息接收時間
    topic = models.CharField(max_length=255)
    payload = models.TextField()

    def __str__(self):
        return f"{self.received_at} - {self.topic}"

8.mqtttest/mqttapp/admin.py

1
2
3
4
5
6
7
8
9
from django.contrib import admin
from .models import MQTTMessage

@admin.register(MQTTMessage)
class MQTTMessageAdmin(admin.ModelAdmin):
    list_display = ('received_at', 'topic', 'payload')  # 可自訂顯示欄位
    list_filter = ('topic',)
    search_fields = ('topic', 'payload')
    ordering = ('-received_at',)

9.mqtttest/mqttapp/views.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from django.shortcuts import render

# Create your views here.
import json
from django.http import JsonResponse
from mqttapp.models import MQTTMessage
from django.views.decorators.csrf import csrf_exempt
import paho.mqtt.client as mqtt

def home(request):
	return render(request, 'index.html')

@csrf_exempt
def publish_message(request):
    if request.method == 'POST':
        try:
            data = json.loads(request.body)
            topic = data.get('topic', 'django/mqtt')
            msg = data.get('msg', 'test')

            # 即時建立連線並發送
            client = mqtt.Client()
            client.connect('broker.MQTTGO.io', 1883, 60)
            rc, mid = client.publish(topic, msg)
            client.disconnect()

            return JsonResponse({'code': rc})
        except Exception as e:
            return JsonResponse({'error': str(e)}, status=400)
    return JsonResponse({'error': 'Only POST allowed'}, status=405)

def mqtt_messages_json(request):
    messages = MQTTMessage.objects.order_by('-received_at')[:20]
    data = [
        {
            'topic': m.topic,
            'payload': m.payload,
            'received_at': m.received_at.strftime('%Y-%m-%d %H:%M:%S')
        }
        for m in messages
    ]
    return JsonResponse(data, safe=False)

10.在mqtttest下建立templates資料夾,並新增mqtttest/templates/index.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
	<head>
		<title>MQTT 測試</title>
		<script>
			function loadMessages() {
				fetch('/api/messages/')
					.then(response => response.json())
					.then(data => {
						const tbody = document.getElementById('messages');
						tbody.innerHTML = '';
						data.forEach(item => {
							const row = `<tr>
								<td>${item.received_at}</td>
								<td>${item.topic}</td>
								<td>${item.payload}</td>
							</tr>`;
							tbody.innerHTML += row;
						});
					});
				}
			function publishMessage() {
				const topic = document.getElementById('topic').value;
				const msg = document.getElementById('msg').value;

				fetch('/publish/', {
					method: 'POST',
					headers: { 'Content-Type': 'application/json' },
					body: JSON.stringify({ topic, msg })
				})
				.then(response => response.json())
				.then(data => {
					alert('已送出 MQTT 訊息!');
				})
				.catch(error => {
					alert('錯誤:' + error);
				});
			}
			setInterval(loadMessages, 3000);
			window.onload = loadMessages;
		</script>
	</head>
	<body>
		<h1>MQTT 測試</h1>
		<h2><a href="https://broker.mqttgo.io/">使用MQTT GO伺服器</a></h2>
		<h2>發送 MQTT 訊息</h2>
		<label>Topic: <input id="topic" value="django/mqtt"></label><br>
		<label>訊息: <input id="msg" value="Hello MQTT!"></label><br>
		<button onclick="publishMessage()">送出</button>
		<h2>最新接收訊息</h2>
		<table border="1">
			<thead>
				<tr><th>時間</th><th>主題</th><th>訊息</th></tr>
			</thead>
			<tbody id="messages"></tbody>
		</table>
	</body>
</html>

12.在mqtttest根目錄下建立mqtt_listener.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import django
import paho.mqtt.client as mqtt

# 初始化 Django 環境
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mqtttest.settings")
django.setup()

from mqttapp.models import MQTTMessage
from django.conf import settings

def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to MQTT broker.")
        client.subscribe("django/mqtt")
    else:
        print("Connection failed with code", rc)

def on_message(client, userdata, msg):
    payload = msg.payload.decode('utf-8')
    print(f"Received message on topic: {msg.topic}, payload: {payload}")
    MQTTMessage.objects.create(topic=msg.topic, payload=payload)

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.username_pw_set(settings.MQTT_USER, settings.MQTT_PASSWORD)
client.connect(settings.MQTT_SERVER, settings.MQTT_PORT, settings.MQTT_KEEPALIVE)

client.loop_forever()

13.回到命令列,做資料庫同步,並建立超級使用者
python manage.py makemigrations
python manage.py migrate

14.執行網站
python manage.py runserver



15.再打啟另一個命令列
python mqtt_listener.py



16.啟動MQTT GO,連線並訂閱django/mqtt



17.打開瀏覽器進行測試,如最上圖

2025年5月30日 星期五

尚虎雲產銷平台助雲林發展農(漁)藝產業

國立虎尾科技大學永續發展暨社會責任處

113學年度第二學期社會責任實踐教育(四)-產銷平台與智慧生活課程教學成果



教學目標:

  • 課程大綱: 本課程以問題導向學習法,結合生成式AI、Python程式設計,帶領學生解決農村農業生產監控與行銷相關問題,並利用Django開發農產品產銷平台。透過數據分析掌握農作物產銷狀況,學生將學習如何應用政府開放數據來分析台灣各地的風土經濟,並以5W2H工具發掘在地問題。解方設計部分,將教授服務設計與食物設計理念,幫助學生創造解決方案。實作階段則涵蓋如何運用Python進行產銷資訊服務的開發。最終,學生將學會設計永續經營的商業模式,培養社會責任實踐精神與創業家思維。
  • SDG 11 永續城鄉的課程目標:本課程針對SDG 11的課程目標是培養學生在農村和農業領域的永續發展能力,透過數據分析和AI技術協助學生了解不同鄉鎮的風土經濟問題,並設計智慧農業解決方案。學生將學習如何運用科技改善農村的生產效率,提升農產品產銷平台的運作,促進鄉村經濟活化,並同時保護自然環境,達成城鄉永續發展的目標。
  • SDG 12 責任消費與生產的課程目標:針對SDG 12的課程目標是教導學生負責任的消費與生產模式,特別是在農業與食品生產鏈中的應用。學生將學習如何利用Python和生成式AI進行數據分析,優化農產品的生產與供應鏈管理,並設計符合環保和永續經營的商業模式。課程還將引導學生考量資源使用與廢棄物管理,提倡低碳、環保的消費與生產習慣,促進資源的有效運用與循環經濟。

場域學習:
  • 114年3月21日生機廚房-慢食。花生。設計所





  • 114年5月10日-成龍濕地和箔子竂漁港




業師教學:
  • 114年4月18日由聯合國永續發展談飲食與健康/南開科技大學餐飲管理系紀璟叡助理教授


  • 114年5月9日使用樹莓派+MCU構建智慧養殖學習平台/致用高中賴銀泉教師


  • 114年5月16日蜜之園有機農場創業分享/蜜之園有機農場場長蔡進煌


  • 114年5月23日Good家博士的淨零挑戰以及來自偉大航道的海灘料理/國立自然科學博物館廖仁滄服務員


成果影片:

開源程式碼:

基礎教學:

進階教學

專題實作:
應用範例:

評量工具:
商業模式圖:





尚虎雲產銷平台-銷售端整合商業模式圖

 


參考文章:尚虎雲產銷平台-銷售端整合市場行情
圖示下載網站:flaticon

1. Sales-side/apps/templates/home/Front page.html 程式修改

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
{% extends "layouts/base.html" %}
{% load static %}
{% comment %} 這個是網頁的title {% endcomment %}
{% block title %}
  {% if web_inf.title %}
    {{ web_inf.title }}
  {% else %}
    尚虎雲
  {% endif %}
{% endblock title %}

{% comment %} 在這裡加入css {% endcomment %}
{% block stylesheets %}
<link href="{{ ASSETS_ROOT }}/css/Front page.css" rel="stylesheet" media="all" autostart="true">
<style>
  .active { /* 示例樣式 */
      color: red;
  }
  .slide {
      display: inline-block;
      width: 100%;
  }
  .carousel-container {
      width: 100%;
      overflow: hidden;
  }
  .carousel-inner {
      display: flex;
      transition: margin-left 0.5s ease;
  }
  table, th, td {
  border: 1px solid white;
  border-collapse: collapse;
}
</style>
{% endblock stylesheets %}

{% block container %}
<!--首頁-->
<div class="bg1">
  <div class="nav">
    <a href="#" class="logo">
      <img src="{% if web_inf.logo %}{{ web_inf.logo.url }}{% else %}{{ ASSETS_ROOT }}/images/favicon.png{% endif %}">
    </a>
    <div class="nav-text">
      <a href="#home">主頁</a>
      <a href="#trading">交易行情</a>
      <a href="#about">關於我們</a>
      <a href="#menu">賣家</a>
      <a href="#business">商業模式圖</a>
      <a href="#contact">聯絡我們</a>
    </div>
  </div>
</div>
<!--首頁-->

<!--圖片輪播-->
<section class="home" id="home">
  <div class="slider">
    <!-- list Items -->
    <div class="list">
      {% for carousel in carousels %}
        {% if forloop.first %}
          <div class="item active">
        {% else %}
          <div class="item">
        {% endif %}
        <img src="{{ carousel.image.url }}">
            <div class="content" style="color: {{ carousel.color }}">
              {% if carousel.header %}
                <p>
                  {{ carousel.header }}
                </p>
              {% endif %}
              {% if carousel.title %}
                <h2>
                  {{ carousel.title }}
                </h2>
              {% endif %}

              {% if carousel.content %}
                <p>
                  {{ carousel.content }}
                </p>
              {% endif %}
            </div>
          </div>
      {% endfor %}
    </div>

    <!-- button arrows -->
    <div class="arrows">
        <button id="prev"><</button>
        <button id="next">></button>
    </div>

    <!-- thumbnail -->
    <div class="thumbnail">
      {% for carousel in carousels %}
        {% if forloop.first %}
          <div class="item active">
        {% else %}
          <div class="item">
        {% endif %}
        <img src="{{ carousel.image.url }}">
          {% if carousel.title %}
          <div class="title" style="color: {{ carousel.color }}">
              {{ carousel.title }}
          </div>
          {% endif %}
        </div>
      {% endfor %}
    </div>
  </div>
</section>
<!--圖片輪播-->
<!--最新行情-->
<section class="trading" id="trading">
  <div class="row" style="border:1px #ccc solid;padding:5px;margin-top:15px;color:white";>
      <center>
{% for row in rows %}
{% if forloop.first %}
<table>
	<caption><h2>落花生市場交易情形</h2></caption>
	<tr>
		<th>交易日期</th>
		<th>作物代號</th>
		<th>作物名稱</th>
		<th>市場代碼</th>
		<th>市場名稱</th>
		<th>上價</th>
		<th>中價</th>
		<th>下價</th>
		<th>平均價</th>
		<th>交易量</th>
	</tr>
{% endif %}
	<tr>
		<td><center>{{ row.交易日期 }}</center></td>
		<td><center>{{ row.作物代號 }}</center></td>
		<td><center>{{ row.作物名稱 }}</center></td>
		<td><center>{{ row.市場代號 }}</center></td>
		<td><center>{{ row.市場名稱 }}</center></td>
		<td><center>{{ row.上價 }}</center></td>
		<td><center>{{ row.中價 }}</center></td>
		<td><center>{{ row.下價 }}</center></td>
		<td><center>{{ row.平均價 }}</center></td>
		<td><center>{{ row.交易量 }}</center></td>
	</tr>
{% if forloop.last %}
</table>
{% endif %}
{% endfor %}
</center>
</row>
</section>
<!--最新行情-->
<!--介紹-->
{% if about %}
  <section class="about" id="about">
    <h1 class="heading"> <span>about</span> us </h1>
    <div class="row">
      <div class="image">
          <img src="{{ about.image.url }}" alt="">
      </div>
      <div class="content2">
        <h3>{{ about.title }}</h3>
        {% if about.simple_introduce %}
          <p>{{ about.simple_introduce }}</p>
        {% endif %}
        {% if about.introduce %}
          <p>{{ about.introduce }}</p>
        {% endif %}
        {% if about.link %}
        <a href="{{ about.link }}" class="btn">
          關於更多
          <span></span><span></span><span></span>
        </a>
        {% endif %}
      </div>
    </div>
  </section>
{% endif %}
<!--介紹-->

<!--產品-->
<section class="menu" id="menu">
  <h1 class="heading">our <span>partner vendors</span> </h1>
  <div class="bix-container">
    {% for parent in parents %}
      <div class="box">
        <img src="{{ parent.seller_image.url }}" alt="">
        <h3>{{ parent.seller_name }}</h3>
        <a href="{% url 'seller_detail' parent.id %}" class="btn">
          關於更多
          <span></span><span></span><span></span>
        </a>
      </div>
    {% endfor %}
  </div>
</section>
<!--產品-->
<!--商業模式模式圖-->
<section class="business" id="business">
<div class="row" style="border:0px #ccc solid;padding:5px;margin-top:15px;color:white">
<h1 class="heading">商業模式模式圖</h1>
<table style="width:100%">
  <tr>
    <td rowspan="2">關係合作夥伴</td>
    <td>關鍵活動</td>
    <td rowspan="2" colspan="2">價值主張</td>
    <td>顧客關係</td>
    <td rowspan="2">
        <img src="{% static 'assets/images/user.png' %}" width="5%">
        <h2>目標客層</h2>
        小農<br>
        店家
    </td>
  </tr>
  <tr>
    <td>關鍵資源</td>
    <td>通路</td>
  </tr>
  <tr>
    <td colspan="3">成本結構</td>
    <td colspan="3">收益流</td>
  </tr>
</table>
<div>
</section>
<!--商業模式模式圖-->
<!--聯絡-->
<section class="contact" id="contact">
  <h1 class="heading"><span>contact </span>us</h1>
  <div class="row">
    {% if mapIframe %}
      {{ mapIframe.map_iframe | safe }}
    {% endif %}
    <form method="post">
      {% csrf_token %}
      <h3>聯 絡 我 們</h3>
      <div class="inputBox">
        <span class="fa-solid fa-user"></span>
        {{ form.name }}
      </div>
      <div class="inputBox">
        <span class="fa-solid fa-envelope"></span>
        {{ form.email }}
      </div>
      <div class="inputBox">
        <span class="fa-solid fa-phone"></span>
        {{ form.phone }}
      </div>
      <div class="inputBox">
        <span class="fa-solid fa-question"></span>
        {{ form.question }}
      </div>
      <button type="submit" class="btn">
        提 交
        <span></span><span></span><span></span>
      </button>
    </form>
  </div>
</section>
<!--聯絡-->

<!--底部-->
<section class="footer">
  <div class="share">
    {% if profiles.facebook_link %}
      <a href="{{ profiles.facebook_link }}" class="fa-brands fa-facebook"></a>
    {% endif %}
    {% if profiles.instagram_link %}
      <a href="{{ profiles.instagram_link }}" class="fa-brands fa-instagram"></a>
    {% endif %}
    {% if profiles.youtube_link %}
      <a href="{{ profiles.youtube_link }}" class="fa-brands fa-youtube"></a>
    {% endif %}
  </div>
  <div class="credit">© <script>document.write(new Date().getFullYear());</script> Copyrights 尚虎雲產銷平台</br><script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with Wen Qi</div>
  {% if profiles.phone_number %}
    <div class="credit">連絡電話: {{ profiles.phone_number }}</div>
  {% endif %}
  {% if profiles.contact_address %}
    <div class="credit">連絡地址: {{ profiles.contact_address }}</div>
  {% endif %}
  {% if profiles.real_name %}
    <div class="credit">聯絡人: {{ profiles.real_name }}</div>
  {% endif %}
  {% if profiles.description %}
    <div class="credit">個人簡介: {{ profiles.description }}</div>
  {% endif %}
</section>
<!--底部-->
{% endblock container %}

{% block javascripts %}
<script>
  document.addEventListener("DOMContentLoaded", function() {
    {% if send_success %}
      alert("表單已提交");
    {% endif %}
  });

  function scroll() {
    var top = $(".bg1").offset().top; // 獲取導航欄變色的位置距頂部的高度
    var scrollTop = $(window).scrollTop(); // 獲取當前窗口距頂部的高度
    if (scrollTop <= top) {
      $('.nav').css('background-color', 'transparent');
    } else {
      $('.nav').css('background-color', '#111111');
    }
  }

  $(window).on('scroll', function() {
    scroll();
  });
</script>
<script src="{{ ASSETS_ROOT }}/js/Front page.js"></script>
{% endblock javascripts %}

2. 上傳圖示