1
This commit is contained in:
		
							parent
							
								
									fc25792e61
								
							
						
					
					
						commit
						9cafbc6073
					
				@ -4,6 +4,7 @@
 | 
			
		||||
    <meta charset="UTF-8"/>
 | 
			
		||||
<!--    <link rel="icon" href="/favicon.ico"/>-->
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
 | 
			
		||||
    <meta name="referer" content="no-referrer">
 | 
			
		||||
    <title></title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										362
									
								
								src/pages/news/wechat_index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										362
									
								
								src/pages/news/wechat_index.vue
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,362 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <t-card :bordered="false">
 | 
			
		||||
    <div class="form-step-container">
 | 
			
		||||
      <t-button @click="add">新增</t-button>
 | 
			
		||||
      <t-table
 | 
			
		||||
        rowKey="index"
 | 
			
		||||
        :data="list"
 | 
			
		||||
        :columns="columns"
 | 
			
		||||
        :stripe="false"
 | 
			
		||||
        :bordered="false"
 | 
			
		||||
        :hover="true"
 | 
			
		||||
        size="large"
 | 
			
		||||
        table-layout="auto"
 | 
			
		||||
        cellEmptyContent="-"
 | 
			
		||||
        :pagination="pagination"
 | 
			
		||||
      >
 | 
			
		||||
        <template #news_title="{ row }">
 | 
			
		||||
          <div v-for="item in row.content.news_item" style="padding-bottom: 10px">
 | 
			
		||||
            {{item.title}}
 | 
			
		||||
          </div>
 | 
			
		||||
        </template>
 | 
			
		||||
        <template #news_auto="{ row }">
 | 
			
		||||
          <div v-for="item in row.content.news_item" >
 | 
			
		||||
            {{item.author}}
 | 
			
		||||
          </div>
 | 
			
		||||
        </template>
 | 
			
		||||
        <template #url="{ row }">
 | 
			
		||||
          <div v-for="item in row.content.news_item" style="padding-bottom: 10px">
 | 
			
		||||
            <t-link :href="item.url" target="_blank">打开链接</t-link>
 | 
			
		||||
          </div>
 | 
			
		||||
        </template>
 | 
			
		||||
        <template #select="{ row }">
 | 
			
		||||
            <t-popconfirm content="确认删除吗" @confirm="del(row)">
 | 
			
		||||
              <t-button theme="danger">删除</t-button>
 | 
			
		||||
            </t-popconfirm>
 | 
			
		||||
        </template>
 | 
			
		||||
      </t-table>
 | 
			
		||||
<!--      <div style="margin-top: 30px">-->
 | 
			
		||||
<!--        <t-pagination-->
 | 
			
		||||
<!--          :total="pagination.total"-->
 | 
			
		||||
<!--          :page-size="pagination.size"-->
 | 
			
		||||
<!--          @current-change="onCurrentChange"-->
 | 
			
		||||
<!--          :showPageSize="false"-->
 | 
			
		||||
<!--        ></t-pagination>-->
 | 
			
		||||
<!--      </div>-->
 | 
			
		||||
    </div>
 | 
			
		||||
    <t-dialog :header="isEdit?'编辑新闻':'新增新闻'" :visible="addMode" :onClose="onCloseMy" @confirm="onSubmit"
 | 
			
		||||
              width="45%" top="20px">
 | 
			
		||||
      <t-form>
 | 
			
		||||
        <t-form-item label="文章标题" name="news_title">
 | 
			
		||||
          <t-input placeholder="请输入文章标题" v-model="addForm.title"/>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="摘要" name="digest">
 | 
			
		||||
          <t-input placeholder="请输入摘要" v-model="addForm.digest"/>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="所属类目" name="activity_location">
 | 
			
		||||
          <t-select v-model="addForm.gory_id">
 | 
			
		||||
            <t-option v-for="(item,index) in gory_list" :key="index" :label="item.name" :value="item.id" />
 | 
			
		||||
          </t-select>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="作者" name="author">
 | 
			
		||||
          <t-input placeholder="请输入作者" v-model="addForm.author"/>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="原文地址" name="content_source_url">
 | 
			
		||||
          <t-input placeholder="请输入原文地址" v-model="addForm.content_source_url"/>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="新闻内容" name="news_content">
 | 
			
		||||
          <div style="border: 1px solid #ccc;z-index: 99">
 | 
			
		||||
            <!-- 工具栏 -->
 | 
			
		||||
            <Toolbar
 | 
			
		||||
              style="border-bottom: 1px solid #ccc"
 | 
			
		||||
              mode="default"
 | 
			
		||||
              :editor="editor"
 | 
			
		||||
              :defaultConfig="toolbarConfig"
 | 
			
		||||
            />
 | 
			
		||||
 | 
			
		||||
            <Editor
 | 
			
		||||
              style="height: 200px"
 | 
			
		||||
              v-model="addForm.content"
 | 
			
		||||
              :defaultConfig="editorConfig"
 | 
			
		||||
              mode="default"
 | 
			
		||||
              @onCreated="(e) => onCreated(e)"
 | 
			
		||||
            />
 | 
			
		||||
          </div>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
        <t-form-item label="新闻主图">
 | 
			
		||||
<!--          <t-upload-->
 | 
			
		||||
<!--            :action="$store.state.user.apiUrl+'/wx_news/wxuploadimg'"-->
 | 
			
		||||
<!--            v-model="addForm.thumb_media_id_show"-->
 | 
			
		||||
<!--            theme="image"-->
 | 
			
		||||
<!--            tips="请选择单张图片文件上传"-->
 | 
			
		||||
<!--            accept="image/*"-->
 | 
			
		||||
<!--            :format-response="formatResponse"-->
 | 
			
		||||
<!--          ></t-upload>-->
 | 
			
		||||
                    <t-upload
 | 
			
		||||
                      action="/api/wx_news/wxuploadimg"
 | 
			
		||||
                      v-model="thumb_media_id_show"
 | 
			
		||||
                      theme="image"
 | 
			
		||||
                      tips="请选择单张图片文件上传"
 | 
			
		||||
                      accept="image/*"
 | 
			
		||||
                      :format-response="formatResponse"
 | 
			
		||||
                    ></t-upload>
 | 
			
		||||
        </t-form-item>
 | 
			
		||||
      </t-form>
 | 
			
		||||
    </t-dialog>
 | 
			
		||||
  </t-card>
 | 
			
		||||
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import store from "@/store";
 | 
			
		||||
import {Editor, Toolbar} from '@wangeditor/editor-for-vue';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  components: {Editor, Toolbar},
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      visible: false,
 | 
			
		||||
      infoMode: false,
 | 
			
		||||
      addForm: {
 | 
			
		||||
        title: '',
 | 
			
		||||
        digest: '',
 | 
			
		||||
        gory_id: null,
 | 
			
		||||
        author: '',
 | 
			
		||||
        content_source_url: '',
 | 
			
		||||
        content: '',
 | 
			
		||||
        thumb_media_id: '',
 | 
			
		||||
      },
 | 
			
		||||
      thumb_media_id_show:[],
 | 
			
		||||
      addMode: false,
 | 
			
		||||
      isEdit: false,
 | 
			
		||||
      editID: 0,
 | 
			
		||||
      list: [],
 | 
			
		||||
      gory_list:[],
 | 
			
		||||
      columns: [
 | 
			
		||||
        {colKey: 'news_title', title: '新闻标题', align: 'center', width: 300},
 | 
			
		||||
        {colKey: 'news_auto', title: '作者', align: 'center'},
 | 
			
		||||
        {colKey: 'url', title: '临时链接', align: 'center'},
 | 
			
		||||
        {colKey: 'select', title: '操作', width: 200, align: 'center'},
 | 
			
		||||
      ],
 | 
			
		||||
      pagination: {
 | 
			
		||||
        page: 1,
 | 
			
		||||
        size: 10,
 | 
			
		||||
        total: 0,
 | 
			
		||||
      },
 | 
			
		||||
      editor: null,
 | 
			
		||||
      toolbarConfig: {
 | 
			
		||||
        showLinkImg: false,
 | 
			
		||||
        uploadImgShowBase64: true,
 | 
			
		||||
        excludeKeys: [
 | 
			
		||||
          'insertVideo', // 删除视频
 | 
			
		||||
          'insertImage',// 删除网络图片上传
 | 
			
		||||
          'insertLink',// 删除链接
 | 
			
		||||
          'insertTable',// 删除表格
 | 
			
		||||
          'codeBlock',// 删除代码块
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
      editorConfig: {
 | 
			
		||||
        placeholder: '',
 | 
			
		||||
        readOnly: false, // 是否只允许阅读,不可编辑
 | 
			
		||||
        autoFocus: true,
 | 
			
		||||
        MENU_CONF: {
 | 
			
		||||
          uploadImage: {
 | 
			
		||||
            //server: store.state.user.apiUrl + '/api/wx_news/wxuploadimg',
 | 
			
		||||
            server:'/api/wx_news/wxuploadimg',
 | 
			
		||||
            fieldName: 'file',
 | 
			
		||||
            meta:{
 | 
			
		||||
              type:'image',
 | 
			
		||||
            },
 | 
			
		||||
            customInsert(res: any, insertFn: InsertFnType) {  // TS 语法
 | 
			
		||||
              // customInsert(res, insertFn) {                  // JS 语法
 | 
			
		||||
              // res 即服务端的返回结果
 | 
			
		||||
              console.log(res);
 | 
			
		||||
              // 从 res 中找到 url alt href ,然后插入图片
 | 
			
		||||
              insertFn(res.data.url, '', '')
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          uploadVideo: {
 | 
			
		||||
            //server: store.state.user.apiUrl + '/api/wx_news/wxuploadimg',
 | 
			
		||||
            server:'/api/wx_news/wxuploadimg',
 | 
			
		||||
            fieldName: 'file',
 | 
			
		||||
            meta:{
 | 
			
		||||
              type:'video',
 | 
			
		||||
            },
 | 
			
		||||
            customInsert(res: any, insertFn: InsertFnType) {  // TS 语法
 | 
			
		||||
              // customInsert(res, insertFn) {                  // JS 语法
 | 
			
		||||
              // res 即服务端的返回结果
 | 
			
		||||
              console.log(res);
 | 
			
		||||
              // 从 res 中找到 url alt href ,然后插入图片
 | 
			
		||||
              insertFn(res.data.fullurl, '', '')
 | 
			
		||||
            },
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  beforeDestroy() {
 | 
			
		||||
    const editor = this.editor
 | 
			
		||||
    if (editor == null) return
 | 
			
		||||
    editor.destroy() // 组件销毁时,及时销毁编辑器
 | 
			
		||||
  },
 | 
			
		||||
  mounted() {
 | 
			
		||||
    //this.member_id=this.$route.query.id;
 | 
			
		||||
    if(typeof (store.state.user.association)=='object'){
 | 
			
		||||
      this.association=store.state.user.association;
 | 
			
		||||
    }else{
 | 
			
		||||
      this.association=JSON.parse(store.state.user.association);
 | 
			
		||||
    }
 | 
			
		||||
    this.editorConfig.MENU_CONF.uploadImage.meta.association_id=this.association.id;
 | 
			
		||||
    this.getList();
 | 
			
		||||
    this.getGory();
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    onCurrentChange(d) {
 | 
			
		||||
      this.pagination.page = d;
 | 
			
		||||
      this.getList();
 | 
			
		||||
    },
 | 
			
		||||
    formatResponse(res) {
 | 
			
		||||
      console.log(res);
 | 
			
		||||
      //this.addForm.news_image = res.data.url;
 | 
			
		||||
      return {url: res.data.url};
 | 
			
		||||
    },
 | 
			
		||||
    onCreated(editor) {
 | 
			
		||||
      this.editor = Object.seal(editor);
 | 
			
		||||
    },
 | 
			
		||||
    del(d) {
 | 
			
		||||
      console.log(d);
 | 
			
		||||
      this.$request
 | 
			
		||||
        .post('/news/del', {news_id: d.news_id})
 | 
			
		||||
        .then((res) => {
 | 
			
		||||
          if (res.code == 1) {
 | 
			
		||||
            this.$message.success(res.msg);
 | 
			
		||||
            this.getList();
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$message.error(res.msg);
 | 
			
		||||
          }
 | 
			
		||||
          console.log(res);
 | 
			
		||||
        })
 | 
			
		||||
        .catch((e) => {
 | 
			
		||||
          console.log(e);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    add() {
 | 
			
		||||
      this.addMode = true;
 | 
			
		||||
      this.isEdit = false;
 | 
			
		||||
      this.addForm={
 | 
			
		||||
        news_title: '',
 | 
			
		||||
        news_titleshort: '',
 | 
			
		||||
        gory_id: null,
 | 
			
		||||
        news_auto: '',
 | 
			
		||||
        news_source: '',
 | 
			
		||||
        news_content: '',
 | 
			
		||||
        news_image: '',
 | 
			
		||||
        news_image_show:[],
 | 
			
		||||
        showtime:'',
 | 
			
		||||
        news_hits:0,
 | 
			
		||||
      };
 | 
			
		||||
    },
 | 
			
		||||
    edit(d) {
 | 
			
		||||
      console.log(d);
 | 
			
		||||
      this.addForm.news_id = d.news_id;
 | 
			
		||||
      this.addForm.news_title = d.news_title;
 | 
			
		||||
      this.addForm.news_titleshort = d.news_titleshort;
 | 
			
		||||
      this.addForm.news_image_show = [{url: store.state.user.apiUrl + d.news_image}];
 | 
			
		||||
      this.addForm.news_image = d.news_image;
 | 
			
		||||
      this.addForm.gory_id = d.gory_id;
 | 
			
		||||
      this.addForm.news_auto = d.news_auto;
 | 
			
		||||
      this.addForm.news_source = d.news_source;
 | 
			
		||||
      this.addForm.news_content = d.news_content;
 | 
			
		||||
      this.addForm.showtime = d.showtime
 | 
			
		||||
      this.addForm.news_hits = d.news_hits;
 | 
			
		||||
      this.addMode = true;
 | 
			
		||||
      this.isEdit = true;
 | 
			
		||||
    },
 | 
			
		||||
    getList() {
 | 
			
		||||
      this.$request
 | 
			
		||||
        .post("/wx_news/getDraftList")
 | 
			
		||||
        .then((res) => {
 | 
			
		||||
          console.log(res);
 | 
			
		||||
          if (res.code == 1) {
 | 
			
		||||
            this.list = res.data.item;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
        .catch((e) => {
 | 
			
		||||
          console.log(e);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    getGory(){
 | 
			
		||||
      this.$request
 | 
			
		||||
        .post("/gory/index")
 | 
			
		||||
        .then((res) => {
 | 
			
		||||
          console.log(res);
 | 
			
		||||
          if (res.code == 1) {
 | 
			
		||||
            this.gory_list=res.data;
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        .catch((e) => {
 | 
			
		||||
          console.log(e);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    onSubmit() {
 | 
			
		||||
      console.log(this.addForm);
 | 
			
		||||
      if (this.addForm.news_title == '') {
 | 
			
		||||
        this.$message.error('新闻标题不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.news_titleshort == '') {
 | 
			
		||||
        this.$message.error('简短标题不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.gory_id == null) {
 | 
			
		||||
        this.$message.error('请选择新闻分类');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.news_auto == '') {
 | 
			
		||||
        this.$message.error('作者不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.news_source == '') {
 | 
			
		||||
        this.$message.error('来源不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.news_content == '') {
 | 
			
		||||
        this.$message.error('详情不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.news_image=='') {
 | 
			
		||||
        this.$message.error('新闻主图不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.addForm.showtime=='') {
 | 
			
		||||
        this.$message.error('展示时间不能为空');
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      var url = '/news/add';
 | 
			
		||||
      if (this.isEdit) {
 | 
			
		||||
        url = '/news/update';
 | 
			
		||||
      }
 | 
			
		||||
      this.$request
 | 
			
		||||
        .post(url, this.addForm)
 | 
			
		||||
        .then((res) => {
 | 
			
		||||
          console.log(res);
 | 
			
		||||
          if (res.code == 1) {
 | 
			
		||||
            this.$message.success(res.msg);
 | 
			
		||||
            this.addMode = false;
 | 
			
		||||
            this.getList();
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$message.error(res.msg);
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        .catch((e) => {
 | 
			
		||||
          console.log(e);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    onCloseMy() {
 | 
			
		||||
      this.addMode = false;
 | 
			
		||||
      this.infoMode = false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style src="@wangeditor/editor/dist/css/style.css"></style>
 | 
			
		||||
@ -593,6 +593,7 @@ getRegion() {
 | 
			
		||||
          this.formData.cardf_image = res.data.cardf_image;
 | 
			
		||||
          this.formData.cardz_image = res.data.cardz_image;
 | 
			
		||||
          this.formData.photo_image = res.data.photo_image;
 | 
			
		||||
          this.formData.company_image = res.data.company_image;
 | 
			
		||||
          if (res.data.business_license_image == '') {
 | 
			
		||||
            this.formData.business_license_image_show = [];
 | 
			
		||||
          } else {
 | 
			
		||||
 | 
			
		||||
@ -94,6 +94,12 @@ export default [
 | 
			
		||||
    redirect: '/news/news_index',
 | 
			
		||||
    meta: {title: '新闻文章', icon: ViewListIcon},
 | 
			
		||||
    children: [
 | 
			
		||||
      {
 | 
			
		||||
        path: 'wechat_index',
 | 
			
		||||
        name: 'wechatIndex',
 | 
			
		||||
        component: () => import('@/pages/news/wechat_index.vue'),
 | 
			
		||||
        meta: {title: '公众号内容管理'},
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        path: 'news_index',
 | 
			
		||||
        name: 'newsIndex',
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import axios from 'axios';
 | 
			
		||||
import store from '../store'
 | 
			
		||||
//const API_HOST = env === 'mock' ? '/' : proxy[env].API; // 如果是mock模式 就不配置host 会走本地Mock拦截
 | 
			
		||||
const API_HOST ="https://hnyea.0rui.cn/api/";
 | 
			
		||||
//const API_HOST ="/api/";
 | 
			
		||||
//const API_HOST ="https://hnyea.0rui.cn/api/";
 | 
			
		||||
const API_HOST ="/api/";
 | 
			
		||||
const CODE = {
 | 
			
		||||
  LOGIN_TIMEOUT: 100000,
 | 
			
		||||
  REQUEST_SUCCESS: 0,
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,7 @@ export default ({ mode }) => {
 | 
			
		||||
        '/api': {
 | 
			
		||||
          // 用于开发环境下的转发请求
 | 
			
		||||
          // 更多请参考:https://vitejs.dev/config/#server-proxy
 | 
			
		||||
          target: 'http://192.168.3.130/',
 | 
			
		||||
          target: 'https://hnyea.0rui.cn/',
 | 
			
		||||
          pathRewrite: {
 | 
			
		||||
            '^/api': ''
 | 
			
		||||
          },
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user