|
|
@@ -1,50 +1,56 @@
|
|
|
<style lang="scss">
|
|
|
-.content {
|
|
|
- .avatar-uploader .el-upload {
|
|
|
- border: 1px dashed #d9d9d9;
|
|
|
- border-radius: 6px;
|
|
|
- cursor: pointer;
|
|
|
- position: relative;
|
|
|
- overflow: hidden;
|
|
|
- }
|
|
|
- .avatar-uploader .el-upload:hover {
|
|
|
- border-color: #409eff;
|
|
|
- }
|
|
|
- .avatar-uploader-icon {
|
|
|
- font-size: 28px;
|
|
|
- color: #8c939d;
|
|
|
- width: 200px;
|
|
|
- height: 120px;
|
|
|
- line-height: 120px;
|
|
|
- text-align: center;
|
|
|
- }
|
|
|
- .avatar {
|
|
|
- width: 200px;
|
|
|
- height: 120px;
|
|
|
- display: block;
|
|
|
- }
|
|
|
- height: 10vh!important;
|
|
|
+ .content {
|
|
|
+ .avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
|
|
|
- .top{
|
|
|
- margin-left: 20px;
|
|
|
- }
|
|
|
- .save{
|
|
|
- margin-left: 50px;
|
|
|
- margin-top: 20px;
|
|
|
- }
|
|
|
- .detail{
|
|
|
- margin-bottom: 100px;
|
|
|
- width: 70%;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+ .avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409eff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 200px;
|
|
|
+ height: 120px;
|
|
|
+ line-height: 120px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
|
|
|
-.w-e-text{
|
|
|
+ .avatar {
|
|
|
+ width: 200px;
|
|
|
+ height: 120px;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+
|
|
|
+ height: 10vh !important;
|
|
|
+
|
|
|
+ .top {
|
|
|
+ margin-left: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .save {
|
|
|
+ margin-left: 50px;
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .detail {
|
|
|
+ margin-bottom: 100px;
|
|
|
+ width: 70%;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ .w-e-text {
|
|
|
font-size: 16px;
|
|
|
- img{
|
|
|
+
|
|
|
+ img {
|
|
|
max-width: 50% !important;
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
</style>
|
|
|
<template>
|
|
|
<section class="content">
|
|
|
@@ -52,7 +58,7 @@
|
|
|
<el-divider></el-divider>
|
|
|
<el-form>
|
|
|
<el-row>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="标题">
|
|
|
<el-input placeholder="标题" v-model="form.name"></el-input>
|
|
|
</el-form-item>
|
|
|
@@ -61,11 +67,7 @@
|
|
|
<el-col :span="3">
|
|
|
<el-form-item label="分类" class="top">
|
|
|
<el-select v-model="form.category" placeholder="">
|
|
|
- <el-option
|
|
|
- v-for="item in categoryList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
+ <el-option v-for="item in categoryList" :key="item.value" :label="item.label" :value="item.value">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -73,11 +75,15 @@
|
|
|
<el-col :span="3" class="top">
|
|
|
<el-form-item label="置顶">
|
|
|
<el-select v-model="form.isbanner" placeholder="">
|
|
|
- <el-option
|
|
|
- v-for="item in bannerList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
+ <el-option v-for="item in bannerList" :key="item.value" :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="3" class="top">
|
|
|
+ <el-form-item label="精选">
|
|
|
+ <el-select v-model="form.ishot" placeholder="">
|
|
|
+ <el-option v-for="item in bannerList" :key="item.value" :label="item.label" :value="item.value">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -91,37 +97,27 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="4" class="save">
|
|
|
+ <el-col :span="2" class="save">
|
|
|
<el-form-item label="">
|
|
|
<el-button type="primary" @click="save">保存</el-button>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
<el-form-item label="封面图">
|
|
|
- <el-upload
|
|
|
- class="avatar-uploader"
|
|
|
- action="/api/admin/uploadfile"
|
|
|
- :show-file-list="false"
|
|
|
- :on-success="handleAvatarSuccess"
|
|
|
- :before-upload="beforeAvatarUpload"
|
|
|
- >
|
|
|
+ <el-upload class="avatar-uploader" action="/api/admin/uploadfile" :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
|
<img v-if="form.img" :src="form.img" class="avatar" />
|
|
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="文章抓取">
|
|
|
- <el-input placeholder="URL地址" v-model="articleurl" style="width:500px"></el-input>
|
|
|
+ <el-input placeholder="URL地址" v-model="articleurl" style="width:500px"></el-input>
|
|
|
<el-button type="primary" @click="spiderArticle" style="margin-left:20px">抓取</el-button>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-loading="loading" class="detail">
|
|
|
- <fuEditor
|
|
|
- v-model="form.content"
|
|
|
- :isClear="isClear"
|
|
|
- @change="change"
|
|
|
- ></fuEditor>
|
|
|
-
|
|
|
+ <fuEditor v-model="form.content" :isClear="isClear" @change="change"></fuEditor>
|
|
|
<!-- <vue-ueditor-wrap ref="editor" v-model="form.content" :config="myConfig"></vue-ueditor-wrap> -->
|
|
|
</el-form-item>
|
|
|
<!-- <el-form-item label="状态" prop="status">
|
|
|
@@ -134,209 +130,242 @@
|
|
|
<el-form-item label="">
|
|
|
<el-button type="primary" @click="save">保存</el-button>
|
|
|
</el-form-item> -->
|
|
|
- <el-form-item >
|
|
|
+ <el-form-item>
|
|
|
</el-form-item>
|
|
|
- <el-form-item >
|
|
|
+ <el-form-item>
|
|
|
</el-form-item>
|
|
|
- <el-form-item >
|
|
|
+ <el-form-item>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</section>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import fuEditor from "@/components/fuEditor/index.vue";
|
|
|
-export default {
|
|
|
- components: {
|
|
|
- fuEditor,
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- loading: false,
|
|
|
- imageUrl: "",
|
|
|
- test: "",
|
|
|
- list: [],
|
|
|
- form: {
|
|
|
- title: "",
|
|
|
- category_id: "",
|
|
|
- content: "",
|
|
|
- imgs: [],
|
|
|
- address: "",
|
|
|
- point: "",
|
|
|
- status: 1,
|
|
|
- img: "",
|
|
|
- isbanner:0,
|
|
|
- category:'每日点评',
|
|
|
- },
|
|
|
- isClear: false,
|
|
|
- keyword: "",
|
|
|
- point: {
|
|
|
- lng: "",
|
|
|
- lat: "",
|
|
|
- },
|
|
|
- BMap: null,
|
|
|
- myConfig: {
|
|
|
- // 编辑器自动被内容撑高
|
|
|
- autoHeightEnabled: true,
|
|
|
- // 初始容器高度
|
|
|
- initialFrameHeight: 500,
|
|
|
- // 初始容器宽度
|
|
|
- initialFrameWidth: '100%',
|
|
|
- // 上传文件接口,实现上传图片功能必须的配置,这个地址会在后端配置的时候产生,此处先放上结果
|
|
|
- serverUrl: '/api/admin/ueditor/upload',
|
|
|
- },
|
|
|
- categoryList:[
|
|
|
- {label:"游资专场",value:"游资专场"},
|
|
|
- {label:"冠军交割",value:"冠军交割"},
|
|
|
- {label:"牛人专场",value:"牛人专场"},
|
|
|
- {label:"妖股列传",value:"妖股列传"},
|
|
|
- {label:"每日点评",value:"每日点评"}
|
|
|
- ],
|
|
|
- bannerList:[
|
|
|
- {label:"否",value:0},
|
|
|
- {label:"是",value:1}
|
|
|
- ],
|
|
|
- articleurl:"",
|
|
|
- };
|
|
|
- },
|
|
|
- methods: {
|
|
|
- getData() {
|
|
|
- this.$api.getArticleById({ id: this.form.id }).then((res) => {
|
|
|
- this.form = res.data.data;
|
|
|
- });
|
|
|
+ import fuEditor from "@/components/fuEditor/index.vue";
|
|
|
+ export default {
|
|
|
+ components: {
|
|
|
+ fuEditor,
|
|
|
},
|
|
|
- getContent() {
|
|
|
- this.$api.getContentList({ page: this.page }).then((res) => {
|
|
|
- this.loading = false;
|
|
|
- if (res.status == 200) {
|
|
|
- this.list = res.data.data.list;
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: res.message,
|
|
|
- type: "error",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- change(val) {
|
|
|
- this.form.content = val;
|
|
|
- },
|
|
|
- upload(type) {
|
|
|
- var file = document.getElementById(type).files;
|
|
|
- var data = new FormData();
|
|
|
- data.append("file", file[0]);
|
|
|
- this.$api.uploadFile(data).then((res) => {
|
|
|
- if (res.data.code == 0) {
|
|
|
- let imgs = this.form.imgs || [];
|
|
|
- imgs.push(res.data.data.url);
|
|
|
- this.form.imgs = imgs;
|
|
|
- // this.$set(form,type,res.data.data.url)
|
|
|
- this.$message({ message: "上传成功!", type: "success" });
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.message);
|
|
|
- }
|
|
|
- });
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ imageUrl: "",
|
|
|
+ test: "",
|
|
|
+ list: [],
|
|
|
+ form: {
|
|
|
+ title: "",
|
|
|
+ category_id: "",
|
|
|
+ content: "",
|
|
|
+ imgs: [],
|
|
|
+ address: "",
|
|
|
+ point: "",
|
|
|
+ status: 1,
|
|
|
+ img: "",
|
|
|
+ isbanner: 0,
|
|
|
+ category: '每日点评',
|
|
|
+ },
|
|
|
+ isClear: false,
|
|
|
+ keyword: "",
|
|
|
+ point: {
|
|
|
+ lng: "",
|
|
|
+ lat: "",
|
|
|
+ },
|
|
|
+ BMap: null,
|
|
|
+ myConfig: {
|
|
|
+ // 编辑器自动被内容撑高
|
|
|
+ autoHeightEnabled: true,
|
|
|
+ // 初始容器高度
|
|
|
+ initialFrameHeight: 500,
|
|
|
+ // 初始容器宽度
|
|
|
+ initialFrameWidth: '100%',
|
|
|
+ // 上传文件接口,实现上传图片功能必须的配置,这个地址会在后端配置的时候产生,此处先放上结果
|
|
|
+ serverUrl: '/api/admin/ueditor/upload',
|
|
|
+ },
|
|
|
+ categoryList: [{
|
|
|
+ label: "游资专场",
|
|
|
+ value: "游资专场"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "冠军交割",
|
|
|
+ value: "冠军交割"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "牛人专场",
|
|
|
+ value: "牛人专场"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "妖股列传",
|
|
|
+ value: "妖股列传"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "每日点评",
|
|
|
+ value: "每日点评"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ bannerList: [{
|
|
|
+ label: "否",
|
|
|
+ value: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "是",
|
|
|
+ value: 1
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ articleurl: "",
|
|
|
+ };
|
|
|
},
|
|
|
- save() {
|
|
|
- var parm = this.form;
|
|
|
- // parm.point=this.point.lng+','+this.point.lat
|
|
|
- parm.type = "champion";
|
|
|
- if (parm.id) {
|
|
|
- // debugger;
|
|
|
- this.$api.editArticle(parm).then((res) => {
|
|
|
- if (res.data.code == 0) {
|
|
|
- this.$message({ message: "修改成功!", type: "success" });
|
|
|
- this.$router.push({ path: "/championsay" });
|
|
|
+ methods: {
|
|
|
+ getData() {
|
|
|
+ this.$api.getArticleById({
|
|
|
+ id: this.form.id
|
|
|
+ }).then((res) => {
|
|
|
+ this.form = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getContent() {
|
|
|
+ this.$api.getContentList({
|
|
|
+ page: this.page
|
|
|
+ }).then((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.list = res.data.data.list;
|
|
|
} else {
|
|
|
- this.$message.error(res.data.message);
|
|
|
+ this.$message({
|
|
|
+ message: res.message,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
- } else {
|
|
|
- this.$api.addArticle(parm).then((res) => {
|
|
|
+ },
|
|
|
+ change(val) {
|
|
|
+ this.form.content = val;
|
|
|
+ },
|
|
|
+ upload(type) {
|
|
|
+ var file = document.getElementById(type).files;
|
|
|
+ var data = new FormData();
|
|
|
+ data.append("file", file[0]);
|
|
|
+ this.$api.uploadFile(data).then((res) => {
|
|
|
if (res.data.code == 0) {
|
|
|
- this.$message({ message: "添加成功!", type: "success" });
|
|
|
- this.$router.push({ path: "/championsay" });
|
|
|
+ let imgs = this.form.imgs || [];
|
|
|
+ imgs.push(res.data.data.url);
|
|
|
+ this.form.imgs = imgs;
|
|
|
+ // this.$set(form,type,res.data.data.url)
|
|
|
+ this.$message({
|
|
|
+ message: "上传成功!",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$message.error(res.data.message);
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
- },
|
|
|
+ },
|
|
|
+ save() {
|
|
|
+ var parm = this.form;
|
|
|
+ // parm.point=this.point.lng+','+this.point.lat
|
|
|
+ parm.type = "champion";
|
|
|
+ if (parm.id) {
|
|
|
+ // debugger;
|
|
|
+ this.$api.editArticle(parm).then((res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: "修改成功!",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.$router.push({
|
|
|
+ path: "/championsay"
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$api.addArticle(parm).then((res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: "添加成功!",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.$router.push({
|
|
|
+ path: "/championsay"
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- spiderArticle() {
|
|
|
- this.loading = true;
|
|
|
+ spiderArticle() {
|
|
|
+ this.loading = true;
|
|
|
|
|
|
- this.$api.getSpiderArticle({ url: this.articleurl }).then((res) => {
|
|
|
- console.log('data',res.data)
|
|
|
- this.form.content = res.data.data;
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
- },
|
|
|
+ this.$api.getSpiderArticle({
|
|
|
+ url: this.articleurl
|
|
|
+ }).then((res) => {
|
|
|
+ console.log('data', res.data)
|
|
|
+ this.form.content = res.data.data;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- handleAvatarSuccess(res, file) {
|
|
|
- this.form.img = res.data.url;
|
|
|
- },
|
|
|
- beforeAvatarUpload(file) {
|
|
|
- return;
|
|
|
- const isJPG = file.type === "image/jpeg";
|
|
|
- const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+ handleAvatarSuccess(res, file) {
|
|
|
+ this.form.img = res.data.url;
|
|
|
+ },
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ return;
|
|
|
+ const isJPG = file.type === "image/jpeg";
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
|
|
|
- if (!isJPG) {
|
|
|
- this.$message.error("上传头像图片只能是 JPG 格式!");
|
|
|
- }
|
|
|
- if (!isLt2M) {
|
|
|
- this.$message.error("上传头像图片大小不能超过 2MB!");
|
|
|
- }
|
|
|
- return isJPG && isLt2M;
|
|
|
- },
|
|
|
- onBaiduMapReady(e) {
|
|
|
- // const that = this
|
|
|
- this.BMap = e.BMap;
|
|
|
- },
|
|
|
- getClickInfo(e) {
|
|
|
- // 调整地图中心位置
|
|
|
- this.point = e.point;
|
|
|
+ if (!isJPG) {
|
|
|
+ this.$message.error("上传头像图片只能是 JPG 格式!");
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error("上传头像图片大小不能超过 2MB!");
|
|
|
+ }
|
|
|
+ return isJPG && isLt2M;
|
|
|
+ },
|
|
|
+ onBaiduMapReady(e) {
|
|
|
+ // const that = this
|
|
|
+ this.BMap = e.BMap;
|
|
|
+ },
|
|
|
+ getClickInfo(e) {
|
|
|
+ // 调整地图中心位置
|
|
|
+ this.point = e.point;
|
|
|
|
|
|
- // 此时已经可以获取到BMap类
|
|
|
- if (this.BMap) {
|
|
|
- const that = this;
|
|
|
- // Geocoder() 类进行地址解析
|
|
|
- // 创建地址解析器的实例
|
|
|
- const geoCoder = new this.BMap.Geocoder();
|
|
|
- // getLocation() 类--利用坐标获取地址的详细信息
|
|
|
- // getPoint() 类--获取位置对应的坐标
|
|
|
- geoCoder.getLocation(e.point, function (res) {
|
|
|
- const addrComponent = res.addressComponents;
|
|
|
- const surroundingPois = res.surroundingPois;
|
|
|
- const province = addrComponent.province;
|
|
|
- const city = addrComponent.city;
|
|
|
- const district = addrComponent.district;
|
|
|
- let addr = addrComponent.street;
|
|
|
- if (surroundingPois.length > 0 && surroundingPois[0].title) {
|
|
|
- if (addr) {
|
|
|
- addr += `-${surroundingPois[0].title}`;
|
|
|
+ // 此时已经可以获取到BMap类
|
|
|
+ if (this.BMap) {
|
|
|
+ const that = this;
|
|
|
+ // Geocoder() 类进行地址解析
|
|
|
+ // 创建地址解析器的实例
|
|
|
+ const geoCoder = new this.BMap.Geocoder();
|
|
|
+ // getLocation() 类--利用坐标获取地址的详细信息
|
|
|
+ // getPoint() 类--获取位置对应的坐标
|
|
|
+ geoCoder.getLocation(e.point, function (res) {
|
|
|
+ const addrComponent = res.addressComponents;
|
|
|
+ const surroundingPois = res.surroundingPois;
|
|
|
+ const province = addrComponent.province;
|
|
|
+ const city = addrComponent.city;
|
|
|
+ const district = addrComponent.district;
|
|
|
+ let addr = addrComponent.street;
|
|
|
+ if (surroundingPois.length > 0 && surroundingPois[0].title) {
|
|
|
+ if (addr) {
|
|
|
+ addr += `-${surroundingPois[0].title}`;
|
|
|
+ } else {
|
|
|
+ addr += `${surroundingPois[0].title}`;
|
|
|
+ }
|
|
|
} else {
|
|
|
- addr += `${surroundingPois[0].title}`;
|
|
|
+ addr += addrComponent.streetNumber;
|
|
|
}
|
|
|
- } else {
|
|
|
- addr += addrComponent.streetNumber;
|
|
|
- }
|
|
|
- that.form.address = province + city + district + addr;
|
|
|
- });
|
|
|
+ that.form.address = province + city + district + addr;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ // this.getContent()
|
|
|
+ if (this.$route.query.id) {
|
|
|
+ this.form.id = this.$route.query.id;
|
|
|
+ this.id = this.$route.query.id;
|
|
|
+ this.getData();
|
|
|
}
|
|
|
},
|
|
|
- },
|
|
|
- created() {
|
|
|
- // this.getContent()
|
|
|
- if (this.$route.query.id) {
|
|
|
- this.form.id = this.$route.query.id;
|
|
|
- this.id = this.$route.query.id;
|
|
|
- this.getData();
|
|
|
- }
|
|
|
- },
|
|
|
-};
|
|
|
-</script>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ };
|
|
|
+</script>
|