Web开发及人机交互导论 大作业(二)

简介: Web开发及人机交互导论 大作业(二)

2. Functional Description


①Find bikes available nearby

In this function, we introduce the API of AutoNavi map to realize the positioning and searching of available bikes around users. After the project enters the back-end development, the positioning device on each bicycle can be used to refresh the positioning on the map in real time. This will greatly facilitate users to find their most convenient bikes.


9777246d79624911ab789ec26ba3696b.png


Source code:

During the programming implementation, the map container is built and the corresponding and scaling levels are set. Then create the corresponding marker point.


<div id="container"></div>  
<script>  
    //初始化地图插件  
    window.onload = function () {  
        var map = new AMap.Map("container", {  
            zoom: 15, //设置地图显示的缩放级别  
            center: [113.93318, 22.53701] //设置地图中心点坐标  
        });  
        // 创建一个 Marker 实例:(标记点)  
        var marker1 = new AMap.Marker({  
            position: new AMap.LngLat(113.98338, 22.53711),  
            title: "bicycle1 available"  
        });  
        var marker2 = new AMap.Marker({  
            position: new AMap.LngLat(113.91358, 22.53761),  
            title: "bicycle2 available"  
        });  
        var marker3 = new AMap.Marker({  
            position: new AMap.LngLat(113.93408, 22.59741),  
            title: "bicycle3 available"  
        });  
        var marker4 = new AMap.Marker({  
            position: new AMap.LngLat(113.98310, 22.54709),  
            title: "bicycle4 available"  
        });  
        var marker5 = new AMap.Marker({  
            position: new AMap.LngLat(113.93314, 22.53704),  
            title: "bicycle5 available"  
        });  
        // 将创建的点标记添加到已有的地图实例:  
        map.add(marker1);  
        map.add(marker2);  
        map.add(marker3);  
        map.add(marker4);  
        map.add(marker5);  
    }  
</script> 


②Price calculating and path planning

0e57e54c740c4743a90e4c6b0a3de1c2.png

After the departure and destination points and corresponding prices are set, the prices are automatically calculated and the route is planned.

d5c8022a208242aab8c82e425d35b285.png

Source code:

To achieve this function, we first design the input box and set the initial value of the corresponding element. Then link into the AutoNavi map API, build the map container, and put the map and route plan into the container. Finally, the calculation is done through JavaScript and the container is set to the anchor point. When the button is clicked, the route is calculated and jumps to the anchor point, so that the user can see the price and route planning directly. In order to make the jump of the anchor not abrupt, smooth sliding is achieved through JavaScript, which makes the website more beautiful.

<div id="search">  
    <div id="searchText">Departure: </div><input type="text" name="" id="startNode" /><br /><br />  
    <div id="searchText">Destination: </div><input type="text" name="" id="endNode" /><br /><br />  
    <div id="searchText">Basic Distance: </div><input type="text" name="" id="send" value="2" /><br /><br />  
    <div id="searchText">Basic Price: </div><input type="text" name="" id="startPrice" value="0.1" /><br /><br />  
    <div id="searchText">Price Per Kilometre: </div><input type="text" name="" id="price" value="0.2" /><br /><br />  
    <a><button id="btn">Start to Calculate</button></a>  
</div>  
<div id="window-container">  
    <table id="window" align="center">  
        <tr>  
            <td>  
                <div id="container" align="center"></div>  
            </td>  
            <td>  
                <div id="panel"></div>  
            </td>  
        </tr>  
    </table>  
</div>  
<div id="result" align="center">  
    <br />  
    <b>Total Distance: </b><span id="road">xx km</span>        
          <b>Total Price: </b><span id="endPrice">xx ¥</span><br />  
