chengkun
2025-09-04 2e12809f4d16aa00239b5e2c6a13a9a51842d134
提交
10 files modified
4 files added
725 ■■■■■ changed files
app/admin/controller/Blog.php 135 ●●●●● patch | view | raw | blame | history
app/admin/controller/OnlineMessage.php 38 ●●●●● patch | view | raw | blame | history
app/admin/validate/Blog.php 20 ●●●● patch | view | raw | blame | history
app/admin/view/blog/add.html 31 ●●●● patch | view | raw | blame | history
app/admin/view/blog/index.html 14 ●●●●● patch | view | raw | blame | history
app/admin/view/common/header.html 8 ●●●● patch | view | raw | blame | history
app/admin/view/online_message/index.html 68 ●●●●● patch | view | raw | blame | history
app/home/controller/Contact.php 36 ●●●●● patch | view | raw | blame | history
app/home/validate/Contact.php 26 ●●●●● patch | view | raw | blame | history
app/home/view/contact/index.html 64 ●●●● patch | view | raw | blame | history
app/home/view/index/index.html 61 ●●●● patch | view | raw | blame | history
public/static/admin/js/blog/add.js 31 ●●●●● patch | view | raw | blame | history
public/static/admin/js/blog/index.js 105 ●●●●● patch | view | raw | blame | history
public/static/admin/js/online_message/index.js 88 ●●●●● patch | view | raw | blame | history
app/admin/controller/Blog.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
use think\facade\Db;
use think\Exception;
use think\exception\ValidateException;
use think\facade\Filesystem;
@@ -13,10 +14,65 @@
        return View::fetch('index');
    }
    
    public function add(): string {
    public function get_blog_list() {
        try {
            $page   = input('page', 1);
            $limit  = input('limit', 10);
            $where  = [];
            $total  = Db::name('blog')->where($where)->count();
            $list   = Db::name('blog')->where($where)->order('id desc')->page($page, $limit)->select()->toArray();
            $result = [
                'code'    => 200,
                'message' => '获取成功',
                'data'    => [
                    'list'  => $list,
                    'total' => $total,
                ],
            ];
        } catch (Exception $exc) {
            $result = [
                'code'    => $exc->getCode(),
                'message' => $exc->getMessage(),
            ];
        }
        return json($result);
    }
    public function add($id = 0): string {
        header('Content-Type:text/html;charset=utf-8');
        View::assign('menuitem', strtolower('Blog-index'));
        View::assign('id', $id);
        return View::fetch('add');
    }
    /**
     * 获取博客信息
     * @return Json
     */
    public function get_blog_info(): Json {
        try {
            $id = input('id');
            if (!is_numeric($id)) {
                throw new Exception('参数错误');
            }
            $info = Db::name('blog')->field('id,title,en_title,desc,en_desc,cover_img,content,en_content')->where('id', $id)->find();
            if (empty($info)) {
                throw new Exception('信息不存在');
            }
            $result = [
                'code'    => 200,
                'message' => '获取成功',
                'data'    => $info,
            ];
        } catch (Exception $exc) {
            $result = [
                'code'    => $exc->getCode(),
                'message' => $exc->getMessage(),
            ];
        }
        return json($result);
    }
    
    /**
@@ -31,7 +87,7 @@
            
            $file    = request()->file('image');
            $files[] = $file;
            validate(['image' => 'fileSize:10240|fileExt:jpg'])->check($files);
            validate(['image' => 'fileSize:10240|fileExt:jpg,jpeg,png'])->check($files);
            // 上传到本地服务器
            $savename = (new Filesystem)::disk('public')->putFile('/images', $file);
            $savename = (new Filesystem)::disk('public')->url($savename); // 获取上传后的文件路径
@@ -71,7 +127,7 @@
            
            $file    = request()->file('file');
            $files[] = $file;
            validate(['image' => 'fileSize:10240|fileExt:jpg'])->check($files);
            validate(['image' => 'fileSize:10240|fileExt:jpg,jpeg,png'])->check($files);
            // 上传到本地服务器
            $savename = (new Filesystem)::disk('public')->putFile('/images', $file);
            $savename = (new Filesystem)::disk('public')->url($savename); // 获取上传后的文件路径
@@ -99,12 +155,50 @@
        return json($result);
    }
    
    public function save_blog() {
    /**
     * 保存博客
     * @return Json
     */
    public function save_blog(): Json {
        try {
            if (!request()->isPost()) {
                throw new Exception('请求方式错误');
            }
            $data = request()->post();
            ///////验证////////////
            $validate        = new \app\admin\validate\Blog();
            $validate_result = $validate->scene('save_blog')->check($data);
            if (!$validate_result) {
                throw new Exception($validate->getError());
            }
            if ($data['id'] && is_numeric($data['id'])) {
                /////////更新////////////
                $info = Db::name('blog')->field('id')->where('id', $data['id'])->find();
                if (empty($info)) {
                    throw new Exception('信息不存在');
                }
                unset($data['create_time']);
                $update_result = Db::name('blog')->where('id', $data['id'])->save($data);
                if (!$update_result) {
                    throw new Exception('更新失败');
                }
            } else {
                //////////添加////////////
                $data['create_time'] = time();
                $data['admin_id']    = $this->admin_id;
                $new_id = Db::name('blog')->insertGetId($data);
                if (!$new_id) {
                    throw new Exception('保存失败');
                }
            }
            $result = [
                'code'    => 200,
                'message' => '保存成功',
            ];
            
        } catch (Exception $exc) {
            $result = [
@@ -114,4 +208,37 @@
        }
        return json($result);
    }
    /**
     * 修改博客状态
     * @return Json
     */
    public function change_blog_status() {
        try {
            $id = input('id');
            if (!is_numeric($id)) {
                throw new Exception('参数错误');
            }
            $info = Db::name('blog')->field('id,status')->where('id', $id)->find();
            if (empty($info)) {
                throw new Exception('信息不存在');
            }
            $status        = $info['status'] == 1 ? 0 : 1;
            $update_result = Db::name('blog')->where('id', $id)->save(['status' => $status]);
            if (!$update_result) {
                throw new Exception('更新失败');
            }
            $result = [
                'code'    => 200,
                'message' => '更新成功',
            ];
        } catch (Exception $exc) {
            $result = [
                'code'    => $exc->getCode(),
                'message' => $exc->getMessage(),
            ];
        }
        return json($result);
    }
}
app/admin/controller/OnlineMessage.php
New file
@@ -0,0 +1,38 @@
<?php
namespace app\admin\controller;
use think\Exception;
use think\facade\Db;
use think\facade\View;
class OnlineMessage extends Common {
    public function index() {
        View::assign('menuitem', strtolower('onlineMessage-index'));
        return View::fetch();
    }
    public function get_online_message_list() {
        try {
            $page   = input('page', 1);
            $limit  = input('limit', 10);
            $where  = [];
            $total  = Db::name('online_message')->where($where)->count();
            $list   = Db::name('online_message')->where($where)->order('id desc')->page($page, $limit)->select()->toArray();
            $result = [
                'code'    => 200,
                'message' => '获取成功',
                'data'    => [
                    'list'  => $list,
                    'total' => $total,
                ],
            ];
        } catch (Exception $exc) {
            $result = [
                'code'    => $exc->getCode(),
                'message' => $exc->getMessage(),
            ];
        }
        return json($result);
    }
}
app/admin/validate/Blog.php
@@ -8,12 +8,24 @@
    
    protected $rule    = [
        'title'      => 'require',
        'menu_index' => 'require',
        'en_title'   => 'require',
        'desc'       => 'require',
        'en_desc'    => 'require',
        'cover_img'  => 'require',
        'content'    => 'require',
        'en_content' => 'require',
    ];
    protected $message = [
        'title.require'      => '请填写菜单名称',
        'menu_index.require' => '请填写菜单索引',
        'title.require'      => '请填写标题名称',
        'en_title.require'   => '请填写英文标题名称',
        'desc.require'       => '请填写标题描述',
        'en_desc.require'    => '请填写英文标题描述',
        'cover_img.require'  => '请上传封面图片',
        'content.require'    => '请填写内容',
        'en_content.require' => '请填写英文内容',
    ];
    
    protected $scene = [
        'save_blog' => ['title', 'en_title', 'desc', 'en_desc', 'cover_img', 'content', 'en_content'], //保存博客
    ];
}
app/admin/view/blog/add.html
@@ -8,6 +8,7 @@
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <include file="common:element-plus" />
    <link rel="stylesheet" href="/static/admin/css/blog/add.css">
    <!-- 富文本编辑器 -->
    <link rel="stylesheet" href="/static/plugin/wangeditor/style.css" media="all">
    <script type="text/javascript" src="/static/plugin/wangeditor/index.js"></script>
@@ -53,6 +54,7 @@
</head>
<body>
    <input type="hidden" id="id" value="{$id}">
    <div id="vue_item" v-cloak>
        <el-container>
            <el-aside class="el-menu-container" :width="el_aside_width">
@@ -90,14 +92,15 @@
                                    <div id="toolbar-container"><!-- 工具栏 --></div>
                                    <div id="editor-container" style="height: calc(100% - 40px);"><!-- 编辑器 --></div>
                                </div>
                                <!-- <div id="editer_data" style="width: 100%;">{{addBlogForm.content}}</div>
                                <textarea name="content" id="content" style="display:none;" v-model="addBlogForm.content"></textarea> -->
                                <!-- <div id="editer_data" style="width: 100%;" v-html="addBlogForm.content"></div> -->
                                <!-- <textarea id="editer_data" style="display:none;" v-model="addBlogForm.content"></textarea> -->
                            </el-form-item>
                            <el-form-item label="内容(英文)">
                                <div id="editor—wrapper-en" class="editor—wrapper" style="height: 500px;">
                                    <div id="toolbar-container-en"><!-- 工具栏 --></div>
                                    <div id="editor-container-en" style="height: calc(100% - 40px);"><!-- 编辑器 --></div>
                                </div>
                                <!-- <div id="editer_data_en" style="width: 100%;" v-html="addBlogForm.en_content"></div> -->
                            </el-form-item>
                            <el-form-item label="封面图">
                                <el-upload class="avatar-uploader" action="/admin/blog/upload_cover_img.html" :show-file-list="false" :on-success="handleCoverImgSuccess" :before-upload="beforeCoverImgUpload">
