Commit 24fed907 authored by Davve's avatar Davve

解决图片上传

parent 1f233f9b
...@@ -15,14 +15,67 @@ class PushListView(APIView): ...@@ -15,14 +15,67 @@ class PushListView(APIView):
data = self.rpc['venus/community/push/get'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/community/push/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
data = { data = {
'total': 200, 'total': 200,
'data': [ 'data': [
{'id': 1, 'title': '测试1', 'content': '测试2', 'push_time': '2018-08-09','create_time':'2019-08-07', 'creator_id':22, }, {
{'id': 2, 'title': '测试1', 'content': '测试2', 'push_time': '2018-08-09', 'create_time': '2019-08-07', 'id': 1,
'creator_id': 22, }, 'title': '测试1',
{'id': 3, 'title': '测试1', 'content': '测试2', 'push_time': '2018-08-09', 'create_time': '2019-08-07', 'content': '测试2',
'creator_id': 22, }, 'push_time': '2018-08-09 23:89:09',
] 'create_time': '2019-08-07 23:89:09',
} 'creator_id': 22,
},
{
'id': 2,
'title': '测试1',
'content': '测试2',
'push_time': '2018-08-09 23:89:09',
'create_time': '2019-08-07 23:89:09',
'creator_id': 22,
},
{
'id': 3,
'title': '测试1',
'content': '测试2',
'push_time': '2018-08-09 23:89:09',
'create_time': '2019-08-07 23:89:09',
'creator_id': 22,
},
]
}
return data
return data class PushUpdateOrCreateView(APIView):
\ No newline at end of file def get(self, request):
id = request.GET.get('id')
try:
data = self.rpc['venus/community/push/detail'](id=id).unwrap()
except Exception as e:
# raise e
data = {
'id': 1,
'create_time': '2018-09-08 23:34:34',
'push_time': 24121273912739, # 返回时间戳
'content': '这是推送内容',
'url': 'http:www.baidu.com',
'icon': 'https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=846134627,633122759&fm=173&app=49&f=JPEG?w=600&h=400&s=84C5D14ADEA4A2575042FFAA0300F005',
'title': '这是一个推送标题',
}
return {'data': data}
def post(self, request):
# TODO 图片icon上传到七牛
data = {
'url': request.POST.get('url', ''),
'push_time': request.POST.get('push_time', ''),
'icon': request.POST.get('icon', ''),
'content': request.POST.get('content', ''),
'title': request.POST.get('title', ''),
}
print(data, '--------------------')
# try:
# self.rpc['venus/community/push/create'](data=data).unwrap()
# except Exception as e:
# raise e
...@@ -14,13 +14,5 @@ class StarListView(APIView): ...@@ -14,13 +14,5 @@ class StarListView(APIView):
try: try:
data = self.rpc['venus/community/star/get'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/community/star/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
data = { raise e
'total': 200,
'data': [
{'id': 1, 'name': '测试1', 'region': '测试2', 'group_nums': 22, 'gender': 1},
{'id': 2, 'name': '测试1', 'region': '测试2', 'group_nums': 13, 'gender': 1},
{'id': 3, 'name': '测试1', 'region': '测试2', 'group_nums': 18, 'gender': 0},
]
}
return data return data
\ No newline at end of file
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/19
from utils.base import APIView
from gm_upload import upload
class FileUpload(APIView):
args_POST = {
'img_type': {
'access': int,
},
}
def post(self, request):
image = request.FILES.get('file')
data = image.read()
full_image_url = upload(data, img_type=self.args_post.get('type')) + '-w'
return {
'file_url': full_image_url
}
...@@ -15,6 +15,7 @@ from .star import * ...@@ -15,6 +15,7 @@ from .star import *
from .account import * from .account import *
from .search import * from .search import *
from .tag import * from .tag import *
from .upload import *
urlpatterns = [ urlpatterns = [
# 登陆,注销相关 # 登陆,注销相关
...@@ -41,6 +42,8 @@ urlpatterns = [ ...@@ -41,6 +42,8 @@ urlpatterns = [
# push相关 # push相关
url(r'push/list$', PushListView.as_view()), url(r'push/list$', PushListView.as_view()),
url(r'push/create', PushUpdateOrCreateView.as_view()),
url(r'push/detail', PushUpdateOrCreateView.as_view()),
# pick相关 # pick相关
url(r'pick/list$', PickListView.as_view()), url(r'pick/list$', PickListView.as_view()),
...@@ -55,11 +58,16 @@ urlpatterns = [ ...@@ -55,11 +58,16 @@ urlpatterns = [
url(r'tag/detail', TagUpdateOrCreateView.as_view()), url(r'tag/detail', TagUpdateOrCreateView.as_view()),
] ]
searchurlpatterns = [ search_urlpatterns = [
url(r'search/group$', GroupSearchView.as_view()), url(r'search/group$', GroupSearchView.as_view()),
url(r'search/region', RegionSearchView.as_view()), url(r'search/region', RegionSearchView.as_view()),
url(r'search/user', UserSearchView.as_view()), url(r'search/user', UserSearchView.as_view()),
url(r'search/tag', TagSearchView.as_view()), url(r'search/tag', TagSearchView.as_view()),
] ]
urlpatterns += searchurlpatterns common_urlpatterns = [
url(r"^file/upload$", FileUpload.as_view()),
]
urlpatterns += search_urlpatterns
urlpatterns += common_urlpatterns
var api = require('./api') var api = require('./api')
// //
// const target = 'http://doctor.test.env' // const target = 'http://doctor.test.env'
// const target = 'http://172.30.8.231:8000' const target = 'http://172.30.8.231:8000'
const target = 'http://192.168.1.6:8000' // const target = 'http://192.168.1.6:8000'
// 可以修改请求内容 // 可以修改请求内容
const onProxyReq = proxyReq => {} const onProxyReq = proxyReq => {}
......
...@@ -8,3 +8,27 @@ export function fetchList(query) { ...@@ -8,3 +8,27 @@ export function fetchList(query) {
}) })
} }
export function OffLineOrOnLine(data) {
console.log(data)
return request({
url: '/api/push/list/update',
method: 'post',
data
})
}
export function CreatePush(data) {
return request({
url: '/api/push/create',
method: 'post',
data
})
}
export function fetchPushDetail(id) {
return request({
url: '/api/push/detail',
method: 'get',
params: { id }
})
}
...@@ -7,18 +7,18 @@ ...@@ -7,18 +7,18 @@
:on-success="handleImageSuccess" :on-success="handleImageSuccess"
class="image-uploader" class="image-uploader"
drag drag
action="https://httpbin.org/post"> action="/api/file/upload">
<i class="el-icon-upload"/> <i class="el-icon-upload"/>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
</el-upload> </el-upload>
<div class="image-preview image-app-preview"> <!--<div class="image-preview image-app-preview">-->
<div v-show="imageUrl.length>1" class="image-preview-wrapper"> <!--<div v-show="imageUrl.length>1" class="image-preview-wrapper">-->
<img :src="imageUrl"> <!--<img :src="imageUrl">-->
<div class="image-preview-action"> <!--<div class="image-preview-action">-->
<i class="el-icon-delete" @click="rmImage"/> <!--<i class="el-icon-delete" @click="rmImage"/>-->
</div> <!--</div>-->
</div> <!--</div>-->
</div> <!--</div>-->
<div class="image-preview"> <div class="image-preview">
<div v-show="imageUrl.length>1" class="image-preview-wrapper"> <div v-show="imageUrl.length>1" class="image-preview-wrapper">
<img :src="imageUrl"> <img :src="imageUrl">
...@@ -39,12 +39,16 @@ export default { ...@@ -39,12 +39,16 @@ export default {
value: { value: {
type: String, type: String,
default: '' default: ''
},
type: {
type: String,
default: ''
} }
}, },
data() { data() {
return { return {
tempUrl: '', tempUrl: '',
dataObj: { token: '', key: '' } dataObj: { type: this.type }
} }
}, },
computed: { computed: {
...@@ -60,7 +64,7 @@ export default { ...@@ -60,7 +64,7 @@ export default {
this.$emit('input', val) this.$emit('input', val)
}, },
handleImageSuccess(file) { handleImageSuccess(file) {
this.emitInput(file.files.file) this.emitInput(file.data.file_url)
}, },
beforeUpload() { beforeUpload() {
const _self = this const _self = this
......
...@@ -100,37 +100,5 @@ export const asyncRouterMap = [ ...@@ -100,37 +100,5 @@ export const asyncRouterMap = [
PushRouter, PushRouter,
PickRouter, PickRouter,
TagRouter, TagRouter,
{
path: '/example',
component: Layout,
redirect: '/example/list',
name: 'Example',
meta: {
title: 'example',
icon: 'example'
},
children: [
{
path: 'create',
component: () => import('@/views/example/create'),
name: 'CreateArticle',
meta: { title: 'createArticle', icon: 'edit' }
},
{
path: 'edit/:id(\\d+)',
component: () => import('@/views/example/edit'),
name: 'EditArticle',
meta: { title: 'editArticle', noCache: true },
hidden: true
},
{
path: 'list',
component: () => import('@/views/example/list'),
name: 'ArticleList',
meta: { title: 'articleList', icon: 'list' }
}
]
},
{ path: '*', redirect: '/404', hidden: true } { path: '*', redirect: '/404', hidden: true }
] ]
...@@ -9,7 +9,7 @@ const AccountRouter = { ...@@ -9,7 +9,7 @@ const AccountRouter = {
name: 'Account', name: 'Account',
meta: { meta: {
title: '账号管理', title: '账号管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const GroupRouter = { ...@@ -9,7 +9,7 @@ const GroupRouter = {
name: 'Group', name: 'Group',
meta: { meta: {
title: '小组管理', title: '小组管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const PickRouter = { ...@@ -9,7 +9,7 @@ const PickRouter = {
name: 'Pick', name: 'Pick',
meta: { meta: {
title: 'Pick管理', title: 'Pick管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const PushRouter = { ...@@ -9,7 +9,7 @@ const PushRouter = {
name: 'Push', name: 'Push',
meta: { meta: {
title: 'Push管理', title: 'Push管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const StarRouter = { ...@@ -9,7 +9,7 @@ const StarRouter = {
name: 'Star', name: 'Star',
meta: { meta: {
title: '明星管理', title: '明星管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -7,7 +7,7 @@ const TagRouter = { ...@@ -7,7 +7,7 @@ const TagRouter = {
name: 'Tag', name: 'Tag',
meta: { meta: {
title: '标签管理', title: '标签管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const TopicRouter = { ...@@ -9,7 +9,7 @@ const TopicRouter = {
name: 'Topic', name: 'Topic',
meta: { meta: {
title: '帖子管理', title: '帖子管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,7 @@ const GroupRouter = { ...@@ -9,7 +9,7 @@ const GroupRouter = {
name: 'User', name: 'User',
meta: { meta: {
title: '用户管理', title: '用户管理',
icon: 'example' icon: 'component'
}, },
children: [ children: [
{ {
......
...@@ -5,75 +5,44 @@ ...@@ -5,75 +5,44 @@
<el-select v-model="listQuery.filter.key" :placeholder="'搜索字段'" clearable class="filter-item" style="width: 110px"> <el-select v-model="listQuery.filter.key" :placeholder="'搜索字段'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in SearchTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in SearchTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
<el-select v-model="listQuery.filter.is_online" :placeholder="'上线'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in BooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.is_recommend" :placeholder="'推荐'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button> <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('online')">上线</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('recommend')">推荐</el-button>
</div> </div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange"> <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column> <el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column align="center" label="小组ID " width="80"> <el-table-column align="center" label="推送ID " width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/push/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="190px" align="center" label="小组名称"> <el-table-column width="190px" align="center" label="推送内容">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.name }}</span> <span>{{ scope.row.content }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="300px" align="center" label="小组简介"> <el-table-column width="300px" align="center" label="推送时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.desc }}</span> <span>{{ scope.row.push_time }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="120px" align="center" label="明星名称"> <el-table-column width="120px" align="center" label="创建时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.star.name }}</span> <span>{{ scope.row.create_time }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="80px" align="center" label="用户数"> <el-table-column width="80px" align="center" label="创建用户">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.user_nums }}</span> <span>{{ scope.row.creator }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="80px" align="center" label="帖子数">
<template slot-scope="scope">
<span>{{ scope.row.topic_nums }}</span>
</template>
</el-table-column>
<el-table-column width="140px" align="center" label="组长">
<template slot-scope="scope">
<span>{{ scope.row.creator.name }}</span>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="下线">
<template slot-scope="scope">
<el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="推荐">
<template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>is_recommend
</el-table> </el-table>
...@@ -90,30 +59,12 @@ import waves from '@/directive/waves' ...@@ -90,30 +59,12 @@ import waves from '@/directive/waves'
export default { export default {
name: 'GroupList', name: 'GroupList',
components: { Pagination }, components: { Pagination },
filters: {
isOnlineFilter(status) {
const statusMap = {
1: 'success',
0: 'info',
}
return statusMap[status]
},
genderFilter(status) {
const statusMap = {
'男': 'success',
'女': 'info',
'全部': 'danger'
}
return statusMap[status]
},
},
directives: { waves }, directives: { waves },
data() { data() {
return { return {
list: null, list: null,
total: 0, total: 0,
listLoading: true, listLoading: true,
multipleSelection: [],
del_list: [], del_list: [],
listQuery: { listQuery: {
page: 0, page: 0,
...@@ -121,22 +72,11 @@ export default { ...@@ -121,22 +72,11 @@ export default {
filter: { filter: {
value: '', value: '',
key: '', key: '',
is_online: '',
is_recommend: '',
}, },
}, },
BooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
],
ReBooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
],
SearchTypeOptions:[ SearchTypeOptions:[
{'key': 'id', 'display_name': '小组ID'}, {'key': 'id', 'display_name': '推送ID'},
{'key': 'name', 'display_name': '小组名称'}, {'key': 'content', 'display_name': '推送内容'},
{'key': 'star_name', 'display_name': '明星名称'},
] ]
} }
}, },
...@@ -152,9 +92,6 @@ export default { ...@@ -152,9 +92,6 @@ export default {
this.listLoading = false this.listLoading = false
}) })
}, },
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.limit = val this.listQuery.limit = val
this.getList() this.getList()
...@@ -163,31 +100,12 @@ export default { ...@@ -163,31 +100,12 @@ export default {
this.listQuery.page = val this.listQuery.page = val
this.getList() this.getList()
}, },
handleOfflineOrOnline(val){
const length = this.multipleSelection.length;
let str = '';
this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) {
if (val === 'offline'){
this.multipleSelection[i].is_online = 0
} else if(val === 'recommend'){
this.multipleSelection[i].is_recommend = 1
} else{
this.multipleSelection[i].is_online = 1
}
str += this.multipleSelection[i].id + ' ';
}
OffLineOrOnLine({type:val, ids:str}).then(response => {
this.multipleSelection = [];
this.$message.success(response.data.data.message);
})
},
handleFilter() { handleFilter() {
this.listQuery.page = 0 this.listQuery.page = 0
this.getList() this.getList()
}, },
handleCreate() { handleCreate() {
this.$router.push('/pick/create') this.$router.push('/push/create')
} }
} }
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<size-select class="international right-menu-item"/> <size-select class="international right-menu-item"/>
</el-tooltip> </el-tooltip>
<lang-select class="international right-menu-item"/>
<el-tooltip :content="$t('navbar.theme')" effect="dark" placement="bottom"> <el-tooltip :content="$t('navbar.theme')" effect="dark" placement="bottom">
<theme-picker class="theme-switch right-menu-item"/> <theme-picker class="theme-switch right-menu-item"/>
</el-tooltip> </el-tooltip>
...@@ -56,6 +56,7 @@ import ErrorLog from '@/components/ErrorLog' ...@@ -56,6 +56,7 @@ import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull' import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect' import SizeSelect from '@/components/SizeSelect'
import ThemePicker from '@/components/ThemePicker' import ThemePicker from '@/components/ThemePicker'
import LangSelect from '@/components/LangSelect'
export default { export default {
components: { components: {
...@@ -64,7 +65,8 @@ export default { ...@@ -64,7 +65,8 @@ export default {
ErrorLog, ErrorLog,
Screenfull, Screenfull,
SizeSelect, SizeSelect,
ThemePicker ThemePicker,
LangSelect
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
......
This diff is collapsed.
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<el-table-column width="150px" align="center" label="小组数量"> <el-table-column width="150px" align="center" label="小组数量">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/pick/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.group_nums }}</span> <span>{{ scope.row.group_counts }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
......
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