</div>  
<div id="navigation">  
    <script>  
        var send = document.querySelector('#send')  
        var startPrice = document.querySelector('#startPrice')  
        var price = document.querySelector('#price')  
        var road = document.querySelector('#road')  
        var endPrice = document.querySelector('#endPrice')  
        //初始化地图  
        var map = new AMap.Map('container', {  
            center: [113.943487, 22.538249],  
            lang: "en"  
        });  
        new AMap.Autocomplete({  
            input: 'startNode'  
        });  
        new AMap.Autocomplete({  
            input: 'endNode'  
        });  
        btn.onclick = function () {  
            if (send.value && startPrice.value && price.value) {  
                //建立地图  
                new AMap.Riding({  
                    map: map,  
                    panel: 'panel'  
                }).search([  
                    { keyword: startNode.value, city: '深圳' },  
                    { keyword: endNode.value, city: '深圳' }  
                ], function (status, data) {  
                    var distance = data.routes[0].distance  
                    console.log(data);  
                    console.log(data.routes[0].distance)  
                    //通过距离计算价格  
                    if (distance > send.value * 1000) {  
                        var newPrice = parseInt(startPrice.value) + Math.ceil(distance / 1000 - send.value) * price.value  
                        endPrice.innerText = newPrice + ' ¥'  
                    } else {  
                        endPrice.innerText = startPrice.value + ' ¥'  
                    }  
                    road.innerText = (distance / 1000).toFixed(2) + ' km'  
                })  
                //锚点平滑滑动  
                let anchorElement = document.getElementById('window-container');  
                if (anchorElement) {  
                    anchorElement.scrollIntoView({ behavior: 'smooth' });  
                }  
            } else {  
                alert('Please complete the information')  
            }  
        };  
    </script>  
</div>  


③Message board

In order to enable users to contact with us, in addition to the QQ for contact, also can give us a message to get in touch with us.

In this project, we created a form that allows users to leave messages by filling in the form. We also use JavaScript to check what is entered if the data is improperly formatted or forgotten. We will give you eye-catching hints.

It is worth noticing that in this project we also introduced a Layui framework for layout purposes.


a69524f9c4d047b2bb263503dd02438a.png


Source code:


4ed0c3b188ea47468125978ddb687087.png


a0b89b955dbf44738b56a5c6071cff72.png

Website Layout,and Website Presentational, Enhancement

1. CSS design document and functional description


①Top:

Top navigation is in the vast majority of pages, playing the role of navigation which makes it convenient for users to choose information they want.

146dcb8932114953b9732b736dd39456.png


104dba9d5f2f4c55a2450537c6ebd8b0.png


②Footer:

The bottom footer is also present on most pages and acts as a copyright notice.


02eb7d13e9144b63b337af8c541fd2b7.png

1ca724138eaa43e2a3fa5d8e2880bff5.png

95d821477ec444d39e87c1d9864d48ab.png


③Index:


a9c69f0c13ef42d4a2c5bde9a2e6f64f.png

fd7eeefe532143f6bd79d7f6673e095e.png


③About Us&employees&employmers:

In the four pages under this section, the CSS styling is basically the same, with only a few differences. Only one is shown here.


1efdf4657e524ba0bf80923fc2818e5f.png


④Administration, Legislation and Insurance Information.

Due to the uncertainty of the content of relevant laws, ‘Sample document.’ is only used here instead of the actual content.


b7094801bc5b428fb1b34f2cd457b76d.png


⑤Price Calculator:

Most of CSS styles of this page are similar to the rest of the page, so we don’t show them, just the different parts.


ebc822072efe41a09b213ffdb321093c.png

30c937a560a54d03967ba50bdcefab3c.png


⑥Contact Us:

Most of CSS styles of this page are similar to the rest of the page, so we don’t show them, just the different parts.

This page is set with layui which makes the website more beautiful.


2c1a4ab796fd4a44830ff7eda6822775.png


On this page, we use JavaScript to validate the input:


2ab3bbe5f8aa4bb9875dc16f67bcc16c.png


2. User manual for the functions


①For employers:

For employers, you are welcomed to visit this website.

This website provides you with a wealth of information about Shared bikes. You can have a deeper understanding of our services in this website. You can also subscribe to our bike-sharing service on this website for your employees.

The first thing you see is the home page, no matter which page you are in you can click the left art character or the navigation ‘HOME’ to jump to the homepage.


6af9896b6989439889f49e1de1c69ebc.png


You can click “About us” to view some information about us. Here are your reasons to share, our advantages, our service and our contact.

24d3f41ecd084ffbba25b01b065b70a0.png

You can also select the corresponding employers section, get more information to communicate with our customer service to subscribe, and view administration, legislation and insurance Information.

175491dbdcc14458bc41bf2fa8deee66.png

Whenever a problem occurs, you are welcomed to send us a message in ‘Contact Us’ page. Our staff will reply you in 24 hours.


cbb4c0206543408dacea808203a30fff.png


②For employees and other visitors:

For employees, you are welcomed to visit this website.

This website provides you with a wealth of information about Shared bikes. You can have a deeper understanding of our services in this website. You can also enjoy the subscription of our bike-sharing service on this website in your group.

The first thing you see is the home page, no matter which page you are in you can click the left art character or the navigation ‘HOME’ to jump to the homepage.

27211c4f246a41edb6bee1f73f60d68b.png

You can click “About us” to view some information about us. Here are your reasons to share, our advantages, our service and our contact.

6985323fb2ae435b8046d52a131a6a62.png

You can also select the corresponding employees section. Here, you can use our interactive map to find the nearest available Shared bikes quickly and easily.

31fbeeabbba94b9a884aafd632ca95be.png

No matter which page you are in, you can click the right orange button which links some social media platform to share this website to your friends.


408a97c75ece4dc69746227ac21679c1.png


We also provide you with a price calculator. Here you can calculate your costs and plan your path. We will provide you with convenient and safe cycling routes.

06bbf10bba714f81af5675534dbda923.png

Whenever a problem occurs, you are welcomed to send us a message in ‘Contact Us’ page. Our staff will reply you in 24 hours.


6b534d66d21e4247b11128c854c4457d.png


Project Results


4df182619c904384bc990d6e311d76a8.png

Project Summary


Through the design of the bike-sharing website, I learned to make proper layout of the website and proper use of CSS and JavaScript. In addition, I also learned the process of doing a project, from the conception to the implementation of the code. Many difficulties were encountered, such as CSS typesetting errors, JavaScript did not run as desired results. At the beginning, what color to choose for the layout always bothered me. Later, when I saw the orange books on the table, I was inspired and chose orange as the overall style. A lot of difficulties have also occurred with JavaScript in projects. Because I’m not familiar with JavaScript, I often get errors or don’t get the results I want. Finally, after a little bit of testing, fortunately all have been solved. I also learned to read developer documentation for other platforms and use their APIs to achieve the functionality I wanted. This lays the foundation for the future study.


I benefited a lot from the study of front-end design in one semester and the design of this project in one month. The Front-end learning, makes me learn to use HTML to write beautiful pages, learn to use CSS to design the page style, learned to use JavaScript language programming to improve interaction. What’s more learned to reference the appropriate framework to improve the appearance of page style and interaction.


In addition, it also cultivated my character of never giving up. In the design of CSS styles, I will often come across styles that are not what I want them to be. This is where the changes need to be made. Analyzing the causes and making modifications becomes particularly important. Little by little, patient modification and debugging are essential to getting the style right. Every time I tried to correct the mistakes; I had a feeling that some of my knowledge was not solid.


In the future study, I will keep this course in mind, and never forget what this project brings me.