@@ -133,7 +136,7 @@
        placeholder: '请输入中文内容...',
        onChange(editor) {
            const html = editor.getHtml();
            setHtmlValue(html);
            getHtmlValue(html);
        },
        MENU_CONF: {},
    }
@@ -167,6 +170,10 @@
        },
    }
    var editor_data = $("#editer_data").html();
    if (editor_data == '') {
        editor_data = '<p><br></p>';
    }
    const editor = createEditor({
        selector: '#editor-container',
        html: '<p><br></p>',
@@ -197,7 +204,7 @@
        placeholder: '请输入英文内容...',
        onChange(editor) {
            const html = editor.getHtml();
            setHtmlValue(html, 2);
            getHtmlValue(html, 2);
        },
        MENU_CONF: {},
    }
@@ -233,7 +240,10 @@
        },
    }
    var editor_data_en = document.getElementById('editer_data_en');
    if (editor_data_en == '') {
        editor_data_en = '<p><br></p>';
    }
    const editor_en = createEditor({
        selector: '#editor-container-en',
        html: '<p><br></p>',
@@ -255,7 +265,16 @@
        selector: '#toolbar-container-en',
        config: toolbarConfigEn,
        mode: 'default', // or 'simple'
    })
    });
    function setHtmlValue(html, type = 1) {
        if (type == 1) {
            editor.setHtml(html);
        } else {
            editor_en.setHtml(html);
        }
    }
</script>
</html>
app/admin/view/blog/index.html
@@ -25,30 +25,34 @@
                    <el-card>
                        <template #header>
                            <div class="card-header">
                                <span>文章列表</span>
                                <span>文章列表({{listCount}})</span>
                                &emsp;
                                <el-link href="/admin/blog/add.html" type="primary" class="header_add_btn" icon="CirclePlusFilled" :underline="false">添加</el-link>
                            </div>
                        </template>
                        <el-table :data="list" :tree-props="{children: 'children'}" row-key="id" default-expand-all border style="width: 100%" ref="tableRef">
                        <el-table :data="blogList" :tree-props="{children: 'children'}" row-key="id" default-expand-all border style="width: 100%" ref="tableRef">
                            <el-table-column label="名称" prop="title"></el-table-column>
                            <!-- <el-table-column label="菜单索引" prop="menu_index"></el-table-column> -->
                            <el-table-column label="添加时间" prop="create_time" width="150">
                                <template #default="scope">
                                   {{formatDate(scope.row['create_time'])}}
                                    {{formatDate(scope.row['create_time'])}}
                                </template>
                            </el-table-column>
                            <el-table-column label="状态" width="150" align="center">
                                <template #default="scope">
                                    <el-switch v-model="scope.row.show_menu" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ccc" :active-value="1" :inactive-value="0" inline-prompt active-text="发布" inactive-text="下架" @change="updateShowMenu(scope.row)" />
                                    <el-switch v-model="scope.row.status" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ccc" :active-value="1" :inactive-value="0" inline-prompt active-text="发布" inactive-text="未发布" @change="changeBlogStatus(scope.row.id)" />
                                </template>
                            </el-table-column>
                            <el-table-column label="操作选项" fixed="right" width="150" :align="alignValue(200)">
                                <template #default="scope">
                                    <el-button icon="edit" type="primary" @click="Edit(scope.row)"></el-button>
                                    <el-button icon="edit" type="primary" @click="editBlog(scope.row.id)" circle></el-button>
                                    <el-button icon="Delete" type="danger" @click="deleteBlog(scope.row.id)" circle></el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <div style="text-align: right;margin-top: 15px">
                            <el-pagination background @current-change="getBlogList" layout="prev, pager, next" :page-size="searchForm.limit" hide-on-single-page="true" :total="listCount"></el-pagination>
                        </div>
                    </el-card>
                </el-main>
                <el-footer></el-footer>
app/admin/view/common/header.html
@@ -1,7 +1,7 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/static/supplier/css/reset.css?t=20180921-1" media="all">
<!-- <link rel="stylesheet" href="/static/supplier/css/reset.css?t=20180921-1" media="all">
<link id="layuicss-layuiAdmin" rel="stylesheet" href="/static/admin/css/admin.css?v=1.1.0 pro-1" media="all">
<link rel="stylesheet" href="/static/admin/css/layui.css?t=20180921-3" media="all">
<script type="text/javascript" src="/static/jquery/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="/static/admin/css/layui.css?t=20180921-3" media="all"> -->
<!-- <script type="text/javascript" src="/static/jquery/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.config.js"></script>
<script type="text/javascript" src="/static/admin/js/function.js"></script>
<script type="text/javascript" src="/static/admin/js/function.js"></script> -->
app/admin/view/online_message/index.html
New file
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <include file="common:title" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <include file="common:element-plus" />
</head>
<body>
    <div id="vue_item" v-cloak>
        <el-container>
            <el-aside class="el-menu-container" :width="el_aside_width">
                <!-- 侧边菜单 -->
                <include file="common:side_menu" />
            </el-aside>
            <el-container>
                <el-header>
                    <include file="common:guide" one_word="在线留言" two_word="官网留言 " />
                </el-header>
                <el-main>
                    <el-card style="width: 100%">
                        <template #header>
                            <div class="card-header">官网留言({{count}})</div>
                        </template>
                        <el-form :model="searchForm" label-width="auto" size="large">
                            <el-input v-model="searchForm.kw" placeholder="请输入标题" style="width: 300px;" clearable></el-input>
                            &ensp;
                            <el-button type="success" icon="Search" @click="getOnlineMessageList()">搜索</el-button>
                        </el-form>
                        <br />
                        <el-table :data="list" border style="width: 100%;position: relative;z-index: 0 !important;" ref="tableRef">
                            <el-table-column prop="name" label="姓名" width="180" show-overflow-tooltip align="center"></el-table-column>
                            <el-table-column prop="phone" label="电话" show-overflow-tooltip width="180" align="center"></el-table-column>
                            <el-table-column prop="email" label="邮箱" width="180" align="center"></el-table-column>
                            <el-table-column prop="subject" label="主题" width="180" align="center"></el-table-column>
                            <el-table-column prop="message" label="内容" align="left"></el-table-column>
                            <el-table-column prop="create_time" label="提交时间" width="180" align="center">
                                <template #default="scope">
                                    {{formatDate(scope.row.create_time)}}
                                </template>
                            </el-table-column>
                            <el-table-column label="状态" width="150" align="center">
                                <template #default="scope">
                                    <el-switch @change="updateExt(scope.row,'status')" v-model="scope.row.status" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ccc" :active-value="1" :inactive-value="0" inline-prompt active-text="已处理" inactive-text="未处理" />
                                </template>
                            </el-table-column>
                        </el-table>
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="searchForm.page" :page-sizes="[20, 30, 40, 50]" :page-size="searchForm.limit" layout="total, sizes, prev, pager, next" :total="count">
                        </el-pagination>
                    </el-card>
                </el-main>
            </el-container>
        </el-container>
    </div>
</body>
<!-- 共用的方法 -->
<script language="JavaScript">
    const viewPath = '{$viewPath}';
</script>
<script src="/static/vue/mixin_admin.js"></script>
<script src="/static/admin/js/online_message/index.js?v=<?php echo rand(1000,9999)?>"></script>
</html>
app/home/controller/Contact.php
@@ -2,12 +2,48 @@
namespace app\home\controller;
use think\Exception;
use think\facade\Db;
use think\facade\View;
use think\facade\Request;
use app\BaseController;
use think\response\Json;
class Contact extends BaseController {
    public function index() {
        return View::fetch('index');
    }
    /**
     * 保存留言
     * @return Json
     */
    public function save_message(): Json {
        try {
            if (!Request::isPost()) {
                throw new Exception('请求方式错误');
            }
            $data            = Request::post();
            $validate        = new \app\home\validate\Contact();
            $validate_result = $validate->check($data);
            if (!$validate_result) {
                throw new Exception($validate->getError());
            }
            $data['create_time'] = time();
            $new_id              = Db::name('online_message')->insertGetId($data);
            if (!$new_id) {
                throw new Exception('保存失败');
            }
            $result = [
                'code'    => 200,
                'message' => '保存成功',
            ];
        } catch (Exception $exc) {
            $result = [
                'code'    => $exc->getCode(),
                'message' => $exc->getMessage(),
            ];
        }
        return json($result);
    }
}
app/home/validate/Contact.php
New file
@@ -0,0 +1,26 @@
<?php
namespace app\home\validate;
use think\Validate;
class Contact extends Validate {
    protected $rule    = [
        'name'    => 'require',
        'phone'   => 'require',
        'email'   => 'require',
        'subject' => 'require',
        'message' => 'require',
    ];
    protected $message = [
        'name.require'    => '请填写姓名',
        'phone.require'   => '请填写联系方式',
        'email.require'   => '请填写邮箱',
        'subject.require' => '请填写主题',
        'message.require' => '请填写内容',
    ];
    protected $scene = [
        'save_message' => ['name', 'phone', 'message'], //保存博客
    ];
}
app/home/view/contact/index.html
@@ -94,7 +94,8 @@
                </div>
            </div>
        </div>
        <!-- contact area2 -->
        <!-- 提交在线咨询 -->
        <div class="contact_area2">
            <div class="container">
                <div class="row">
@@ -106,33 +107,33 @@
                                <h2>{{ $t('message.common.submit-contact-information') }}</h2>
                            </div>
                            <div class="witr_apartment_form">
                                <form action="mail.php" method="post" id="contact-form">
                                <form method="post" id="contact-form">
                                    <div class="row">
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="text" name="name" :placeholder="$t('message.common.name')">
                                                <input type="text" name="name" :placeholder="$t('message.common.name')" v-model="form.name">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="email" name="email" :placeholder="$t('message.common.email')">
                                                <input type="email" name="email" :placeholder="$t('message.common.email')" v-model="form.email">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="number" name="number" :placeholder="$t('message.common.phone')">
                                                <input type="number" name="number" :placeholder="$t('message.common.phone')" v-model="form.phone">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="text" name="subject" :placeholder="$t('message.common.subject')">
                                                <input type="text" name="subject" :placeholder="$t('message.common.subject')" v-model="form.subject">
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="twr_form_box ">
                                                <textarea name="textarea" :placeholder="$t('message.common.message')"></textarea>
                                                <textarea name="textarea" :placeholder="$t('message.common.message')" v-model="form.message"></textarea>
                                            </div>
                                            <button type="submit" name="ok" class="btn ">{{ $t('message.common.submit') }}</button>
                                            <button type="button" name="ok" class="btn" @click="submitForm" :disabled="submitDisabled">{{ $t('message.common.submit') }}</button>
                                        </div>
                                        <div class="col-lg-12 text-center">
                                            <p class="form-messege"></p>
@@ -155,7 +156,13 @@
            mixins: [sharedMixin],
            data() {
                return {
                    form: {
                        name: '',
                        email: '',
                        phone: '',
                        subject: '',
                        message: '',
                    }
                };
            },
            computed: {
@@ -166,6 +173,45 @@
            created() {
            },
            methods: {
                submitForm() {
                    var that = this;
                    that.submitDisabled = true;
                    const loading = this.$loading({
                        lock: true,
                        text: '提交中',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.2)'
                    });
                    let url = "/home/contact/save_message.html";
                    postRequest(url, that.form).then(res => {
                        loading.close();
                        if (res.data.code == 200) {
                            that.$message({
                                message: res.data.message,
                                type: 'success',
                                duration: 1000,
                                center: true,
                                onClose: function () {
                                    that.form = {
                                        name: '',
                                        email: '',
                                        phone: '',
                                        subject: '',
                                        message: '',
                                    }
                                }
                            });
                        } else {
                            that.submitDisabled = false;
                            that.$message({
                                message: res.data.message,
                                type: 'error',
                                duration: 1500,
                                center: true
                            });
                        }
                    });
                }
            },
        };
app/home/view/index/index.html
@@ -1307,29 +1307,29 @@
                                    <div class="row">
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="text" name="name" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" :placeholder="$t('message.common.name')">
                                                <input type="text" name="name" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" :placeholder="$t('message.common.name')" v-model="form.name">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="email" name="email" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" :placeholder="$t('message.common.email')">
                                                <input type="email" name="email" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" :placeholder="$t('message.common.email')" v-model="form.email">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="number" name="number" class="wpcf7-form-control wpcf7-number wpcf7-validates-as-required wpcf7-validates-as-number form-control" :placeholder="$t('message.common.phone')">
                                                <input type="number" name="number" class="wpcf7-form-control wpcf7-number wpcf7-validates-as-required wpcf7-validates-as-number form-control" :placeholder="$t('message.common.phone')" v-model="form.phone">
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6">
                                            <div class="twr_form_box">
                                                <input type="text" name="subject" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" :placeholder="$t('message.common.subject')">
                                                <input type="text" name="subject" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" :placeholder="$t('message.common.subject')" v-model="form.subject">
                                            </div>
                                        </div>
                                        <div class="col-lg-12 col-md-12">
                                            <div class="twr_form_box ">
                                                <textarea name="textarea" class="wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-control" :placeholder="$t('message.common.message')"></textarea>
                                                <textarea name="textarea" class="wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-control" :placeholder="$t('message.common.message')" v-model="form.message"></textarea>
                                            </div>
                                            <button type="submit" name="ok" class="btn">{{ $t('message.common.submit') }}</button>
                                            <button type="button" name="ok" class="btn" @click="submitForm" :disabled="submitDisabled">{{ $t('message.common.submit') }}</button>
                                        </div>
                                        <div class="col-lg-12 text-center">
                                            <p class="form-messege"></p>
@@ -1410,7 +1410,13 @@
            mixins: [sharedMixin],
            data() {
                return {
                    form: {
                        name: '',
                        email: '',
                        phone: '',
                        subject: '',
                        message: '',
                    }
                };
            },
            computed: {
@@ -1421,6 +1427,46 @@
            created() {
            },
            methods: {
                submitForm() {
                    var that = this;
                    that.submitDisabled = true;
                    const loading = this.$loading({
                        lock: true,
                        text: '提交中',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.2)'
                    });
                    let url = "/home/contact/save_message.html";
                    postRequest(url, that.form).then(res => {
                        loading.close();
                        if (res.data.code == 200) {
                            that.$message({
                                message: res.data.message,
                                type: 'success',
                                duration: 1000,
                                center: true,
                                onClose: function () {
                                    that.form = {
                                        name: '',
                                        email: '',
                                        phone: '',
                                        subject: '',
                                        message: '',
                                    }
                                }
                            });
                        } else {
                            that.submitDisabled = false;
                            that.$message({
                                message: res.data.message,
                                type: 'error',
                                duration: 1500,
                                center: true
                            });
                        }
                    });
                }
            },
        };
@@ -1436,4 +1482,5 @@
    </script>
</body>
<include file="common:html-css-js" />
</html>
public/static/admin/js/blog/add.js
@@ -1,7 +1,9 @@
var id = $("#id").val();
const App = {
    mixins: [sharedMixin],/////共用的方法/////
    data() {
        return {
            blog_id: id,
            addBlogForm: {
                title: '',
                en_title: '',
@@ -17,11 +19,14 @@
    mounted() {
    },
    created() {
        window.setHtmlValue = this.setHtmlValue;
        window.getHtmlValue = this.getHtmlValue;
        if (this.blog_id > 0) {
            this.getBlogInfo();
        }
    },
    methods: {
        /////获取富文本内容/////
        setHtmlValue(value, type = 1) {
        getHtmlValue(value, type = 1) {
            if (type == 1) {
                this.addBlogForm.content = value;
            } else {
@@ -64,6 +69,28 @@
            }
            return true;
        },
        /////获取博客信息/////
        getBlogInfo() {
            let that = this;
            let url = "/admin/blog/get_blog_info.html";
            postRequest(url, { id: that.blog_id }).then(res => {
                if (res.data.code == 200) {
                    that.addBlogForm = res.data.data;
                    setTimeout(function () {
                        window.setHtmlValue(res.data.data.content, 1);
                        window.setHtmlValue(res.data.data.en_content, 2);
                    })
                } else {
                    that.$message({
                        message: res.data.message,
                        type: 'error',
                        duration: 1500,
                        center: true
                    });
                }
            })
        },
        /////保存/////
        onSubmit() {
            var that = this;
public/static/admin/js/blog/index.js
@@ -2,19 +2,112 @@
    mixins: [sharedMixin],/////共用的方法/////
    data() {
        return {
            list: [],
            blogList: [],
            listCount: 0,
            searchForm: {
                keyword: "",
                page: 1,
                limit: 20,
            },
            ifsubmit: false,
        };
    },
    mounted() {
    },
    created() { },
    created() {
        this.getBlogList();
    },
    methods: {
        index() {
        formatDate(time) {
            return moment(time * 1000).format("YYYY-MM-DD H:m");
        },
        /////改变状态/////
        changeBlogStatus(id) {
            let that = this;
            let url = "/admin/adminmenu/index.html"
            postRequest(url, {}).then(res => {
            let loading = this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            let url = "/admin/blog/change_blog_status.html";
            postRequest(url, { id: id }).then(res => {
                loading.close()
                if (res.data.code == 200) {
                    that.list = res.data.list;
                    that.$message({
                        message: res.data.message,
                        type: 'success',
                        duration: 1000,
                        center: true,
                        onClose: function () {
                            that.getBlogList();
                        }
                    })
                } else {
                    that.$message({
                        message: res.data.message,
                        type: 'error',
                        duration: 2000,
                        center: true
                    });
                }
            })
        },
        /////进入编辑页面/////
        editBlog(id) {
            window.location.href = "/admin/blog/add/id/" + id + ".html";
        },
        /////删除文章/////
        deleteBlog(id) {
            let that = this;
            let loading = this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
            });
            let url = "/admin/blog/delete_blog.html";
            postRequest(url, { id: id }).then(res => {
                loading.close()
                if (res.data.code == 200) {
                    that.$message({
                        message: res.data.message,
                        type: 'success',
                        duration: 1000,
                        center: true,
                        onClose: function () {
                            that.getBlogList();
                        }
                    })
                } else {
                    that.$message({
                        message: res.data.message,
                        type: 'error',
                        duration: 2000,
                        center: true
                    });
                }
            })
        },
        /////获取文章列表/////
        getBlogList(page = 1) {
            let that = this;
            that.searchForm.page = page;
            let loading = this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            let url = "/admin/blog/get_blog_list.html"
            postRequest(url, that.searchForm).then(res => {
                loading.close()
                if (res.data.code == 200) {
                    that.blogList = res.data.data.list;
                    that.listCount = +res.data.data.total;
                }
            });
        },
public/static/admin/js/online_message/index.js
New file
@@ -0,0 +1,88 @@
const App = {
    mixins: [sharedMixin],/////共用的方法/////
    data() {
        return {
            list: [],
            count: 0,
            searchForm: {
                page: 1,
                page_size: 20,
                kw: '',
            },
        };
    },
    mounted() {
        this.getOnlineMessageList();
    },
    created() { },
    methods: {
        formatDate(time) {
            return moment(time * 1000).format("YYYY-MM-DD H:m");
        },
        ///修改扩展字段的值////
        updateExt(row, field) {
            if (row.id) {
                let that = this;
                let url = "/admin/" + viewPath + "/updateExt.html"
                postRequest(url, { id: row.id, [field]: row[field] }).then(res => {
                    if (res.data.code == 200) {
                        that.$notify({
                            title: "成功",
                            message: res.data.message,
                            position: "top-left",
                            type: "success",
                        });
                    }
                    else {
                        that.$notify.error({
                            title: "错误",
                            position: "top-left",
                            message: res.data.message,
                        });
                    }
                });
            }
        },
        handleSizeChange(val) {
            //////设置每页多少条
            this.searchForm.page_size = val
            this.getOnlineMessageList();
        },
        handleCurrentChange(val) {
            ///改变当前页///////
            this.searchForm.page = val
            this.getOnlineMessageList();
        },
        // 获取公告列表
        getOnlineMessageList() {
            let that = this;
            const loading = this.$loading({
                lock: true,
                text: '获取中',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.2)'
            });
            let url = "/admin/onlineMessage/get_online_message_list.html"
            postRequest(url, that.searchForm).then(res => {
                loading.close();
                if (res.data.code == 200) {
                    that.list = res.data.data.list;
                    that.count = +res.data.data.total;
                }
            }).catch(() => {
                //取消,不做处理
            });
        },
    }
};
const app = Vue.createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(ElementPlus, {
    locale: ElementPlusLocaleZhCn,
});
app.mount("#vue_item");