145 lines
4.1 KiB
Vue
145 lines
4.1 KiB
Vue
<template>
|
|
<div class="suggest">
|
|
<topTitle
|
|
@cahngeShow='sugcontshow=!sugcontshow'></topTitle>
|
|
<sugBody
|
|
:sugcontshow='sugcontshow'
|
|
@handleSubSuggest='handleSubSuggest'
|
|
:contShow='contShow'></sugBody>
|
|
<appFooter></appFooter>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import topTitle from './SugTopTitle'
|
|
import sugBody from './SugBody'
|
|
import appFooter from '../AppFooter'
|
|
import axios from 'axios'
|
|
// import axios from './api.config'
|
|
import qs from 'qs'
|
|
export default {
|
|
data(){
|
|
return{
|
|
sugcontshow:false,
|
|
contShow:false,
|
|
}
|
|
},
|
|
components:{
|
|
topTitle,
|
|
sugBody,
|
|
appFooter
|
|
},
|
|
mounted() {
|
|
this.contShow=true;
|
|
},
|
|
methods:{
|
|
handleSubSuggest(sugForm){
|
|
let flag = true;
|
|
if(sugForm.userName=='' || !/^([\u4E00-\u9FFF]|\w){2,11}$/.test(sugForm.userName)){
|
|
flag =false;
|
|
this.$message({
|
|
message: '姓名格式不对!',
|
|
type: 'error',
|
|
showClose:true
|
|
});
|
|
}else if(sugForm.phoneNum=='' || !/^1[3-8][0-9]{9}$/.test(sugForm.phoneNum)){
|
|
flag =false;
|
|
this.$message({
|
|
message: '电话格式不对!',
|
|
type: 'error',
|
|
showClose:true
|
|
});
|
|
}else if(sugForm.suggestText==''){
|
|
flag =false;
|
|
this.$message({
|
|
message: '内容不能为空!',
|
|
type: 'error',
|
|
showClose:true
|
|
});
|
|
}
|
|
|
|
/*if(flag){
|
|
let loading = this.$loading({lock:true,text:'玩命加载中...'});
|
|
axios.post(`/admin/submitSuggest`,sugForm).then(response=>{
|
|
let res = response.data;
|
|
loading.close();
|
|
if(res.status=='0'){
|
|
this.$message({
|
|
message: '感谢您的反馈信息,我们会努力做好!',
|
|
type: 'success',
|
|
showClose:true
|
|
});
|
|
}else{
|
|
console.log(res.msg);
|
|
}
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
|
|
})
|
|
}*/
|
|
if (flag){
|
|
|
|
let data
|
|
data = {
|
|
name:sugForm.userName,
|
|
phone:sugForm.phoneNum,
|
|
content:sugForm.suggestText,
|
|
}
|
|
console.log(data)
|
|
// const baseUrl = 'http://localhost:8083/api/'
|
|
const baseUrl = 'http://api.tomey.live/api/'
|
|
axios({
|
|
method: 'post',
|
|
url: baseUrl + 'addcomplaint',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
|
|
},
|
|
data: qs.stringify(data, { arrayFormat: 'brackets' })
|
|
}).then(res => {
|
|
console.log(res)
|
|
console.log("0000")
|
|
if (res.data.code==1){
|
|
this.$notify({
|
|
title: '提交成功',
|
|
duration: 2000,
|
|
message:res.msg,
|
|
type: 'success'
|
|
})
|
|
}else {
|
|
this.$notify({
|
|
title: '提交失败',
|
|
duration: 2000,
|
|
// message:'管理员请前往admin登录',
|
|
type: 'error'
|
|
})
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
this.$notify({
|
|
title: '提交失败',
|
|
// message: data.msg,
|
|
duration: 2000,
|
|
type: 'error'
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang='scss'>
|
|
.suggest{
|
|
position: relative;
|
|
width: 100%;
|
|
background-color: #f7f7f7;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
</style>
|