相关文章
|
8月前
|
算法 Java Go
【GoGin】(1)上手Go Gin 基于Go语言开发的Web框架,本文介绍了各种路由的配置信息;包含各场景下请求参数的基本传入接收
gin 框架中采用的路优酷是基于httprouter做的是一个高性能的 HTTP 请求路由器,适用于 Go 语言。它的设计目标是提供高效的路由匹配和低内存占用,特别适合需要高性能和简单路由的应用场景。
617 4
|
12月前
|
缓存 JavaScript 前端开发
鸿蒙5开发宝藏案例分享---Web开发优化案例分享
本文深入解读鸿蒙官方文档中的 `ArkWeb` 性能优化技巧,从预启动进程到预渲染,涵盖预下载、预连接、预取POST等八大优化策略。通过代码示例详解如何提升Web页面加载速度,助你打造流畅的HarmonyOS应用体验。内容实用,按需选用,让H5页面快到飞起!
|
12月前
|
JavaScript 前端开发 API
鸿蒙5开发宝藏案例分享---Web加载时延优化解析
本文深入解析了鸿蒙开发中Web加载完成时延的优化技巧,结合官方案例与实际代码,助你提升性能。核心内容包括:使用DevEco Profiler和DevTools定位瓶颈、四大优化方向(资源合并、接口预取、图片懒加载、任务拆解)及高频手段总结。同时提供性能优化黄金准则,如首屏资源控制在300KB内、关键接口响应≤200ms等,帮助开发者实现丝般流畅体验。
|
前端开发 JavaScript Shell
鸿蒙5开发宝藏案例分享---Web页面内点击响应时延分析
本文为鸿蒙开发者整理了Web性能优化的实战案例解析,结合官方文档深度扩展。内容涵盖点击响应时延核心指标(≤100ms)、性能分析工具链(如DevTools时间线、ArkUI Trace抓取)以及高频优化场景,包括递归函数优化、网络请求阻塞解决方案和setTimeout滥用问题等。同时提供进阶技巧,如首帧加速、透明动画陷阱规避及Web组件初始化加速,并通过优化前后Trace对比展示成果。最后总结了快速定位问题的方法与开发建议,助力开发者提升Web应用性能。
|
JSON 开发框架 自然语言处理
【HarmonyOS Next之旅】基于ArkTS开发(三) -> 兼容JS的类Web开发(三)
本文主要介绍了应用开发中的三大核心内容:生命周期管理、资源限定与访问以及多语言支持。在生命周期部分,详细说明了应用和页面的生命周期函数及其触发时机,帮助开发者更好地掌控应用状态变化。资源限定与访问章节,则聚焦于资源限定词的定义、命名规则及匹配逻辑,并阐述了如何通过 `$r` 引用 JS 模块内的资源。最后,多语言支持部分讲解了如何通过 JSON 文件定义多语言资源,使用 `$t` 和 `$tc` 方法实现简单格式化与单复数格式化,为全球化应用提供便利。
372 104
|
JavaScript 前端开发 API
【HarmonyOS Next之旅】基于ArkTS开发(三) -> 兼容JS的类Web开发(二)
本文介绍了HarmonyOS应用开发中的HML、CSS和JS语法。HML作为标记语言,支持数据绑定、事件处理、列表渲染等功能;CSS用于样式定义,涵盖尺寸单位、样式导入、选择器及伪类等特性;JS实现业务逻辑,包括ES6语法支持、对象属性、数据方法及事件处理。通过具体代码示例,详细解析了页面构建与交互的实现方式,为开发者提供全面的技术指导。
421 104
|
开发框架 编解码 JavaScript
【HarmonyOS Next之旅】基于ArkTS开发(三) -> 兼容JS的类Web开发(一)
该文档详细介绍了一个兼容JS的类Web开发范式的方舟开发框架,涵盖概述、文件组织、js标签配置及app.js等内容。框架采用HML、CSS、JavaScript三段式开发方式,支持单向数据绑定,适合中小型应用开发。文件组织部分说明了目录结构、访问规则和媒体文件格式;js标签配置包括实例名称、页面路由和窗口样式信息;app.js则描述了应用生命周期与对象管理。整体内容旨在帮助开发者快速构建基于方舟框架的应用程序。
427 102
|
开发框架 搜索推荐 数据可视化
Django框架适合开发哪种类型的Web应用程序?
Django 框架凭借其强大的功能、稳定性和可扩展性,几乎可以适应各种类型的 Web 应用程序开发需求。无论是简单的网站还是复杂的企业级系统,Django 都能提供可靠的支持,帮助开发者快速构建高质量的应用。同时,其活跃的社区和丰富的资源也为开发者在项目实施过程中提供了有力的保障。
1109 157
|
关系型数据库 MySQL 数据库
基于Flink CDC 开发,支持Web-UI的实时KingBase 连接器,三大模式无缝切换,效率翻倍!
TIS 是一款基于Web-UI的开源大数据集成工具,通过与人大金仓Kingbase的深度整合,提供高效、灵活的实时数据集成方案。它支持增量数据监听和实时写入,兼容MySQL、PostgreSQL和Oracle模式,无需编写复杂脚本,操作简单直观,特别适合非专业开发人员使用。TIS率先实现了Kingbase CDC连接器的整合,成为业界首个开箱即用的Kingbase CDC数据同步解决方案,助力企业数字化转型。
3135 5
基于Flink CDC 开发,支持Web-UI的实时KingBase 连接器,三大模式无缝切换,效率翻倍!