1.模态确认框
html中
<u-modal v-model="show_w" @confirm="toUpdate" :content="versionContent" show-cancel-button>
</u-modal>
v-model 控制是否显示 @confirm为确定事件 content 为其中显示的内容 show-cancel-button 为取消键
2.安卓机更新app downloadApkUrl 为存放地址
//apk的服务地址
var downloadApkUrl = "https://xxx.xxx。com/inkspatchstdapp/Release.apk";
var dtask = plus.downloader.createDownload(downloadApkUrl,{
filename:"_downloads/"+ "inkspatchstdapp.apk" //利用保存路径,实现下载文件的重命名
},function(d,status){
console.log(d,status);
//d为下载的文件对象
if(status==200){
//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
console.log(fileSaveUrl);
plus.runtime.openFile(d.filename); //选择软件打开文件
}else{
//下载失败
plus.downloader.clear(); //清除下载任务
}
})
console.log(dtask);
dtask.start()
}
3.简易绑定值 {{ username || '请登录' }} {{ username?'退出登录' : '请登录' }}
4.常规获得数据
async BindData() {
this.PageIndex == 1 ? this.lst = [] : "" //防止多次刷新重复
let res = await this.$post("API地址", JSON.stringify(this.queryParams))
console.log(res);
this.total = res.data.total
this.lst = this.lst.concat(res.data.list ? res.data.list :
""); // 列表添加 同时控制是否加载到底了
this.total > this.lst.length ? this.nomore = false : this.nomore = true;
},
//搜索
search(res) {
if (res != "") {
this.queryParams.SearchPojo = {
RefNo: res,
ProgramName: res
};
} else {
this.$delete(this.queryParams, 'SearchPojo')
}
this.lst = []
this.queryParams.SearchType = 1;
this.queryParams.PageNum = 1;
this.queryParams.PageSize = 10;
this.BindData();
},
//下拉刷新
onPullDownRefresh() {
//console.log('下拉刷新');
uni.stopPullDownRefresh()
this.lst = []
this.queryParams.PageIndex = 1
this.BindData()
},
//触底加载更多
onReachBottom(e) {
//console.log('触底加载更多');
//console.log(this.total , this.lst.length);
if (this.total <= this.lst.length) {
this.$msg("没有更多了")
return
} else {
this.queryParams.PageIndex++
this.BindData()
}
},
5.常规data data() { return { //常规data title: "",//页面名 listLoading: true, lst: [], // 列表数 idx: 0, Searchstr: "", // sql查询文本 total: 0, queryParams: { PageNum: 1, PageSize: 10, OrderType: 1, SearchType: 1, //1为模糊搜索 }, nomore: false, //加载更多 } },