HBuilderX

HBuilderX

极客开发工具
uni-app

uni-app

开发一次,多端覆盖
uniCloud

uniCloud

云开发平台
HTML5+

HTML5+

增强HTML5的功能体验
MUI

MUI

上万Star的前端框架

仿UC头条HTML模板

演示截图

模板下载
https://21sqw.lanzous.com/iHEWPfb23ri

演示截图

模板下载
https://21sqw.lanzous.com/iHEWPfb23ri

点击展开底部菜单-手机下滑屏幕收起底部菜单html源码

演示截图

模板下载
https://21sqw.lanzous.com/iwsklfb1xvg

演示截图

模板下载
https://21sqw.lanzous.com/iwsklfb1xvg

上下滑动屏幕网站顶部展开收起源码html模板

演示截图

源码下载
https://21sqw.lanzous.com/i5L1sfb1s2h

演示截图

源码下载
https://21sqw.lanzous.com/i5L1sfb1s2h

上滑隐藏底部下滑展开底部HTML模板

演示截图

模板下载
https://21sqw.lanzous.com/ij7k8fb1l4h

演示截图

模板下载
https://21sqw.lanzous.com/ij7k8fb1l4h

webview会自动铺满,解决占领手机状态栏

在webview的page页面中,created()生命周期中,
// #ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
setTimeout(function() {
var wv = currentWebview.children()[0];
wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
top: uni.getSystemInfoSync().statusBarHeight,
})
}, 1000);
// #endif

继续阅读 »

在webview的page页面中,created()生命周期中,
// #ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
setTimeout(function() {
var wv = currentWebview.children()[0];
wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
top: uni.getSystemInfoSync().statusBarHeight,
})
}, 1000);
// #endif

收起阅读 »

热更新

