Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
82640cea
Commit
82640cea
authored
Jun 27, 2023
by
Anh Kieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call api contact
parent
a489abb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
22 deletions
+52
-22
index.vue
pages/home-page/contact/index.vue
+35
-5
axios.js
plugins/axios.js
+17
-17
No files found.
pages/home-page/contact/index.vue
View file @
82640cea
...
...
@@ -37,12 +37,12 @@
<h4
class=
"font-weight-light"
>
Your email address will not be published. Required fields are marked *
</h4>
<v-textarea
outlined
auto-grow
placeholder=
"Comment*
"
/>
<v-textarea
v-model=
"comment"
outlined
auto-grow
placeholder=
"Comment*"
:rules=
"requiredRules
"
/>
<v-row>
<v-col><v-text-field
outlined
placeholder=
"Name
"
/></v-col>
<v-col><v-text-field
outlined
placeholder=
"Email
"
/></v-col>
<v-col><v-text-field
v-model=
"name"
outlined
placeholder=
"Name"
:rules=
"requiredRules
"
/></v-col>
<v-col><v-text-field
v-model=
"mail"
outlined
placeholder=
"Email"
:rules=
"requiredRules
"
/></v-col>
</v-row>
<V-btn
class=
"post-btn"
>
<V-btn
class=
"post-btn"
@
click=
"sendMailContact"
>
POST COMMENT
</V-btn>
</v-row>
...
...
@@ -133,12 +133,42 @@ export default {
subtitle2
:
'
phone:0965615899
'
}
],
requiredRules
:
[
v
=>
!!
v
||
'
This field is required
'
],
comment
:
''
,
name
:
''
,
email
:
''
mail
:
''
}
},
methods
:
{
async
sendMailContact
()
{
const
self
=
this
const
fd
=
new
FormData
()
fd
.
append
(
'
mail
'
,
this
.
mail
)
fd
.
append
(
'
name
'
,
this
.
name
)
fd
.
append
(
'
comment
'
,
this
.
comment
)
const
resp
=
await
this
.
$axios
.
post
(
'
/contact/send-mail-contact
'
,
fd
,
{
headers
:
{
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}).
then
(
function
(
response
)
{
self
.
$toast
.
success
(
'
Send Mail Success!
'
,
{
duration
:
10000
})
})
.
catch
(
function
(
errors
)
{
console
.
log
(
errors
)
const
message
=
errors
.
response
.
data
self
.
$toast
.
error
(
'
Send Mail Success!
'
,
{
// duration: 10000
// })
})
console
.
log
(
resp
)
}
}
}
// eslint-disable-next-line eol-last
</
script
>
...
...
plugins/axios.js
View file @
82640cea
export
default
function
({
$axios
},
inject
,
redirect
)
{
$axios
.
onError
((
error
)
=>
{
if
(
error
.
response
.
status
===
500
)
{
redirect
(
'
/500
'
)
}
})
//
$axios.onError((error) => {
//
if (error.response.status === 500) {
//
redirect('/500')
//
}
//
})
$axios
.
onError
((
error
)
=>
{
const
code
=
parseInt
(
error
.
response
&&
error
.
response
.
status
)
if
(
code
===
400
)
{
redirect
(
'
/400
'
)
}
})
//
$axios.onError((error) => {
//
const code = parseInt(error.response && error.response.status)
//
if (code === 400) {
//
redirect('/400')
//
}
//
})
$axios
.
onError
((
error
)
=>
{
const
code
=
parseInt
(
error
.
response
&&
error
.
response
.
status
)
if
(
code
===
403
)
{
redirect
(
'
/login
'
)
}
})
//
$axios.onError((error) => {
//
const code = parseInt(error.response && error.response.status)
//
if (code === 403) {
//
redirect('/login')
//
}
//
})
const
api
=
$axios
.
create
({
headers
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment