HBuilderX

HBuilderX

极客开发工具
uni-app

uni-app

开发一次,多端覆盖
uniCloud

uniCloud

云开发平台
HTML5+

HTML5+

增强HTML5的功能体验
MUI

MUI

上万Star的前端框架

【分享】uniapp环境开H5端打开微信小程序,解决苹果端首次进入页面显示异常

<wx-open-launch-weapp path="pages/card/visit_card.html?id=19" id="launch-wxapp" username="gh_abc199886dfa">  
        <script type="text/wxtag-template">  
            <style>  
                .btn-open-weapp{  
                    background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);  
                    border: 0;  
                    color: #424242;  
                    text-shadow: 0px 1px 1px #fff;  
                    border-radius: 50px;  
                    text-align: center;  
                    width: 120px;  
                    height: 35px;  
                    line-height: 35px;  
                    outline:none;  
                }  
            </style>  
            <button class="btn-open-weapp">进店逛逛</button >  
        <script>  
</wx-open-launch-weapp>`  

原来直接这样子用,发现有问题,安卓端正常,但苹果端首次进入H5页面显示不了按钮,只有刷新才能显示,于是折腾一翻,因为H5端支持v-html,测试了下一切正常

下面这种方式,微信开发者工具也能看到按钮哦

<!-- #ifdef H5 -->  
    <view v-html="wxOpenTags"></view>  
<!-- #endif --> 
//#ifdef H5  
    setTimeout(()=>{  
        this.wxOpenTags=`<wx-open-launch-weapp path="pages/card/visit_card.html?id=19" id="launch-wxapp" username="gh_abc199886dfa">  
            <template>  
                <style>  
                .btn-open-weapp{  
                    background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);  
                    border: 0;  
                    color: #424242;  
                    text-shadow: 0px 1px 1px #fff;  
                    border-radius: 50px;  
                    text-align: center;  
                    width: 120px;  
                    height: 35px;  
                    line-height: 35px;  
                    outline:none;  
                }  
                </style>  
                <button class="btn-open-weapp">进店逛逛</button >  
            </template>  
        </wx-open-launch-weapp>`;  
    },1000);  
//#endif

wx-open-launch-app也用v-html的方式

继续阅读 »
<wx-open-launch-weapp path="pages/card/visit_card.html?id=19" id="launch-wxapp" username="gh_abc199886dfa">  
        <script type="text/wxtag-template">  
            <style>  
                .btn-open-weapp{  
                    background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);  
                    border: 0;  
                    color: #424242;  
                    text-shadow: 0px 1px 1px #fff;  
                    border-radius: 50px;  
                    text-align: center;  
                    width: 120px;  
                    height: 35px;  
                    line-height: 35px;  
                    outline:none;  
                }  
            </style>  
            <button class="btn-open-weapp">进店逛逛</button >  
        <script>  
</wx-open-launch-weapp>`  

原来直接这样子用,发现有问题,安卓端正常,但苹果端首次进入H5页面显示不了按钮,只有刷新才能显示,于是折腾一翻,因为H5端支持v-html,测试了下一切正常

下面这种方式,微信开发者工具也能看到按钮哦

<!-- #ifdef H5 -->  
    <view v-html="wxOpenTags"></view>  
<!-- #endif --> 
//#ifdef H5  
    setTimeout(()=>{  
        this.wxOpenTags=`<wx-open-launch-weapp path="pages/card/visit_card.html?id=19" id="launch-wxapp" username="gh_abc199886dfa">  
            <template>  
                <style>  
                .btn-open-weapp{  
                    background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);  
                    border: 0;  
                    color: #424242;  
                    text-shadow: 0px 1px 1px #fff;  
                    border-radius: 50px;  
                    text-align: center;  
                    width: 120px;  
                    height: 35px;  
                    line-height: 35px;  
                    outline:none;  
                }  
                </style>  
                <button class="btn-open-weapp">进店逛逛</button >  
            </template>  
        </wx-open-launch-weapp>`;  
    },1000);  
