Commit 5b1f28d9 authored by lixy's avatar lixy

关于我们

parent 0ab9830c
import fetch from 'utils/fetch';
/**
* 编辑、新增关于我们
* @param query
*/
export function addUpdate(query) {
return fetch({
url: '/api/website/companyInfo/addUpdate',
method: 'post',
data: query
});
}
/**
* 关于我们-公司信息
*/
export function companyInfo() {
return fetch({
url: '/api/website/companyInfo/detail',
method: 'get'
});
}
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
</div> </div>
</template> </template>
<script> <script type="javascript">
import 'kindeditor/kindeditor-all.js' // import 'kindeditor/kindeditor-all.js'
import 'static/kindeditor-all.js' // 重写图片上传方法
import 'kindeditor/lang/zh-CN.js' import 'kindeditor/lang/zh-CN.js'
import 'kindeditor/themes/default/default.css' import 'kindeditor/themes/default/default.css'
export default { export default {
name: 'kindeditor', name: 'kindeditor',
data () { data() {
return { return {
editor: null, editor: null,
outContent: this.content outContent: this.content
...@@ -59,7 +61,7 @@ export default { ...@@ -59,7 +61,7 @@ export default {
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', 'unlink', '|', 'about' 'anchor', 'link', 'unlink', '|', 'about'
] ]
...@@ -370,4 +372,4 @@ export default { ...@@ -370,4 +372,4 @@ export default {
}) })
} }
} }
</script> </script>
\ No newline at end of file
...@@ -13,18 +13,18 @@ ...@@ -13,18 +13,18 @@
<div class="title">关于我们</div> <div class="title">关于我们</div>
</div> </div>
<div class="content"> <div class="content">
<el-form ref="form" :model="form" label-width="180px"> <el-form ref="form" :model="form" label-width="180px" :rules="rule">
<el-form-item label="*联系电话"> <el-form-item label="联系电话" prop="phone">
<el-col :span="12"> <el-col :span="12">
<el-input v-model="form.title" placeholder="请输入联系电话"></el-input> <el-input v-model="form.phone" placeholder="请输入联系电话"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="*邮箱"> <el-form-item label="邮箱" prop="email">
<el-col :span="12"> <el-col :span="12">
<el-input v-model="form.email" placeholder="请输入邮箱"></el-input> <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="*公司地址"> <el-form-item label="公司地址" prop="address">
<el-col :span="12"> <el-col :span="12">
<!-- <el-input v-model="form.address" placeholder="请输入公司地址"></el-input> --> <!-- <el-input v-model="form.address" placeholder="请输入公司地址"></el-input> -->
<el-autocomplete style="width:100%;" <el-autocomplete style="width:100%;"
...@@ -45,14 +45,14 @@ ...@@ -45,14 +45,14 @@
</el-autocomplete> </el-autocomplete>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label=""> <el-form-item label="" prop="lat">
<div id="map-container"> <div id="map-container">
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="*公司简介"> <el-form-item label="公司简介" prop="intro">
<el-col :span="20"> <el-col :span="20">
<kind-editor id="editor_id" :content.sync="form.introduce" :afterChange="afterChange()" :loadStyleMode="false"@on-content-change="onContentChange"></kind-editor> <kind-editor id="editor_id" :content.sync="form.intro" :afterChange="afterChange()" :loadStyleMode="false"@on-content-change="onContentChange"></kind-editor>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
...@@ -64,9 +64,10 @@ ...@@ -64,9 +64,10 @@
</div> </div>
</template> </template>
<script> <script type="javascript">
import KindEditor from "@/components/Kindeditor"; import KindEditor from "@/components/Kindeditor";
import loadBMap from '@/utils/loadBMap.js' import loadBMap from '@/utils/loadBMap.js'
import { addUpdate, companyInfo } from "api/website/aboutUs"
export default { export default {
name: "AboutUs", name: "AboutUs",
components: { components: {
...@@ -75,11 +76,45 @@ export default { ...@@ -75,11 +76,45 @@ export default {
data() { data() {
return { return {
form: { form: {
title: '', id: undefined,
email: '', phone: undefined, // 联系电话
address: '', email: undefined, // 邮箱
addrPoint: '', address: undefined, // 地址
introduce: '' lat: 23.12005,
lng: 113.30765,
intro: undefined // 简介
},
rule: {
phone: {
required: true,
message: "请输入电话",
trigger: "blur"
},
email: {
required: true,
message: "请输入邮箱",
trigger: "blur"
},
address: {
required: true,
message: "请输入地址",
trigger: "blur"
},
lng: {
required: true,
message: "请输入经纬度",
trigger: "blur"
},
lat: {
required: true,
message: "请输入经纬度",
trigger: "blur"
},
intro: {
required: true,
message: "请输入简介",
trigger: "blur"
},
}, },
map: '', //地图实例 map: '', //地图实例
mk: '' //Marker实例 mk: '' //Marker实例
...@@ -87,13 +122,13 @@ export default { ...@@ -87,13 +122,13 @@ export default {
}, },
async mounted() { async mounted() {
await loadBMap('gvQPveN9YrlPSgKUMPK2u2u2BA4yQFRm') await loadBMap('gvQPveN9YrlPSgKUMPK2u2u2BA4yQFRm')
this.initMap() this.getCompanyInfo() // 获取关于我们详情
}, },
methods: { methods: {
initMap() { initMap() {
var that = this; var that = this;
this.map = new BMap.Map("map-container", {enableMapClick:false}) //新建地图实例,enableMapClick:false :禁用地图默认点击弹框 this.map = new BMap.Map("map-container", {enableMapClick:false}) //新建地图实例,enableMapClick:false :禁用地图默认点击弹框
var point = new BMap.Point(113.30765,23.12005); var point = new BMap.Point(this.form.lng, this.form.lat);
this.map.centerAndZoom(point,19) this.map.centerAndZoom(point,19)
/** 设置图像标注并绑定拖拽标注结束后事件 */ /** 设置图像标注并绑定拖拽标注结束后事件 */
...@@ -139,7 +174,9 @@ export default { ...@@ -139,7 +174,9 @@ export default {
that.mk.setPosition(point) //重新设置标注的地理坐标 that.mk.setPosition(point) //重新设置标注的地理坐标
that.map.panTo(point) //将地图的中心点更改为给定的点 that.map.panTo(point) //将地图的中心点更改为给定的点
that.form.address = res.address; //记录该点的详细地址信息 that.form.address = res.address; //记录该点的详细地址信息
that.form.addrPoint = point; //记录当前坐标点 that.form.lat = point.lat
that.form.lng = point.lng
// that.form.addrPoint = point; //记录当前坐标点
}) })
}, },
/** /**
...@@ -154,7 +191,7 @@ export default { ...@@ -154,7 +191,7 @@ export default {
} else { } else {
// alert('failed'+this.getStatus()); //失败时,弹出失败状态码 // alert('failed'+this.getStatus()); //失败时,弹出失败状态码
console.log("失败状态码",this.getStatus()) console.log("失败状态码",this.getStatus())
} }
},{enableHighAccuracy: true}) //enableHighAccuracy:是否要求浏览器获取最佳效果,默认为false },{enableHighAccuracy: true}) //enableHighAccuracy:是否要求浏览器获取最佳效果,默认为false
}, },
/** /**
...@@ -182,7 +219,9 @@ export default { ...@@ -182,7 +219,9 @@ export default {
*/ */
handleSelect(item) { handleSelect(item) {
this.form.address = item.address + item.title; //记录详细地址,含建筑物名 this.form.address = item.address + item.title; //记录详细地址,含建筑物名
this.form.addrPoint = item.point; //记录当前选中地址坐标 // this.form.addrPoint = item.point; //记录当前选中地址坐标
this.form.lat = point.lat
this.form.lng = point.lng
this.map.clearOverlays() //清除地图上所有覆盖物 this.map.clearOverlays() //清除地图上所有覆盖物
this.mk = new BMap.Marker(item.point) //根据所选坐标重新创建Marker this.mk = new BMap.Marker(item.point) //根据所选坐标重新创建Marker
this.map.addOverlay(this.mk) //将覆盖物重新添加到地图中 this.map.addOverlay(this.mk) //将覆盖物重新添加到地图中
...@@ -194,7 +233,59 @@ export default { ...@@ -194,7 +233,59 @@ export default {
afterChange () { afterChange () {
}, },
/**
* 关于我们-信息
*/
getCompanyInfo(){
companyInfo().then((res) => {
if(res.status == 200){
this.form = {
id: res.data.id,
phone: res.data.phone, // 联系电话
email: res.data.email, // 邮箱
address: res.data.address, // 地址
lng: parseFloat(res.data.lng), // 经纬度
lat: parseFloat(res.data.lat), // 经纬度
intro: res.data.intro // 简介
}
} else {
this.$notify({
title: "失败",
message: res.message,
type: "error",
duration: 2000
});
}
this.initMap()
});
},
/**
* 关于我们-数据保存
*/
onSubmit() { onSubmit() {
this.$refs["form"].validate(valid => {
if (valid) {
addUpdate(this.form).then((res) => {
if(res.status == 200){
this.$notify({
title: "成功",
message: '提交成功',
type: "success",
duration: 2000
});
} else {
this.$notify({
title: "失败",
message: res.message,
type: "error",
duration: 2000
});
}
});
} else {
return false;
}
});
console.log('submit!'); console.log('submit!');
} }
}, },
...@@ -252,4 +343,4 @@ export default { ...@@ -252,4 +343,4 @@ export default {
} }
} }
} }
</style> </style>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment