diff --git a/cloudfunctions/openapi/index.js b/cloudfunctions/openapi/index.js
index e17b789..dbe6265 100644
--- a/cloudfunctions/openapi/index.js
+++ b/cloudfunctions/openapi/index.js
@@ -5,6 +5,7 @@ cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV})
exports.main = async (event, context) => {
+ console.log("调用云函数openapi, 参数event:", event);
let {name, data} = event;
switch (event.name||event.action) {
case "wxacode.getUnlimited":
@@ -17,7 +18,9 @@ exports.main = async (event, context) => {
}
case "security.msgSecCheck":{
try{
+ console.log("检查文本安全, 参数:", data);
var res = await cloud.openapi.security.msgSecCheck(data);
+ console.log("返回结果: ", res);
return res;
}catch(e){
return e;
@@ -25,13 +28,21 @@ exports.main = async (event, context) => {
}
case "security.imgSecCheck":{
try{
- console.log(data);
+ console.log("检查图片安全, 参数:", data);
+ if(data.media)
+ var value = Buffer.from(data.media);
+ else if(data.fileID){
+ var {fileID} = data;
+ var res = await cloud.downloadFile({fileID});
+ var value = res.fileContent;
+ }
var res = await cloud.openapi.security.imgSecCheck({
media:{
- contentType:"image/jpg",
- value:Buffer.from(data.media)
+ contentType:"image/png",
+ value
}
});
+ console.log("返回结果: ", res);
return res;
}catch(e){
return e;
diff --git a/miniprogram/account/pages/profile/add-department/add-department.js b/miniprogram/account/pages/profile/add-department/add-department.js
index a680613..876e748 100644
--- a/miniprogram/account/pages/profile/add-department/add-department.js
+++ b/miniprogram/account/pages/profile/add-department/add-department.js
@@ -1,4 +1,23 @@
const app = getApp();
+import {throttle} from "../../../../js/utils";
+const risk_message = "检测到内容含有敏感词汇";
+function msgSecCheck({name="", remarks=""}){
+ let content = name+","+ remarks;
+ console.log("msgsecCheck", content);
+ if(this.tmp_promise&&this.tmp_content==content)
+ return this.tmp_promise;
+ this.tmp_promise = app.openapi("security.msgSecCheck")({content});
+ this.tmp_content = content;
+ this.tmp_promise.then(res=>{
+ if(res.errCode==87014){
+ wx.showToast({
+ title: risk_message,icon:"none",duration:4000
+ })
+ }
+ })
+ return this.tmp_promise;
+}
+
Component({
properties: {
show:{
@@ -12,7 +31,9 @@ Component({
buttons:[
{text:"取消"},
{text:"提交"}
- ]
+ ],
+ name: "",
+ remarks:""
},
methods: {
cancel(){
@@ -20,9 +41,11 @@ Component({
},
updateName({detail:{value}}){
this.setData({name:value});
+ this.throttledMsgSecCheck(this.data);
},
updateRemarks({detail:{value}}){
this.setData({remarks:value});
+ this.throttledMsgSecCheck(this.data);
},
checkInput(){
if(!this.data.name)
@@ -31,15 +54,16 @@ Component({
})&&false;
return true;
},
+ throttledMsgSecCheck:throttle(msgSecCheck, 1000, {}),
+ msgSecCheck,
submit(){
if(!this.checkInput())
return;
let {remarks, name, school_id} = this.data;
- let content = name + (remarks?","+remarks:'');
wx.showLoading({
title: '检查内容中...'
})
- app.callOpenapi({name:"security.msgSecCheck",data:{content},success:res=>{
+ this.msgSecCheck({name, remarks}).then(res=>{
if(res.errCode==0){
wx.showLoading({
title: '正在添加'
@@ -58,12 +82,18 @@ Component({
}else{
wx.hideLoading();
- wx.showToast({
- title: '内容含有敏感词汇',icon:"none"
- });
+ wx.showModal({
+ content:risk_message,
+ showCancel:false
+ })
}
- }});
- ;
+ }).catch(e=>{
+ //app.showError(e);
+ wx.showToast({
+ title: '出错了\n>_<',icon:"none"
+ })
+ throw e;
+ })
},
onTapButton({detail}){
if(detail.index==0)
diff --git a/miniprogram/account/pages/profile/add-department/add-department.wxml b/miniprogram/account/pages/profile/add-department/add-department.wxml
index cc544e6..d08f610 100644
--- a/miniprogram/account/pages/profile/add-department/add-department.wxml
+++ b/miniprogram/account/pages/profile/add-department/add-department.wxml
@@ -1,19 +1,16 @@
-
\ No newline at end of file
diff --git a/miniprogram/account/pages/profile/profile.js b/miniprogram/account/pages/profile/profile.js
index 5615ed2..29a8916 100644
--- a/miniprogram/account/pages/profile/profile.js
+++ b/miniprogram/account/pages/profile/profile.js
@@ -1,5 +1,24 @@
+import {throttle} from "../../../js/utils";
const app = getApp();
var locationData = require("./data.js");
+const risk_message = "检测到名称中含有敏感词汇";
+
+function msgSecCheck({name, nickname}){
+ let content = name+","+nickname;
+ console.log("secCheck", content);
+ if(this.tmp_promise&&this.tmp_content==content)
+ return this.tmp_promise;
+ this.tmp_promise = app.openapi("security.msgSecCheck")({content});
+ this.tmp_content = content;
+ this.tmp_promise.then(res=>{
+ if(res.errCode==87014){
+ wx.showToast({
+ title: risk_message,icon:"none",duration:4000
+ })
+ }
+ })
+ return this.tmp_promise;
+}
Page({
data: {
@@ -23,6 +42,16 @@ Page({
this.showError(e);
});
},
+ msgSecCheck,
+ throttledMsgSecCheck: throttle(msgSecCheck, 1000, {}),
+ updateNickName({detail:{value}}){
+ this.setData({nickname: value});
+ this.throttledMsgSecCheck(this.data);
+ },
+ updateName({detail:{value}}){
+ this.setData({name: value});
+ this.throttledMsgSecCheck(this.data);
+ },
setInfo(res){
let locations = Object.keys(locationData);
let location_index = locations.indexOf(res.location);
@@ -83,7 +112,6 @@ Page({
this.setData({identity_index:value, technical_index:-1});
},
onTechnicalChange(e){
- ;
let { detail: { value } } = e;
this.setData({technical_index: value});
},
@@ -140,7 +168,6 @@ Page({
},
checkProInfo(value){
let info = this.originInfo;
- ;
if (info.identity != value.identity)
return true;
if(info.identity=='student'){
@@ -156,7 +183,6 @@ Page({
},
onSubmit(e){
let {detail:{value}} = e;
- ;
if(!this.checkInput(value)) return;
if(this.data.pro_authen&&this.checkProInfo(value)){
wx.showModal({
@@ -168,8 +194,9 @@ Page({
this.saveInfo(value);
}
});
- }else
+ }else{
this.saveInfo(value);
+ }
},
checkInput(value){
var showTip = key=>{
@@ -204,20 +231,33 @@ Page({
},
saveInfo(value){
value.gender = parseInt(value.gender);
- app.api("users.accounts", { method: "PUT" })(value)
- .then(res => {
- app.syncUser({refresh:1});
- res.message = "更新成功";
- app.showMsg(res);
- ;
- setTimeout(() => {
- wx.navigateBack({
- delta: 1
- })
- }, 420);
- }).catch(e => {
- this.showError(e);
- })
+ this.msgSecCheck(value).then(res=>{
+ if(res.errCode==87014){
+ wx.showModal({
+ content: risk_message,showCancel:false
+ })
+ }else{
+ app.api("users.accounts", { method: "PUT" })(value)
+ .then(res => {
+ app.syncUser({refresh:1});
+ res.message = "更新成功";
+ app.showMsg(res);
+ setTimeout(() => {
+ wx.navigateBack({
+ delta: 1
+ })
+ }, 420);
+ }).catch(e => {
+ this.showError(e);
+ })
+ }
+ }).catch(e=>{
+ wx.showToast({
+ title: '出错了\n>︿<',icon:"none"
+ });
+ throw e;
+ })
+
},
onTap(e){
;
diff --git a/miniprogram/account/pages/profile/profile.wxml b/miniprogram/account/pages/profile/profile.wxml
index a71a366..2927c1a 100644
--- a/miniprogram/account/pages/profile/profile.wxml
+++ b/miniprogram/account/pages/profile/profile.wxml
@@ -11,14 +11,14 @@
昵称头像
-
+
姓名
-
+
显示姓名
diff --git a/miniprogram/app.js b/miniprogram/app.js
index 0ce0297..cf2bd5b 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -24,7 +24,6 @@ App({
return new Promise((resolve, reject)=>{
return wx.cloud.callFunction({name, data,
success:res=>{
- console.log(Date.now(), "success");
success&&success(res.result);
resolve(res.result);
complete&&complete(res.result);
diff --git a/miniprogram/setting/pages/image_crop/image_crop.js b/miniprogram/setting/pages/image_crop/image_crop.js
index 5e42dfa..00de37e 100644
--- a/miniprogram/setting/pages/image_crop/image_crop.js
+++ b/miniprogram/setting/pages/image_crop/image_crop.js
@@ -1,5 +1,6 @@
import WeCropper from '../../we-cropper/dist/we-cropper.min.js'
+const rich_message = "检测到所选的图片中有敏感内容,请选择其他图片";
const app = getApp();
Page({
@@ -20,17 +21,26 @@ Page({
touchEnd(e) {
this.mycropper.touchEnd(e)
},
+ async _checkImg({path}){
+ let cloudPath = "images/avatars/"+ path.replace(/[\/\\:]/g, "_");
+ let res = await wx.cloud.uploadFile({
+ cloudPath,
+ filePath: path
+ });
+ let {fileID} = res;
+ return app.openapi("security.imgSecCheck")({fileID});
+ },
checkImg({path}){
if(this.promise&&path==this.tmp_path)
return this.promise;
let buffer = wx.getFileSystemManager().readFileSync(path);
- this.promise = app.openapi("security.imgSecCheck")({media: buffer});
+ this.promise = this._checkImg({path});
this.tmp_path = path;
this.promise.then(res=>{
console.log(res);
if(res.errCode==87014){
wx.showToast({
- title:"检测所选的图片有敏感内容,请重新选择图片",icon: "none"
+ title:rich_message,icon: "none",duration:5000
})
}
});
@@ -39,7 +49,7 @@ Page({
onConfirm(){
if(!this.mycropper||!this.mycropper.src)
return wx.showToast({
- title: '请选取图片',icon:"none"
+ title: '请先选取图片',icon:"none"
})
let {src} = this.mycropper;
wx.showLoading({
@@ -51,19 +61,22 @@ Page({
else if(res.errCode==87014){
wx.hideLoading();
wx.showModal({
- content:"检测所选图片有敏感内容,请重新选择图片",showCancel: false
+ content:rich_message,showCancel: false
})
}else{
wx.showToast({
title: '发生了未知错误',icon:"none"
});
wx.reportMonitor('2', 1);
- global.realTimeLog.error("未知错误 checkImg");
+ global.realTimeLog.error("未知错误 checkImg1");
global.realTimeLog.setFilterMsg("unexpected");
}
}).catch(e=>{
wx.hideLoading();
app.showError(e);
+ wx.reportMonitor('2', 1);
+ global.realTimeLog.error("未知错误 checkImg2");
+ global.realTimeLog.setFilterMsg("unexpected");
})
},
uploadAvartar(filePath) {
@@ -95,7 +108,7 @@ Page({
wx.navigateBack({
delta: 1
});
- },400);
+ },500);
}).catch(e => {
wx.showToast({
title: '上传失败',