Browse Source

视频上传页面完成

liting2017 6 years ago
parent
commit
28905ae930

+ 3 - 0
js/admin/index/content.jsx

@@ -20,6 +20,8 @@ import AuthExamine from '@/administration/authentication/authExamine';
 import Banner from '@/administration/banner/banner';
 import Vouchers from '@/administration/ticket/vouchers';
 import Coupon from '@/administration/ticket/coupon';
+import Video from '@/administration/video/videoList';
+
 
 import {hashHistory,Route,Router} from 'react-router';
 import {Layout} from 'antd';
@@ -53,6 +55,7 @@ export default class ContentRouter extends React.Component {
             <Route path="/banner" component={Banner} />
             <Route path="/vouchers" component={Vouchers} />
             <Route path="/coupon" component={Coupon} />
+            <Route path="/video" component={Video} />
         </Router>
       </Content>
     )

+ 3 - 2
js/admin/menu.jsx

@@ -72,11 +72,12 @@ module.exports = {
         ]
       },
       {
-        name: '轮播管理',
+        name: '视频/轮播管理',
         url: 'sub10',
         icon: 'picture',
         children: [
           { name: '轮播图库', url: 'banner' },
+          {name:'视频管理',url:'video'}
         ]
       },
       {
@@ -97,6 +98,6 @@ module.exports = {
           { name: '抵用券管理', url: 'vouchers' },
           { name: '劵面管理', url: 'coupon' },
         ]
-      }
+      },
     ]
 }

+ 36 - 0
js/component/administration/ticket/video.jsx

@@ -0,0 +1,36 @@
+import { Component } from 'react';
+import {Button, Icon,message } from 'antd';
+import VideoComponent from '@/crop/video';
+
+class Video extends Component {
+	constructor(props) {
+		super(props);
+		this.state = {
+            fileList:{},
+            videoUrl:[]
+        }
+    }
+    
+	render() {
+		return (
+			<div className="user-content">
+				<div className="content-title">
+					<span>视频管理</span>
+				</div>
+                < VideoComponent
+                    fileList={(e)=>{this.setState({videoUrl:e})}}
+                    dataUrl={{
+                        url:'/api/user/demand/uploadPicture',
+                        keyWord:'demand_picture',
+                        type:'image',
+                        page:1
+                    }}
+                    videoUrl={this.state.videoUrl}
+                    visible={this.props.visible}
+                />
+			</div>
+		)
+	}
+}
+
+export default Video;

+ 69 - 0
js/component/administration/video/videoDesc.jsx

@@ -0,0 +1,69 @@
+import React from 'react';
+import { Modal } from 'antd';
+import NewForm from '@/administration/video/videoForm';
+import NewDetaiel from '@/administration/video/videoDetails';
+
+class DemandDesc extends React.Component {
+	constructor(props) {
+		super(props);
+		this.state = {
+			loading: false,
+			pictureUrl: [],
+			showState:false
+		};
+	}
+	handleCancel() {
+		this.setState({
+			visible: false,
+		});
+		this.props.closeDesc(false, false);
+	}
+	handOk() {
+		this.setState({
+			visible: false,
+		});
+		this.props.closeDesc(false, true);
+	}
+	componentWillReceiveProps(nextProps) {
+		this.state.visible = nextProps.showDesc;
+	}
+	render() {
+		let data = this.props.data || [];
+		return (
+			<div className="patent-desc">
+				<Modal
+					maskClosable={false}
+					visible={this.state.visible}
+					onOk={this.handOk.bind(this)}
+					onCancel={this.handleCancel.bind(this)}
+					width="800px"
+					title={!data.id ? '新建视频' : '视频详情'}
+					footer=""
+					className="admin-desc-content"
+				>
+					<div>
+						<div>
+								{data.auditStatus=='1'||data.auditStatus=='2'?
+									<NewDetaiel
+									closeDesc={this.handleCancel.bind(this)}
+									data={this.props.data}
+									visible={this.state.visible}
+									handOk={this.handOk.bind(this)}
+									/>
+									:
+									<NewForm 
+										closeDesc={this.handleCancel.bind(this)}
+										data={this.props.data}
+										visible={this.state.visible}
+										handOk={this.handOk.bind(this)}
+										/>
+								} 
+						</div>
+					</div>
+				</Modal>
+			</div>
+		);
+	}
+}
+
+export default DemandDesc;

+ 230 - 0
js/component/administration/video/videoDetails.jsx

@@ -0,0 +1,230 @@
+import React from 'react';
+import $ from 'jquery/src/ajax';
+import {
+	Modal,
+	message,
+	Spin,
+	Upload,
+	Button,
+	Form,
+} from 'antd';
+import {getReleaseStateList,getPolicyPosition,splitUrl} from '@/tools';
+const NewDetail = Form.create()(React.createClass({
+    getInitialState() {
+        return {
+            visible: false,
+            loading: false,
+            auditStatus: 0,
+            textFileList: [],
+            videoFileList: [],
+            pictureUrl: [],
+            videoUrl:[]
+        };
+    },
+    loadData(id) {
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context +  '/api/admin/policy/detail' ,
+            data: {
+                id: id
+            },
+            success: function (data) {
+                let thisData = data.data;
+                if (!thisData) {
+                    if (data.error && data.error.length) {
+                        message.warning(data.error[0].message);
+                    };
+                    thisData = {};
+                };
+                this.setState({
+                    id:thisData.id,
+                    page:thisData.publishPages,
+                    data: thisData,
+                    auditStatus:thisData.auditStatus,
+                    pictureUrl: thisData.titleImg ? splitUrl(thisData.titleImg, ',', globalConfig.avatarHost + '/upload') : []
+                });
+            }.bind(this),
+        }).always(function () {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+   
+	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({
+            loading:true
+        })
+        $.ajax({
+            method: "POST",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context +  '/api/admin/policy/updateStatus',
+            data: {
+                id: this.state.id,
+                auditStatus:4,
+            }
+        }).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));
+    },
+    componentWillMount() {
+        if (this.props.data.id) {
+            this.loadData(this.props.data.id);
+           
+        } else {
+            this.state.data = {};
+        };
+    },
+    componentWillReceiveProps(nextProps) {
+        if (!this.props.visible && nextProps.visible) {
+            this.state.textFileList = [];
+            this.state.videoFileList = [];
+            if (nextProps.data.id) {
+                this.loadData(nextProps.data.id);
+            } else {
+				this.state.data = {};
+                this.state.pictureUrl = [];
+            };
+            this.props.form.resetFields();
+        };
+    },
+    render() {
+        const theData = this.state.data || {};
+        const FormItem = Form.Item
+        const formItemLayout = {
+            labelCol: { span: 6 },
+            wrapperCol: { span: 12 },
+        };
+        return (
+			<div className='login'>
+			<Form layout="horizontal" id="demand-form">
+				<Spin spinning={this.state.loading}>
+					<div className="clearfix">
+                        <FormItem className="half-item" {...formItemLayout} label="视频名称">
+							<span>{theData.title}</span>
+						</FormItem>
+						<FormItem className="half-item" {...formItemLayout} label="视频类型">
+							<span>{theData.hot=='0'&&'否'}{theData.hot=='1'&&'是'}</span>
+						</FormItem>
+                        <FormItem className="half-item" {...formItemLayout} label="视频文件">
+                            <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,
+                                        });
+                                    }} >
+                                </Upload>
+                                <Modal maskClosable={false} footer={null}
+                                    visible={this.state.previewVisible}
+                                    onCancel={() => { this.setState({ previewVisible: false }) }}>
+                                    <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
+                                </Modal>
+                            </div> 
+					    </FormItem>
+                        <FormItem className="half-item" {...formItemLayout} label="视频封面">
+                            <div className="clearfix">
+                                <Upload className="demandDetailShow-upload"
+                                    listType="picture-card"
+                                    fileList={this.state.pictureUrl}                               
+                                    onPreview={(file) => {
+                                        this.setState({
+                                            previewImage: file.url || file.thumbUrl,
+                                            previewVisible: true,
+                                        });
+                                    }} >
+                                </Upload>
+                                <Modal maskClosable={false} footer={null}
+                                    visible={this.state.previewVisible}
+                                    onCancel={() => { this.setState({ previewVisible: false }) }}>
+                                    <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
+                                </Modal>
+                            </div> 
+					    </FormItem>
+					</div>
+                    <div className="clearfix breakWord">
+						<FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="视频简介">
+							<span>{theData.summary}</span>
+						</FormItem>
+					</div>
+                    <div className="clearfix">
+						<FormItem className="half-item" {...formItemLayout} label="发布人">
+							<span>{theData.admin?theData.admin:'管理员'}</span>
+						</FormItem>
+                        <FormItem className="half-item" {...formItemLayout} label="发布状态">
+							<span>{theData.summary?theData.summary:'已发布'}</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>
+							<Button type="danger" style={{marginRight:20}} onClick={(e)=>{this.revokeFun()}}>
+								撤销发布
+							</Button>
+							<Button className="set-submit" type="ghost" onClick={this.cancelFun}>
+								取消
+							</Button>
+						</FormItem>}
+					</div>
+				</Spin>
+			</Form>    
+		</div>
+        )
+    }
+}));
+export default NewDetail;
+
+
+
+

