Sfoglia il codice sorgente

专家顾问提示

liting2017 6 anni fa
parent
commit
2aaf25678b

+ 9 - 14
js/component/account/index/normal.jsx

@@ -40,6 +40,7 @@ const Content = React.createClass({
                     intellectualPropertyNum: data.data.intellectualPropertyNum,
                     logoUrl: data.data.logoUrl,
                     level: data.data.lvl,
+                    authentication:data.data.authentication,  //0-专家  1--顾问
                     nickname: data.data.nickname,
                     number: data.data.number,
                     patentNum: data.data.patentNum,
@@ -47,7 +48,7 @@ const Content = React.createClass({
                     techProjectNum: data.data.techProjectNum,
                     type: data.data.type,
                     uid: data.data.uid,
-                    visible: data.data.type == '0'||data.data.type=='1' ? false : true
+                    visible: (data.data.authentication||data.data.authentication=='0')&&data.data.type=='0'? false : true
                 })
             }
         }.bind(this)).always(function () {
@@ -90,7 +91,9 @@ const Content = React.createClass({
                         <div className="userdata-content">
                             {(() => {
                                 if (this.state.type == '0') {
-                                    return <p className="userdata-lvl">已个人认证</p>;
+                                    return <div>
+                                                {this.state.authentication=='0'?<p className="userdata-lvl">已专家认证</p>:this.state.authentication=='1'?<p className="userdata-lvl">已顾问认证</p>:<p className="userdata-lvl">已个人认证</p>}
+                                            </div>;
                                 } else if(this.state.type == '1'){
                                     return <p className="userdata-lvl"><span>已企业认证</span></p>
                                 }
@@ -118,22 +121,14 @@ const Content = React.createClass({
                                     })()
                                 }
                             </div>
-                            <p className="userdata-relate" style={{ 'display': 'none' }}>
-                                <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
-                                <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
-                                <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
-                            </p>
                         </div>
                     </div>
-                    {/* <div className="index-record">
-                        <p className="acc-title">我的轨迹</p>
-                    </div>*/}
                     <div className="index-activity">
                         <Collection nub={1}/>
                     </div> 
                 </div>
                 <Modal maskClosable={false}
-                    title="实名认证提示"
+                    title="认证提示"
                     visible={this.state.visible}
                     onCancel={() => {
                         this.setState({
@@ -143,11 +138,11 @@ const Content = React.createClass({
                     width='400px'
                     footer={[]} >
                     <p style={{ textAlign: 'center' }}>
-                        <span>您还未进行认证,请完成认证,为您提供更多服务</span>
+                        <span>您还未进行 ( 专家 / 顾问 ) 认证,请完成认证,为您提供更多服务</span>
                     </p>
                     <div style={{ marginTop: '20px', textAlign: 'center' }}>
-                        <Button type="primary" style={{marginRight:15}}><Link to="/personal">个人认证</Link></Button>
-                        <Button type="primary"><Link to="/unit">企业认证</Link></Button>
+                        <Button type="primary" style={{marginRight:15}}><Link to="/personal">专家认证</Link></Button>
+                        <Button type="primary"><Link to="/personal">顾问认证</Link></Button>
                     </div>
                 </Modal>
             </Spin>

+ 1 - 0
js/component/administration/banner/banner.jsx

@@ -2,6 +2,7 @@ import { Component } from 'react';
 import { Input, Select, Spin, Table, message, Button,Icon } from 'antd';
 import BannerFrom from '@/administration/banner/bannerDes.jsx';
 import {  splitUrl} from '@/tools.js';
+import Crop from  '@/crop/cropBlock';
 
 class Banner extends Component {
 	constructor(props) {

+ 81 - 0
js/component/crop/crop.css

@@ -0,0 +1,81 @@
+@charset 'utf-8';
+
+.crop-block {
+	position: relative;
+	display: inline-block;
+}
+.crop-add-img {
+	position: relative;
+	display: inline-block;
+	width: 80px;
+	height: 24px;
+	line-height: 24px;
+	text-align: center;
+	font-size: 12px;
+	border: 1px solid #2F86C9;
+	color: #2F86C9;
+	cursor: pointer;
+}
+.crop-img-block {
+	display: inline-block;
+	width: 50px;
+	height: 50px;
+	margin: 5px;
+	
+}
+.crop-img {
+	max-width: 100%;
+	max-height: 100%;
+	cursor: pointer;
+}
+
+.crop-box {
+	position: fixed;
+	left: 0;
+	top: 0;
+	width: 100%;
+	height: 100%;
+	z-index: 1000;
+}
+.crop-box-bg {
+	position: absolute;
+	left: 0;
+	top: 0;
+	width: 100%;
+	height: 100%;
+	background-color: #000;
+	opacity: 0.5;
+}
+.crop-box-content {
+	position: relative;
+	width: 800px;
+	height: 500px;
+	margin: 50px auto 0 auto;
+	background-color: #fff;
+}
+.crop-close {
+	position: absolute;
+	right: 10px;
+	top: 10px;
+	border: 1px solid #2F86C9;
+	color: #2F86C9;
+	font-size: 12px;
+	padding: 0 5px;
+	height: 24px;
+	line-height: 24px;
+	cursor: pointer;
+}
+.crop-input {
+	position: relative;
+	padding: 10px;
+	text-align: center;
+	border-bottom: 1px solid #2F86C9;
+}
+.crop-area {
+	position: relative;
+	padding-left: 200px;
+	border-bottom: 1px solid #2F86C9;
+}
+.crop-sure-btn {
+	margin: 10px 0 0 350px;
+}

+ 94 - 0
js/component/crop/cropBlock.jsx

@@ -0,0 +1,94 @@
+import React, {
+  Component
+} from 'react';
+import CropBox from './cropBox.jsx';
+import './crop.css';
+
+class CropBlock extends Component {
+	constructor(props) {
+		super(props);
+		this.state = {
+			urlArr: this.props.imgArr ? this.props.imgArr : [],
+			number: this.props.number ? this.props.number : '',
+			uploadData: this.props.uploadData ? this.props.uploadData : {},
+			aspectRatio: this.props.aspectRatio ? this.props.aspectRatio : '',
+			url: this.props.url ? this.props.url : '',
+			close: true,
+		}
+
+		this.getUrl = this.getUrl.bind(this);
+		this.addImg = this.addImg.bind(this);
+		this.delImg = this.delImg.bind(this);
+		this.getAllImg = this.getAllImg.bind(this);
+	}
+
+	getUrl(url) {
+		let urlArr2 = this.state.urlArr;
+		urlArr2.push(url);
+		this.setState({
+			urlArr: urlArr2,
+			close: true
+		})
+		this.getAllImg(urlArr2);
+	}
+
+	addImg() {
+		if(!this.state.number || (this.state.urlArr.length < this.state.number)) {
+			this.setState({
+				close: false
+			})
+		}
+		else {
+			alert("最多上传"+this.state.number+"张图片!");
+		}
+	}
+
+	delImg(index) {
+		if(window.confirm("你确定要删除改图片吗")) {
+			let urlArr2 = this.state.urlArr;
+			urlArr2.splice(index, 1);
+			this.setState({
+				urlArr: urlArr2,
+				close: true
+			})
+			this.getAllImg(urlArr2);
+		}
+	}
+
+	getAllImg(urlArr) {
+		if(this.props.getAllImg) {
+			this.props.getAllImg(urlArr);
+		}
+	}
+
+	render() {
+		console.log(this.state.urlArr)
+		let imgList = this.state.urlArr.map((src, index) =>
+			<div key = {index} className="crop-img-block">
+				<img alt = "图片" className = "crop-img" title = "删除" src = {src} onClick = {this.delImg.bind(this, index)} />
+			</div>
+		)
+		return (
+			<div className = "crop-block">
+			   {imgList}
+				<div className="crop-add-img" onClick = {this.addImg}>添加图片</div>
+				<CropBox getUrl = {this.getUrl} uploadData = {this.state.uploadData} aspectRatio = {this.state.aspectRatio} url = {this.state.url} close = {this.state.close}/>
+			</div>
+		)
+	}
+}
+
+export default CropBlock;
+
+
+/* 
+   //调用
+ <Crop 
+ number = {5} 
+ aspectRatio = {1/1}
+  url ={globalConfig.context + '/api/admin/banners/uploadPicture'}
+  uploadData = {{sign: 'banners'}} 
+  urlArr = {[]} 
+/>
+
+*/

+ 145 - 0
js/component/crop/cropBox.jsx

@@ -0,0 +1,145 @@
+import React, {
+  Component
+} from 'react';
+import $ from 'jquery';
+import Cropper from 'react-cropper';
+import 'cropperjs/dist/cropper.css';
+
+class CropBox extends Component {
+	constructor(props) {
+		super(props);
+
+		this.state = {
+	      src: '',
+	      close: this.props.close ? this.props.close : true,
+	      url: this.props.url ? this.props.url : '',
+	      uploadData: this.props.uploadData ? this.props.uploadData : {},
+	      aspectRatio: this.props.aspectRatio ? this.props.aspectRatio : ''
+	    }
+
+	    this.onChange = this.onChange.bind(this);
+	    this.cropImage = this.cropImage.bind(this);
+	    this.convertBase64UrlToBlob = this.convertBase64UrlToBlob.bind(this);
+	    this.submitUpload = this.submitUpload.bind(this);
+	    this.closeBox = this.closeBox.bind(this);
+
+	}
+
+	componentWillReceiveProps(nextProps) {
+        this.setState({
+            close: nextProps.close
+        })
+    }
+
+	onChange(e) {
+	    e.preventDefault();
+	    let files;
+	    if (e.dataTransfer) {
+	      	files = e.dataTransfer.files;
+	    } else if (e.target) {
+	      	files = e.target.files;
+	    }
+	    let reader = new FileReader();
+	    reader.onload = () => {
+	      this.setState({
+	        src: reader.result
+	      });
+	    };
+	    reader.readAsDataURL(files[0]);
+	}
+
+	cropImage() {
+	    if (typeof this.cropper.getCroppedCanvas() === 'undefined') {
+	      return;
+	    }
+		let img64Data = this.cropper.getCroppedCanvas().toDataURL();
+		console.log(img64Data)
+		//let imgblobDate = this.convertBase64UrlToBlob(img64Data);
+		let imgblobDate = this.dataURLtoFile(img64Data,'nihao');
+	    this.submitUpload(imgblobDate);
+	}
+
+	submitUpload(imgBlob) {
+		console.log(imgBlob)
+		let _this = this;
+		let fd = new FormData();
+		fd.append('file', imgBlob);
+		for(let key in this.state.uploadData) {
+			fd.append(key, this.state.uploadData[key]);
+		}
+		
+		$.ajax({
+		    url: this.state.url,
+		    type: 'POST',
+		    data: fd,
+		    contentType: false,
+		    processData: false,
+		    dataType: 'json',
+		    success: function (data) {
+	    		console.log(data.result);
+	    		if(_this.props.getUrl) {
+	    			_this.props.getUrl(data.result);
+	    		}
+	    		_this.setState({
+	    			close: true,
+	    			src: ''
+	    		})
+		    },
+		    error: function(err) {
+		    	console.log(err);
+		    }
+		});
+	}
+	//将base64转换为文件
+    dataURLtoFile(dataurl, filename) {
+		var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
+		bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
+		while(n--){
+			u8arr[n] = bstr.charCodeAt(n);
+		}
+		return new File([u8arr], filename, {type:mime});
+	}
+	//base64转二进制文件格式
+	convertBase64UrlToBlob(urlData) {
+		var bytes=window.atob(urlData.split(',')[1]);        //去掉url的头,并转换为byte  
+	    //处理异常,将ascii码小于0的转换为大于0  
+	    var ab = new ArrayBuffer(bytes.length);  
+	    var ia = new Uint8Array(ab);  
+	    for (var i = 0; i < bytes.length; i++) {  
+	        ia[i] = bytes.charCodeAt(i);  
+	    }  
+	    return new Blob( [ab] , {type : 'image/png'});
+	}
+	closeBox() {
+		this.setState({
+			close: true
+		})
+	}
+	render() {
+		return (
+			<div className = "crop-box" style = {this.state.close ? {"display": "none"} : {"display": "block"}}>
+				<div className="crop-box-bg"></div>
+				<div className="crop-box-content">
+					<div className="crop-input">	
+						<input type="file" onChange={this.onChange} key = {this.state.src}/>
+						<div className="crop-close" onClick = {this.closeBox}>关闭</div>
+					</div>
+					<div className="crop-area">
+						<Cropper key = {this.state.src}
+				            style={{ height: 400, width: 400 }}
+						    aspectRatio = {this.state.aspectRatio}
+						    preview = ".img-preview"
+				            guides={true}
+				            src={this.state.src}
+				            ref={cropper => { this.cropper = cropper; }}
+				        />
+					</div>
+					<button className = "crop-sure-btn" onClick={this.cropImage}>确认裁剪</button>
+					
+				</div>
+			</div>
+		);
+	}
+}
+
+export default CropBox;

+ 16 - 0
package-lock.json

@@ -2078,6 +2078,12 @@
         "object-assign": "4.1.1"
       }
     },
+    "cropperjs": {
+      "version": "1.0.0-rc.3",
+      "resolved": "http://registry.npm.taobao.org/cropperjs/download/cropperjs-1.0.0-rc.3.tgz",
+      "integrity": "sha1-UKfHYRvvxEJwL4Re3nfX30Vy6Cs=",
+      "dev": true
+    },
     "crypto-browserify": {
       "version": "3.11.1",
       "resolved": "http://registry.npm.taobao.org/crypto-browserify/download/crypto-browserify-3.11.1.tgz",
@@ -6927,6 +6933,16 @@
         "prop-types": "15.5.10"
       }
     },
+    "react-cropper": {
+      "version": "1.0.1",
+      "resolved": "http://registry.npm.taobao.org/react-cropper/download/react-cropper-1.0.1.tgz",
+      "integrity": "sha1-blWVq7hXYIirPlHs/c/l+GXQNA8=",
+      "dev": true,
+      "requires": {
+        "cropperjs": "1.0.0-rc.3",
+        "prop-types": "15.5.10"
+      }
+    },
     "react-dom": {
       "version": "15.6.1",
       "resolved": "http://registry.npm.taobao.org/react-dom/download/react-dom-15.6.1.tgz",

+ 1 - 0
package.json

@@ -38,6 +38,7 @@
     "jsx-loader": "^0.13.2",
     "less": "^2.7.2",
     "less-loader": "^2.2.3",
+    "react-cropper": "^1.0.1",
     "react-hot-loader": "^1.3.1",
     "react-router": "^3.0.2",
     "style-loader": "^0.13.2",

+ 3 - 3
webpack.config.js

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

+ 7 - 7
webpack/entry.config.js

@@ -11,32 +11,32 @@ module.exports = {
     'admin/index': './js/admin/index.js',
   },
   watch: {
-    'user/index': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'user/index': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/user/index.js'
     ],
-    'user/login': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'user/login': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/user/login.js'
     ],
-    'user/signIn': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'user/signIn': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/user/signIn.js'
     ],
-    'user/account/index': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'user/account/index': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/user/account/index.js'
     ],
-    'user/account/evaluateInfo': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'user/account/evaluateInfo': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/user/account/assessment.js'
     ],
     //admin
-    'admin/login': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'admin/login': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
     'webpack/hot/only-dev-server',
     './js/user/adminLogin.js'
     ],
-    'admin/index': ['webpack-dev-server/client?http://192.168.0.190:8088', // WebpackDevServer host and port
+    'admin/index': ['webpack-dev-server/client?http://192.168.0.188:8088', // WebpackDevServer host and port
       'webpack/hot/only-dev-server',
       './js/admin/index.js'
     ]