3 Star 18 Fork 8

成都恰巧网络科技有限公司 / uniapp前端模板

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

Uni-App模板Demo

此项目适用于纯手机端的小程序、公众号、H5、APP; 不适用于PC、自适应等项目

UI框架及文档

其他常用优秀插件推荐

目录

|- components       UNIAPP插件目录
|------ 
|- common
|------ /api 		接口目录
|------ http.api.js	请求API集中管理
|------ http.interceptor.js	请求拦截器
|------ function.js 常用方法封装
|------ function.js 常用方法封装
|------ config.js	项目参数配置
|- pages 			页面目录
|------ index/index 			  
|- static			静态资源目录
|------ imgs		图片目录 
|------ css			公共样式目录
|- App.vue			 
|- main.js          主入口文件,引入了uviewui的js
|- pages.json
|- uni.scss         

富文本解析

<view>
	<u-parse :html="content"></u-parse>
</view>

网络请求

  1. GET/POST请求 [Promise]
uni.$u.get("/api/home/banner").then((res)=>{
	if(res.code==200){this.banner=res.data}
});
uni.$u.post("/api/login",{username:"admin",password:"xxx"},{'Content-Type':'application/json'})
	.then((res)=>{
	
	})
  1. 常用方法调用 uni.$func.xxx
	uni.$func.cache("uid",1);
	uni.$func.datetime(1600000000);

分页查询DEMO

此分页只兼容ThinkPHP框架和Laravel框架自带的分页,其他框架参考接口格式亦可

	this.page=uni.$func.initPage();//首次初始化
	var page=uni.$func.nextPage(this.page);//下一页
	if(!page)return;//已经加载到最后一页
	page.type=1;//page附加其他查询参数,post提交整个page
	uni.$u.post("/xxx",page).then((res)=>{
		if(res.code==200){
			this.list=this.list.concat(res.data.data);
			this.page=res.data;
		}
	});
	
	接口返回格式参考:
	{
		code:200,
		data:{
			current_page:1,
			total:150,
			last_page:10,
			per_page:15,
			data:[
				{id:1,name:"xxx"}
			],
			
		}
	}

API集中管理

注册文件/common/http.api.js , /common/api/下为各个模块api,用法:

	uni.$api.user.login();
	this.$api.common.sendCode({mobile:"xxx"});

常用方法封装

  1. 浮点运算,避免出现js浮点bug
let res = uni.$func.jia(1.9,1.82131);
let res = uni.$func.jian(1.9,1.82131);
let res = uni.$func.cheng(1.9,1.82131);
let res = uni.$func.chu(1.9,1.82131);
  1. 时间转换相关
var timestamp=uni.$func.now(); //当前时间戳 
uni.$func.datetime(timestamp,3);//获取格式化的年,月,日,时,分,秒,周 
console.log("格式化时间",arr);
console.log("XX小时、XX天以前",uni.$func.beforeTime(timestamp));
console.log("今天是星期几",arr.weekday); 
console.log('完整时间',uni.$func.datetime(timestamp,0));
console.log('日期',uni.$func.datetime(timestamp,1));
console.log('时间',uni.$func.datetime(timestamp,2));
  1. 随机数、字符串
let random = uni.$func.rand(10000,999999); //随机整数
let randChar = uni.$func.randChar(20); //随机字符串,无特殊符号
let randChar = uni.$func.randChar(20,true); //随机字符串,含特殊符号
  1. 带遮盖层的提示、加载中,可用于避免重复点击
uni.$func.toast("验证码错误");
uni.$func.toast("验证码错误",'success');//定义图标,默认none
uni.$func.toast("验证码错误",null,5000);//定时关闭毫秒,默认1500 
uni.$func.loading('上传中');//uni.hideLoading();
uni.$func.alert("密码错误")
  1. H5微信浏览器判断
uni.$func.isWechat();//微信浏览器返回true
  1. 缓存数据
uni.$func.cache("token");//读取缓存
uni.$func.cache("token","xxxxx");//设置缓存,自动增加config.js里面的前缀
  1. 敏感数据加密解密(AES-128-CBC)
uni.$func.encrypt("要加密的字符串");//加密
uni.$func.decrypt("要解密的字符串");//解密
  1. 返回N天N分钟以前
uni.$func.beforeTime(1620000000);
uni.$func.beforeTime("2022-01-01 15:00:00");
MIT License Copyright (c) 2022 未设想de路 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

uniapp前端模板,基于uview-ui,封装了一些常用方法 expand collapse
JavaScript and 4 more languages
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
JavaScript
1
https://gitee.com/qq_admin_dev_team/uniapp-front.git
git@gitee.com:qq_admin_dev_team/uniapp-front.git
qq_admin_dev_team
uniapp-front
uniapp前端模板
master

Search