//#endif

wx-open-launch-app也用v-html的方式

收起阅读 »

最新版本的编辑器,云打包报这个错误

HBuilderX升级 HBuilder X

最新版本的编辑器,云打包报这个错误。麻烦官方大佬 解决下

最新版本的编辑器,云打包报这个错误。麻烦官方大佬 解决下

有关自定义底部导航栏 / 自定义tabbar的一些经验

自定义 tabbar

在开发的过程中,我们经常会遇到一些设计的很好看的底部导航栏,最常见的比如下面这种的


中间会有凸起的一部分,这个时候我们再次使用常规的做法显然已经不再合适了,在pages.json中如何配置都无法达到我们的这个需求,这个时候我们需要自定义底部导航栏,那么究竟该如何自定义呢,我看了众多的博客插件,他们的做法基本上如初一辙,写上一个自定义的导航栏,然后通过索引值判断去不断的用v-if去进行组件的切换,虽然也能实现,但是此做法存在较为严重的性能问题,我下面提供的这个做法,大家可以一试!
1.我们依然在pages.json中去配置底部导航栏,只是我们只用去配置pagePath即可,如下

"tabBar": {  
        "list": [{  
                "pagePath": "pages/tabbar/index/index" // 页面文件路径  
            },  
            {  
                "pagePath": "pages/tabbar/user/user" // 页面文件路径  
            }  
        ]  
    }

2.上方配置完成后,我们可以在app.vue 中的onLaunch周期中,写入 uni.hideTabBar() ,此作用是隐藏底部导航,特别注意,因为此api不兼容字节跳动的小程序,所以,想要在字节跳动小程序内使用需要写入tt.hideTabBar()

  1. 然后我们就可以去写上一个底部导航栏的组件,这个就是一个组件,我想大家应该都会写的,下面是我项目中写的一份


4.把此组件引入在底部导航栏的页面就可以了,这样就能较为完美的解决底部导航栏这一问题,有兴趣的开发者可以一试,至少本人写自定义导航栏一直都是这么写的,嘿嘿
当然,我依然还是推荐原生的写法,不要整那么多花里胡哨的,除了好看,一无是处,只要是自定义底部导航栏总会有那么几个性能的问题,所以建议还是要给经理,客户,老板提提建议,这样我们开发人员也能省点劲

翻看大厂的微信小程序都是原生配置的底部导航栏,为什么老板总觉得不好看,我觉得还可以啊0.0,脑壳疼

继续阅读 »

在开发的过程中,我们经常会遇到一些设计的很好看的底部导航栏,最常见的比如下面这种的


中间会有凸起的一部分,这个时候我们再次使用常规的做法显然已经不再合适了,在pages.json中如何配置都无法达到我们的这个需求,这个时候我们需要自定义底部导航栏,那么究竟该如何自定义呢,我看了众多的博客插件,他们的做法基本上如初一辙,写上一个自定义的导航栏,然后通过索引值判断去不断的用v-if去进行组件的切换,虽然也能实现,但是此做法存在较为严重的性能问题,我下面提供的这个做法,大家可以一试!
1.我们依然在pages.json中去配置底部导航栏,只是我们只用去配置pagePath即可,如下

"tabBar": {  
        "list": [{  
                "pagePath": "pages/tabbar/index/index" // 页面文件路径  
            },  
            {  
                "pagePath": "pages/tabbar/user/user" // 页面文件路径  
            }  
        ]  
    }

2.上方配置完成后,我们可以在app.vue 中的onLaunch周期中,写入 uni.hideTabBar() ,此作用是隐藏底部导航,特别注意,因为此api不兼容字节跳动的小程序,所以,想要在字节跳动小程序内使用需要写入tt.hideTabBar()

  1. 然后我们就可以去写上一个底部导航栏的组件,这个就是一个组件,我想大家应该都会写的,下面是我项目中写的一份