热更新
//APP更新  
import httpUtil from "./HttpUtils.js"  
import Urls from "./Urls.js"  
var update = function(callback) {  
    uni.showToast({  
        title: '开始检查更新',  
        mask: false,  
        duration: 5000,  
        icon: "none"  
    });  

    uni.getSystemInfo({  
        success: (res) => {  
            console.log(res)  
            CheckUpdate(res.platform, callback);  
        }  
    })  

    function autoUpdateRes(url) {  
        //#ifdef APP-PLUS  
        const dtask = plus.downloader.createDownload(url, {  

            },  
            function(d, status) {  
                // 下载完成    
                if (status == 200) {  
                    // var files = plus.io.convertLocalFileSystemURL(d.filename);  

                    //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径  
                    //var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);  
                    // plus.runtime.openFile(d.filename); //选择软件打开文件  

                    plus.nativeUI.showWaiting("安装wgt文件...");  
                    plus.runtime.install(d.filename, {}, function() {  
                        plus.nativeUI.closeWaiting();  
                        console.log("安装wgt文件成功!");  
                        plus.nativeUI.alert("应用资源更新完成!", function() {  
                            plus.runtime.restart();  
                        });  
                    }, function(e) {  
                        plus.nativeUI.closeWaiting();  
                        console.log("安装wgt文件失败[" + e.code + "]:" + e.message);  
                        plus.nativeUI.alert("安装wgt文件失败[" + e.code + "]:" + e.message);  
                    });  
                } else {  
                    uni.showToast({  
                        title: '更新失败' + status,  
                        mask: false,  
                        duration: 1500  
                    });  
                    //下载失败  
                    plus.downloader.clear(); //清除下载任务  
                }  
            });  
        dtask.start();  

        //#endif  
    };  

    // 自动更新  
    function CheckUpdate(platform, callback) {  

        httpUtil.httpUtil(Urls.URLDATA.UPDATE_VERSION, {  
            'platform': platform  
        }, function(res) {  
            console.log(res)  
            if (res.data.data && (res.data.data.number > plus.runtime.version)) {  
                /* if (plus.networkinfo.getCurrentType() != 3) {  
                    uni.showToast({  
                        title: '有新的版本发布,检测到您目前非Wifi连接,为节约您的流量,程序已停止自动更新,将在您连接WIFI之后重新检测更新。',  
                        mask: false,  
                        duration: 5000,  
                        icon: "none"  
                    });  
                    return;  
                } */  

                if (res.data.data.type < 3) {  

                    uni.showModal({  
                        title: '新版本提示',  
                        content: res.data.data.desc,  
                        success: function(re) {  
                            if (re.confirm) {  
                                if (res.data.data.type == 1) { // 热更新   
                                    autoUpdateRes(res.data.data.path);  
                                } else {  
                                    downloadFile(res.data.data.path, callback);  
                                }  

                            } else if (re.cancel) {  
                                uni.showToast({  
                                    title: '已取消更新',  
                                    mask: false,  
                                    duration: 5000,  
                                    icon: "none"  
                                });  
                            }  
                        }  
                    });  
                } else {  
                    // 强制更新  

                    if (res.data.data.type == 3) { // 热更新  
                        autoUpdateRes(res.data.data.path);  
                    } else {  
                        downloadFile(res.data.data.path, callback);  
                    }  
                }  

            } else {  
                uni.showToast({  
                    title: '当前已是最新版',  
                    mask: false,  
                    duration: 5000,  
                    icon: "none"  
                });  
            }  
        })  
    }  

    //整包更新  

    function packageDownload(downloadUrl) {  

        plus.runtime.openURL(downloadUrl) //整包下载  

    }  

    function downloadFile(url, callback) {  
        //#ifdef APP-PLUS  
        const dtask = plus.downloader.createDownload(url, {},  
            function(d, status) {  
                // 下载完成    
                if (status == 200) {  
                    // plus.runtime.openFile(d.filename); //选择软件打开文件  
                    plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), {}, function(e) {  
                        uni.showToast({  
                            title: '更新成功,需要重启' + JSON.stringify(e),  
                            mask: false,  
                            duration: 1000  
                        });  
                        uni.removeSavedFile({  
                            filePath: plus.io.convertLocalFileSystemURL(d.filename),  
                            complete: function(res) {  
                                console.log(res);  
                            }  
                        });  
                        plus.runtime.restart();  

                    }, function(error) {  
                        uni.showToast({  
                            title: '安装失败' + error.message,  
                            mask: false,  
                            duration: 1000  
                        });  
                        uni.removeSavedFile({  
                            filePath: plus.io.convertLocalFileSystemURL(d.filename),  
                            complete: function(res) {  
                                console.log(res);  
                            }  
                        });  
                    })  

                } else {  
                    uni.showToast({  
                        title: '更新失败' + status,  
                        mask: false,  
                        duration: 1000  
                    });  
                    //下载失败  
                    plus.downloader.clear(); //清除下载任务  
                }  
            });  
        dtask.addEventListener('statechanged', (task) => {  
            if (callback) {  
                callback(task);  
            }  

        });  
        dtask.start();  

        //#endif  

    }  

}  
module.exports = {  
    update  
}  
继续阅读 »
//APP更新  
import httpUtil from "./HttpUtils.js"  
import Urls from "./Urls.js"  
var update = function(callback) {  
    uni.showToast({  
        title: '开始检查更新',  
        mask: false,  
        duration: 5000,  
        icon: "none"  
    });  

    uni.getSystemInfo({  
        success: (res) => {  
            console.log(res)  
            CheckUpdate(res.platform, callback);  
        }  
    })  

    function autoUpdateRes(url) {  
        //#ifdef APP-PLUS  
        const dtask = plus.downloader.createDownload(url, {  

            },  
            function(d, status) {  
                // 下载完成    
                if (status == 200) {  
                    // var files = plus.io.convertLocalFileSystemURL(d.filename);  

                    //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径  
                    //var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);  
                    // plus.runtime.openFile(d.filename); //选择软件打开文件  

                    plus.nativeUI.showWaiting("安装wgt文件...");  
                    plus.runtime.install(d.filename, {}, function() {  
                        plus.nativeUI.closeWaiting();  
                        console.log("安装wgt文件成功!");  
                        plus.nativeUI.alert("应用资源更新完成!", function() {  
                            plus.runtime.restart();  
                        });  
                    }, function(e) {  
                        plus.nativeUI.closeWaiting();  
                        console.log("安装wgt文件失败[" + e.code + "]:" + e.message);  
                        plus.nativeUI.alert("安装wgt文件失败[" + e.code + "]:" + e.message);  
                    });  
                } else {  
                    uni.showToast({  
                        title: '更新失败' + status,  
                        mask: false,  
                        duration: 1500  
                    });  
                    //下载失败  
                    plus.downloader.clear(); //清除下载任务  
                }  
            });  
        dtask.start();  

        //#endif  
    };  

    // 自动更新  
    function CheckUpdate(platform, callback) {  

        httpUtil.httpUtil(Urls.URLDATA.UPDATE_VERSION, {  
            'platform': platform  
        }, function(res) {  
            console.log(res)  
            if (res.data.data && (res.data.data.number > plus.runtime.version)) {  
                /* if (plus.networkinfo.getCurrentType() != 3) {  
                    uni.showToast({  
                        title: '有新的版本发布,检测到您目前非Wifi连接,为节约您的流量,程序已停止自动更新,将在您连接WIFI之后重新检测更新。',  
                        mask: false,  
                        duration: 5000,  
                        icon: "none"  
                    });  
                    return;  
                } */  

                if (res.data.data.type < 3) {  

                    uni.showModal({  
                        title: '新版本提示',  
                        content: res.data.data.desc,  
                        success: function(re) {  
                            if (re.confirm) {  
                                if (res.data.data.type == 1) { // 热更新   
                                    autoUpdateRes(res.data.data.path);  
                                } else {  
                                    downloadFile(res.data.data.path, callback);  
                                }  

                            } else if (re.cancel) {  
                                uni.showToast({  
                                    title: '已取消更新',  
                                    mask: false,  
                                    duration: 5000,  
                                    icon: "none"  
                                });  
                            }  
                        }  
                    });  
                } else {  
                    // 强制更新  

                    if (res.data.data.type == 3) { // 热更新  
                        autoUpdateRes(res.data.data.path);  
                    } else {  
                        downloadFile(res.data.data.path, callback);  
                    }  
                }  

            } else {  
                uni.showToast({  
                    title: '当前已是最新版',  
                    mask: false,  
                    duration: 5000,  
                    icon: "none"  
                });  
            }  
        })  
    }  

    //整包更新  

    function packageDownload(downloadUrl) {  

        plus.runtime.openURL(downloadUrl) //整包下载  

    }  

    function downloadFile(url, callback) {  
        //#ifdef APP-PLUS  
        const dtask = plus.downloader.createDownload(url, {},  
            function(d, status) {  
                // 下载完成    
                if (status == 200) {  
                    // plus.runtime.openFile(d.filename); //选择软件打开文件  
                    plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), {}, function(e) {  
                        uni.showToast({  
                            title: '更新成功,需要重启' + JSON.stringify(e),  
                            mask: false,  
                            duration: 1000  
                        });  
                        uni.removeSavedFile({  
                            filePath: plus.io.convertLocalFileSystemURL(d.filename),  
                            complete: function(res) {  
                                console.log(res);  
                            }  
                        });  
                        plus.runtime.restart();  

                    }, function(error) {  
                        uni.showToast({  
                            title: '安装失败' + error.message,  
                            mask: false,  
                            duration: 1000  
                        });  
                        uni.removeSavedFile({  
                            filePath: plus.io.convertLocalFileSystemURL(d.filename),  
                            complete: function(res) {  
                                console.log(res);  
                            }  
                        });  
                    })  

                } else {  
                    uni.showToast({  
                        title: '更新失败' + status,  
                        mask: false,  
                        duration: 1000  
                    });  
                    //下载失败  
                    plus.downloader.clear(); //清除下载任务  
                }  
            });  
        dtask.addEventListener('statechanged', (task) => {  
            if (callback) {  
                callback(task);  
            }  

        });  
        dtask.start();  

        //#endif  

    }  

}  
module.exports = {  
    update  
}  
收起阅读 »

uni.requestSubscribeMessage 没响应的问题

1、微信调试基础库 调到2.8.2以上
2、uni 的button 不论是@click 还是@tap ,微信小程序都识别不了,都说要bindtap 绑定来触发
解决方法 : 利用uni.showmodal 来触发 就OK了

1、微信调试基础库 调到2.8.2以上
2、uni 的button 不论是@click 还是@tap ,微信小程序都识别不了,都说要bindtap 绑定来触发
解决方法 : 利用uni.showmodal 来触发 就OK了

uni-app清除定时器

uniapp

export default {
data() {
return {
timer: null,
}
},
methods: {
timeUp() {
clearInterval(this.timer)
},
this.timer = setInterval(() => {
uni.navigateTo({
url: '../index/index'
});
this.timeUp()
}, 2000)
}
}

继续阅读 »

export default {
data() {
return {
timer: null,
}
},
methods: {
timeUp() {
clearInterval(this.timer)
},
this.timer = setInterval(() => {
uni.navigateTo({
url: '../index/index'
});
this.timeUp()
}, 2000)
}
}

收起阅读 »

uni app使用mobx | uni app状态管理mobx

使用mobx的响应函数autorun监听状态变化进行赋值和运行函数,页面onLoad时执行所有autorun,页面onUnload时销毁所有autorun

以下是ts代码模板

<template>  
  <div class="${NAME}">  

  </div>  
</template>  

<script lang="ts">  
import {Vue, Component, Prop, Watch} from "vue-property-decorator";  
import {autorun, observe, toJS} from "mobx";  
import _ from 'lodash';  
import {store} from '@/utils/store'  

@Component  
export default class ${NAME} extends Vue {  

  /*创建监听*/  
  createDisposer() {  
    //观察状态变化  
    this.disposer.push(autorun(() => {  
      //this.step3 = store.step  
    }))  
  }  

  //映射监听  
  createDisposerMap(obj: any) {  
    const _this = this  
    _.forOwn(obj, (v, k) => {  
      _this.disposer.push(autorun(() => {  
        if (_.isArray(obj)) {  
          _this[v] = toJS(store[v])  
        } else {  
          _this[k] = toJS(store[v])  
        }  
      }))  
    })  
  }  

  //销毁监听  
  destroyDisposer() {  
    this.disposer.map(x => x())  
    this.disposer.length = 0  
  }  

  //监听列表  
  disposer: Function[] = []  

  onUnload() {  
    this.destroyDisposer()  
  }  

  onLoad(evt?: any) {  
    this.createDisposer()  
    //this.createDisposerMap(['step'])  
    //this.createDisposerMap({step2: 'step'})  
  }  

}  
</script>  

<style scoped lang="stylus">  

.${NAME}  
  padding 0  

</style>  
继续阅读 »

使用mobx的响应函数autorun监听状态变化进行赋值和运行函数,页面onLoad时执行所有autorun,页面onUnload时销毁所有autorun

以下是ts代码模板

<template>  
  <div class="${NAME}">  

  </div>  
</template>  

<script lang="ts">  
import {Vue, Component, Prop, Watch} from "vue-property-decorator";  
import {autorun, observe, toJS} from "mobx";  
import _ from 'lodash';  
import {store} from '@/utils/store'  

@Component  
export default class ${NAME} extends Vue {  

  /*创建监听*/  
  createDisposer() {  
    //观察状态变化  
    this.disposer.push(autorun(() => {  
      //this.step3 = store.step  
    }))  
  }  

  //映射监听  
  createDisposerMap(obj: any) {  
    const _this = this  
    _.forOwn(obj, (v, k) => {  
      _this.disposer.push(autorun(() => {  
        if (_.isArray(obj)) {  
          _this[v] = toJS(store[v])  
        } else {  
          _this[k] = toJS(store[v])  
        }  
      }))  
    })  
  }  

  //销毁监听  
  destroyDisposer() {  
    this.disposer.map(x => x())  
    this.disposer.length = 0  
  }  

  //监听列表  
  disposer: Function[] = []  

  onUnload() {  
    this.destroyDisposer()  
  }  

  onLoad(evt?: any) {  
    this.createDisposer()  
    //this.createDisposerMap(['step'])  
    //this.createDisposerMap({step2: 'step'})  
  }  

}  
</script>  

<style scoped lang="stylus">  

.${NAME}  
  padding 0  

</style>  
收起阅读 »

海康(HIKVISION)视频监控,实时视频预览、录像回放

海康(HIKVISION)视频监控,实时视频预览、录像回放:https://ext.dcloud.net.cn/plugin?id=2403

海康(HIKVISION)视频监控,实时视频预览、录像回放:https://ext.dcloud.net.cn/plugin?id=2403

挺好用的

第一次发布文章,不知道说点啥。
第一次发布文章,不知道说点啥。

SQLITE 用plus.io操作www目录移植doc目录异常的问题和操作www目录报错的问题。

sqllite

首先 www 不支持写入操作的,所以一些东西我们需要有移到doc操作
但是用plus.io操作操作www目录时就会报 “执行错误” 或者 ”路径不存在“。

首先说明下原因:那是因为没有权限造成的。

没有权限之前的目录定位在> /storage/emulated/下的APP包名中,
这种情况下www目录是不存在的,所以也就没有资源,路径什么的也就不正确了。

设置权限以后则定为到> /data/user/目录下APP包名中,
这个目录下找到对应的APP就有之前打包的所有资源。

可以通过以下的操作来完成配置权限。

打开 manifest 选择 App权限配置 再右侧权限列表中 勾选

<uses-permission android:name=\"android.permission.WRITE_PROFILE\"/>

重新打包就可以了,

继续阅读 »

首先 www 不支持写入操作的,所以一些东西我们需要有移到doc操作
但是用plus.io操作操作www目录时就会报 “执行错误” 或者 ”路径不存在“。

首先说明下原因:那是因为没有权限造成的。

没有权限之前的目录定位在> /storage/emulated/下的APP包名中,
这种情况下www目录是不存在的,所以也就没有资源,路径什么的也就不正确了。

设置权限以后则定为到> /data/user/目录下APP包名中,
这个目录下找到对应的APP就有之前打包的所有资源。

可以通过以下的操作来完成配置权限。

打开 manifest 选择 App权限配置 再右侧权限列表中 勾选

<uses-permission android:name=\"android.permission.WRITE_PROFILE\"/>

重新打包就可以了,

收起阅读 »