Browse Source

视频功能优化

liting2017 6 years ago
parent
commit
f8a5d047df

+ 1 - 1
js/component/administration/video/videoDesc.jsx

@@ -43,7 +43,7 @@ class DemandDesc extends React.Component {
 				>
 					<div>
 						<div>
-								{data.auditStatus=='1'||data.auditStatus=='2'?
+								{data.status=='1'||data.status=='3'?
 									<NewDetaiel
 									closeDesc={this.handleCancel.bind(this)}
 									data={this.props.data}

+ 20 - 51
js/component/administration/video/videoDetails.jsx

@@ -8,15 +8,15 @@ import {
 	Button,
 	Form,
 } from 'antd';
-import {getReleaseStateList,getPolicyPosition,splitUrl} from '@/tools';
+import {getVideoStatus,splitUrl,getVideoType} from '@/tools';
 const NewDetail = Form.create()(React.createClass({
     getInitialState() {
         return {
             visible: false,
             loading: false,
-            auditStatus: 0,
             textFileList: [],
             videoFileList: [],
+            previewVisibleImg:false,
             pictureUrl: [],
             videoUrl:[]
         };
@@ -29,7 +29,7 @@ const NewDetail = Form.create()(React.createClass({
             method: "get",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context +  '/api/admin/policy/detail' ,
+            url: globalConfig.context +  '/api/admin/video/getVideoById' ,
             data: {
                 id: id
             },
@@ -43,10 +43,9 @@ const NewDetail = Form.create()(React.createClass({
                 };
                 this.setState({
                     id:thisData.id,
-                    page:thisData.publishPages,
                     data: thisData,
-                    auditStatus:thisData.auditStatus,
-                    pictureUrl: thisData.titleImg ? splitUrl(thisData.titleImg, ',', globalConfig.avatarHost + '/upload') : []
+                    videoUrl: thisData.url ? splitUrl(thisData.url, ',', 'http://118.190.205.7:8000' ) : [],
+                    pictureUrl: thisData.coverUrl ? splitUrl(thisData.coverUrl, ',', globalConfig.avatarHost + '/upload') : []
                 });
             }.bind(this),
         }).always(function () {
@@ -59,34 +58,6 @@ const NewDetail = Form.create()(React.createClass({
 	cancelFun(){
 		this.props.closeDesc();
     },
-    //刷新发布
-    updateFun(inex){
-        this.setState({
-            loading:true
-        })
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context +'/api/admin/policy/updateStatus',
-            data: {
-                id: this.state.id,
-                auditStatus:this.state.auditStatus,
-                refresh:1
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('刷新成功!');
-                this.setState({
-                    loading: false,
-                });
-            } else {
-                message.warning(data.error[0].message);
-            };
-            this.props.handOk();
-           
-        }.bind(this));
-    },
     //撤销发布
     revokeFun(){
         this.setState({
@@ -96,10 +67,10 @@ const NewDetail = Form.create()(React.createClass({
             method: "POST",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context +  '/api/admin/policy/updateStatus',
+            url: globalConfig.context +  '/api/admin/video/updateVideo',
             data: {
                 id: this.state.id,
-                auditStatus:4,
+                status:2,
             }
         }).done(function (data) {
             if (!data.error.length) {
@@ -147,29 +118,30 @@ const NewDetail = Form.create()(React.createClass({
 				<Spin spinning={this.state.loading}>
 					<div className="clearfix">
                         <FormItem className="half-item" {...formItemLayout} label="视频名称">
-							<span>{theData.title}</span>
+							<span>{theData.name}</span>
 						</FormItem>
 						<FormItem className="half-item" {...formItemLayout} label="视频类型">
-							<span>{theData.hot=='0'&&'否'}{theData.hot=='1'&&'是'}</span>
+							<span>{getVideoType(theData.type)}</span>
 						</FormItem>
                         <FormItem className="half-item" {...formItemLayout} label="视频文件">
-                            <div className="clearfix">
+                            <span>{theData.url?(theData.url).split('/').pop():''}</span>
+                           {/*  <div className="clearfix">
                                 <Upload className="demandDetailShow-upload"
                                     listType="picture-card"
                                     fileList={this.state.videoUrl}                               
                                     onPreview={(file) => {
                                         this.setState({
                                             previewImage: file.url || file.thumbUrl,
-                                            previewVisible: true,
+                                            previewVisible: false,
                                         });
                                     }} >
                                 </Upload>
                                 <Modal maskClosable={false} footer={null}
                                     visible={this.state.previewVisible}
                                     onCancel={() => { this.setState({ previewVisible: false }) }}>
-                                    <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
+                                    <video alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} controls></video>
                                 </Modal>
-                            </div> 
+                            </div>  */}
 					    </FormItem>
                         <FormItem className="half-item" {...formItemLayout} label="视频封面">
                             <div className="clearfix">
@@ -179,13 +151,13 @@ const NewDetail = Form.create()(React.createClass({
                                     onPreview={(file) => {
                                         this.setState({
                                             previewImage: file.url || file.thumbUrl,
-                                            previewVisible: true,
+                                            previewVisibleImg: true,
                                         });
                                     }} >
                                 </Upload>
                                 <Modal maskClosable={false} footer={null}
-                                    visible={this.state.previewVisible}
-                                    onCancel={() => { this.setState({ previewVisible: false }) }}>
+                                    visible={this.state.previewVisibleImg}
+                                    onCancel={() => { this.setState({ previewVisibleImg: false }) }}>
                                     <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
                                 </Modal>
                             </div> 
@@ -198,17 +170,14 @@ const NewDetail = Form.create()(React.createClass({
 					</div>
                     <div className="clearfix">
 						<FormItem className="half-item" {...formItemLayout} label="发布人">
-							<span>{theData.admin?theData.admin:'管理员'}</span>
+							<span>{theData.owner}</span>
 						</FormItem>
                         <FormItem className="half-item" {...formItemLayout} label="发布状态">
-							<span>{theData.summary?theData.summary:'已发布'}</span>
+							<span>{getVideoStatus(theData.status)}</span>
 						</FormItem>
 					</div>
 					<div className="clearfix">
-						{this.props.data.auditStatus=='2'&&<FormItem wrapperCol={{ span: 12, offset: 3 }}>
-							<Button className="set-submit" type="primary"  onClick={(e)=>{this.updateFun()}} >
-								刷新发布
-							</Button>
+						{theData.status=='1'&&<FormItem wrapperCol={{ span: 12, offset: 3 }}>
 							<Button type="danger" style={{marginRight:20}} onClick={(e)=>{this.revokeFun()}}>
 								撤销发布
 							</Button>

+ 111 - 55
js/component/administration/video/videoForm.jsx

@@ -12,7 +12,7 @@ import {
 	Select
 } from 'antd';
 import { videoType } from '@/dataDic.js';
-import { getVideoType} from '@/tools.js';	
+import { getVideoType,getReleaseStateList,splitUrl} from '@/tools.js';	
 import VideoComponent from '@/crop/video';
 import Crop from '@/crop/cropBlock';
 
@@ -21,7 +21,8 @@ const NewDetailForm = Form.create()(React.createClass({
         return {
             visible: false,
             loading: false,
-            auditStatus: 0,
+			auditStatus: 0,
+			fileList:[],
             textFileList: [],
 			videoImg: [],
 			vedioUrl:[]
@@ -35,7 +36,7 @@ const NewDetailForm = Form.create()(React.createClass({
             method: "get",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context +  '/api/admin/policy/detail' ,
+            url: globalConfig.context +  '/api/admin/video/getVideoById' ,
             data: {
                 id: id
             },
@@ -48,12 +49,14 @@ const NewDetailForm = Form.create()(React.createClass({
                     thisData = {};
 				};
 				let proArr=[];
+				let fileList =thisData.url ? splitUrl(thisData.url, ',','http://118.190.205.7:8000') : [];
+					fileList[0].url='javascript:;';
+					fileList[0].name=(thisData.url).split('/').pop();
                 this.setState({
 					id:thisData.id,
 					data: thisData,
-					auditStatus:thisData.auditStatus,
-					videoUrl:[],
-                    videoImg: thisData.titleImg ? splitUrl(thisData.titleImg, ',', globalConfig.avatarHost + '/upload') : []
+					fileList:fileList,
+                    videoImg: thisData.coverUrl ? thisData.coverUrl.split(',') : []
                 });
             }.bind(this),
         }).always(function () {
@@ -62,23 +65,28 @@ const NewDetailForm = Form.create()(React.createClass({
             });
         }.bind(this));
     },
-    getPictureUrl(e) {
-        this.setState({ pictureUrl: e });
-    },
     handleSubmit(e,index) {
 		e.preventDefault();
         this.props.form.validateFields((err, values) => {
 			//url转化
-            let thePictureUrl = [];
-            if (this.state.pictureUrl.length) {
+			let theVideoUrl = [];
+            if (this.state.fileList.length) {
                 let picArr = [];
-                this.state.pictureUrl.map(function (item) {
+                this.state.fileList.map(function (item) {
                     if ( item.response && item.response.data && item.response.data.length ){
                         picArr.push(item.response.data);
                     }
                 });
-                thePictureUrl = picArr.join(",");
+                theVideoUrl = picArr.join(",");
+			}else{
+				message.warning('请上传视频文件!');
+				return false;
+			}
+            if (!this.state.videoImg.length) {
+				message.warning('请上传视频封面图片!');
+				return false;
 			};
+			
             if (!err) {
                 this.setState({
                     loading: true
@@ -87,26 +95,20 @@ const NewDetailForm = Form.create()(React.createClass({
                     method: "post",
 					dataType: "json",
 					async:true,
-                    url: this.props.data.id ? globalConfig.context + '/api/admin/policy/update' : globalConfig.context + '/api/admin/policy/apply',
+                    url: this.props.data.id ? globalConfig.context + '/api/admin/video/updateVideo' : globalConfig.context + '/api/admin/video/insertVideo',
                     data: {
 						id: this.props.data.id,
-						type:0,
-						title: values.title,
-                        author: values.author,
-                        titleImg: thePictureUrl.length?thePictureUrl:'',
-						content:this.state.edit.content,
-						hot:values.hot,
-						source:values.source,
-						sourceUrl:values.sourceUrl,
-						keyword:values.keyword,
-						auditStatus:index,
-                        summary: values.summary,
+						type:values.type,
+						name: values.name,
+                        url: theVideoUrl.length?theVideoUrl:'',
+						summary:values.summary,
+						coverUrl:this.state.videoImg.join(','),
+						status:index?index:0
                     }
                 }).done(function (data) {
                     this.setState({
                         loading: false
 					});
-
                     if (!data.error.length) {
                         message.success('操作成功!');
                         this.setState({
@@ -132,7 +134,7 @@ const NewDetailForm = Form.create()(React.createClass({
 			this.state.videoImg = [];
 			this.state.videoUrl=[];
         };
-    },
+	},
     componentWillReceiveProps(nextProps) {
         if (!this.props.visible && nextProps.visible) {
             if (nextProps.data.id) {
@@ -145,34 +147,78 @@ const NewDetailForm = Form.create()(React.createClass({
             };
 			this.props.form.resetFields();
         };
-    },
+	},
+	//视频上传
+	handleChange(info) {
+		let fileList = info.fileList;
+        this.setState({ fileList,loading:true });
+        if (info.file.status !== 'uploading') {
+        }
+        if (info.file.status === 'done') {
+			message.success(`上传成功`);
+			fileList[0].url='javascript:;';
+			fileList[0].name=(fileList[0].response.data).split('/').pop();
+			this.setState({
+				fileList:fileList
+			})
+            this.setState({
+				loading:false,
+            })
+        } else if (info.file.status === 'error') {
+			message.error(`上传失败`);
+			this.setState({
+				loading:false,
+            })
+        }
+	},
+    beforeUpload(info){
+		if(info.type.indexOf('video')<0){
+			message.warning('请上传MP4格式视频文件.');
+			return false;
+		};
+		let sizeMb = info.size/(1024*1024),size=100;
+		if(sizeMb>size){  //100Mb之内
+			message.warning(`视频大小不超过${size}`);
+			return false;
+		};
+	},
+	videoRemove(file){
+		let fileList = this.state.fileList;
+		this.setState(({ fileList }) => {
+			const index = (fileList).indexOf(file);
+			const newFileList = fileList.slice();
+			newFileList.splice(index, 1);
+			return {
+			  fileList: newFileList,
+			  loading:false,
+			};
+		  });
+	},
     render() {
         const theData = this.state.data || {};
         const { getFieldDecorator } = this.props.form;
-        const FormItem = Form.Item
+        const FormItem = Form.Item;
         const formItemLayout = {
             labelCol: { span: 6 },
             wrapperCol: { span: 12 },
 		};
-		const formItemLayouts = {
-            labelCol: { span: 3 },
-            wrapperCol: { span: 18 },
-		};
+		const fileList= this.state.fileList||[];
+		console.log(fileList)
         return (
 			<div className='login'>
 			<Form layout="horizontal" onSubmit={(e)=>{this.handleSubmit(e,0)}} id="demand-form">
 				<Spin spinning={this.state.loading}>
 					<div className="clearfix">
 						<FormItem className="half-item" {...formItemLayout} label="视频名称">
-							{getFieldDecorator('title', {
+							{getFieldDecorator('name', {
 								rules: [ { required: true, message: '此项为必填项!' } ],
-								initialValue: theData.title
+								initialValue: theData.name
 							})(<Input placeholder="请输入视频的名称" />)}
 						</FormItem>
 						<FormItem className="half-item" {...formItemLayout} label="视频类型">
-							{getFieldDecorator('title1', {
+							{getFieldDecorator('type', {
 								rules: [ { required: true, message: '此项为必填项!' } ],
-								initialValue: theData.title1
+								initialValue: theData.type||theData.type=='0'?String(theData.type):theData.type
 							})(<Select placeholder="请选择视频类型">
 									{videoType.map(item=>{
 										return <Select.Option value={item.value}>{item.key}</Select.Option>
@@ -181,26 +227,36 @@ const NewDetailForm = Form.create()(React.createClass({
 						</FormItem>
 					</div>
 					<div className="clearfix">
-						<FormItem className="half-item" {...formItemLayout} label="视频文件">
-							< VideoComponent
-								fileList={(e)=>{this.setState({videoUrl:e})}}
-								dataUrl={{
-									url:'/api/user/demand/uploadPicture',
-									keyWord:'demand_picture',
-									type:'video',
-									page:1
-								}}
-								videoUrl={this.state.videoUrl}
-								visible={this.props.visible}
-							/>
+						<FormItem
+							className="half-item" 
+							{...formItemLayout} 
+							label={<span><strong style={{color:'#f00',fontSize:12}}>* </strong>视频文件</span>}
+						>
+							 <Upload
+								action={globalConfig.context +'/api/admin/video/upload' }
+								data={{ sign:'video' }}
+								fileList={this.state.fileList}
+								listType="text"
+								beforeUpload={this.beforeUpload.bind(this)}
+								onChange={this.handleChange.bind(this)}
+								onRemove ={this.videoRemove}
+							>
+								{fileList.length >= 1 ? null : <div>
+									<Button type="primary">点击上传</Button>
+								</div>}
+							</Upload>
 						</FormItem>
-						<FormItem className="half-item" {...formItemLayout} label="封面图片">
+						<FormItem 
+							className="half-item" 
+							{...formItemLayout} 
+							label={<span><strong style={{color:'#f00',fontSize:12}}>* </strong>封面图片</span>}
+						>
 							<Crop 
 								getAllImg={(e)=>{this.setState({videoImg:e})}}
 								number = {1} 
 								aspectRatio = {1/1}
-								url ={globalConfig.context + '/api/user/uploadPicture64'}
-								uploadData = {{sign:'user_picture'}} 
+								url ={globalConfig.context + '/api/admin/video/upload'}
+								uploadData = {{sign:'video_cover'}} 
 								urlArr = {this.state.videoImg} 
 							/>
 						</FormItem>
@@ -214,10 +270,10 @@ const NewDetailForm = Form.create()(React.createClass({
 					</div>
 					<div className="clearfix">
 						<FormItem className="half-item" {...formItemLayout} label="发布人">
-							<span>{theData.releaseStatus?'已发布':'管理员'}</span>
+							<span>{theData.owner?theData.owner:'管理员'}</span>
 						</FormItem>
 						{theData.createTime&&<FormItem className="half-item" {...formItemLayout} label="发布状态">
-							<span>{theData.releaseStatus?'已发布':'未发布'}</span>
+							<span>{getReleaseStateList(theData.status)}</span>
 						</FormItem>}
 					</div>
 					<div className="clearfix">
@@ -229,7 +285,7 @@ const NewDetailForm = Form.create()(React.createClass({
 								className="set-submit"
 								type="ghost"
 								onClick={(e) => {
-										this.handleSubmit(e,2)
+										this.handleSubmit(e,1)
 								}}
 							>
 								发布视频

+ 57 - 92
js/component/administration/video/videoList.jsx

@@ -4,8 +4,8 @@ import $ from 'jquery/src/ajax';
 import moment from 'moment';
 import '@/account/demand/techDemand.less';
 import NewDesc from '@/administration/video/videoDesc';
-import { videoType ,releaseStateList} from '@/dataDic.js';
-import {getVideoType,getReleaseStateList } from '@/tools.js';
+import { videoType ,videoStatus} from '@/dataDic.js';
+import {getVideoType,getVideoStatus } from '@/tools.js';
 
 const PolicyList = React.createClass({
     loadData(pageNo) {
@@ -18,14 +18,13 @@ const PolicyList = React.createClass({
             method: "get",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + "/api/admin/policy/list",
+            url: globalConfig.context + "/api/admin/video/getVideoList",
             data: {
                 pageNo: pageNo || 1,
                 pageSize: this.state.pagination.pageSize,
-                title: this.state.nameSearch, //政策标题
-                startReleaseDate: this.state.releaseDate[0],
-                endReleaseDate: this.state.releaseDate[1],
-                auditStatus:this.state.auditStatusSearch,
+                name: this.state.videoName, 
+                type: this.state.videoType,
+                status:this.state.videoState,
             },
             success: function (data) {
                 let theArr = [];
@@ -39,11 +38,15 @@ const PolicyList = React.createClass({
                         theArr.push({
                             key: i,
                             id: thisdata.id,
-                            title: thisdata.title,
-                            author:thisdata.author,
-                            source: thisdata.source,
-                            auditStatus: thisdata.auditStatus, //审核状态
-                            releaseDate:thisdata.releaseDate?(new Date(thisdata.releaseDate)).toLocaleString():''
+                            name: thisdata.name,
+                            url:'http://118.190.205.7:8000'+thisdata.url,
+                            type: thisdata.type,
+                            owner: thisdata.owner, //审核状态
+                            status:thisdata.status,
+                            transcoding:thisdata.transcoding,
+                            summary:thisdata.summary,
+                            createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'',
+                            releaseTime:thisdata.releaseTime?(new Date(thisdata.releaseTime)).toLocaleString():''
                         });
                     };
                 };
@@ -68,7 +71,6 @@ const PolicyList = React.createClass({
     getInitialState() {
         return {
             searchMore: true,
-            validityPeriodDate: [],
             releaseDate: [],
             selectedRowKeys: [],
             selectedRows: [],
@@ -88,36 +90,48 @@ const PolicyList = React.createClass({
             columns: [
                 {
                     title: '视频名称',
-                    dataIndex: 'title',
-                    key: 'title',
+                    dataIndex: 'name',
+                    key: 'name',
                 },  {
                     title: '视频地址',
-                    dataIndex: 'author',
-                    key: 'author',
+                    dataIndex: 'url',
+                    key: 'url',
                     
                 },
                 {
                     title: '视频类型',
-                    dataIndex: 'auditStatus',
-                    key: 'auditStatus',
+                    dataIndex: 'type',
+                    key: 'type',
                     render: text => { return getVideoType(text) }
                 },
                 {
                     title: '上传者',
-                    dataIndex: 'source',
-                    key: 'source',
-                    render:text=>{return <span>管理员</span>}
+                    dataIndex: 'owner',
+                    key: 'owner',
                 },
                 {
-                    title: '上传时间',
-                    dataIndex: 'releaseDate',
-                    key: 'releaseDate'
+                    title: '转码状态',
+                    dataIndex: 'transcoding',
+                    key: 'transcoding',
+                    render:text=>{
+                        return text==2?'已转码':'正在转码'
+                    }
+                },
+                {
+                    title: '发布时间',
+                    dataIndex: 'releaseTime',
+                    key: 'releaseTime'
+                },
+                {
+                    title: '创建时间',
+                    dataIndex: 'createTime',
+                    key: 'createTime'
                 },
                 {
                     title: '状态',
-                    dataIndex: 'releaseDate1',
-                    key: 'releaseDate1',
-                    render: text => { return getReleaseStateList(text) }
+                    dataIndex: 'status',
+                    key: 'status',
+                    render: text => { return getVideoStatus(text) }
                 },
                 {
                     title: '操作',
@@ -125,9 +139,8 @@ const PolicyList = React.createClass({
                     key: 'caozuo',
                     render:(text,recard) => {
                         return  <div className="btnRight">
-                                   {recard.auditStatus!='1'&&recard.auditStatus!='2'&&<Button type="primary" style={{ background: "#3fcf9e", border: "none", color: "#fff" }} onClick={(e)=>{e.stopPropagation(),this.submission(recard)}}>发布</Button>}
-                                   {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="success" onClick={(e)=>{ e.stopPropagation(),this.updateFun(recard)}}>刷新发布</Button>}
-                                   {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="danger" onClick={(e)=>{e.stopPropagation(),this.revokeFun(recard)}}>撤销发布</Button>}
+                                   {((recard.status=='0'||recard.status=='2')&&recard.transcoding=='2')&&<Button type="primary" style={{ background: "#3fcf9e", border: "none", color: "#fff" }} onClick={(e)=>{e.stopPropagation(),this.submission(recard,1)}}>发布</Button>}
+                                   {recard.status=='1'&&<Button type="danger" onClick={(e)=>{e.stopPropagation(),this.submission(recard,2)}}>撤销发布</Button>}
                                 </div>
                     }
                 }
@@ -137,7 +150,7 @@ const PolicyList = React.createClass({
         };
     },
     //发布
-    submission(record){
+    submission(record,nub){
         this.setState({
             showDesc:false,
             loading:true
@@ -146,14 +159,14 @@ const PolicyList = React.createClass({
             method: "POST",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + "/api/admin/policy/updateStatus",
+            url: globalConfig.context + "/api/admin/video/updateVideo",
             data: {
                 id:record.id,
-                auditStatus:2
+                status:nub
             }
         }).done(function (data) {
             if (!data.error.length) {
-                message.success('发布成功.');
+                message.success(nub=='1'?'发布成功.':'撤销发布');
                 this.setState({
                     loading: false,
                 });
@@ -163,59 +176,6 @@ const PolicyList = React.createClass({
             };
         }.bind(this));
     },
-    //刷新发布
-    updateFun(recard){
-        this.setState({
-            loading:true
-        })
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context +'/api/admin/policy/updateStatus',
-            data: {
-                id: recard.id,
-                auditStatus:recard.auditStatus,
-                refresh:1
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('刷新成功!');
-                this.setState({
-                    loading: false,
-                });
-            } else {
-                message.warning(data.error[0].message);
-            };
-            this.loadData(this.state.page);
-        }.bind(this));
-    },
-    //撤销发布
-    revokeFun(recard){
-        this.setState({
-            loading:true
-        })
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context +  '/api/admin/policy/updateStatus',
-            data: {
-                id: recard.id,
-                auditStatus:4,
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('撤销成功!');
-                this.setState({
-                    loading: false,
-                });
-                this.loadData(this.state.page);
-            } else {
-                message.warning(data.error[0].message);
-            };
-        }.bind(this));
-    },
     componentWillMount() {
         this.loadData();
     },
@@ -239,9 +199,10 @@ const PolicyList = React.createClass({
             method: "POST",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + "/api/admin/policy/delete",
+            url: globalConfig.context + "/api/admin/video/updateVideo",
             data: {
-                id: deletedIds[0]
+                id: deletedIds[0],
+                status:3
             }
         }).done(function (data) {
             if (!data.error.length) {
@@ -249,7 +210,11 @@ const PolicyList = React.createClass({
                 this.setState({
                     loading: false
                 });
-                this.loadData(this.state.page);
+                if(this.state.pagination.total%10==1){
+                    this.loadData((this.state.page)-1);
+                }else{
+                    this.loadData(this.state.page);
+                }
             } else {
                 message.warning(data.error[0].message);
             };
@@ -318,7 +283,7 @@ const PolicyList = React.createClass({
                     <Select placeholder="视频状态" style={{ width: 120 }}
                         value={this.state.videoState}
                         onChange={(e) => { this.setState({ videoState: e }) }}>
-                         {releaseStateList.map(item=>{
+                         {videoStatus.map(item=>{
                             return <Select.Option value={item.value}>{item.key}</Select.Option>
                         })}
                     </Select>

+ 35 - 24
js/component/crop/video.jsx

@@ -1,13 +1,15 @@
 import { Component } from 'react';
-import { Upload, message, Icon, Modal,Button } from 'antd';
+import { Upload, message, Icon, Modal,Spin } from 'antd';
+
 class VideoComponent extends Component {
 	constructor(props) {
 		super(props);
         this.state = {
             previewVisible: false,
-			previewImage: '',
-			fileList: [],
-			urls: []
+            previewImage: '',
+            loading:false,
+            fileList: [],
+            fileListUrl:''
         };
 	}
 	handleCancel() {
@@ -15,23 +17,28 @@ class VideoComponent extends Component {
 	}
 	handlePreview(file) {
 		this.setState({
-			previewImage: file.url || file.thumbUrl,
+			previewImage: file.url ,
 			previewVisible: true
 		});
 	}
 	handleChange(info) {
+        this.props.loadState(true);
+        this.setState({loading:true})
         let fileList = info.fileList;
         this.setState({ fileList });
         if (info.file.status !== 'uploading') {
-            console.log(info.file, info.fileList);
         }
         if (info.file.status === 'done') {
             message.success(`上传成功`);
             this.props.fileList(fileList);
+            this.props.loadState(false);
             this.setState({
-                urls:fileList[0].response.data});
+                loading:false,
+                fileListUrl:fileList[0].response.data,
+            })
         } else if (info.file.status === 'error') {
             message.error(`上传失败`);
+            this.props.loadState(false);
         }
 	}
     beforeUpload(info){
@@ -52,7 +59,7 @@ class VideoComponent extends Component {
                 return false;
             };
             let sizeMb = info.size/(1024*1024),size=1;
-            if(sizeMb>size){  //100Mb之内
+            if(sizeMb>size){  //1Mb之内
                 message.warning(`图片大小不超过${size}MB.`);
                 return false;
             };
@@ -62,7 +69,6 @@ class VideoComponent extends Component {
         this.state.fileList = nextProps.videoUrl;
 	}
 	render() {
-       
         const { previewVisible, previewImage, fileList } = this.state;
 		const uploadButton = (
 			<div>
@@ -71,23 +77,28 @@ class VideoComponent extends Component {
 			</div>
         );
         const dataUrl = this.props.dataUrl||{};
+        if(this.state.loading){
+            return false;
+        }
 		return (
 			<div className="clearfix">
-				<Upload
-					action={globalConfig.context + dataUrl.url}
-					data={{ sign:dataUrl.keyWord }}
-					listType="picture-card"
-                    fileList={fileList}
-                    beforeUpload={this.beforeUpload.bind(this)}
-					onPreview={this.handlePreview.bind(this)}
-					onChange={this.handleChange.bind(this)}
-				>
-					{fileList.length >= this.props.dataUrl.page ? null : uploadButton}
-				</Upload>
-				<Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel.bind(this)}>
-					{this.props.dataUrl.type.indexOf('video')>-1?<video alt="example" style={{ width: '100%' }} src={globalConfig.context+this.state.urls} controls></video>
-                    :<img alt="example" style={{ width: '100%' }} src={previewImage} />}
-                </Modal>
+                <Spin spinning={this.state.loading}>
+                    <Upload
+                        action={globalConfig.context + dataUrl.url}
+                        data={{ sign:dataUrl.keyWord }}
+                        listType="picture-card"
+                        fileList={fileList}
+                        beforeUpload={this.beforeUpload.bind(this)}
+                        onPreview={this.handlePreview.bind(this)}
+                        onChange={this.handleChange.bind(this)}
+                    >
+                        {fileList.length >= this.props.dataUrl.page ? null : uploadButton}
+                    </Upload>
+                    {previewImage&&<Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel.bind(this)}>
+                        {this.props.dataUrl.type.indexOf('video')>-1?<video alt="example" style={{ width: '100%' }} src={previewImage||'http://118.190.205.7:8000/'+this.state.fileListUrl} controls></video>
+                        :<img alt="example" style={{ width: '100%' }} src={previewImage} />}
+                    </Modal>}   
+                </Spin>
 			</div>
 		);
 	}

+ 17 - 1
js/component/dataDic.js

@@ -2515,5 +2515,21 @@ module.exports = {
 	        value: "2",
 	        key: "付费观看"
 	    }
-    ]
+    ],
+     //视频状态
+     videoStatus:[
+        {
+	        value: "0",
+	        key: "未发布"
+	    },{
+	        value: "1",
+	        key: "已发布"
+	    }, {
+	        value: "2",
+	        key: "撤销发布"
+	    },{
+	        value: "3",
+	        key: "已删除"
+	    } 
+    ],
 };

+ 14 - 1
js/component/tools.js

@@ -90,7 +90,8 @@ import {
     couponAuthState,
     couponAuthStates,
     couponCome,
-    videoType
+    videoType,
+    videoStatus
 } from './dataDic.js';
 
 import { provinceList} from './NewDicProvinceList.js';
@@ -1646,5 +1647,17 @@ module.exports = {
             });
             return theType;
         }
+    },
+    //视频状态
+    getVideoStatus: function (e) {
+        if (e||e=='0') {
+            let theType = '';
+            videoStatus.map(function (item) {
+                if (item.value == e) {
+                    theType = item.key;
+                };
+            });
+            return theType;
+        }
     }
 }

+ 1 - 1
package.json

@@ -12,7 +12,7 @@
     "buildtest": "node bin/clean.js && webpack --progress --colors --env.deploy test",
     "buildstage": "node bin/clean.js && webpack --progress --colors --env.deploy stage",
     "pro": "node bin/clean.js && webpack --progress --colors --env.deploy prod",
-    "dev": "webpack-dev-server --port 80 --devtool eval --progress --colors --hot --content-base build --env.deploy dev --env.watch watch"
+    "dev": "webpack-dev-server --port 8088 --devtool eval --progress --colors --hot --content-base build --env.deploy dev --env.watch watch"
   },
   "repository": {
     "type": "git",

+ 1 - 1
webpack-dll.config.js

@@ -10,7 +10,7 @@ let theme = {
   '@link-color': '#58a3ff'
 };
 module.exports = (function () {
-	let staticHost = 'http://192.168.0.188';   
+	let staticHost = 'http://192.168.0.188:8088';   
     switch (argv.env.deploy) {
         case 'test':
             staticHost = 'http://statics.jishutao.com';

+ 2 - 2
webpack.config.js

@@ -121,7 +121,7 @@ module.exports = (function () {
         }));
     }
 
-    let staticHost = 'http://192.168.0.188';    
+    let staticHost = 'http://192.168.0.188:8088';    
     switch (argv.env.deploy) {
         case 'test':
             staticHost = 'http://statics.jishutao.com';
@@ -157,7 +157,7 @@ module.exports = (function () {
         devServer: {
             disableHostCheck: true,
             host: '192.168.0.188',
-            port: 80,
+            port: 8088,
             allowedHosts: ['127.0.0.1','192.168.0.20','192.168.0.99'],
             headers: {
                 "Access-Control-Allow-Origin": "*"