+ 256 - 0
js/component/administration/video/videoForm.jsx

@@ -0,0 +1,256 @@
+import React from 'react';
+import $ from 'jquery/src/ajax';
+import {
+	Icon,
+	Modal,
+	message,
+	Spin,
+	Upload,
+	Input,
+	Button,
+	Form,
+	Select
+} from 'antd';
+import { videoType } from '@/dataDic.js';
+import { getVideoType} from '@/tools.js';	
+import VideoComponent from '@/crop/video';
+
+const NewDetailForm = Form.create()(React.createClass({
+    getInitialState() {
+        return {
+            visible: false,
+            loading: false,
+            auditStatus: 0,
+            textFileList: [],
+			pictureUrl: [],
+			vedioUrl:[]
+        };
+    },
+    loadData(id) {
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context +  '/api/admin/policy/detail' ,
+            data: {
+                id: id
+            },
+            success: function (data) {
+                let thisData = data.data,provice=[];
+                if (!thisData) {
+                    if (data.error && data.error.length) {
+                        message.warning(data.error[0].message);
+                    };
+                    thisData = {};
+				};
+				let proArr=[];
+                this.setState({
+					id:thisData.id,
+					data: thisData,
+					auditStatus:thisData.auditStatus,
+					videoUrl:[],
+                    pictureUrl: thisData.titleImg ? splitUrl(thisData.titleImg, ',', globalConfig.avatarHost + '/upload') : []
+                });
+            }.bind(this),
+        }).always(function () {
+            this.setState({
+                loading: false
+            });
+        }.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 picArr = [];
+                this.state.pictureUrl.map(function (item) {
+                    if ( item.response && item.response.data && item.response.data.length ){
+                        picArr.push(item.response.data);
+                    }
+                });
+                thePictureUrl = picArr.join(",");
+			};
+            if (!err) {
+                this.setState({
+                    loading: true
+                });
+                $.ajax({
+                    method: "post",
+					dataType: "json",
+					async:true,
+                    url: this.props.data.id ? globalConfig.context + '/api/admin/policy/update' : globalConfig.context + '/api/admin/policy/apply',
+                    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,
+						province: (values.ProvinceCity)[0],
+						publishPages:publishPages
+                    }
+                }).done(function (data) {
+                    this.setState({
+                        loading: false
+					});
+
+                    if (!data.error.length) {
+                        message.success('操作成功!');
+                        this.setState({
+                            visible: false
+                        });
+                        this.props.handOk();
+                    } else {
+                        message.warning(data.error[0].message);
+                    }
+                }.bind(this));
+            }
+        });
+	},
+	cancelFun(){
+		this.state.edit={};
+		this.props.closeDesc();
+	},
+    componentWillMount() {
+        if (this.props.data.id) {
+            this.loadData(this.props.data.id);
+        } else {
+			this.state.data = {};
+			this.state.pictureUrl = [];
+			this.state.videoUrl=[];
+        };
+    },
+    componentWillReceiveProps(nextProps) {
+        if (!this.props.visible && nextProps.visible) {
+            if (nextProps.data.id) {
+                this.loadData(nextProps.data.id);
+            } else {
+				this.state.data = {};
+				this.state.pictureUrl = [];
+				this.state.theData={};
+				this.state.videoUrl=[];
+            };
+			this.props.form.resetFields();
+        };
+    },
+    render() {
+        const theData = this.state.data || {};
+        const { getFieldDecorator } = this.props.form;
+        const FormItem = Form.Item
+        const formItemLayout = {
+            labelCol: { span: 6 },
+            wrapperCol: { span: 12 },
+		};
+		const formItemLayouts = {
+            labelCol: { span: 3 },
+            wrapperCol: { span: 18 },
+		};
+        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', {
+								rules: [ { required: true, message: '此项为必填项!' } ],
+								initialValue: theData.title
+							})(<Input placeholder="请输入视频的名称" />)}
+						</FormItem>
+						<FormItem className="half-item" {...formItemLayout} label="视频类型">
+							{getFieldDecorator('title1', {
+								rules: [ { required: true, message: '此项为必填项!' } ],
+								initialValue: theData.title1
+							})(<Select placeholder="请选择视频类型">
+									{videoType.map(item=>{
+										return <Select.Option value={item.value}>{item.key}</Select.Option>
+									})}
+								</Select>)}
+						</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>
+						<FormItem className="half-item" {...formItemLayout} label="封面图片">
+							<VideoComponent
+								fileList={this.getPictureUrl}
+								videoUrl={this.state.pictureUrl}
+								dataUrl={{
+									url:'/api/user/demand/uploadPicture',
+									keyWord:'demand_picture',
+									type:'image',
+									page:1
+								}}
+								visible={this.props.visible}
+							/>
+						</FormItem>
+					</div>
+					<div className="clearfix">
+						<FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="视频简介">
+							{getFieldDecorator('summary', {
+								initialValue: theData.summary
+							})(<Input type="textarea" rows={4} placeholder="输入视频简介" />)}
+						</FormItem>
+					</div>
+					<div className="clearfix">
+						<FormItem className="half-item" {...formItemLayout} label="发布人">
+							<span>{theData.releaseStatus?'已发布':'管理员'}</span>
+						</FormItem>
+						{theData.createTime&&<FormItem className="half-item" {...formItemLayout} label="发布状态">
+							<span>{theData.releaseStatus?'已发布':'未发布'}</span>
+						</FormItem>}
+					</div>
+					<div className="clearfix">
+						<FormItem wrapperCol={{ span: 12, offset: 3 }}>
+							<Button className="set-submit" type="primary" htmlType="submit">
+								保存草稿
+							</Button>
+							<Button
+								className="set-submit"
+								type="ghost"
+								onClick={(e) => {
+										this.handleSubmit(e,2)
+								}}
+							>
+								发布视频
+							</Button>
+							<Button className="set-submit" type="ghost" onClick={this.cancelFun}>
+								取消
+							</Button>
+						</FormItem>
+					</div>
+				</Spin>
+			</Form>    
+		</div>
+        )
+    }
+}));
+export default NewDetailForm;
+
+
+
+

