Skip to content

Commit

Permalink
又完成一点
Browse files Browse the repository at this point in the history
  • Loading branch information
changge committed Oct 11, 2018
1 parent 5f88c04 commit 07a48f9
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 15 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions server/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const COS = require('cos-nodejs-sdk-v5');
const formidable = require('formidable')
const gm = require('gm');
const Album= model.getModel('album')
const ClassIfy= model.getModel('classIfy')
const ClassIfyModel= model.getModel('classIfy')
const PhotoList= model.getModel('photoList')
const User= model.getModel('user')
const _filter = {'password':0,'__v':0}
Expand Down Expand Up @@ -45,6 +45,27 @@ Router.post('/tmpUploadFile',function(req,res){
return res.json({error,code:1})
})
})
Router.post('/info',function(req,res){
const {albumId}=req.body
Album.findOne({_id:albumId},function(err,doc){
if(err){
return res.json({code:1,errorMsg:'服务器错误',error:err})
}else{
const {activityName,author,coverPic,bannerPic,desc,date}=doc
ClassIfyModel.find({albumId},function(err,doc){
if(err){
return res.json({code:1,errorMsg:'服务器错误',error:err})
}else{
let classIfy=doc.map(el=>{
return {id:el._id,title:el.title,date:el.date}
})
let photoList=[]
return res.json({code:0,errorMsg:'查询成功',data:{activityName,author,coverPic,bannerPic,desc,date,classIfy,photoList}})
}
})
}
})
})
module.exports = Router
/*cosUpload(newPath,avatarName).then(result=>{
return res.json({avatarName,errorMsg:'成功上传到暂存文件夹,保存后生效',code:0})
Expand Down Expand Up @@ -114,7 +135,7 @@ function addClassify(req,albumId){
return new Promise((resolve,reject)=>{
let result=[]
classIfy.forEach(el=>{
new ClassIfy({albumId:albumId,title:el.title,date:new Date().getTime()}).save((err,doc)=>{
new ClassIfyModel({albumId:albumId,title:el.title,date:new Date().getTime()}).save((err,doc)=>{
if(err){
reject({code:1,errorMsg:'服务器出现错误',error:err})
}else{
Expand Down
99 changes: 86 additions & 13 deletions src/componment/EditAlbum/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,99 @@
import React from 'react'
import './index.scss'
import { Input, Upload, Icon, message, Button ,Select} from 'antd'
import { getBase64, beforeUpload,getQueryString } from '../../util'
import {Redirect,withRouter} from 'react-router-dom'
import { Input, Upload, Icon, message, Button, Select } from 'antd'
import { getBase64, beforeUpload, getQueryString } from '../../util'
import { Redirect, withRouter } from 'react-router-dom'
import axios from 'axios'
@withRouter
class EditAlbum extends React.Component {
constructor(){
constructor() {
super()
this.state={
albumId:''
this.state = {
albumId: '',
photoList: [],
activityName: '',
activityNameSelected: [],
classIfy: [],
author:'',
date:'',
bannerPic:'',
coverPic:'',
desc:''
}
}
componentDidMount(){
let albumId=getQueryString('id')
this.setState({
albumId
componentDidMount() {
let albumId = getQueryString('id')
debugger
axios.post('/album/info',{albumId}).then(res => {
if(res.request.status===200&&res.data.code===0){
message.success(res.data.error_Msg)
const {activityName,date,classIfy,photoList,bannerPic,coverPic,desc}=res.data.data
this.setState({
activityName,date,classIfy,photoList,bannerPic,coverPic,desc
})
}else{
console.error("error")
}
})
console.log(albumId)
}
render(){
return null
handleSelectChange = () => {

}

render() {
const props = {
name: 'file',
multiple: true,
action: '//jsonplaceholder.typicode.com/posts/',
onChange(info) {
const status = info.file.status;
if (status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (status === 'done') {
message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
},
};
const { albumId, photoList, activityName, activityNameSelected, classIfy } = this.state
const Option = Select.Option
const Dragger = Upload.Dragger;
console.log(this.state)
return <div className="edit-album">
<div className="edit-album-section">
<p>相册编辑</p>
</div>
<div className="edit-album-section">
<div className="edit-album-section-title">
活动分类
</div>
<div className="edit-album-section-select">
{classIfy.length !== 0 && <Select value={activityNameSelected} onChange={this.handleSelectChange}>
{classIfy.map(el => {
return <Option value={el._id}>{el.title}</Option>
})
}
</Select>
}
</div>
<div className="edit-album-section-upload">
<Dragger {...props}>
<p className="ant-upload-drag-icon">
<Icon type="inbox" />
</p>
<p className="ant-upload-text">单机或者拖拽文件上传</p>
<p className="ant-upload-hint">支持单文件,多选,目录上传</p>
</Dragger>
</div>
</div>
<div className="edit-album-section">
<div className="edit-album-section-pic-list">

</div>
</div>
</div>
}
}
export default EditAlbum
24 changes: 24 additions & 0 deletions src/componment/EditAlbum/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.edit-album{
max-width: 320px;
margin:0 auto;
width: 100%;
min-width: 300px;
min-height: 600px;
padding: 10px;
box-sizing:content-box;
border-radius: 10px;
background-color: #fff;
.edit-album-section{
width: 100%;
min-height: 60px;
.edit-album-section-title{
width: 100%;
height: 30px;
background: #dcd5d5;
line-height: 30px;
border-radius: 5px;
text-indent: 10px;
margin:10px 0px 10px 0px;
}
}
}

0 comments on commit 07a48f9

Please sign in to comment.