k***@uii.net
k***@uii.net
  • 发布:2021-05-06 16:15
  • 更新:2023-04-19 12:21
  • 阅读:657

【报Bug】网络请求,web端正常,app端部分机型 会返回一段 html标签,打开看像一些检测

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

手机系统: Android

手机系统版本号: Android 7.1.1

手机厂商: 小米

手机机型: Max2

页面类型: vue

打包方式: 云端

项目创建方式: CLI

CLI版本号: 4.5.12

操作步骤:

小米max2,请求接口,就会返回上述奇怪的代码

预期结果:

应该和web端一样返回正常的请求数据

实际结果:
{  
    "data": "<!DOCTYPE html>\n<html>\n<head>\n<meta id=\"viewport\" name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\" />\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n</head>\n<body>\n<script type=\"text/javascript\">\n//获取url参数\nfunction getUrlParam(name) {\n    var reg = new RegExp(\"(^|&)\" + name + \"=([^&]*)(&|$)\", \"i\"),\n        r = decodeURIComponent(window.location.search).substr(1).match(reg);\n    return r!=null ? decodeURI(r[2]) : null;\n}\n\n(function(){\n\tvar ratio = window.devicePixelRatio || 1;\n\tvar UA = String(navigator.userAgent).toLowerCase();\n\t//alert(navigator.userAgent)\n\t//var hasTouch = document.documentElement.ontouchstart !== undefined;\n\tvar isMobile = UA.indexOf('mobile') > -1;\n\t//var isAndroid = UA.indexOf('android') > -1;\n\tvar isIPad = UA.indexOf('ipad') > -1;\n\t//var isIPhone = UA.indexOf('iphone') > -1;\n\t//此方法误判很严重\n\t//var isBigScreen = Math.min(screen.height/ratio,screen.width/ratio) > 600;\n\t//针对点一点扫一扫,跳转结果界面\n\tvar g_type = getUrlParam(\"type\");\n\tvar g_tips = getUrlParam(\"tips\");\n\tvar tabs = getUrlParam(\"tabs\");\n\tvar sms = getUrlParam(\"sms\");\n\t\n\t//检测平台\n\tvar p = String(navigator.platform.toLowerCase()),\n\t\tisWin = p.indexOf(\"win\") == 0,  \n\t\tisMac = p.indexOf(\"mac\") == 0, \n\t\tisX11 = (p == \"x11\") || (p.indexOf(\"linux\") == 0);  \n\t\t\n\tvar template = getUrlParam(\"template\") || \"default\";\n\tvar $href = '';\n\t//1、not mobile //pc\n\t//2、mobile but ipad\n\t//3、big screen //android pad\n\t//4、检测平台\n\tif((isMobile && !isIPad)||!(isWin||isMac||isX11||isIPad)){\n\t\t$href = \"mobile.html\";\n\t\tif(tabs == \"wx\"){\n\t\t\tif (sms != 1){\n\t\t\t\tif(g_type==\"logout\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=success\";\n\t\t\t\t\treturn;\n\t\t\t\t} else if(g_type==\"authfailed\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=failure&g_tips=\"+g_tips;\n\t\t\t\t\treturn;\n\t\t\t\t} else if(g_type==\"authalready\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=warn&g_tips=\"+g_tips;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$href = \"mobile_sms.html\";\n\t\t\t\tlocation.href = template+\"/\"+$href+location.search;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\t\t\n\t}else{\n\t\t$href = \"pc.html\";\n\t}\t\n\tlocation.href = template+\"/\"+$href+location.search;\n})();\n</script>\n</body>\n</html>\n\n",  
    "statusCode": 200,  
    "header": {  
        "Set-Cookie": "AUTHSESSID=8f94d30c53c5; HttpOnly;Secure;",  
        "Content-Length": "2250",  
        "Connection": "keep-alive",  
        "X-Frame-Options": "SAMEORIGIN",  
        "Content-Type": "text/html",  
        "Date": "Thu, 06 May 2021 08:08:00 GMT"  
    },  
    "errMsg": "request:ok",  
    "cookies": ["AUTHSESSID=8f94d30c53c5; HttpOnly;Secure;"]  
}

