Commit 24fed907 authored by Davve's avatar Davve

解决图片上传

parent 1f233f9b
......@@ -17,12 +17,65 @@ class PushListView(APIView):
data = {
'total': 200,
'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',
'creator_id': 22, },
{'id': 3, 'title': '测试1', 'content': '测试2', 'push_time': '2018-08-09', 'create_time': '2019-08-07',
'creator_id': 22, },
{
'id': 1,
'title': '测试1',
'content': '测试2',
'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
class PushUpdateOrCreateView(APIView):
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):
try:
data = self.rpc['venus/community/star/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
data = {
'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},
]
}
raise e
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 *
from .account import *
from .search import *
from .tag import *
from .upload import *
urlpatterns = [
# 登陆,注销相关
......@@ -41,6 +42,8 @@ urlpatterns = [
# push相关
url(r'push/list$', PushListView.as_view()),
url(r'push/create', PushUpdateOrCreateView.as_view()),
url(r'push/detail', PushUpdateOrCreateView.as_view()),
# pick相关
url(r'pick/list$', PickListView.as_view()),
......@@ -55,11 +58,16 @@ urlpatterns = [
url(r'tag/detail', TagUpdateOrCreateView.as_view()),
]
searchurlpatterns = [
search_urlpatterns = [
url(r'search/group$', GroupSearchView.as_view()),
url(r'search/region', RegionSearchView.as_view()),
url(r'search/user', UserSearchView.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')
//
// const target = 'http://doctor.test.env'
// const target = 'http://172.30.8.231:8000'
const target = 'http://192.168.1.6:8000'
const target = 'http://172.30.8.231:8000'
// const target = 'http://192.168.1.6:8000'
// 可以修改请求内容
const onProxyReq = proxyReq => {}
......
......@@ -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 @@
:on-success="handleImageSuccess"
class="image-uploader"
drag
action="https://httpbin.org/post">
action="/api/file/upload">
<i class="el-icon-upload"/>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
</el-upload>
<div class="image-preview image-app-preview">
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
<img :src="imageUrl">
<div class="image-preview-action">
<i class="el-icon-delete" @click="rmImage"/>
</div>
</div>
</div>
<!--<div class="image-preview image-app-preview">-->
<!--<div v-show="imageUrl.length>1" class="image-preview-wrapper">-->
<!--<img :src="imageUrl">-->
<!--<div class="image-preview-action">-->
<!--<i class="el-icon-delete" @click="rmImage"/>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<div class="image-preview">
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
<img :src="imageUrl">
......@@ -39,12 +39,16 @@ export default {
value: {
type: String,
default: ''
},
type: {
type: String,
default: ''
}
},
data() {
return {
tempUrl: '',
dataObj: { token: '', key: '' }
dataObj: { type: this.type }
}
},
computed: {
......@@ -60,7 +64,7 @@ export default {
this.$emit('input', val)
},
handleImageSuccess(file) {
this.emitInput(file.files.file)
this.emitInput(file.data.file_url)
},
beforeUpload() {
const _self = this
......
......@@ -100,37 +100,5 @@ export const asyncRouterMap = [
PushRouter,
PickRouter,
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 }
]
......@@ -9,7 +9,7 @@ const AccountRouter = {
name: 'Account',
meta: {
title: '账号管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const GroupRouter = {
name: 'Group',
meta: {
title: '小组管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const PickRouter = {
name: 'Pick',
meta: {
title: 'Pick管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const PushRouter = {
name: 'Push',
meta: {
title: 'Push管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const StarRouter = {
name: 'Star',
meta: {
title: '明星管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -7,7 +7,7 @@ const TagRouter = {
name: 'Tag',
meta: {
title: '标签管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const TopicRouter = {
name: 'Topic',
meta: {
title: '帖子管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -9,7 +9,7 @@ const GroupRouter = {
name: 'User',
meta: {
title: '用户管理',
icon: 'example'
icon: 'component'
},
children: [
{
......
......@@ -5,75 +5,44 @@
<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-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 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>
<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 align="center" label="小组ID " width="80">
<el-table-column align="center" label="推送ID " width="80">
<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>
</router-link>
</template>
</el-table-column>
<el-table-column width="190px" align="center" label="小组名称">
<el-table-column width="190px" align="center" label="推送内容">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
<span>{{ scope.row.content }}</span>
</template>
</el-table-column>
<el-table-column width="300px" align="center" label="小组简介">
<el-table-column width="300px" align="center" label="推送时间">
<template slot-scope="scope">
<span>{{ scope.row.desc }}</span>
<span>{{ scope.row.push_time }}</span>
</template>
</el-table-column>
<el-table-column width="120px" align="center" label="明星名称">
<el-table-column width="120px" align="center" label="创建时间">
<template slot-scope="scope">
<span>{{ scope.row.star.name }}</span>
<span>{{ scope.row.create_time }}</span>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="用户数">
<el-table-column width="80px" align="center" label="创建用户">
<template slot-scope="scope">
<span>{{ scope.row.user_nums }}</span>
<span>{{ scope.row.creator }}</span>
</template>
</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>
......@@ -90,30 +59,12 @@ import waves from '@/directive/waves'
export default {
name: 'GroupList',
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 },
data() {
return {
list: null,
total: 0,
listLoading: true,
multipleSelection: [],
del_list: [],
listQuery: {
page: 0,
......@@ -121,22 +72,11 @@ export default {
filter: {
value: '',
key: '',
is_online: '',
is_recommend: '',
},
},
BooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
],
ReBooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
],
SearchTypeOptions:[
{'key': 'id', 'display_name': '小组ID'},
{'key': 'name', 'display_name': '小组名称'},
{'key': 'star_name', 'display_name': '明星名称'},
{'key': 'id', 'display_name': '推送ID'},
{'key': 'content', 'display_name': '推送内容'},
]
}
},
......@@ -152,9 +92,6 @@ export default {
this.listLoading = false
})
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
......@@ -163,31 +100,12 @@ export default {
this.listQuery.page = val
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() {
this.listQuery.page = 0
this.getList()
},
handleCreate() {
this.$router.push('/pick/create')
this.$router.push('/push/create')
}
}
}
......
......@@ -16,7 +16,7 @@
<size-select class="international right-menu-item"/>
</el-tooltip>
<lang-select class="international right-menu-item"/>
<el-tooltip :content="$t('navbar.theme')" effect="dark" placement="bottom">
<theme-picker class="theme-switch right-menu-item"/>
</el-tooltip>
......@@ -56,6 +56,7 @@ import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import ThemePicker from '@/components/ThemePicker'
import LangSelect from '@/components/LangSelect'
export default {
components: {
......@@ -64,7 +65,8 @@ export default {
ErrorLog,
Screenfull,
SizeSelect,
ThemePicker
ThemePicker,
LangSelect
},
computed: {
...mapGetters([
......
This diff is collapsed.
......@@ -47,7 +47,7 @@
<el-table-column width="150px" align="center" label="小组数量">
<template slot-scope="scope">
<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>
</template>
</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