wen
2 years ago
22 changed files with 173 additions and 466 deletions
@ -1,24 +1,17 @@
@@ -1,24 +1,17 @@
|
||||
import request from '@/utils/request' |
||||
|
||||
export function login(data) { |
||||
export function captcha(datas) { |
||||
return request({ |
||||
url: '/vue-admin-template/user/login', |
||||
url: '/api/captcha', |
||||
method: 'post', |
||||
data |
||||
data: datas |
||||
}) |
||||
} |
||||
|
||||
export function getInfo(token) { |
||||
export function login(datas) { |
||||
return request({ |
||||
url: '/vue-admin-template/user/info', |
||||
method: 'get', |
||||
params: { token } |
||||
}) |
||||
} |
||||
|
||||
export function logout() { |
||||
return request({ |
||||
url: '/vue-admin-template/user/logout', |
||||
method: 'post' |
||||
url: '/api/login', |
||||
method: 'post', |
||||
data: datas |
||||
}) |
||||
} |
@ -1,85 +1,89 @@
@@ -1,85 +1,89 @@
|
||||
import axios from 'axios' |
||||
import { MessageBox, Message } from 'element-ui' |
||||
import store from '@/store' |
||||
import { getToken } from '@/utils/auth' |
||||
//import { MessageBox, Message } from 'element-ui'
|
||||
//import store from '@/store'
|
||||
//import { getToken } from '@/utils/auth'
|
||||
|
||||
// create an axios instance
|
||||
const service = axios.create({ |
||||
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
|
||||
//baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
|
||||
// withCredentials: true, // send cookies when cross-domain requests
|
||||
timeout: 5000 // request timeout
|
||||
headers: { 'Content-Type': 'multipart/form-data' }, |
||||
// headers: {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded'
|
||||
// },
|
||||
timeout: 0 // request timeout
|
||||
}) |
||||
|
||||
// request interceptor
|
||||
service.interceptors.request.use( |
||||
config => { |
||||
// do something before request is sent
|
||||
// service.interceptors.request.use(
|
||||
// config => {
|
||||
// // do something before request is sent
|
||||
|
||||
if (store.getters.token) { |
||||
// let each request carry token
|
||||
// ['X-Token'] is a custom headers key
|
||||
// please modify it according to the actual situation
|
||||
config.headers['X-Token'] = getToken() |
||||
} |
||||
return config |
||||
}, |
||||
error => { |
||||
// do something with request error
|
||||
console.log(error) // for debug
|
||||
return Promise.reject(error) |
||||
} |
||||
) |
||||
// if (store.getters.token) {
|
||||
// // let each request carry token
|
||||
// // ['X-Token'] is a custom headers key
|
||||
// // please modify it according to the actual situation
|
||||
// config.headers['X-Token'] = getToken()
|
||||
// }
|
||||
// return config
|
||||
// },
|
||||
// error => {
|
||||
// // do something with request error
|
||||
// console.log(error) // for debug
|
||||
// return Promise.reject(error)
|
||||
// }
|
||||
// )
|
||||
|
||||
// response interceptor
|
||||
service.interceptors.response.use( |
||||
/** |
||||
* If you want to get http information such as headers or status |
||||
* Please return response => response |
||||
*/ |
||||
// // response interceptor
|
||||
// service.interceptors.response.use(
|
||||
// /**
|
||||
// * If you want to get http information such as headers or status
|
||||
// * Please return response => response
|
||||
// */
|
||||
|
||||
/** |
||||
* Determine the request status by custom code |
||||
* Here is just an example |
||||
* You can also judge the status by HTTP Status Code |
||||
*/ |
||||
response => { |
||||
const res = response.data |
||||
// /**
|
||||
// * Determine the request status by custom code
|
||||
// * Here is just an example
|
||||
// * You can also judge the status by HTTP Status Code
|
||||
// */
|
||||
// response => {
|
||||
// const res = response.data
|
||||
|
||||
// if the custom code is not 20000, it is judged as an error.
|
||||
if (res.code !== 20000) { |
||||
Message({ |
||||
message: res.message || 'Error', |
||||
type: 'error', |
||||
duration: 5 * 1000 |
||||
}) |
||||
// // if the custom code is not 20000, it is judged as an error.
|
||||
// if (res.code !== 20000) {
|
||||
// Message({
|
||||
// message: res.message || 'Error',
|
||||
// type: 'error',
|
||||
// duration: 5 * 1000
|
||||
// })
|
||||
|
||||
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
|
||||
if (res.code === 50008 || res.code === 50012 || res.code === 50014) { |
||||
// to re-login
|
||||
MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { |
||||
confirmButtonText: 'Re-Login', |
||||
cancelButtonText: 'Cancel', |
||||
type: 'warning' |
||||
}).then(() => { |
||||
store.dispatch('user/resetToken').then(() => { |
||||
location.reload() |
||||
}) |
||||
}) |
||||
} |
||||
return Promise.reject(new Error(res.message || 'Error')) |
||||
} else { |
||||
return res |
||||
} |
||||
}, |
||||
error => { |
||||
console.log('err' + error) // for debug
|
||||
Message({ |
||||
message: error.message, |
||||
type: 'error', |
||||
duration: 5 * 1000 |
||||
}) |
||||
return Promise.reject(error) |
||||
} |
||||
) |
||||
// // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
|
||||
// if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
|
||||
// // to re-login
|
||||
// MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
|
||||
// confirmButtonText: 'Re-Login',
|
||||
// cancelButtonText: 'Cancel',
|
||||
// type: 'warning'
|
||||
// }).then(() => {
|
||||
// store.dispatch('user/resetToken').then(() => {
|
||||
// location.reload()
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
// return Promise.reject(new Error(res.message || 'Error'))
|
||||
// } else {
|
||||
// return res
|
||||
// }
|
||||
// },
|
||||
// error => {
|
||||
// console.log('err' + error) // for debug
|
||||
// Message({
|
||||
// message: error.message,
|
||||
// type: 'error',
|
||||
// duration: 5 * 1000
|
||||
// })
|
||||
// return Promise.reject(error)
|
||||
// }
|
||||
// )
|
||||
|
||||
export default service |
||||
|
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
<template> |
||||
<div class="dashboard-container"> |
||||
<div class="dashboard-text"> |
||||
<el-button type="primary">创建目录</el-button> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
|
||||
//import { mapGetters } from 'vuex' |
||||
|
||||
export default { |
||||
|
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.dashboard { |
||||
&-container { |
||||
margin: 30px; |
||||
} |
||||
&-text { |
||||
font-size: 30px; |
||||
line-height: 46px; |
||||
} |
||||
} |
||||
</style> |
@ -1,87 +0,0 @@
@@ -1,87 +0,0 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<el-form ref="form" :model="form" label-width="120px"> |
||||
<el-form-item label="Activity name"> |
||||
<el-input v-model="form.name" /> |
||||
</el-form-item> |
||||
<el-form-item label="Activity zone"> |
||||
<el-select v-model="form.region" placeholder="please select your zone"> |
||||
<el-option label="Zone one" value="shanghai" /> |
||||
<el-option label="Zone two" value="beijing" /> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="Activity time"> |
||||
<el-col :span="11"> |
||||
<el-date-picker v-model="form.date1" type="date" placeholder="Pick a date" style="width: 100%;" /> |
||||
</el-col> |
||||
<el-col :span="2" class="line">-</el-col> |
||||
<el-col :span="11"> |
||||
<el-time-picker v-model="form.date2" type="fixed-time" placeholder="Pick a time" style="width: 100%;" /> |
||||
</el-col> |
||||
</el-form-item> |
||||
<el-form-item label="Instant delivery"> |
||||
<el-switch v-model="form.delivery" /> |
||||
</el-form-item> |
||||
<el-form-item label="Activity type"> |
||||
<el-checkbox-group v-model="form.type"> |
||||
<el-checkbox label="Online activities" name="type" /> |
||||
<el-checkbox label="Promotion activities" name="type" /> |
||||
<el-checkbox label="Offline activities" name="type" /> |
||||
<el-checkbox label="Simple brand exposure" name="type" /> |
||||
</el-checkbox-group> |
||||
</el-form-item> |
||||
<el-form-item label="Resources"> |
||||
<el-radio-group v-model="form.resource"> |
||||
<el-radio label="Sponsor" /> |
||||
<el-radio label="Venue" /> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
<el-form-item label="Activity form"> |
||||
<el-input v-model="form.desc" type="textarea" /> |
||||
</el-form-item> |
||||
<el-form-item> |
||||
<el-button type="primary" @click="onSubmit">Create</el-button> |
||||
<el-button @click="onCancel">Cancel</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
|
||||
export default { |
||||
data() { |
||||
return { |
||||
form: { |
||||
name: '', |
||||
region: '', |
||||
date1: '', |
||||
date2: '', |
||||
delivery: false, |
||||
type: [], |
||||
resource: '', |
||||
desc: '' |
||||
} |
||||
} |
||||
}, |
||||
methods: { |
||||
onSubmit() { |
||||
this.$message('submit!') |
||||
}, |
||||
onCancel() { |
||||
this.$message({ |
||||
message: 'cancel!', |
||||
type: 'warning' |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.line{ |
||||
text-align: center; |
||||
} |
||||
</style> |
||||
|
@ -1,7 +0,0 @@
@@ -1,7 +0,0 @@
|
||||
<template> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1"> |
||||
<router-view /> |
||||
</el-alert> |
||||
</div> |
||||
</template> |
@ -1,7 +0,0 @@
@@ -1,7 +0,0 @@
|
||||
<template> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1-1" type="success"> |
||||
<router-view /> |
||||
</el-alert> |
||||
</div> |
||||
</template> |
@ -1,7 +0,0 @@
@@ -1,7 +0,0 @@
|
||||
<template> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1-2" type="success"> |
||||
<router-view /> |
||||
</el-alert> |
||||
</div> |
||||
</template> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<template functional> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1-2-1" type="warning" /> |
||||
</div> |
||||
</template> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<template functional> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1-2-2" type="warning" /> |
||||
</div> |
||||
</template> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<template functional> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 1-3" type="success" /> |
||||
</div> |
||||
</template> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<template> |
||||
<div style="padding:30px;"> |
||||
<el-alert :closable="false" title="menu 2" /> |
||||
</div> |
||||
</template> |
@ -1,79 +0,0 @@
@@ -1,79 +0,0 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<el-table |
||||
v-loading="listLoading" |
||||
:data="list" |
||||
element-loading-text="Loading" |
||||
border |
||||
fit |
||||
highlight-current-row |
||||
> |
||||
<el-table-column align="center" label="ID" width="95"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.$index }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="Title"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.title }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="Author" width="110" align="center"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.author }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="Pageviews" width="110" align="center"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.pageviews }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column class-name="status-col" label="Status" width="110" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="created_at" label="Display_time" width="200"> |
||||
<template slot-scope="scope"> |
||||
<i class="el-icon-time" /> |
||||
<span>{{ scope.row.display_time }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getList } from '@/api/table' |
||||
|
||||
export default { |
||||
filters: { |
||||
statusFilter(status) { |
||||
const statusMap = { |
||||
published: 'success', |
||||
draft: 'gray', |
||||
deleted: 'danger' |
||||
} |
||||
return statusMap[status] |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
list: null, |
||||
listLoading: true |
||||
} |
||||
}, |
||||
created() { |
||||
this.fetchData() |
||||
}, |
||||
methods: { |
||||
fetchData() { |
||||
this.listLoading = true |
||||
getList().then(response => { |
||||
this.list = response.data.items |
||||
this.listLoading = false |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
@ -1,78 +0,0 @@
@@ -1,78 +0,0 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<el-input v-model="filterText" placeholder="Filter keyword" style="margin-bottom:30px;" /> |
||||
|
||||
<el-tree |
||||
ref="tree2" |
||||
:data="data2" |
||||
:props="defaultProps" |
||||
:filter-node-method="filterNode" |
||||
class="filter-tree" |
||||
default-expand-all |
||||
/> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
|
||||
data() { |
||||
return { |
||||
filterText: '', |
||||
data2: [{ |
||||
id: 1, |
||||
label: 'Level one 1', |
||||
children: [{ |
||||
id: 4, |
||||
label: 'Level two 1-1', |
||||
children: [{ |
||||
id: 9, |
||||
label: 'Level three 1-1-1' |
||||
}, { |
||||
id: 10, |
||||
label: 'Level three 1-1-2' |
||||
}] |
||||
}] |
||||
}, { |
||||
id: 2, |
||||
label: 'Level one 2', |
||||
children: [{ |
||||
id: 5, |
||||
label: 'Level two 2-1' |
||||
}, { |
||||
id: 6, |
||||
label: 'Level two 2-2' |
||||
}] |
||||
}, { |
||||
id: 3, |
||||
label: 'Level one 3', |
||||
children: [{ |
||||
id: 7, |
||||
label: 'Level two 3-1' |
||||
}, { |
||||
id: 8, |
||||
label: 'Level two 3-2' |
||||
}] |
||||
}], |
||||
defaultProps: { |
||||
children: 'children', |
||||
label: 'label' |
||||
} |
||||
} |
||||
}, |
||||
watch: { |
||||
filterText(val) { |
||||
this.$refs.tree2.filter(val) |
||||
} |
||||
}, |
||||
|
||||
methods: { |
||||
filterNode(value, data) { |
||||
if (!value) return true |
||||
return data.label.indexOf(value) !== -1 |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
Loading…
Reference in new issue