| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- {{define "setting_bottom"}}
- <script>
- var ACTION="{{.action}}";
- var QINIU_DOMAIN="{{.qiniu_domain}}";
- </script>
- <script>
- var app=new Vue({
- el: '#app',
- delimiters:["<{","}>"],
- data: {
- iframeUrl:"/setting_statistics",
- fullscreenLoading:false,
- openIndex:[1],
- account: {
- username: "",
- password: "",
- },
- mysql: {
- server: "",
- port: "",
- database: "",
- username: "",
- password: "",
- },
- rules: {
- server: [
- { required: true, message: '请输入服务地址', trigger: 'blur' },
- ],
- port: [
- { required: true, message: '请输入端口号', trigger: 'blur' },
- ],
- database: [
- { required: true, message: '请输入数据库名', trigger: 'blur' },
- ],
- username: [
- { required: true, message: '请输入用户名', trigger: 'blur' },
- ],
- name: [
- { required: true, message: '请输入用户名', trigger: 'blur' },
- ],
- avator: [
- { required: true, message: '请选择头像', trigger: 'blur' },
- ],
- role_id: [
- { required: true, message: '请选择角色', trigger: 'blur' },
- ],
- password: [
- { required: true, message: '请输入密码', trigger: 'blur' },
- ],
- nickname: [
- { required: true, message: '请输入昵称', trigger: 'blur' },
- ],
- method: [
- { required: true, message: '请输入允许的方法', trigger: 'blur' },
- ],
- path: [
- { required: true, message: '请输入允许的路径', trigger: 'blur' },
- ],
- },
- kefuList:[],
- kefuDialog:false,
- kefuForm:{
- id:"",
- name:"",
- password:"",
- avator:"",
- nickname:"",
- role_name:"",
- role_id:"",
- enabled:0,
- },
- enabledItems: [
- {id:2, text: "禁用"},
- {id:1, text: "启用"}
- ],
- domain: QINIU_DOMAIN,
- roleList:[],
- configList:[],
- roleDialog:false,
- noticeList:[],
- welcomeDialog:false,
- ipblackList:[],
- welcomeForm: {
- content: "",
- },
- roleForm:{
- id:"",
- name:"",
- method:"",
- path:"",
- },
- statistics:{},
- pageindex: {
- title_cn: "",
- title_en: "",
- keywords_cn: "",
- keywords_en: "",
- desc_cn: "",
- desc_en: "",
- css_js: "",
- html_cn: "",
- html_en: "",
- },
- },
- methods: {
- //提交表单
- setAccount(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- $.post("/setting_account",_this.account,function(data){
- if(data.code==200){
- _this.$message({
- message: data.msg,
- type: 'success'
- });
- }else{
- _this.$message({
- message: data.msg,
- type: 'error'
- });
- }
- });
- } else {
- return false;
- }
- });
- },
- //设置mysql
- setMysql(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- $.ajax({
- type:"POST",
- url:"/mysql",
- data:_this.mysql,
- headers:{
- "token":localStorage.getItem("token")
- },
- success: function(data) {
- if(data.code==200){
- _this.$message({
- message: data.msg,
- type: 'success'
- });
- }else{
- _this.$message({
- message: data.msg,
- type: 'error'
- });
- }
- }
- });
- } else {
- return false;
- }
- });
- },
- //重置表单
- resetForm(formName) {
- this.loading=false;
- this.$refs[formName].resetFields();
- },
- //跳转
- openUrl(url){
- //window.location.href=url;
- this.iframeUrl=url;
- },
- //展示提示
- showNotice(){
- this.fullscreenLoading=false;
- this.$message({
- message: '配置信息写入同级config目录,目录不存在会自动创建!',
- type: 'warning',
- duration:'8000',
- showClose:true,
- });
- },
- addWelcome(){
- this.welcomeForm.content="";
- this.welcomeDialog=true;
- },
- //初始化数据
- initInfo(){
- let _this=this;
- if(ACTION=="setting_mysql"){
- this.sendAjax("/mysql","get",{},function(result){
- _this.mysql.username=result.Username;
- _this.mysql.password=result.Password;
- _this.mysql.database=result.Database;
- _this.mysql.server=result.Server;
- _this.mysql.port=result.Port;
- });
- }
- if(ACTION=="setting_kefu_list"){
- this.sendAjax("/kefulist","get",{},function(result){
- _this.kefuList=result;
- });
- this.sendAjax("/roles","get",{},function(result){
- _this.roleList=result;
- });
- }
- if(ACTION=="roles_list"){
- this.sendAjax("/roles","get",{},function(result){
- _this.roleList=result;
- });
- }
- if(ACTION=="setting_statistics"){
- this.sendAjax("/statistics","get",{},function(result) {
- _this.statistics = result;
- });
- }
- if(ACTION=="setting_welcome"){
- this.sendAjax("/notices","get",{},function(result){
- _this.noticeList=result;
- });
- }
- if(ACTION=="setting_ipblack"){
- this.sendAjax("/ipblacks_all","get",{},function(result){
- _this.ipblackList=result.list;
- });
- }
- if(ACTION=="setting_config"){
- this.sendAjax("/configs","get",{},function(result){
- _this.configList=result;
- });
- }
- if(ACTION=="setting_pageindex"){
- this.sendAjax("/about","get",{},function(result){
- _this.pageindex=result;
- });
- }
- },
- sendAjax(url,method,params,callback){
- let _this=this;
- $.ajax({
- type: method,
- url: url,
- data:params,
- headers: {
- "token": localStorage.getItem("token")
- },
- success: function(data) {
- if(data.code!=200){
- _this.$message({
- message: data.msg,
- type: 'error'
- });
- }else if(data.result!=null){
- callback(data.result);
- }else{
- callback(data);
- }
- _this.fullscreenLoading=false
- }
- });
- },
- //添加客服的dialog
- addKefu(){
- this.kefuForm={
- id:"",
- name:"",
- password:"",
- avator:"",
- };
- this.kefuDialog=true;
- },
- //提交客服表单
- submitKefuForm(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.sendAjax("/kefuinfo","POST",_this.kefuForm,function(result){
- _this.kefuDialog=false;
- _this.sendAjax("/kefulist","get",{},function(result){
- _this.kefuList=result;
- });
- });
- } else {
- return false;
- }
- });
- },
- //提交欢迎表单
- submitWelcomeForm(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.sendAjax("/notice","POST",_this.welcomeForm,function(result){
- _this.welcomeDialog=false;
- _this.sendAjax("/notices","get",{},function(result){
- _this.noticeList=result;
- });
- });
- } else {
- return false;
- }
- });
- },
- //编辑客服表单
- editKefuForm(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- _this.sendAjax("/kefulist","PUT",_this.kefuForm,function(result){
- _this.kefuList=result;
- });
- } else {
- return false;
- }
- });
- },
- //获取客服
- getKefu(kefuId){
- let _this=this;
- this.sendAjax("/kefuinfo_setting","GET",{kefu_id:kefuId},function(result){
- _this.kefuDialog=true;
- _this.kefuForm=result;
- _this.kefuForm.password="";
- });
- },
- //删除客服
- deleteKefu(kefuId){
- let _this=this;
- this.sendAjax("/kefuinfo?id="+kefuId,"DELETE",{id:kefuId},function(result){
- _this.kefuDialog=false;
- _this.sendAjax("/kefulist","get",{},function(result){
- _this.kefuList=result;
- });
- });
- },
- //删除欢迎
- deleteWelcome(id){
- let _this=this;
- this.sendAjax("/notice?id="+id,"DELETE",{id:id},function(result){
- _this.kefuDialog=false;
- _this.sendAjax("/notices","get",{},function(result){
- _this.noticeList=result;
- });
- });
- },
- //删除ip
- deleteIpblack(ip){
- let _this=this;
- this.sendAjax("/ipblack?ip="+ip,"DELETE",{ip:ip},function(result){
- _this.sendAjax("/ipblacks_all","get",{},function(result){
- _this.ipblackList=result.list;
- });
- });
- },
- //配置角色权限
- showAuthDialog(id,name,method,path){
- this.roleForm.id=id
- this.roleForm.name=name
- this.roleForm.method=method
- this.roleForm.path=path
- this.roleDialog=true;
- },
- //设置配置项
- setConfigItem(key,value){
- let _this=this;
- this.sendAjax("/config","POST",{key:key,value:value},function(result){
- _this.sendAjax("/configs","get",{},function(result){
- _this.configList=result;
- });
- });
- },
- //设置配置项
- setWelcomeItem(id,content){
- let _this=this;
- this.sendAjax("/notice_save","POST",{id:id,content:content},function(result){
- _this.sendAjax("/notices","get",{},function(result){
- _this.noticeList=result;
- });
- });
- },
- //提交角色表单
- submitRoleForm(formName){
- let _this=this;
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.sendAjax("/role","POST",_this.roleForm,function(result){
- _this.roleDialog=false;
- _this.sendAjax("/roles","get",{},function(result){
- _this.roleList=result;
- });
- _this.$message({
- message: result.msg,
- type: 'success'
- });
- });
- } else {
- return false;
- }
- });
- },
- //提交首页表单
- setPageIndex(){
- let _this=this;
- this.sendAjax("/about","POST",this.pageindex,function(result){
- _this.$message({
- message: "编辑成功",
- type: 'success'
- });
- });
- },
- //生成部署js
- createDeployJs(){
- let domain=window.location.host;
- this.$alert(' <script type="text/javascript">\n' +
- ' var GOFLY_KEFU_ID="'+this.kefuForm.name+'";\n' +
- ' <\/script>\n'+
- ' <script type="text/javascript" src="http://'+domain+'/webjs"><\/script>', '网页部署');
- }
- },
- created: function () {
- // if(ACTION=="setting"){
- // this.showNotice();
- // }
- this.initInfo();
- }
- })
- </script>
- </html>
- {{end}}
|