kefu/wechathook/templates/setting_bottom.html

129 lines
4.9 KiB
HTML

<{define "setting_bottom"}>
<script>
new Vue({
el: '#app',
data: {
avatar:"",
nickname:"",
form: {
apiBase: '',
openaiBase: '',
openaiKey: '',
openaiModel: '',
replyTemplate:"",
keywords:"",
finalReply:"",
loopSpeaks:"",
delayTime:"",
groupAIStatus:true,
personAIStatus:true,
groupKeywordStatus:true,
personKeywordStatus:true,
},
settings:[],
contacts:[],
wechatWhiteList:[],
},
methods: {
getWechatInfo(){
let _this=this;
$.get("/wechatInfo",function (res) {
res=JSON.parse(res);
_this.avatar=res.result.avatarUrl;
_this.nickname=res.result.nick;
});
},
getSetting(){
let _this=this;
$.get("/getSetting",function (res) {
console.log(res);
_this.settings=res;
_this.form.apiBase=_this.getConfig("apiBase");
_this.form.openaiBase=_this.getConfig("openaiBase");
_this.form.openaiKey=_this.getConfig("openaiKey");
_this.form.openaiModel=_this.getConfig("openaiModel");
_this.form.replyTemplate=_this.getConfig("replyTemplate");
_this.form.keywords=_this.getConfig("keywords");
_this.form.finalReply=_this.getConfig("finalReply");
_this.form.loopSpeaks=_this.getConfig("loopSpeaks");
_this.form.delayTime=_this.getConfig("delayTime");
_this.form.groupAIStatus=_this.getConfig("groupAIStatus")=="no" ? false:true;
_this.form.personAIStatus=_this.getConfig("personAIStatus")=="no" ? false:true;
_this.form.groupKeywordStatus=_this.getConfig("groupKeywordStatus")=="no" ? false:true;
_this.form.personKeywordStatus=_this.getConfig("personKeywordStatus")=="no" ? false:true;
let wechatWhiteList=_this.getConfig("wechatWhiteList");
_this.wechatWhiteList=wechatWhiteList!="" ? wechatWhiteList.split("|"):[];
});
},
saveSetting(){
let _this=this;
$.post("/postSetting",this.form,function (res) {
_this.$message({
message: "操作成功!",
type: 'success'
});
_this.settings=res;
});
},
getConfig(key){
for(index in this.settings){
if(key==this.settings[index].key){
return this.settings[index].value;
}
}
return "";
},
//修改ai接口开关
wechatAIStatus(){
let _this=this;
$.post("/wechatAIStatus",{
groupAIStatus:this.form.groupAIStatus ? "yes":"no",
personAIStatus:this.form.personAIStatus ? "yes":"no",
groupKeywordStatus:this.form.groupKeywordStatus ? "yes":"no",
personKeywordStatus:this.form.personKeywordStatus ? "yes":"no",
},function (res) {
_this.$message({
message: "操作成功!",
type: 'success'
});
});
},
//保存白名单
saveWhite(){
let _this=this;
$.post("/postSettingByKey",{key:"wechatWhiteList",val:this.wechatWhiteList.join("|"),name:"微信白名单"},function (res) {
_this.$message({
message: "操作成功!",
type: 'success'
});
});
},
//微信hook
wechatHook(){
let _this=this;
$.get("/wechat39825Hook",{},function (res) {
_this.$message({
message: "操作成功!",
type: 'success'
});
});
},
getContacts(){
let _this=this;
$.get("/wechat39825Contacts",function (res) {
res=JSON.parse(res);
_this.contacts=res.data;
});
},
},
mounted:function(){
// this.getWechatInfo();
this.getSetting();
this.getContacts();
},
created: function () {
}
})
</script>
<{end}>