126 lines
2.8 KiB
Vue
126 lines
2.8 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 data
|
|
data = {
|
|
name: sugForm.userName,
|
|
phone: sugForm.phoneNum,
|
|
content: sugForm.suggestText,
|
|
}
|
|
console.log(data)
|
|
// const baseUrl = 'http://localhost:8083/api/'
|
|
// const baseUrl = 'https://api.tomey.live/api/'
|
|
const baseUrl = 'http://mytwins.top/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 => {
|
|
if (res.data.code == 1) {
|
|
this.$notify({
|
|
title: '提交成功',
|
|
duration: 2000,
|
|
message: res.msg,
|
|
type: 'success'
|
|
})
|
|
sugForm.userName = ''
|
|
sugForm.phoneNum = ''
|
|
sugForm.suggestText = ''
|
|
} else {
|
|
this.$notify({
|
|
title: '提交失败',
|
|
duration: 2000,
|
|
type: 'error'
|
|
})
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
this.$notify({
|
|
title: '提交失败',
|
|
duration: 2000,
|
|
type: 'error'
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang='scss'>
|
|
.suggest {
|
|
position: relative;
|
|
width: 100%;
|
|
background-color: #f7f7f7;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
</style>
|