Commit 77bd81a8 by baihong

add:登录接口对接,活动列表获取

parent c9d5c6b8
...@@ -25,6 +25,9 @@ body { ...@@ -25,6 +25,9 @@ body {
#app { #app {
.size; .size;
} }
.margin-top-10 {
margin-top: 10px;
}
.content { .content {
background: #ffffff; background: #ffffff;
padding: 30px; padding: 30px;
......
import { $http } from '@/libs/http'
export const activityClocks = (data) => {
return $http.get('/cms/activityClocks', data)
}
\ No newline at end of file
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
this.$refs.loginForm.validate((valid) => { this.$refs.loginForm.validate((valid) => {
if (valid) { if (valid) {
this.$emit('on-success-valid', { this.$emit('on-success-valid', {
username: this.form.userName, account: this.form.userName,
password: this.form.password password: this.form.password
}) })
} }
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
<Badge :dot="!!messageUnreadCount"> <Badge :dot="!!messageUnreadCount">
<Avatar :src="userAvatar"/> <Avatar :src="userAvatar"/>
</Badge> </Badge>
{{userName}}
<Icon :size="18" type="md-arrow-dropdown"></Icon> <Icon :size="18" type="md-arrow-dropdown"></Icon>
<DropdownMenu slot="list"> <DropdownMenu slot="list">
<DropdownItem name="message"> <!-- <DropdownItem name="message">
消息中心<Badge style="margin-left: 10px" :count="messageUnreadCount"></Badge> 消息中心<Badge style="margin-left: 10px" :count="messageUnreadCount"></Badge>
</DropdownItem> </DropdownItem> -->
<DropdownItem name="logout">退出登录</DropdownItem> <DropdownItem name="logout">退出登录</DropdownItem>
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
...@@ -30,6 +31,11 @@ export default { ...@@ -30,6 +31,11 @@ export default {
default: 0 default: 0
} }
}, },
data () {
return {
userName:sessionStorage.getItem('username')
}
},
methods: { methods: {
...mapActions([ ...mapActions([
'handleLogOut' 'handleLogOut'
......
...@@ -37,11 +37,11 @@ ...@@ -37,11 +37,11 @@
style="margin-right: 10px;" style="margin-right: 10px;"
v-if="$config.useI18n" v-if="$config.useI18n"
/> />
<error-store <!-- <error-store
:count="errorCount" :count="errorCount"
:has-read="hasReadErrorPage" :has-read="hasReadErrorPage"
v-if="$config.plugin['error-store'] && $config.plugin['error-store'].showInHeader" v-if="$config.plugin['error-store'] && $config.plugin['error-store'].showInHeader"
></error-store> ></error-store> -->
<fullscreen style="margin-right: 10px;" v-model="isFullscreen" /> <fullscreen style="margin-right: 10px;" v-model="isFullscreen" />
</header-bar> </header-bar>
</Header> </Header>
......
...@@ -17,8 +17,8 @@ export default { ...@@ -17,8 +17,8 @@ export default {
* @description api请求基础路径 * @description api请求基础路径
*/ */
baseUrl: { baseUrl: {
dev: '/bg', dev: '/v1',
pro: 'https://applet.mwcx.cn/bg' pro: 'https://api.sign.dankal.cn/v1'
}, },
/** /**
* @description 默认打开的首页的路由name值,默认为home * @description 默认打开的首页的路由name值,默认为home
......
import axios from 'axios' import axios from "axios";
import Qs from 'qs' import Qs from "qs";
import store from '@/store' import store from "@/store";
import router from '@/router' import router from "@/router";
import config from '@/config' import config from "@/config";
import { Message } from 'iview' import { Message } from "iview";
import { getToken } from '@/libs/util' import { getToken } from "@/libs/util";
const baseUrl = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro const baseUrl =
process.env.NODE_ENV === "development"
? config.baseUrl.dev
: config.baseUrl.pro;
const _baseConfig = { const _baseConfig = {
baseURL: baseUrl, baseURL: baseUrl,
headers: {}, headers: {},
params: {}, params: {},
paramsSerializer: function (params) { paramsSerializer: function(params) {
return Qs.stringify(params) return Qs.stringify(params);
}, },
validateStatus: status => { validateStatus: status => {
// 处理响应状态码 // 处理响应状态码
switch (status) { switch (status) {
case 401: case 401:
router.push({ name: 'login' }) router.push({ name: "login" });
return false return false;
case 500: case 500:
// console.log(500); // console.log(500);
return false return false;
} }
return status >= 200 && status < 300 // 默认的, 为false时进入'响应拦截器'catch return status >= 200 && status < 300; // 默认的, 为false时进入'响应拦截器'catch
}, },
transformResponse: [ transformResponse: [
function (data) { function(data) {
// 对 data 进行任意转换处理 // 对 data 进行任意转换处理
// console.log(data); // console.log(data);
return data return data;
} }
], ],
timeout: 3 * 60 * 1000, timeout: 3 * 60 * 1000,
responseType: 'json' responseType: "json"
} };
const _http = axios.create(_baseConfig) const _http = axios.create(_baseConfig);
// 请求拦截器 // 请求拦截器
_http.interceptors.request.use( _http.interceptors.request.use(
function (config) { function(config) {
config.setLoading && store.commit('setIsLoading', true) config.setLoading && store.commit("setIsLoading", true);
// 可以在这里修改请求头 // 可以在这里修改请求头
config.headers.Authorization = getToken() config.headers.Authorization = getToken();
return config return config;
}, },
function (error) { function(error) {
// 对请求错误做些什么 // 对请求错误做些什么
return Promise.reject(error) return Promise.reject(error);
} }
) );
// 响应拦截器 // 响应拦截器
_http.interceptors.response.use( _http.interceptors.response.use(
function (response) { function(response) {
console.log(response) console.log(response);
// 在这里统一处理自定义状态码(如果有) // 在这里统一处理自定义状态码(如果有)
// console.log(response.headers.pragma); // console.log(response.headers.pragma);
store.commit('setIsLoading', false) store.commit("setIsLoading", false);
let result = response.data let result = response.data;
if (result.code === -1) { if (result.code === -1) {
Message.error(result.message) Message.error(result.message);
} }
if (typeof result === 'string') { if (typeof result === "string") {
result = JSON.parse(result) result = JSON.parse(result);
} }
return result return result;
}, },
function (error) { function(error) {
if (!navigator.onLine) { if (!navigator.onLine) {
console.log('无法连接网络') console.log("无法连接网络");
} }
store.commit('setIsLoading', false) store.commit("setIsLoading", false);
return Promise.reject(error) return Promise.reject(error);
} }
) );
const _HttpService = { const _HttpService = {
post: (url, data, config) => { post: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
}, },
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.post(url, Qs.stringify(data), config) return _http.post(url, Qs.stringify(data), config);
}, },
postObj: (url, data, config) => { postObj: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
headers: { headers: {
'Content-Type': 'application/json' "Content-Type": "application/json",
"X-Access-Token":
sessionStorage.getItem("token") || "1b8cc15a59947ce27dd62b"
}, },
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.post(url, JSON.stringify(data), config) return _http.post(url, JSON.stringify(data), config);
}, },
postParams: (url, data, config) => { postParams: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
params: data, params: data,
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.post(url, null, config) return _http.post(url, null, config);
}, },
get: (url, data, config) => { get: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
headers: {
"Content-Type": "application/json",
"X-Access-Token":
sessionStorage.getItem("token") || "1b8cc15a59947ce27dd62b"
},
params: data, params: data,
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.get(url, config) return _http.get(url, config);
}, },
delete: (url, data, config) => { delete: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
headers: { headers: {
'Content-Type': 'application/json' "Content-Type": "application/json"
}, },
data: JSON.stringify(data), data: JSON.stringify(data),
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.delete(url, config) return _http.delete(url, config);
}, },
patch: (url, data, config) => { patch: (url, data, config) => {
const _selfConfig = { const _selfConfig = {
headers: { headers: {
'Content-Type': 'application/json' "Content-Type": "application/json"
}, },
setLoading: true setLoading: true
} };
config = Object.assign({}, _selfConfig, config) config = Object.assign({}, _selfConfig, config);
return _http.patch(url, JSON.stringify(data), config) return _http.patch(url, JSON.stringify(data), config);
} }
} };
export const $http = _HttpService export const $http = _HttpService;
export const $BASEURL = baseUrl export const $BASEURL = baseUrl;
...@@ -403,7 +403,7 @@ export const formatDate = time => { ...@@ -403,7 +403,7 @@ export const formatDate = time => {
if (time === null) { if (time === null) {
return '' return ''
} }
time = new Date(time * 1000) time = new Date(time )
let year = time.getFullYear() let year = time.getFullYear()
let month = time.getMonth() + 1 let month = time.getMonth() + 1
let date = time.getDate() let date = time.getDate()
...@@ -417,15 +417,9 @@ export const formatDate = time => { ...@@ -417,15 +417,9 @@ export const formatDate = time => {
second = second < 10 ? '0' + second : second second = second < 10 ? '0' + second : second
return ( return (
year + year +
'' + '-' +
month + month +
'月' + '-' +
date + date
'日' +
hour +
':' +
minute +
':' +
second
) )
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="left"> <div class="left">
选择日期: 选择日期:
<DatePicker <DatePicker
:value="value2" v-model="date"
format="yyyy/MM/dd" format="yyyy/MM/dd"
type="daterange" type="daterange"
placement="bottom-end" placement="bottom-end"
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
style="width: 200px" style="width: 200px"
></DatePicker> ></DatePicker>
<span style="margin-left:10px">活动状态:</span> <span style="margin-left:10px">活动状态:</span>
<Select style="width: 150px" placeholder="请选择"> <Select v-model="status" style="width: 150px" placeholder="请选择">
<Option value="beijing">未开始</Option> <Option :value="0">未开始</Option>
<Option value="shanghai">进行中</Option> <Option :value="1">进行中</Option>
<Option :value="2">已结束</Option>
</Select> </Select>
<Button type="primary" @click="goDetail">查 询</Button> <Button type="primary" @click="search">查 询</Button>
<Button type="primary" ghost>重 置</Button> <Button type="primary" ghost>重 置</Button>
</div> </div>
<div class="right"> <div class="right">
...@@ -30,11 +31,11 @@ ...@@ -30,11 +31,11 @@
:columns="columns" :columns="columns"
:data="data" :data="data"
> >
<template slot-scope="{ row }" slot="name"> <template slot-scope="{ row }" slot="activity_date">
<span>{{ row.details.name }}</span> <span>{{ row.activity_date | format }}</span>
</template> </template>
<template slot-scope="{ row }" slot="title"> <template slot-scope="{ row }" slot="status">
<span>{{ row.details.title }}</span> <span>{{ row.status===0 ? '未开始':row.status===1?'进行中':'已结束' }}</span>
</template> </template>
<template slot-scope="{ row }" slot="created_at"> <template slot-scope="{ row }" slot="created_at">
<span>{{ row.created_at | format }}</span> <span>{{ row.created_at | format }}</span>
...@@ -56,41 +57,60 @@ ...@@ -56,41 +57,60 @@
<a @click="goTheme(row)">编辑</a> <a @click="goTheme(row)">编辑</a>
</template> </template>
</Table> </Table>
<Pager
class="margin-top-10"
:config="config"
@on-change="handlePager"
></Pager>
</div> </div>
</template> </template>
<script> <script>
import { getScenes, delScenes, editScenes } from "@/api/scenes"; import { activityClocks } from "@/api/clock/activityClocks";
import { formatDate } from '@/libs/util'
import Pager from "@/view/common/Pager.vue";
export default { export default {
name: "categories", name: "categories",
components: {}, components: {
Pager
},
filters: {
format (value) {
return formatDate(value)
}
},
data() { data() {
return { return {
config: { total: 0, size: 10, current: 1 },
date: [],
status: null,
pageIndex: 1,
pageSize: 10,
data: [], data: [],
columns: [ columns: [
{ {
title: "活动日期", title: "活动日期",
key: "created_at" slot: "activity_date"
}, },
{ {
title: "活动缴费金额(真我币)", title: "活动缴费金额(真我币)",
slot: "name" key: "pay_amount"
}, },
{ {
title: "活动状态", title: "活动状态",
slot: "title" slot: "status"
}, },
{ {
title: "报名人数", title: "报名人数",
key: "created_at" key: "apply_num"
}, },
{ {
title: "签到人数", title: "签到人数",
slot: "title" key: "sign_in_num"
}, },
{ {
title: "本场瓜分(真我币)", title: "本场瓜分(真我币)",
key: "created_at" key: "expense_amount"
}, },
{ {
title: "操作", title: "操作",
...@@ -100,11 +120,32 @@ export default { ...@@ -100,11 +120,32 @@ export default {
}; };
}, },
methods: { methods: {
search() {
let params = {
status: this.status,
startDate: this.date[0],
endDate: this.date[1],
pageIndex: this.pageIndex,
pageSize: this.pageSize
};
activityClocks(params).then(res => {
this.config.total = res.total;
this.data = res.data
});
},
handlePager(pager) {
this.pageIndex = pager.current;
this.pageSize = pager.size;
this.search();
},
goDetail() { goDetail() {
this.$router.push({ path: "/signIn/detail", query: { id: "new" } }); this.$router.push({ path: "/signIn/detail", query: { id: "new" } });
} }
}, },
mounted() {} mounted() {
console.log(11);
this.search();
}
}; };
</script> </script>
......
<style lang="less"> <style lang="less">
@import './login.less'; @import "./login.less";
</style> </style>
<template> <template>
...@@ -16,44 +16,40 @@ ...@@ -16,44 +16,40 @@
</template> </template>
<script> <script>
import LoginForm from '_c/login-form' import LoginForm from "_c/login-form";
import { mapActions } from 'vuex' import { mapActions } from "vuex";
import { $http } from '@/libs/http' import { $http } from "@/libs/http";
import { setToken } from '@/libs/util' import { setToken } from "@/libs/util";
export default { export default {
components: { components: {
LoginForm LoginForm
}, },
methods: { methods: {
...mapActions([ ...mapActions(["handleLogin", "getUserInfo"]),
'handleLogin', handleSubmit({ account, password }) {
'getUserInfo'
]),
handleSubmit ({ username, password }) {
$http $http
.postParams('/manager/login', { .postObj("/cms/admins/login", {
account: username, account: account,
pwd: password password: password
}) })
.then(data => { .then(data => {
console.log(data) console.log(data);
if (data.status === 200) { if (data.token && data.token.access_token) {
let token = data.data sessionStorage.setItem("token", data.token.access_token);
setToken(token) sessionStorage.setItem("username", data.user_info.name);
this.$Message.success('登录成功') this.$Message.success("登录成功");
this.$router.push({ this.$router.push({
name: this.$config.homeName name: this.$config.homeName
}) });
} else { }
this.errorMsg = data.msg else {
this.errorMsg = data.msg;
} }
}) })
.catch(() => { }) .catch(() => {});
} }
} }
} };
</script> </script>
<style> <style></style>
</style>
...@@ -40,11 +40,11 @@ module.exports = { ...@@ -40,11 +40,11 @@ module.exports = {
devServer: { devServer: {
disableHostCheck: true, disableHostCheck: true,
proxy: { proxy: {
'/bg': { '/v1': {
'target': 'https://applet.mwcx.cn', 'target': 'https://api.sign.dankal.cn',
'changeOrigin': true, 'changeOrigin': true,
'pathRewirte': { 'pathRewirte': {
'^/bg': '' '^/v1': ''
} }
} }
} }
......
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