Commit 626302b9 authored by Davve's avatar Davve

完善用户获取信息

parent 6b6f5db0
...@@ -12,7 +12,7 @@ class PickListView(APIView): ...@@ -12,7 +12,7 @@ class PickListView(APIView):
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', "")) filter = self.handle_filter(request.GET.get('filter', ""))
try: try:
data = self.rpc['venus/community/pick/get'](offset=offset, limit=limit, filters=filter).unwrap() data = self.rpc['venus/sun/pick/list'](offset=(offset - 1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return data return data
...@@ -20,8 +20,15 @@ class PickListView(APIView): ...@@ -20,8 +20,15 @@ class PickListView(APIView):
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = request.POST.get('ids', '').split()
type = request.POST.get('type', '') type = request.POST.get('type', '')
updates = {}
if type == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try: try:
self.rpc['venus/community/pick/offline_pick'](type=type, ids=ids).unwrap() self.rpc['venus/sun/pick/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return { return {
...@@ -33,12 +40,13 @@ class UpdateOrCreateView(APIView): ...@@ -33,12 +40,13 @@ class UpdateOrCreateView(APIView):
def get(self, request): def get(self, request):
id = request.GET.get('id') id = request.GET.get('id')
try: try:
data = self.rpc['venus/community/pick/detail'](id=id).unwrap() data = self.rpc['venus/sun/pick/get'](id=id).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
def post(self, request): def post(self, request):
id = request.POST.get('id', '')
data = { data = {
'name': request.POST.get('name'), 'name': request.POST.get('name'),
'desc': request.POST.get('desc'), 'desc': request.POST.get('desc'),
...@@ -50,7 +58,7 @@ class UpdateOrCreateView(APIView): ...@@ -50,7 +58,7 @@ class UpdateOrCreateView(APIView):
'is_online': request.POST.get('is_online'), 'is_online': request.POST.get('is_online'),
} }
try: try:
self.rpc['venus/community/pick/update_or_create'](data=data).unwrap() self.rpc['venus/sun/pick/edit'](id=id, data=data).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return { return {
......
...@@ -13,7 +13,7 @@ class PushListView(APIView): ...@@ -13,7 +13,7 @@ class PushListView(APIView):
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', "")) filter = self.handle_filter(request.GET.get('filter', ""))
try: try:
data = self.rpc['venus/community/push/sun_list'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/sun/push/list'](offset=(page-1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return data return data
...@@ -23,7 +23,7 @@ class PushUpdateOrCreateView(APIView): ...@@ -23,7 +23,7 @@ class PushUpdateOrCreateView(APIView):
def get(self, request): def get(self, request):
id = request.GET.get('id') id = request.GET.get('id')
try: try:
data = self.rpc['venus/community/push/get'](id=id).unwrap() data = self.rpc['venus/sun/push/get'](id=id).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
...@@ -38,9 +38,10 @@ class PushUpdateOrCreateView(APIView): ...@@ -38,9 +38,10 @@ class PushUpdateOrCreateView(APIView):
'icon': request.POST.get('icon', '')[:-2], 'icon': request.POST.get('icon', '')[:-2],
'content': request.POST.get('content', ''), 'content': request.POST.get('content', ''),
'title': request.POST.get('title', ''), 'title': request.POST.get('title', ''),
'creator_id': '' # TODO 运营ID
} }
try: try:
self.rpc['venus/community/push/update_or_create'](id=id, data=data).unwrap() self.rpc['venus/sun/push/edit'](id=id, data=data).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return { return {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/15 # Date: 2018/11/15
import time
import json import json
from utils.base import APIView from utils.base import APIView
from utils.time_utils import analysis_time from utils.time_utils import analysis_time
...@@ -33,16 +34,19 @@ class UserUpdateOrCreate(APIView): ...@@ -33,16 +34,19 @@ class UserUpdateOrCreate(APIView):
return data return data
def post(self, request): def post(self, request):
id = request.POST.get('id', '') user_id = request.POST.get('id', '')
show_time = analysis_time(request.POST.get('show_time', 0)) show_time = analysis_time(request.POST.get('show_time', 0))
tag_ids = list(set(request.POST.get('tag_ids').split(',')))
if not user_id:
user_id = time.time()
data = { data = {
'user_id': user_id,
'is_recommend': request.POST.get('is_recommend'), 'is_recommend': request.POST.get('is_recommend'),
'profile_pic': request.POST.get('avatar')[:-2], 'profile_pic': request.POST.get('avatar')[:-2],
'nick_name': request.POST.get('nick_name'), 'nick_name': request.POST.get('nick_name'),
'tag_ids': request.POST.get('tag_ids'), 'tag_ids': list(filter(lambda x: x, tag_ids)),
'is_puppet': request.POST.get('is_puppet'), 'is_puppet': request.POST.get('is_puppet'),
'city': request.POST.get('city'), 'city_id': request.POST.get('city'),
'show_time': show_time, 'show_time': show_time,
'phone': request.POST.get('phone'), 'phone': request.POST.get('phone'),
'email': request.POST.get('email'), 'email': request.POST.get('email'),
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label-width="45px" label="地区:" class="postInfo-container-item"> <el-form-item label-width="45px" label="地区:" class="postInfo-container-item">
<el-select v-model="postForm.region" :remote-method="getRemoteRegionList" filterable remote multiple value-key="id" <el-select v-model="postForm.region" :remote-method="getRemoteCityList" filterable remote multiple value-key="id"
placeholder="搜索地区" style="width: 100%"> placeholder="搜索地区" style="width: 100%">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select> </el-select>
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
import MDinput from '@/components/MDinput' import MDinput from '@/components/MDinput'
import Sticky from '@/components/Sticky' // 粘性header组件 import Sticky from '@/components/Sticky' // 粘性header组件
import {fetchPickDetail, CreatePick} from '@/api/pick' import {fetchPickDetail, CreatePick} from '@/api/pick'
import {groupSearch, regionSearch} from '@/api/remoteSearch' import {groupSearch, regionSearch, citySearch} from '@/api/remoteSearch'
import { isInArray, removeByvale} from "@/utils"; import { isInArray, removeByvale} from "@/utils";
function Assembledata(target, source) { function Assembledata(target, source) {
...@@ -241,7 +241,6 @@ ...@@ -241,7 +241,6 @@
this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region); this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region);
this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group); this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group);
}else{ }else{
this.postForm.region = this.postForm.region.join(',')
this.postForm.region = this.postForm.region.join(',') this.postForm.region = this.postForm.region.join(',')
this.postForm.pick_group = this.postForm.pick_group.join(',') this.postForm.pick_group = this.postForm.pick_group.join(',')
} }
...@@ -274,8 +273,8 @@ ...@@ -274,8 +273,8 @@
} }
}) })
}, },
getRemoteRegionList(query) { getRemoteCityList(query) {
regionSearch(query).then(response => { citySearch(query).then(response => {
if (!response.data.data.data) return if (!response.data.data.data) return
this.regionListOptions = response.data.data.data this.regionListOptions = response.data.data.data
}) })
......
...@@ -80,10 +80,10 @@ ...@@ -80,10 +80,10 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label-width="75px" label="地区:"> <el-form-item label-width="75px" label="城市:">
<el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote <el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote
value-key="id" value-key="id"
placeholder="搜索地区" style="width: 230px"> placeholder="搜索城市" style="width: 230px">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" <el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name"
:value="item.id"/> :value="item.id"/>
</el-select> </el-select>
...@@ -307,7 +307,8 @@ ...@@ -307,7 +307,8 @@
del_list: [], del_list: [],
temp: { temp: {
tags:[], tags:[],
city_temp:'', city_temp_id:'',
city_temp_name: '',
group_ids: [] group_ids: []
} }
} }
...@@ -333,7 +334,8 @@ ...@@ -333,7 +334,8 @@
let rep = response.data.data let rep = response.data.data
let temp_tags = [] let temp_tags = []
this.postForm = response.data.data this.postForm = response.data.data
console.log(rep.tag_list.length) this.temp.city_temp_id = response.data.data.city.id
this.postForm.city = this.temp.city_temp_name = response.data.data.city.name
for (let i = 0;i < rep.tag_list.length; i++){ for (let i = 0;i < rep.tag_list.length; i++){
temp_tags.push(rep.tag_list[i].name) temp_tags.push(rep.tag_list[i].name)
this.temp.tags.push(rep.tag_list[i]) this.temp.tags.push(rep.tag_list[i])
...@@ -351,6 +353,10 @@ ...@@ -351,6 +353,10 @@
this.loading = true this.loading = true
this.postForm.group_ids = JSON.stringify(this.temp.group_ids) this.postForm.group_ids = JSON.stringify(this.temp.group_ids)
if (this.temp.city_temp_name === this.postForm.city){
this.postForm.city = this.temp.city_temp_id
}
if (this.isEdit){ if (this.isEdit){
this.postForm.tag_ids = Assembledata(this.temp.tags, this.postForm.tag_ids) this.postForm.tag_ids = Assembledata(this.temp.tags, this.postForm.tag_ids)
}else{ }else{
...@@ -418,8 +424,8 @@ ...@@ -418,8 +424,8 @@
}, },
getRemoteTagList(query) { getRemoteTagList(query) {
tagSearch(query).then(response => { tagSearch(query).then(response => {
if (!response.data.items) return if (!response.data.data.data) return
this.userListOptions = response.data.data.data this.tagListOptions = response.data.data.data
}) })
}, },
getList() { getList() {
......
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