4.把此组件引入在底部导航栏的页面就可以了,这样就能较为完美的解决底部导航栏这一问题,有兴趣的开发者可以一试,至少本人写自定义导航栏一直都是这么写的,嘿嘿
当然,我依然还是推荐原生的写法,不要整那么多花里胡哨的,除了好看,一无是处,只要是自定义底部导航栏总会有那么几个性能的问题,所以建议还是要给经理,客户,老板提提建议,这样我们开发人员也能省点劲

翻看大厂的微信小程序都是原生配置的底部导航栏,为什么老板总觉得不好看,我觉得还可以啊0.0,脑壳疼

收起阅读 »

v3编译遇到的问题

v3

一开始如图中疯狂报错cid unmatched [object Object] at view.umd.min.js:1
10:21:33.673 TypeError: Invalid attempt to destructure non-iterable instance.
10:21:33.693 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1,找不出原因,然后网上百度到的内容说循环遍历出了问题,由于我的app其他列表是好的就这一个出问题,然后我就与其他列表做对比,发现写循环时一开始是这么写的<station v-for="station in stationList" :station="station" :key="station.id" />
而其他列表中则是<station v-for="station in stationList" :station="station" :key="station.stationId" />更改完之后问题就解决了

继续阅读 »

一开始如图中疯狂报错cid unmatched [object Object] at view.umd.min.js:1
10:21:33.673 TypeError: Invalid attempt to destructure non-iterable instance.
10:21:33.693 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1,找不出原因,然后网上百度到的内容说循环遍历出了问题,由于我的app其他列表是好的就这一个出问题,然后我就与其他列表做对比,发现写循环时一开始是这么写的<station v-for="station in stationList" :station="station" :key="station.id" />
而其他列表中则是<station v-for="station in stationList" :station="station" :key="station.stationId" />更改完之后问题就解决了

收起阅读 »

在调用的时候就知道API对不同平台的支持

HBuilder X

现在遇到一个特别麻烦的事情,uni-app混合了H5、小程序、uni-app自己的语言,很多时候不知道H5不能在app端用,写完之后发现不能用来回调试。

能否让HBuilderX工具更智能一些,调用的时候就告诉这个API能在哪个平台使用,可以为开发者节约很多的时间。

继续阅读 »

现在遇到一个特别麻烦的事情,uni-app混合了H5、小程序、uni-app自己的语言,很多时候不知道H5不能在app端用,写完之后发现不能用来回调试。

能否让HBuilderX工具更智能一些,调用的时候就告诉这个API能在哪个平台使用,可以为开发者节约很多的时间。

收起阅读 »

app进入后台,多任务管理器,界面变毛玻璃高斯模糊、透明效果

app进入后台毛玻璃高斯模糊效果(ios):https://ext.dcloud.net.cn/plugin?id=2373
app进入后台透明效果、应用内禁止截屏(andorid):https://ext.dcloud.net.cn/plugin?id=2379

继续阅读 »

app进入后台毛玻璃高斯模糊效果(ios):https://ext.dcloud.net.cn/plugin?id=2373
app进入后台透明效果、应用内禁止截屏(andorid):https://ext.dcloud.net.cn/plugin?id=2379

收起阅读 »

苹果上架好难呀 准则4.3 -设计 请问下 这么修改

准则4.3 -设计

我们注意到您的app提供的功能设置与提交到app Store的其他app相同;它只是在内容或语言上有所不同,这被认为是垃圾邮件的一种形式。

准则4.3 -设计

我们注意到您的app提供的功能设置与提交到app Store的其他app相同;它只是在内容或语言上有所不同,这被认为是垃圾邮件的一种形式。

android自动截图,并利用插件canvas生成可自定义的图片分享到微信(5+接口因为map地图和echarts截图后会出现黑色部分)