+ 347 - 0
js/component/administration/video/videoList.jsx

@@ -0,0 +1,347 @@
+import React from 'react';
+import { Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker } from 'antd';
+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';
+
+const PolicyList = React.createClass({
+    loadData(pageNo) {
+        this.state.data = [];
+        this.setState({
+            page:pageNo,
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/policy/list",
+            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,
+            },
+            success: function (data) {
+                let theArr = [];
+                if (!data.data || !data.data.list) {
+                    if (data.error && data.error.length) {
+                        message.warning(data.error[0].message);
+                    };
+                } else {
+                    for (let i = 0; i < data.data.list.length; i++) {
+                        let thisdata = data.data.list[i];
+                        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():''
+                        });
+                    };
+                };
+                this.state.selectedRowKeys=[];
+                this.state.pagination.current = data.data.pageNo;
+                this.state.pagination.total = data.data.totalCount;
+                if(data.data&&data.data.list&&!data.data.list.length){
+					this.state.pagination.current=0
+					this.state.pagination.total=0
+				};
+                this.setState({
+                    dataSource: theArr,
+                    pagination: this.state.pagination
+                });
+            }.bind(this),
+        }).always(function () {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+    getInitialState() {
+        return {
+            searchMore: true,
+            validityPeriodDate: [],
+            releaseDate: [],
+            selectedRowKeys: [],
+            selectedRows: [],
+            loading: false,
+            pagination: {
+                defaultCurrent: 1,
+                defaultPageSize: 10,
+                showQuickJumper: true,
+                pageSize: 10,
+                onChange: function (page) {
+                    this.loadData(page);
+                }.bind(this),
+                showTotal: function (total) {
+                    return '共' + total + '条数据';
+                }
+            },
+            columns: [
+                {
+                    title: '视频名称',
+                    dataIndex: 'title',
+                    key: 'title',
+                },  {
+                    title: '视频地址',
+                    dataIndex: 'author',
+                    key: 'author',
+                    
+                },
+                {
+                    title: '视频类型',
+                    dataIndex: 'auditStatus',
+                    key: 'auditStatus',
+                    render: text => { return getVideoType(text) }
+                },
+                {
+                    title: '上传者',
+                    dataIndex: 'source',
+                    key: 'source',
+                    render:text=>{return <span>管理员</span>}
+                },
+                {
+                    title: '上传时间',
+                    dataIndex: 'releaseDate',
+                    key: 'releaseDate'
+                },
+                {
+                    title: '状态',
+                    dataIndex: 'releaseDate1',
+                    key: 'releaseDate1',
+                    render: text => { return getReleaseStateList(text) }
+                },
+                {
+                    title: '操作',
+                    dataIndex: 'caozuo',
+                    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>}
+                                </div>
+                    }
+                }
+            ],
+            dataSource: [],
+            searchTime: [,]
+        };
+    },
+    //发布
+    submission(record){
+        this.setState({
+            showDesc:false,
+            loading:true
+        });
+        $.ajax({
+            method: "POST",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/policy/updateStatus",
+            data: {
+                id:record.id,
+                auditStatus:2
+            }
+        }).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));
+    },
+    //刷新发布
+    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();
+    },
+    tableRowClick(record, index) {
+        this.state.RowData = record;
+        this.setState({
+            showDesc: true
+        });
+    },
+    delectRow() {
+        this.setState({
+            loading:true
+        })
+        let deletedIds =[];
+        let rowItem = this.state.selectedRowKeys[0];
+        let data = this.state.dataSource ||[];
+        if (data.length) {
+            deletedIds.push(data[rowItem].id);
+        }
+        $.ajax({
+            method: "POST",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/policy/delete",
+            data: {
+                id: deletedIds[0]
+            }
+        }).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));
+    },
+    addClick() {
+        this.state.RowData = {};
+        this.setState({
+            showDesc: true
+        });
+    },
+    closeDesc(e, s) {
+        this.state.showDesc = e;
+        if (s) {
+            this.loadData(this.state.page);
+        };
+    },
+    search() {
+        this.loadData();
+    },
+    reset() {
+        this.state.videoName = '';
+        this.state.releaseDate = [];
+        this.state.videoType = undefined;
+        this.state.videoState = undefined;
+        this.loadData();
+        
+    },
+    searchSwitch() {
+        this.setState({
+            searchMore: !this.state.searchMore
+        });
+    },
+    render() {
+        const rowSelection = {
+            selectedRowKeys: this.state.selectedRowKeys,
+            onChange: (selectedRowKeys, selectedRows) => {
+                this.setState({
+                    selectedRows: selectedRows.slice(-1),
+                    selectedRowKeys: selectedRowKeys.slice(-1)
+                });
+            }
+
+        };
+        const { RangePicker } = DatePicker;
+        const hasSelect = this.state.selectedRowKeys.length;
+        return (
+            <div className="user-content" >
+                <div className="content-title">
+                    <span>视频管理</span>
+                    <div className="patent-addNew">
+                        <Button type="primary" onClick={this.addClick}>新建视频<Icon type="plus" /></Button>
+                    </div>
+                </div>
+                <div className="user-search">
+                    <Input placeholder="视频名称"
+                        value={this.state.videoName}
+                        onChange={(e) => { this.setState({ videoName: e.target.value }); }} />
+                    <Select placeholder="视频类型" style={{ width: 120 }}
+                        value={this.state.videoType}
+                        onChange={(e) => { this.setState({ videoType: e }) }}>
+                        {videoType.map(item=>{
+                            return <Select.Option value={item.value}>{item.key}</Select.Option>
+                        })}
+                    </Select>
+                    <Select placeholder="视频状态" style={{ width: 120 }}
+                        value={this.state.videoState}
+                        onChange={(e) => { this.setState({ videoState: e }) }}>
+                         {releaseStateList.map(item=>{
+                            return <Select.Option value={item.value}>{item.key}</Select.Option>
+                        })}
+                    </Select>
+                    <Button type="primary" onClick={this.search}>搜索</Button>
+                    <Button onClick={this.reset}>重置</Button>
+                    <Button type="danger" disabled={!hasSelect}  onClick={(e)=>{this.delectRow()}}>删除</Button>
+                </div>
+                <div className="patent-table">
+                    <Spin spinning={this.state.loading}>
+                        <Table columns={this.state.columns}
+                            dataSource={this.state.dataSource}
+                            rowSelection={rowSelection}
+                            pagination={this.state.pagination}
+                            onRowClick={this.tableRowClick} />
+                    </Spin>
+                </div>
+                <NewDesc
+                    data={this.state.RowData}
+                    showDesc={this.state.showDesc}
+                    closeDesc={this.closeDesc} />
+            </div >
+        );
+    }
+});
+
+export default PolicyList;