bug描述:

正常请求一个地址,网页端正常,手机端新机型正常,小米max2 在本地调试的时候,post请求会返回一串奇怪的内容

{  
    "data": "<!DOCTYPE html>\n<html>\n<head>\n<meta id=\"viewport\" name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\" />\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n</head>\n<body>\n<script type=\"text/javascript\">\n//获取url参数\nfunction getUrlParam(name) {\n    var reg = new RegExp(\"(^|&)\" + name + \"=([^&]*)(&|$)\", \"i\"),\n        r = decodeURIComponent(window.location.search).substr(1).match(reg);\n    return r!=null ? decodeURI(r[2]) : null;\n}\n\n(function(){\n\tvar ratio = window.devicePixelRatio || 1;\n\tvar UA = String(navigator.userAgent).toLowerCase();\n\t//alert(navigator.userAgent)\n\t//var hasTouch = document.documentElement.ontouchstart !== undefined;\n\tvar isMobile = UA.indexOf('mobile') > -1;\n\t//var isAndroid = UA.indexOf('android') > -1;\n\tvar isIPad = UA.indexOf('ipad') > -1;\n\t//var isIPhone = UA.indexOf('iphone') > -1;\n\t//此方法误判很严重\n\t//var isBigScreen = Math.min(screen.height/ratio,screen.width/ratio) > 600;\n\t//针对点一点扫一扫,跳转结果界面\n\tvar g_type = getUrlParam(\"type\");\n\tvar g_tips = getUrlParam(\"tips\");\n\tvar tabs = getUrlParam(\"tabs\");\n\tvar sms = getUrlParam(\"sms\");\n\t\n\t//检测平台\n\tvar p = String(navigator.platform.toLowerCase()),\n\t\tisWin = p.indexOf(\"win\") == 0,  \n\t\tisMac = p.indexOf(\"mac\") == 0, \n\t\tisX11 = (p == \"x11\") || (p.indexOf(\"linux\") == 0);  \n\t\t\n\tvar template = getUrlParam(\"template\") || \"default\";\n\tvar $href = '';\n\t//1、not mobile //pc\n\t//2、mobile but ipad\n\t//3、big screen //android pad\n\t//4、检测平台\n\tif((isMobile && !isIPad)||!(isWin||isMac||isX11||isIPad)){\n\t\t$href = \"mobile.html\";\n\t\tif(tabs == \"wx\"){\n\t\t\tif (sms != 1){\n\t\t\t\tif(g_type==\"logout\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=success\";\n\t\t\t\t\treturn;\n\t\t\t\t} else if(g_type==\"authfailed\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=failure&g_tips=\"+g_tips;\n\t\t\t\t\treturn;\n\t\t\t\t} else if(g_type==\"authalready\") {\n\t\t\t\t\tlocation.href = template+\"/result.html?type=warn&g_tips=\"+g_tips;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$href = \"mobile_sms.html\";\n\t\t\t\tlocation.href = template+\"/\"+$href+location.search;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\t\t\n\t}else{\n\t\t$href = \"pc.html\";\n\t}\t\n\tlocation.href = template+\"/\"+$href+location.search;\n})();\n</script>\n</body>\n</html>\n\n",  
    "statusCode": 200,  
    "header": {  
        "Set-Cookie": "AUTHSESSID=8f94d30c53c5; HttpOnly;Secure;",  
        "Content-Length": "2250",  
        "Connection": "keep-alive",  
        "X-Frame-Options": "SAMEORIGIN",  
        "Content-Type": "text/html",  
        "Date": "Thu, 06 May 2021 08:08:00 GMT"  
    },  
    "errMsg": "request:ok",  
    "cookies": ["AUTHSESSID=8f94d30c53c5; HttpOnly;Secure;"]  
}
2021-05-06 16:15 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

你好,请问你解决了吗

要回复问题请先登录注册