第一步:自动截图
使用的插件市场的大佬:https://ext.dcloud.net.cn/plugin?id=1886
// 转码
getBase64ByUri(screenrShotUri) {
console.log("654321");
return new Promise((resolve, reject) => {
try {
console.log("123456");
plus.io.resolveLocalFileSystemURL(
screenrShotUri,
function(entry) {
// 可通过entry对象操作test.html文件
// console.log("可通过entry对象操作test.html文件");
entry.file(function(file) {
var fileReader = new plus.io.FileReader();
// console.log("getFile:" + JSON.stringify(file));

                            fileReader.onloadend = function(evt) {  
                                // console.log(evt.target.result)  
                                resolve(evt.target.result);  
                            };  
                            // fileReader.readAsText(file, 'utf-8');  
                            fileReader.readAsDataURL(file);  
                        });  
                    },  
                    function(e) {  
                        console.log('Resolve file URL failed: ', e);  
                        uni.showToast({  
                            title: '图片读取失败',  
                            icon: 'none'  
                        });  
                        reject();  
                    }  
                );  
            } catch (e) {  
                uni.showToast({  
                    title: '图片读取失败',  
                    icon: 'none'  
                });  
                reject();  
            }  
        });  
    },  
    // 分享  
    shareTraing() {  
        const ssTest = uni.requireNativePlugin('hsj-screenshothsj');  
        ssTest.handle2ScreenShotNotDialogFuncV2({ msg: 'handle2ScreenShotNotDialogFuncV2 ...' }, result => {  
            switch (result.type) {  
                case 0:  
                    this.backText.push(result.data.toString());  
                    break;  
                case 1:  
                    //显示图片  
                    this.src = result.data.toString();  
                    console.log(this.src);  
                    this.getBase64ByUri(this.src).then(res => {  
                        // console.log(res)  
                        this.src = res;  
                        // this.istestshow = true  
                        this.shareFc();  
                    });  
                    this.backText.push('-图片地址路径:' + result.data.toString());  

                    break;  
                default:  
                    console.log('no have type');  
            }  
        });  

另附上5+的方法:
/ let pages = getCurrentPages();
let page = pages[pages.length - 1];
// #ifdef APP-PLUS
let ws = page.$getAppWebview();
// #endif
// ws.append(this.mapCtx);
let bitmap = new plus.nativeObj.Bitmap('drawScreen');
// 将webview内容绘制到Bitmap对象中
ws.draw(bitmap, () => {
// 保存图片到本地
bitmap.save("_doc/"+new Date().getTime()+".jpg", {
overwrite: true
}, res => {
console.log(res.target); // 图片地址
}, error => {
console.log(JSON.stringify(error)); // 保存失败信息
});
bitmap.clear(); // 清除Bitmap对象
}, error => {
console.log(JSON.stringify(error)); // 绘制失败
}, {
check: true, // 设置为检测白屏
});
/

第二步:将截图自定义成想要的图片
插件大佬:https://ext.dcloud.net.cn/plugin?id=471#custom
// 画布
async shareFc() {
try {
_app.log('准备生成:' + new Date())
const d = await getSharePoster({
_this: this, //若在组件中使用 必传
type: 'testShareType',
formData: {
//访问接口获取背景图携带自定义数据

                },  
                posterCanvasId: this.canvasId,  //canvasId  
                delayTimeScale: 20, //延时系数  
                backgroundImage: this.src,  
                drawArray: ({  
                    bgObj,  
                    type,  
                    bgScale  
                }) => {  
                    const dx = bgObj.width * 0.3;  
                    const fontSize = bgObj.width * 0.045;  
                    const lineHeight = bgObj.height * 0.06;  
                    //可直接return数组,也可以return一个promise对象, 但最终resolve一个数组, 这样就可以方便实现后台可控绘制海报  
                    return new Promise((rs, rj) => {  
                        rs([{  
                                type: 'custom',  
                                setDraw(Context) {  
                                    Context.setFillStyle('black');  
                                    Context.setGlobalAlpha(0.7);  
                                    Context.fillRect(0, bgObj.height - bgObj.height * 0.13, bgObj.width, bgObj.height * 0.13);  
                                    Context.setGlobalAlpha(1);  
                                }  
                            },  
                            {  
                                type: 'image',  
                                url: 'http://哈哈哈哈.png', // 图标或者用户头像  
                                alpha: 1,  
                                dx,  
                                dy: bgObj.height - bgObj.width * 0.25,  
                                infoCallBack(imageInfo) {  
                                    let scale = bgObj.width * 0.2 / imageInfo.height;  
                                    return {  
                                        circleSet: {  
                                            x: imageInfo.width * scale / 2,  
                                            y: bgObj.width * 0.2 / 2,  
                                            r: bgObj.width * 0.2 / 2  
                                        }, // 圆形图片 , 若circleSet与roundRectSet一同设置 优先circleSet设置  
                                        dWidth: imageInfo.width * scale, // 因为设置了圆形图片 所以要乘以2  
                                        dHeight: bgObj.width * 0.2,  
                                        /* roundRectSet: { // 圆角矩形  
                                            r: imageInfo.width * .1  
                                        } */  
                                    }  
                                }  
                            },  
                            {  
                                type: 'text',  
                                text: 'app 名称或者其他想要展示的文字',  
                                fontWeight: 'bold',  
                                size: fontSize,  
                                color: 'white',  
                                alpha: 1,  
                                textAlign: 'left',  
                                textBaseline: 'middle',  
                                serialNum: 1,  
                                infoCallBack(textLength) {  
                                    return {  
                                        dx: bgObj.width - textLength - fontSize,  
                                        dy: bgObj.height - lineHeight + 20  
                                    }  
                                }  
                            },  
                            {  
                                type: 'qrcode',  
                                text: 'http:/我的 app下载连接aab0e4d9ebd89d.apk', // 这里是可以将连接或者文件,生成二维码。  
                                size: bgObj.width * 0.2,  
                                dx: bgObj.width*0.05,  
                                dy: bgObj.height - bgObj.width*0.25  
                            }  
                        ]);  
                    })  
                },  
                setCanvasWH: ({  
                    bgObj,  
                    type,  
                    bgScale  
                }) => { // 为动态设置画布宽高的方法,  
                    this.poster = bgObj;  
                }  
            });  
            _app.log('海报生成成功, 时间:' + new Date() + ', 临时路径: ' + d.poster.tempFilePath)  
            this.poster.finalPath = d.poster.tempFilePath;  
            this.qrShow = true;  
        } catch (e) {  
            _app.hideLoading();  
            _app.showToast(JSON.stringify(e));  
            console.log(JSON.stringify(e));  
        }  
    },  
    saveImage() {  
        // #ifndef H5  
        uni.saveImageToPhotosAlbum({  
            filePath: this.poster.finalPath,  
            success(res) {  
                _app.showToast('保存成功');  
            }  
        })  
        // #endif  
        // #ifdef H5  
        _app.showToast('保存了');  
        // #endif  
    },  
    share() {  
        // #ifdef APP-PLUS  
        _app.getShare(false, false, 2, '', '', '', this.poster.finalPath, false, false);  
        // #endif  

        // #ifndef APP-PLUS  
        _app.showToast('分享成功');  
        // #endif  
    },  
继续阅读 »

第一步:自动截图
使用的插件市场的大佬:https://ext.dcloud.net.cn/plugin?id=1886
// 转码
getBase64ByUri(screenrShotUri) {
console.log("654321");
return new Promise((resolve, reject) => {
try {
console.log("123456");
plus.io.resolveLocalFileSystemURL(
screenrShotUri,
function(entry) {
// 可通过entry对象操作test.html文件
// console.log("可通过entry对象操作test.html文件");
entry.file(function(file) {
var fileReader = new plus.io.FileReader();
// console.log("getFile:" + JSON.stringify(file));

                            fileReader.onloadend = function(evt) {  
                                // console.log(evt.target.result)  
                                resolve(evt.target.result);  
                            };  
                            // fileReader.readAsText(file, 'utf-8');  
                            fileReader.readAsDataURL(file);  
                        });  
                    },  
                    function(e) {  
                        console.log('Resolve file URL failed: ', e);  
                        uni.showToast({  
                            title: '图片读取失败',  
                            icon: 'none'  
                        });  
                        reject();  
                    }  
                );  
            } catch (e) {  
                uni.showToast({  
                    title: '图片读取失败',  
                    icon: 'none'  
                });  
                reject();  
            }  
        });  
    },  
    // 分享  
    shareTraing() {  
        const ssTest = uni.requireNativePlugin('hsj-screenshothsj');  
        ssTest.handle2ScreenShotNotDialogFuncV2({ msg: 'handle2ScreenShotNotDialogFuncV2 ...' }, result => {  
            switch (result.type) {  
                case 0:  
                    this.backText.push(result.data.toString());  
                    break;  
                case 1:  
                    //显示图片  
                    this.src = result.data.toString();  
                    console.log(this.src);  
                    this.getBase64ByUri(this.src).then(res => {  
                        // console.log(res)  
                        this.src = res;  
                        // this.istestshow = true  
                        this.shareFc();  
                    });  
                    this.backText.push('-图片地址路径:' + result.data.toString());  

                    break;  
                default:  
                    console.log('no have type');  
            }  
        });  

另附上5+的方法:
/ let pages = getCurrentPages();
let page = pages[pages.length - 1];
// #ifdef APP-PLUS
let ws = page.$getAppWebview();
// #endif
// ws.append(this.mapCtx);
let bitmap = new plus.nativeObj.Bitmap('drawScreen');
// 将webview内容绘制到Bitmap对象中
ws.draw(bitmap, () => {
// 保存图片到本地
bitmap.save("_doc/"+new Date().getTime()+".jpg", {
overwrite: true
}, res => {
console.log(res.target); // 图片地址
}, error => {
console.log(JSON.stringify(error)); // 保存失败信息
});
bitmap.clear(); // 清除Bitmap对象
}, error => {
console.log(JSON.stringify(error)); // 绘制失败
}, {
check: true, // 设置为检测白屏
});
/

第二步:将截图自定义成想要的图片
插件大佬:https://ext.dcloud.net.cn/plugin?id=471#custom
// 画布
async shareFc() {
try {
_app.log('准备生成:' + new Date())
const d = await getSharePoster({
_this: this, //若在组件中使用 必传
type: 'testShareType',
formData: {
//访问接口获取背景图携带自定义数据

                },  
                posterCanvasId: this.canvasId,  //canvasId  
                delayTimeScale: 20, //延时系数  
                backgroundImage: this.src,  
                drawArray: ({  
                    bgObj,  
                    type,  
                    bgScale  
                }) => {  
                    const dx = bgObj.width * 0.3;  
                    const fontSize = bgObj.width * 0.045;  
                    const lineHeight = bgObj.height * 0.06;  
                    //可直接return数组,也可以return一个promise对象, 但最终resolve一个数组, 这样就可以方便实现后台可控绘制海报  
                    return new Promise((rs, rj) => {  
                        rs([{  
                                type: 'custom',  
                                setDraw(Context) {  
                                    Context.setFillStyle('black');  
                                    Context.setGlobalAlpha(0.7);  
                                    Context.fillRect(0, bgObj.height - bgObj.height * 0.13, bgObj.width, bgObj.height * 0.13);  
                                    Context.setGlobalAlpha(1);  
                                }  
                            },  
                            {  
                                type: 'image',  
                                url: 'http://哈哈哈哈.png', // 图标或者用户头像  
                                alpha: 1,  
                                dx,  
                                dy: bgObj.height - bgObj.width * 0.25,  
                                infoCallBack(imageInfo) {  
                                    let scale = bgObj.width * 0.2 / imageInfo.height;  
                                    return {  
                                        circleSet: {  
                                            x: imageInfo.width * scale / 2,  
                                            y: bgObj.width * 0.2 / 2,  
                                            r: bgObj.width * 0.2 / 2  
                                        }, // 圆形图片 , 若circleSet与roundRectSet一同设置 优先circleSet设置  
                                        dWidth: imageInfo.width * scale, // 因为设置了圆形图片 所以要乘以2  
                                        dHeight: bgObj.width * 0.2,  
                                        /* roundRectSet: { // 圆角矩形  
                                            r: imageInfo.width * .1  
                                        } */  
                                    }  
                                }  
                            },  
                            {  
                                type: 'text',  
                                text: 'app 名称或者其他想要展示的文字',  
                                fontWeight: 'bold',  
                                size: fontSize,  
                                color: 'white',  
                                alpha: 1,  
                                textAlign: 'left',  
                                textBaseline: 'middle',  
                                serialNum: 1,  
                                infoCallBack(textLength) {  
                                    return {  
                                        dx: bgObj.width - textLength - fontSize,  
                                        dy: bgObj.height - lineHeight + 20  
                                    }  
                                }  
                            },  
                            {  
                                type: 'qrcode',  
                                text: 'http:/我的 app下载连接aab0e4d9ebd89d.apk', // 这里是可以将连接或者文件,生成二维码。  
                                size: bgObj.width * 0.2,  
                                dx: bgObj.width*0.05,  
                                dy: bgObj.height - bgObj.width*0.25  
                            }  
                        ]);  
                    })  
                },  
                setCanvasWH: ({  
                    bgObj,  
                    type,  
                    bgScale  
                }) => { // 为动态设置画布宽高的方法,  
                    this.poster = bgObj;  
                }  
            });  
            _app.log('海报生成成功, 时间:' + new Date() + ', 临时路径: ' + d.poster.tempFilePath)  
            this.poster.finalPath = d.poster.tempFilePath;  
            this.qrShow = true;  
        } catch (e) {  
            _app.hideLoading();  
            _app.showToast(JSON.stringify(e));  
            console.log(JSON.stringify(e));  
        }  
    },  
    saveImage() {  
        // #ifndef H5  
        uni.saveImageToPhotosAlbum({  
            filePath: this.poster.finalPath,  
            success(res) {  
                _app.showToast('保存成功');  
            }  
        })  
        // #endif  
        // #ifdef H5  
        _app.showToast('保存了');  
        // #endif  
    },  
    share() {  
        // #ifdef APP-PLUS  
        _app.getShare(false, false, 2, '', '', '', this.poster.finalPath, false, false);  
        // #endif  

        // #ifndef APP-PLUS  
        _app.showToast('分享成功');  
        // #endif  
    },  
收起阅读 »

composition-api 在 uni-app 微信小程序中的使用

微信小程序

一开始我按照 composition-api 官方文档 中所说的引入 import VueCompositionAPI from "@vue/composition-api"; 然后使用 Vue.use(VueCompositionAPI); 在开发模式下一切完美。

但编译之后就不行了,在网上找到了 https://github.com/dcloudio/uni-app/issues/1839 ,里面有我的解决方案,但修改 npm 包终究不太好,刚刚终于研究出了在main.js 中使用一段代码解决这个问题的方法

  /** uni-app composition api补丁 */ (() => {  
    /** uni-app 会在 beforeUpdate 的时候调用这个函数来进行和微信进程数据的交换 */  
    const oldPatch = Vue.prototype.__patch__ as Function;  
    Vue.prototype.__patch__ = function(...arg: any) {  
      补丁(this);  
      oldPatch.call(this, ...arg);  
    };  

    function 补丁(vm: any) {  
      if (vm._computedWatchers === undefined) {  
        vm._computedWatchers = {};  
      }  
      const ret = vm._data;  
      var rawBindings = getRawBindings(vm);  
      if (rawBindings) {  
        Object.keys(rawBindings).forEach(function(key) {  
          // && vm.mpType === "component"  
          if (config.is_dev) {  
            /** 开发版补丁 */  
            const v = rawBindings[key];  
            // console.log("[ret[key]] " + key, ret[key], v);  
            if (isRef(v)) {  
              if (isReadonly(v)) {  
                /**  只读的值一般是计算属性,所以放到computed中,要是放到data中uni-app会尝试写,这样导致报错 */  
                vm._computedWatchers[key] = v;  
              } else {  
                ret[key] = v.value;  
              }  
            } else {  
              ret[key] = v;  
            }  
          } else {  
            /** 编译版补丁 */  
            ret[key] = undefined;  
          }  
        });  
      }  
    }  
    function getRawBindings(vm: any) {  
      return vm.__composition_api_state__ && vm.__composition_api_state__.rawBindings;  
    }  
  })();

只需要在加上这段代码即可编译后也能正常使用 composition-api 了。composition-api 真滴香

继续阅读 »

一开始我按照 composition-api 官方文档 中所说的引入 import VueCompositionAPI from "@vue/composition-api"; 然后使用 Vue.use(VueCompositionAPI); 在开发模式下一切完美。

但编译之后就不行了,在网上找到了 https://github.com/dcloudio/uni-app/issues/1839 ,里面有我的解决方案,但修改 npm 包终究不太好,刚刚终于研究出了在main.js 中使用一段代码解决这个问题的方法

  /** uni-app composition api补丁 */ (() => {  
    /** uni-app 会在 beforeUpdate 的时候调用这个函数来进行和微信进程数据的交换 */  
    const oldPatch = Vue.prototype.__patch__ as Function;  
    Vue.prototype.__patch__ = function(...arg: any) {  
      补丁(this);  
      oldPatch.call(this, ...arg);  
    };  

    function 补丁(vm: any) {  
      if (vm._computedWatchers === undefined) {  
        vm._computedWatchers = {};  
      }  
      const ret = vm._data;  
      var rawBindings = getRawBindings(vm);  
      if (rawBindings) {  
        Object.keys(rawBindings).forEach(function(key) {  
          // && vm.mpType === "component"  
          if (config.is_dev) {  
            /** 开发版补丁 */  
            const v = rawBindings[key];  
            // console.log("[ret[key]] " + key, ret[key], v);  
            if (isRef(v)) {  
              if (isReadonly(v)) {  
                /**  只读的值一般是计算属性,所以放到computed中,要是放到data中uni-app会尝试写,这样导致报错 */  
                vm._computedWatchers[key] = v;  
              } else {  
                ret[key] = v.value;  
              }  
            } else {  
              ret[key] = v;  
            }  
          } else {  
            /** 编译版补丁 */  
            ret[key] = undefined;  
          }  
        });  
      }  
    }  
    function getRawBindings(vm: any) {  
      return vm.__composition_api_state__ && vm.__composition_api_state__.rawBindings;  
    }  
  })();

只需要在加上这段代码即可编译后也能正常使用 composition-api 了。composition-api 真滴香

收起阅读 »

ios toDataURL 问题

修改 ios 打包时的内核

tips:
首先 要确保 海报生成 在safai 正常,多看看 html2canvas 的使用,调整

修改 ios 打包时的内核

tips:
首先 要确保 海报生成 在safai 正常,多看看 html2canvas 的使用,调整

电话状态监听、接听电话、挂断电话、来电自动接听、来电自动挂断、回调手机号码(ios、android)

电话状态监听、接听电话、挂断电话、来电自动接听、来电自动挂断、回调手机号码(ios、android):https://ext.dcloud.net.cn/plugin?id=8756

继续阅读 »

电话状态监听、接听电话、挂断电话、来电自动接听、来电自动挂断、回调手机号码(ios、android):https://ext.dcloud.net.cn/plugin?id=8756

收起阅读 »