+ 96 - 0
js/component/crop/video.jsx

@@ -0,0 +1,96 @@
+import { Component } from 'react';
+import { Upload, message, Icon, Modal,Button } from 'antd';
+class VideoComponent extends Component {
+	constructor(props) {
+		super(props);
+        this.state = {
+            previewVisible: false,
+			previewImage: '',
+			fileList: [],
+			urls: []
+        };
+	}
+	handleCancel() {
+		this.setState({ previewVisible: false });
+	}
+	handlePreview(file) {
+		this.setState({
+			previewImage: file.url || file.thumbUrl,
+			previewVisible: true
+		});
+	}
+	handleChange(info) {
+        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.setState({
+                urls:fileList[0].response.data});
+        } else if (info.file.status === 'error') {
+            message.error(`上传失败`);
+        }
+	}
+    beforeUpload(info){
+        if(this.props.dataUrl.type.indexOf('video')>-1){
+            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;
+            };
+        };
+        if(this.props.dataUrl.type.indexOf('image')>-1){
+            if(info.type.indexOf('image')<0){
+                message.warning('请上传图片.');
+                return false;
+            };
+            let sizeMb = info.size/(1024*1024),size=1;
+            if(sizeMb>size){  //100Mb之内
+                message.warning(`图片大小不超过${size}MB.`);
+                return false;
+            };
+        }
+    }
+	componentWillReceiveProps(nextProps) {
+        this.state.fileList = nextProps.videoUrl;
+	}
+	render() {
+       
+        const { previewVisible, previewImage, fileList } = this.state;
+		const uploadButton = (
+			<div>
+				<Icon type="plus" />
+				<div className="ant-upload-text">点击上传</div>
+			</div>
+        );
+        const dataUrl = this.props.dataUrl||{};
+		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>
+			</div>
+		);
+	}
+}
+
+export default VideoComponent;

