一盘大包子
一盘大包子
  • 发布:2020-06-05 16:29
  • 更新:2020-06-22 13:06
  • 阅读:2370

扫码怎么后自动跳转网址

分类:uni-app
// 二维码扫描成功  
function onmarked(type, result, file){  
    switch(type){  
        case plus.barcode.QR:  
        type = 'QR';//二维码  
        break;  
        case plus.barcode.EAN13:  
        type = 'EAN13';//13位条形码  
        break;  
        case plus.barcode.EAN8:  
        type = 'EAN8';//8位条形码  
        break;  
        default:  
        type = '其它'+type;//其它  
        break;  
    }  
    //判断是不是网址  
    if(result.indexOf('http://')==0  || result.indexOf('https://')==0){  
        //是网址,直接跳转  
        //plus.runtime.openURL(result);//调用手机浏览器  
        //怎么在APP内跳转网址?  
    } else{  
        //不是网址,打印出结果  
        alert(result);  
    }  
}

上面的代码中,result代表完整的http网址,plus.runtime.openURL(result);可以唤起手机浏览器直接打开result网址,但是用什么办法可以在app内部跳转到这个网址呢。我的这个扫码页面已经是外部链接了,是我网站的一个php页面,扫码的结果页是另一个网址,不知道怎么直接跳转。

2020-06-05 16:29 负责人:无 分享
已邀请:
一盘大包子

一盘大包子 (作者)

大佬们求助啊 啊啊啊 啊啊 啊 啊 啊啊啊啊 啊

8***@qq.com

8***@qq.com

创建webview

3***@qq.com

3***@qq.com

plus.webview.open(result, 'new' , { }, 'slide-in-right', 200);

一盘大包子

一盘大包子 (作者)

感谢楼上两位,已经实现跳转,但是又一个新的问题,就是跳转到新的页面之后,点击手机物理返回键,页面会闪一下,然后显示原来的页面,是什么原因。

一盘大包子

一盘大包子 (作者)

if(result.indexOf('http://')==0  || result.indexOf('https://')==0){    
        //是网址,直接跳转    
        plus.webview.open(result, 'id');//跳转  
        //plus.webview.currentWebview().close('none');//关闭方法1  
        //plus.webview.currentWebview().hide();//关闭方法2  
    } else{    
        //不是网址,打印出结果    
        alert(result);    
    }

上面的跳转代码用的合理吗?
关闭的方法用close('none')可以正常,用close()会闪一下再关闭
用hide()也是正常关闭
还想问下,这个关闭的动作是关闭的页面还是窗口?
我的APP打开默认外网的index.php,这个页面也是默认的扫码页面,扫码后打开二维码中的网址,这个关闭动作,关的是我的index,还是扫码跳转的结果页面?
求解答!!!

一盘大包子

一盘大包子 (作者)

顶一下下

一盘大包子

一盘大包子 (作者)

0.0 

aimernos

aimernos

请问一下楼主,uniapp怎么实现扫码功能?[system] API scanCode is not yet implemented,这个该怎么解决

该问题目前已经被锁定, 无法添加新回复