Fetch the repository succeeded.
此项目适用于纯手机端的小程序、公众号、H5、APP; 不适用于PC、自适应等项目
|- 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>
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)=>{
})
uni.$func.cache("uid",1);
uni.$func.datetime(1600000000);
此分页只兼容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"}
],
}
}
注册文件/common/http.api.js , /common/api/下为各个模块api,用法:
uni.$api.user.login();
this.$api.common.sendCode({mobile:"xxx"});
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);
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));
let random = uni.$func.rand(10000,999999); //随机整数
let randChar = uni.$func.randChar(20); //随机字符串,无特殊符号
let randChar = uni.$func.randChar(20,true); //随机字符串,含特殊符号
uni.$func.toast("验证码错误");
uni.$func.toast("验证码错误",'success');//定义图标,默认none
uni.$func.toast("验证码错误",null,5000);//定时关闭毫秒,默认1500
uni.$func.loading('上传中');//uni.hideLoading();
uni.$func.alert("密码错误")
uni.$func.isWechat();//微信浏览器返回true
uni.$func.cache("token");//读取缓存
uni.$func.cache("token","xxxxx");//设置缓存,自动增加config.js里面的前缀
uni.$func.encrypt("要加密的字符串");//加密
uni.$func.decrypt("要解密的字符串");//解密
uni.$func.beforeTime(1620000000);
uni.$func.beforeTime("2022-01-01 15:00:00");
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。