|
|
@@ -79,6 +79,105 @@ function put(url, data, isloading=true) {
|
|
|
|
|
|
function del(url, data, isloading=true) {
|
|
|
return $http(url, 'DELETE', data, true, isloading)
|
|
|
+}
|
|
|
+
|
|
|
+//检测文本和图像
|
|
|
+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}/wx/secCheckMsg`,
|
|
|
+ dataType:'json',
|
|
|
+ data:{
|
|
|
+ content:encodeURIComponent(content),
|
|
|
+ openId:JSON.parse(uni.getStorageSync('userInfo')).openId
|
|
|
+ },
|
|
|
+ success:res=>{
|
|
|
+ let result = {};
|
|
|
+ if(res.data.code===0){
|
|
|
+ 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)
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ return reject(err)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }else if(type==2){
|
|
|
+ return new Promise((resolve,reject)=>{
|
|
|
+ wx.uploadFile({
|
|
|
+ method:'POST',
|
|
|
+ url:`${BaseApi}/wx/secCheckImg`,
|
|
|
+ filePath: content,
|
|
|
+ name: 'file',
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/octet-stream'
|
|
|
+ },
|
|
|
+ formData:{
|
|
|
+ media:content
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ let data = JSON.parse(res.data);
|
|
|
+ let result = {code:999,msg:'数据错误'};
|
|
|
+ if(data&&data.code===0){
|
|
|
+ let resu = JSON.parse(data.data);
|
|
|
+ if(!resu) return;
|
|
|
+ result.code = resu.errcode;
|
|
|
+ if(resu.errcode==87014) result.msg = '图片含有敏感违规信息';
|
|
|
+ else if(resu.errcode==40001) result.msg = 'token无效';
|
|
|
+ else if(resu.errcode==40003) result.msg = 'openid无效';
|
|
|
+ else if(resu.errcode==61010) result.msg = '用户访问记录超时';
|
|
|
+ else{
|
|
|
+ result.code = 0;
|
|
|
+ result.msg = '内容正常';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resolve(result)
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ return reject(err)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
@@ -86,5 +185,6 @@ export default {
|
|
|
get,
|
|
|
post,
|
|
|
put,
|
|
|
- del
|
|
|
+ del,
|
|
|
+ detectionContent
|
|
|
}
|