+ 13 - 0
js/component/dataDic.js

@@ -2502,5 +2502,18 @@ module.exports = {
 	        value: "4",
 	        key: "活动返券"
 	    },
+    ],
+    //视频类型
+    videoType:[
+        {
+	        value: "0",
+	        key: "直接观看"
+	    },{
+	        value: "1",
+	        key: "注册观看"
+	    },{
+	        value: "2",
+	        key: "付费观看"
+	    }
     ]
 };

+ 14 - 1
js/component/tools.js

@@ -89,7 +89,8 @@ import {
     ziYuanType,
     couponAuthState,
     couponAuthStates,
-    couponCome
+    couponCome,
+    videoType
 } from './dataDic.js';
 
 import { provinceList} from './NewDicProvinceList.js';
@@ -1633,5 +1634,17 @@ module.exports = {
             });
             return theType;
         }
+    },
+    //视频类型
+    getVideoType: function (e) {
+        if (e||e=='0') {
+            let theType = '';
+            videoType.map(function (item) {
+                if (item.value == e) {
+                    theType = item.key;
+                };
+            });
+            return theType;
+        }
     }
 }

File diff suppressed because it is too large
+ 1135 - 87
package-lock.json


+ 2 - 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 8088 --devtool eval --progress --colors --hot --content-base build --env.deploy dev --env.watch watch"
+    "dev": "webpack-dev-server --port 80 --devtool eval --progress --colors --hot --content-base build --env.deploy dev --env.watch watch"
   },
   "repository": {
     "type": "git",
@@ -49,6 +49,7 @@
   "dependencies": {
     "antd": "^2.7.4",
     "axios": "^0.18.0",
+    "dplayer": "^1.25.0",
     "echarts": "^3.6.2",
     "echarts-for-react": "^1.4.4",
     "html2canvas": "^0.5.0-beta4",

+ 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:8088';   
+	let staticHost = 'http://192.168.0.188';   
     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:8088';    
+    let staticHost = 'http://192.168.0.188';    
     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: 8088,
+            port: 80,
             allowedHosts: ['127.0.0.1','192.168.0.20','192.168.0.99'],
             headers: {
                 "Access-Control-Allow-Origin": "*"