Ver código fonte

文本检测内容方法修改

htc 5 meses atrás
pai
commit
5106010f71
1 arquivos alterados com 41 adições e 11 exclusões
  1. 41 11
      http/index.js

+ 41 - 11
http/index.js

@@ -310,26 +310,56 @@ function del(url, data, json = true, isAuth = true, isBuffer = false) {
 }
 
 //检测文本和图像
-import { BaseApi } from './baseApi.js'
+import { BaseApi } from './baseApi.js';
+const labelCfg = {
+	10001:'含有广告内容',
+	20001:'含有时政内容',
+	20002:'含有色情内容',
+	20003:'含有辱骂内容',
+	20006:'含有违法犯罪内容',
+	20008:'含有欺诈内容',
+	20012:'含有低俗内容',
+	20013:'含有版权内容',
+	21000:'含有其他违规内容'
+}
 async function detectionContent(content,type=1){
 	if(type==1){
+		if(!uni.getStorageSync('userInfo')){
+			return uni.showToast({
+				title:'请先进行登录',
+				icon:'none',
+				duration:1500
+			})
+		}
 		return new Promise((resolve,reject)=>{
 			wx.request({
 				method: 'POST',
 				url:`${BaseApi}/api/app/wx/secCheckMsg`,
 				dataType:'json',
-				data:{content},
+				data:{
+					content,
+					openId:JSON.parse(uni.getStorageSync('userInfo')).openId
+				},
 				success:res=>{
-					let result = {code:999,msg:'数据错误'};
+					let result = {};
 					if(res.data.code===0){
-						result.code = res.data.data.errcode;
-						if(res.data.data.errcode==87014) result.msg = '内容包含敏感违规信息';
-						else if(res.data.data.errcode==40001) result.msg = 'token无效';
-						else if(res.data.data.errcode==40003) result.msg = 'openid无效';
-						else if(res.data.data.errcode==61010) result.msg = '用户访问记录超时';
-						else{
-							result.code = 0;
-							result.msg = '内容正常';
+						let errcode = res.data.data.errcode;
+						result.code = errcode;
+						
+						if(errcode===0){
+							let resu = res.data.data.result;
+							if(resu.label===100){
+								result.code = 0;
+								result.msg = '系统繁忙,请稍后再试';
+							}else{
+								result.code = resu.label;
+								result.msg = labelCfg[resu.label]||'含有其他违规内容';
+							}
+						}else{
+							if(errcode==-1) result.msg = '系统繁忙,请稍后再试';
+							else if(errcode==87014) result.msg = '内容包含敏感违规信息';
+							else if(errcode==40003) result.msg = 'openid无效,请重新登录';
+							else result.msg = '系统错误';
 						}
 					}
 					return resolve(result)