hui框架开发APP

2024-01-12 07:40
文章标签 app 开发 框架 hui

本文主要是介绍hui框架开发APP,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

hui是类似于mui框架的app构建框架,通过一段时间学习,写了个app例子

GitHub地址   等待中..........

数据来源--------聚合数据

hui框架地址:http://www.hcoder.net/hui/docs

 

先看下效果吧

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

功能就这么简单

 

 

开始吧

入口界面  index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>HUI</title>
<link rel="stylesheet" type="text/css" href="css/hui.css" />
<style type="text/css">hui-start-banner{width:100%; height:100%; position:fixed; z-index:9998; left:0px; top:0px; background:#FFFFFF; display:none;}
#hui-start-banner-close{width:50px; height:50px; position:fixed; z-index:9999; top:50px; right:20px; background:#F5F6F7; display:none; text-align:center; border-radius:50px; line-height:50px; font-size:14px; color:#666;}
.hui-start-banner .hui-swipe-indicator{width:96%; position:absolute; z-index:3; left:2%; bottom:20px; display:none;}
#hui-footer a{
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-user-select: none;
-moz-user-focus: none;
-moz-user-select: none;
}
</style>
</head>
<body>	
<div class="hui-wrap"></div>
<div id="hui-footer"><a href="javascript:changeSubView(0);" id="nav-home" class="hui-footer-active"><div class="hui-footer-icons hui-icons-home"></div><div class="hui-footer-text">首页</div></a><a href="javascript:changeSubView(1);" id="nav-news"><div class="hui-footer-icons hui-icons-news"></div><div class="hui-footer-text">新闻</div></a><a href="javascript:changeSubView(2);" id="nav-forum"><div class="hui-footer-icons hui-icons-forum"></div><div class="hui-footer-text">社区</div></a><a href="javascript:changeSubView(3);" id="nav-my"><div class="hui-footer-icons hui-icons-my"></div><div class="hui-footer-text">我的</div></a>
</div>
<script src="js/hui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">setTimeout(function(){plus.navigator.closeSplashscreen();},1500)// 创建子窗口
var subpages =  new Array(new Array('html/sub1.html', {top:'0px', bottom:"55px", left:"0"}),new Array('html/sub2.html', {top:'0px', bottom:"55px", left:"100%"}),new Array('html/sub3.html', {top:'0px', bottom:"55px", left:"200%"}),new Array('html/cutPicture.html', {top:'0px', bottom:"55px", left:"300%"})
);
hui.plusReady(function(){hui.subpages(subpages);
});//点击底部按钮切换窗口
function changeSubView(index){for(var i = 0; i< subpages.length; i++){var subpage = hui.getView(subpages[i][0]);subpage.setStyle({'top':0,'left' : ((index - i) * 100 )+'%'});}//选项状态激活hui('#hui-footer a').removeClass('hui-footer-active');hui('#hui-footer a').eq(index).addClass('hui-footer-active');
}var height = document.documentElement.clientHeight || document.body.clientHeight;
window.onresize = function() {var heightView = document.documentElement.clientHeight || document.body.clientHeight;if(heightView < height) {plus.webview.currentWebview().setStyle({height: height});}
}
</script>
</body>
</html>

 sub1.html  新闻列表页

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>HUI</title>
<link rel="stylesheet" type="text/css" href="../css/hui.css" />
</head>
<body>
<header class="hui-header"><h1>腾讯新闻</h1>
</header>
<div class="hui-wrap"><div class="hui-swipe" id="swipe2"><div class="hui-swipe-items"></div></div>
</div>
<div class="hui-wrap"><div class="hui-center-title"><h1>新闻列表</h1></div><div style="padding:10px;"><div id="refreshContainer" class="hui-refresh"><div class="hui-refresh-icon"></div><div class="hui-refresh-content hui-list" id="list"><ul id="arcicle"><!--描述:内容集合--></ul></div></div></div>
</div><script src="../js/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/hui-swipe.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/hui-refresh-load-more.js"></script>
<script src="../js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">hui.Back = null;
hui.plusReady(function(){//判断是否支持沉浸式var isImmersedStatusbar = plus.navigator.isImmersedStatusbar();//获取系统状态栏高度var StatusbarHeight = plus.navigator.getStatusbarHeight();		   console.log(StatusbarHeight);hui('.hui-header').css({'paddingTop':StatusbarHeight + 'px'});hui('#hui-back').css({top:StatusbarHeight+'px'});var indexView = plus.webview.getLaunchWebview();var nextPage = {pageId : 'html/sub2.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-news").addClass("hui-footer-active")');}};var prevPage = null;hui.drag(prevPage, nextPage);
});
hui.get('http://hoa.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=lunbo',function(res){var arr  = res.split('--hcSplitor--');for(var i = 0; i < arr.length; i++){var div = document.createElement('div')div.setAttribute('class', 'hui-swipe-item');div.innerHTML = arr[i];hui(div).appendTo('#swipe2 .hui-swipe-items');    }var swipe2 = new huiSwpie('#swipe2');swipe2.run();},function(){hui.toast('读取远程数据失败');}   
);	
</script>
<script>function showProductInfo(url,titles){hui.open("createShow.html",{},true,{url:url,titles:titles})}
hui.refresh('#refreshContainer', refresh);
hui.loadMore(getMore);
//加载更多
function getMore(){$.ajax({ url:'http://v.juhe.cn/toutiao/index?key=76db99a8de0bb25da0ea78e8747f4971&type=guoji', type:'GET', dataType:'json',  // 处理Ajax跨域问题success: function(res){ var data = JSON.stringify(res);data = JSON.parse(data);data = data.result.data;for(var i = 0; i < data.length; i++){var li = document.createElement('li');li.style.borderBottom="1px solid gray";li.style.height="auto";var pic1 =  data[i].thumbnail_pic_s02 ? '<img src='+data[i].thumbnail_pic_s02+'/>':" ";var pic2 =  data[i].thumbnail_pic_s03 ? '<img src='+data[i].thumbnail_pic_s03+'/>':" ";li.innerHTML ='<div class="hui-media-content" style="width:100%;height:auto">'+'<p style="width:95%;margin:1em auto;color:red"><a href="javascript:showProductInfo(\''+data[i].url+'\',\''+data[i].author_name+'\');">'+data[i].title +'</a></p>'+'<img src='+data[i].thumbnail_pic_s+'/>'+pic1+pic2+'<p>'+'<span>'+data[i].author_name+'</span>'+'<span style="float: right;">'+data[i].date+'</span>'+'</p>'+'</div>';hui(li).appendTo('#arcicle');}hui.endLoadMore();}})
}
function refresh(){if(hui.refreshNumber < 1){hui.loading('加载中...');}$.ajax({ url:'http://v.juhe.cn/toutiao/index?key=76db99a8de0bb25da0ea78e8747f4971&type=top', type:'GET', dataType:'json',  // 处理Ajax跨域问题success: function(res){ var data = JSON.stringify(res);data = JSON.parse(data);data = data.result.data;console.log(data)var html = '';for(var i = 0; i < data.length; i++){var pic1 =  data[i].thumbnail_pic_s02 ? '<img src='+data[i].thumbnail_pic_s02+'/>':" ";var pic2 =  data[i].thumbnail_pic_s03 ? '<img src='+data[i].thumbnail_pic_s03+'/>':" ";html += '<li style="border-bottom:1px solid gray;height:auto !important">'+'<div class="hui-media-content" style="width:100%;height:auto">'+'<p style="width:95%;margin:1em auto;color:red"><a href="javascript:showProductInfo(\''+data[i].url+'\',\''+data[i].author_name+'\');">'+data[i].title +'</a></p>'+'<img src='+data[i].thumbnail_pic_s+'/>'+pic1+pic2+'<p>'+'<span>'+data[i].author_name+'</span>'+'<span style="float: right;">'+data[i].date+'</span>'+'</p>'+'</div>'+'</li>';}hui('#arcicle').html(html);hui.endRefresh();//关闭loadinghui.loading('加载中...', true);},error:function(){hui.loading('加载中...', true);title="无法完成操作"message="由于你的支付宝账户还未绑定淘宝账户请登请登录www.taobao.com"hui('#arcicle').html('<div style="text-align: center;margin:50px auto">'+'<img src="../image/GIyMDJnuqmcqPLpHCSkj.svg">'+'<h2 style="text-align: center;line-height: 2rem;">无法获取数据</h2>'+'<p style="text-align: center;color:red;ine-height:2rem;">请检查网络是否正确</p>'+'</div>');hui.toast('连接服务器失败!');hui.endRefresh();}}); }
</script>
</body>
</html>

 

sub2.html   笑话总集

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><title>HUI</title>
<link rel="stylesheet" type="text/css" href="../css/hui.css" />
</head>
<body>
<header class="hui-header"><h1>笑话总集</h1> 
</header>
<div class="hui-wrap"> <div class="hui-wrap"><div id="refreshContainer" class="hui-refresh"><div class="hui-refresh-icon"></div><div class="hui-refresh-content hui-list" id="list"><ul id="arcicle" style="margin-top: 10px;"><!--描述:内容集合--></ul></div></div>
</div>
</div><!--播放笑话
-->
<div id="bdtts_div_id"><audio id="tts_autio_id" autoplay="autoplay"><source id="tts_source_id" src="http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=5&text=" type="audio/mpeg"><embed id="tts_embed_id" height="0" width="0" src=""></audio>
</div>
<script src="../js/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/hui-refresh-load-more.js"></script>
<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
hui.refresh('#refreshContainer', refresh);hui.loadMore(getMore);
//加载更多
function getMore(){$.ajax({ url:"https:\/\/v.juhe.cn\/joke\/content\/text.php?key=e0f404df1a1469811b3ce7239f0462d4&pagesize=10&page="+page, type:'GET', dataType:'JSONP',  // 处理Ajax跨域问题success: function(res){ var data = JSON.stringify(res);data = JSON.parse(data);data = data.result.data;for(var i = 0; i < data.length; i++){var li = document.createElement('li');li.style.borderBottom="1px solid gray";li.style.height="auto";li.innerHTML ='<div class="hui-media-content" style="width:100%;height:auto">'+'<p style="width:95%;margin:1em auto;color:red" onclick="songs(this.innerText)">'+data[i].content +'</p>'+'<p>'+'<span>'+data[i].unixtime+'</span>'+'<span style="float: right;">'+data[i].updatetime+'</span>'+'</p>'+'</div>';hui(li).appendTo('#arcicle');}hui.endLoadMore();page++;}})
}
function refresh(){if(hui.refreshNumber < 1){hui.loading('加载中...');}$.ajax({ url:"https:\/\/v.juhe.cn\/joke\/content\/text.php?key=e0f404df1a1469811b3ce7239f0462d4&page=1&pagesize=10", type:'GET', dataType:'JSONP',  // 处理Ajax跨域问题success: function(res){ var data = JSON.stringify(res);data = JSON.parse(data);data = data.result.data;var html = '';for(var i = 0; i < data.length; i++){html += '<li style="border-bottom:1px solid gray;height:auto !important">'+'<div class="hui-media-content" style="width:100%;height:auto">'+'<p style="width:95%;margin:1em auto;color:red" onclick="songs(this.innerText)">'+data[i].content +'</p>'+'<p>'+'<span>'+data[i].unixtime+'</span>'+'<span style="float: right;">'+data[i].updatetime+'</span>'+'</p>'+'</div>'+'</li>';}hui('#arcicle').html(html);hui.endRefresh();page=2;//关闭loadinghui.loading('加载中...', true);},error:function(){hui.loading('加载中...', true);hui('#arcicle').html('<div style="text-align: center;margin:50px auto">'+'<img src="../image/GIyMDJnuqmcqPLpHCSkj.svg">'+'<h2 style="text-align: center;line-height: 2rem;">无法获取数据</h2>'+'<p style="text-align: center;color:red;ine-height:2rem;">请检查网络是否正确</p>'+'</div>');;hui.toast('连接服务器失败!');hui.endRefresh();}}); }function songs(val){hui.confirm('您确认要播放笑话吗?', ['取消','确定'], function(){var ttsDiv = document.getElementById('bdtts_div_id');var ttsAudio = document.getElementById('tts_autio_id');ttsDiv.removeChild(ttsAudio);var au1 = '<audio id="tts_autio_id" autoplay="autoplay">';var sss = '<source id="tts_source_id" src="http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=6&text='+val+'" type="audio/mpeg">';var eee = '<embed id="tts_embed_id" height="0" width="0" src="">';var au2 = '</audio>';ttsDiv.innerHTML = au1 + sss + eee + au2;ttsAudio = document.getElementById('tts_autio_id');ttsAudio.play();},function(){console.log('取消后执行...');});
}
</script>
<script type="text/javascript">//禁用返回键
hui.Back = null;
hui.plusReady(function(){//判断是否支持沉浸式var isImmersedStatusbar = plus.navigator.isImmersedStatusbar();//获取系统状态栏高度var StatusbarHeight = plus.navigator.getStatusbarHeight();console.log(StatusbarHeight);hui('.hui-header').css({'paddingTop':StatusbarHeight + 'px'});hui('#hui-back').css({top:StatusbarHeight+'px'});var indexView = plus.webview.getLaunchWebview();var nextPage = {pageId : 'html/sub3.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-forum").addClass("hui-footer-active")');}};var prevPage = {pageId : 'html/sub1.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-home").addClass("hui-footer-active")');}};hui.drag(prevPage, nextPage);});
</script>
</body>
</html>

 

sub3.html  联系我们

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>HUI</title>
<link rel="stylesheet" type="text/css" href="../css/hui.css" />
</head>
<body>
<header class="hui-header"><h1 style="text-align: left;">反馈信息</h1><h1 style="text-align: right;" id="subMitConfig">提交反馈</h1>
</header>
<div class="hui-warp" style="margin-top:55px;"><textarea name="textareas" rows="20" id="textareas" style="margin:10px 5% 10px;width:80%;border-radius: 20px;padding-left:5%;padding-right:5%" placeholder="请留下您宝贵的建议,让我们一同进步吧~~"></textarea>
</div>
<div class="hui-warp" style="position: relative;"><h2 style="text-align: center;">十分真诚的希望留下您的印记</h2>
</div>
<script src="../js/hui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
hui.Back = null;
hui.plusReady(function(){//判断是否支持沉浸式var isImmersedStatusbar = plus.navigator.isImmersedStatusbar();//获取系统状态栏高度var StatusbarHeight = plus.navigator.getStatusbarHeight();		   console.log(StatusbarHeight);hui('.hui-header').css({'paddingTop':StatusbarHeight + 'px'});hui('#hui-back').css({top:StatusbarHeight+'px'});var indexView = plus.webview.getLaunchWebview();var nextPage = {pageId : 'html/cutPicture.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-my").addClass("hui-footer-active")');}};var prevPage = {pageId : 'html/sub2.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-news").addClass("hui-footer-active")');}};hui.drag(prevPage, nextPage);});hui("#subMitConfig").click(function(){hui.toast(hui("#textareas").val());if(hui("#textareas").val()==""){hui.toast("请留下您的意见,谢谢");}else{hui.toast("感谢您宝贵的意见,我们会尽快完善的,谢谢");hui("#textareas").val("");}	})</script>
</body>
</html>

cutPicture.html   个人中心

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="../css/hui.css" />
<style type="text/css">#hui-swaper{position: fixed;bottom:10%;}#hui-swaper h2{text-align: center;margin-top:2%;color: grey;}
</style>
</head>
<body>
<header class="hui-header"><h1>abuot us</h1>
</header>
<div class="hui-warp" style="margin:0 auto;margin-top: 150px;"><div style="margin:0 auto; width:120px"><img src="../image/chrome.png" style="width:120px;height:120px;border-radius: 15%;"/></div><h2 style="text-align: center;font-size: 24px;color: royalblue;">IReading</h2><p style="text-align: center;font-size: 24px;color: red;">让生活更精彩</p>
</div>
<div id="hui-swaper" style="height: 100px;width: 100%;"><h2>版权所有@ wangweiruning<h2><h2>开法者 :wangweiruning@163.com</h2><h2>如有需求,请发送消息至邮箱wangweiruning163.con</h2>
</div>
<script type="text/javascript" src="../js/hui.js" charset="UTF-8"></script>
<script type="text/javascript" src="../js/hui-image-cuter.js" charset="UTF-8"></script>
<script type="text/javascript">hui.Back = null;hui.plusReady(function(){//判断是否支持沉浸式var isImmersedStatusbar = plus.navigator.isImmersedStatusbar();//获取系统状态栏高度var StatusbarHeight = plus.navigator.getStatusbarHeight();		   console.log(StatusbarHeight);hui('.hui-header').css({'paddingTop':StatusbarHeight + 'px'});hui('#hui-back').css({top:StatusbarHeight+'px'});var indexView = plus.webview.getLaunchWebview();var nextPage = null;var prevPage ={pageId : 'html/sub3.html', callBack : function(){indexView.evalJS('hui("#hui-footer").find("a").removeClass("hui-footer-active"); hui("#nav-forum").addClass("hui-footer-active")');}}; hui.drag(prevPage, nextPage);});</script>
</body>
</html>

 

createShow.html    新闻详情页

<!doctype html>
<html><head><meta charset="UTF-8"><title></title><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /><link href="../css/hui.css" rel="stylesheet" /></head><body><header class="hui-header"><div id="hui-back"></div><h1 id="titles"></h1></header><script src="../js/hui.js"></script><script type="text/javascript">hui.loading("加载中...");var _self;hui.plusReady(function(){_self = plus.webview.currentWebview();var urls = _self.url;var titles = _self.titles;hui("#titles").html(titles);var bnv = plus.webview.create(urls,'detail',{top:"60px"},{});plus.webview.currentWebview().append(bnv);hui.closeLoading();})</script></body></html>

应用打包请使用  hbuilder  开发工具

配置项在manifest.json中设置

写不下去了,具体看代码吧(~_~)~~~~~~~~~~~~~~~~~

 

欢迎大家一起交流

这篇关于hui框架开发APP的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:https://blog.csdn.net/qq_39197547/article/details/81127948
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/597212

相关文章

基于Python开发一个有趣的工作时长计算器

《基于Python开发一个有趣的工作时长计算器》随着远程办公和弹性工作制的兴起,个人及团队对于工作时长的准确统计需求日益增长,本文将使用Python和PyQt5打造一个工作时长计算器,感兴趣的小伙伴可... 目录概述功能介绍界面展示php软件使用步骤说明代码详解1.窗口初始化与布局2.工作时长计算核心逻辑3

python web 开发之Flask中间件与请求处理钩子的最佳实践

《pythonweb开发之Flask中间件与请求处理钩子的最佳实践》Flask作为轻量级Web框架,提供了灵活的请求处理机制,中间件和请求钩子允许开发者在请求处理的不同阶段插入自定义逻辑,实现诸如... 目录Flask中间件与请求处理钩子完全指南1. 引言2. 请求处理生命周期概述3. 请求钩子详解3.1

如何基于Python开发一个微信自动化工具

《如何基于Python开发一个微信自动化工具》在当今数字化办公场景中,自动化工具已成为提升工作效率的利器,本文将深入剖析一个基于Python的微信自动化工具开发全过程,有需要的小伙伴可以了解下... 目录概述功能全景1. 核心功能模块2. 特色功能效果展示1. 主界面概览2. 定时任务配置3. 操作日志演示

JavaScript实战:智能密码生成器开发指南

本文通过JavaScript实战开发智能密码生成器,详解如何运用crypto.getRandomValues实现加密级随机密码生成,包含多字符组合、安全强度可视化、易混淆字符排除等企业级功能。学习密码强度检测算法与信息熵计算原理,获取可直接嵌入项目的完整代码,提升Web应用的安全开发能力 目录

C++ HTTP框架推荐(特点及优势)

《C++HTTP框架推荐(特点及优势)》:本文主要介绍C++HTTP框架推荐的相关资料,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录1. Crow2. Drogon3. Pistache4. cpp-httplib5. Beast (Boos

SpringBoot基础框架详解

《SpringBoot基础框架详解》SpringBoot开发目的是为了简化Spring应用的创建、运行、调试和部署等,使用SpringBoot可以不用或者只需要很少的Spring配置就可以让企业项目快... 目录SpringBoot基础 – 框架介绍1.SpringBoot介绍1.1 概述1.2 核心功能2

一文教你如何解决Python开发总是import出错的问题

《一文教你如何解决Python开发总是import出错的问题》经常朋友碰到Python开发的过程中import包报错的问题,所以本文将和大家介绍一下可编辑安装(EditableInstall)模式,可... 目录摘要1. 可编辑安装(Editable Install)模式到底在解决什么问题?2. 原理3.

Spring框架中@Lazy延迟加载原理和使用详解

《Spring框架中@Lazy延迟加载原理和使用详解》:本文主要介绍Spring框架中@Lazy延迟加载原理和使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录一、@Lazy延迟加载原理1.延迟加载原理1.1 @Lazy三种配置方法1.2 @Component

Python+PyQt5开发一个Windows电脑启动项管理神器

《Python+PyQt5开发一个Windows电脑启动项管理神器》:本文主要介绍如何使用PyQt5开发一款颜值与功能并存的Windows启动项管理工具,不仅能查看/删除现有启动项,还能智能添加新... 目录开篇:为什么我们需要启动项管理工具功能全景图核心技术解析1. Windows注册表操作2. 启动文件

使用Python开发Markdown兼容公式格式转换工具

《使用Python开发Markdown兼容公式格式转换工具》在技术写作中我们经常遇到公式格式问题,例如MathML无法显示,LaTeX格式错乱等,所以本文我们将使用Python开发Markdown兼容... 目录一、工具背景二、环境配置(Windows 10/11)1. 创建conda环境2. 获取XSLT