Browse Source

取后台微信头像存储本地

RaoMeng 6 years ago
parent
commit
d0ac565b45

+ 1 - 1
frontend/wechat-web/src/configs/router.config.js

@@ -78,7 +78,7 @@ export default class RouteConfig extends Component {
                     <Route path="/homePage" component={HomePage}/>{/*首页*/}
                     <Route path='/userInfoPage/:type?' component={UserInfo}/>{/*个人信息*/}
 
-                    <Route path='/bindMenu/:type/:openid?/' component={BindMenu}/>{/*绑定菜单页面*/}
+                    <Route path='/bindMenu/:type/:openid?/:wxAvatar?' component={BindMenu}/>{/*绑定菜单页面*/}
                     <Route path='/accountBind/:type?' component={AccountBind}/>{/*绑定页面*/}
 
                     <Route path='/newAlbum/:classId/:name?' component={NewAlbum}/>{/*新建相册*/}

+ 16 - 2
frontend/wechat-web/src/modules/accountBind/BindMenu.jsx

@@ -13,8 +13,9 @@ import {API} from "../../configs/api.config";
 import {switchUser} from 'action/userInfo'
 import {getIntValue, getStrValue, isObjEmpty} from "../../utils/common";
 import {clearUserInfo} from "../../redux/actions/userInfo";
+import {connect} from "react-redux";
 
-export default class BindMenu extends Component {
+class BindMenu extends Component {
 
     constructor() {
         super()
@@ -54,9 +55,14 @@ export default class BindMenu extends Component {
                 errorMsg: '获取绑定信息中...'
             })
             this.openid = this.paramId
+            this.wxAvatar = this.props.match.params.wxAvatar
 
             //清除用户信息
             clearUserInfo()()
+
+            switchUser({
+                userAvatar: decodeURIComponent(this.wxAvatar),
+            })()
             this.obtainBindStatus()
         }
     }
@@ -201,4 +207,12 @@ export default class BindMenu extends Component {
     teacherBind = () => {
         this.props.history.push('/accountBind/teacher')
     }
-}
+}
+
+let mapStateToProps = (state) => ({
+    userInfo: {...state.redUserInfo}
+})
+
+let mapDispatchToProps = (dispatch) => ({})
+
+export default connect(mapStateToProps, mapDispatchToProps)(BindMenu)

+ 40 - 37
frontend/wechat-web/src/modules/hiPages/accessnoticedetail/AccessNoticeDetail.js

@@ -1,54 +1,55 @@
 /**
-*   Created by FANGlh on 2019/1/17 8:57.
-*   Desc: 进出校通知详情
-*/
+ *   Created by FANGlh on 2019/1/17 8:57.
+ *   Desc: 进出校通知详情
+ */
 
-import React,{Component} from 'react';
+import React, {Component} from 'react';
 import {connect} from 'react-redux';
 import './AccessNoticeDetail.css';
-import {isObjEmpty,getIntValue, getStrValue} from  '../../../utils/common';
-import {getWeixinInfo} from '../../../utils/api.request'
-import {fetchPost, fetchGet, fetchGetNoSession} from '../../../utils/fetchRequest';
+import {isObjEmpty, getIntValue, getStrValue} from '../../../utils/common';
+import {fetchGet, fetchGetNoSession} from '../../../utils/fetchRequest';
 import {API, _baseURL} from '../../../configs/api.config';
 
 
-class AccessNoticeDetail extends Component{
-   constructor(props){
+class AccessNoticeDetail extends Component {
+    constructor(props) {
         super(props);
         this.state = {
-            studentName:'',
-            studentType:'出校时间',
-            studentPhoto:'http://pic.vjshi.com/2018-08-28/8b163ad1a98e567f26cea40f34d56a27/00001.jpg?x-oss-process=style/watermark',
-            studentHourMinues:'',
+            studentName: '',
+            studentType: '出校时间',
+            studentPhoto: 'http://pic.vjshi.com/2018-08-28/8b163ad1a98e567f26cea40f34d56a27/00001.jpg?x-oss-process=style/watermark',
+            studentHourMinues: '',
 
         }
     }
+
     componentWillMount() {
     }
+
     componentDidMount() {
         let stuId = this.props.match.params.stuId
         let role = this.props.match.params.role
         let anId = this.props.match.params.anId
-        console.log("stuId",stuId)
-        if (!isObjEmpty(stuId)){
-            this.getANDetail(stuId,anId)
+        console.log("stuId", stuId)
+        if (!isObjEmpty(stuId)) {
+            this.getANDetail(stuId, anId)
         }
 
 
         let curDay = new Date().getDay()
-        if(curDay == 1){
+        if (curDay == 1) {
             curDay = '星期一'
-        }else if(curDay == 2){
+        } else if (curDay == 2) {
             curDay = '星期二'
-        }else if(curDay == 3){
+        } else if (curDay == 3) {
             curDay = '星期三'
-        }else if(curDay == 4){
+        } else if (curDay == 4) {
             curDay = '星期四'
-        }else if(curDay ==  5){
+        } else if (curDay == 5) {
             curDay = '星期五'
-        }else if(curDay == 6){
+        } else if (curDay == 6) {
             curDay = '星期六'
-        }else if(curDay ==  7){
+        } else if (curDay == 7) {
             curDay = '星期日'
         }
 
@@ -56,31 +57,33 @@ class AccessNoticeDetail extends Component{
         let hout_min = new Date().getHours() + ':' + new Date().getMinutes()
 
         this.setState({
-            studentName:this.props.userInfo.user.student.stuName,
-            studentType:'出校时间',
-            studentPhoto:'http://pic.vjshi.com/2018-08-28/8b163ad1a98e567f26cea40f34d56a27/00001.jpg?x-oss-process=style/watermark',
-            studentTime:hout_min,
-            studentDate:date,
+            studentName: this.props.userInfo.user.student.stuName,
+            studentType: '出校时间',
+            studentPhoto: 'http://pic.vjshi.com/2018-08-28/8b163ad1a98e567f26cea40f34d56a27/00001.jpg?x-oss-process=style/watermark',
+            studentTime: hout_min,
+            studentDate: date,
         })
     }
-     render(){
-       const  { studentName,studentType,studentPhoto,studentTime,studentDate} = this.state
-        return(
-            <div style={{textAlign:'center',}}>
+
+    render() {
+        const {studentName, studentType, studentPhoto, studentTime, studentDate} = this.state
+        return (
+            <div style={{textAlign: 'center',}}>
                 <div className="an_student_name">{studentName}</div>
-                <img className="an_student_photo"  src = {studentPhoto} alt = ""/>
+                <img className="an_student_photo" src={studentPhoto} alt=""/>
                 <div className="an_student_type">{studentType}</div>
                 <div className='an_student_foot_time'>
-                    <span style={{color:'#222222',fontSize:24,paddingRight:10,}}>{studentTime}</span>
-                    <span style={{color:'#666666',fontsize:12,}}>{studentDate}</span>
+                    <span style={{color: '#222222', fontSize: 24, paddingRight: 10,}}>{studentTime}</span>
+                    <span style={{color: '#666666', fontsize: 12,}}>{studentDate}</span>
                 </div>
             </div>
         )
     }
-    getANDetail =(stuId,anId)=>{
+
+    getANDetail = (stuId, anId) => {
         fetchGet(API.leaveDetail, {
             stuId: stuId,
-            anId:anId
+            anId: anId
         }).then((response) => {
             if (response.success && !isObjEmpty(response.data)) {
 

+ 4 - 7
frontend/wechat-web/src/modules/home/HomePage.jsx

@@ -20,7 +20,6 @@ import 'css/home-page.css'
 import {fetchGet, fetchPost} from "../../utils/fetchRequest";
 import {_baseURL, API} from "../../configs/api.config";
 import icon_home_change from "../../style/imgs/icon_home_change.png";
-import {getWeixinInfo} from '../../utils/api.request'
 
 const operation = Modal.operation;
 
@@ -35,7 +34,7 @@ class HomePage extends Component {
     }
 
     componentWillMount() {
-        // getWeixinInfo()
+
     }
 
     componentDidMount() {
@@ -290,17 +289,15 @@ class HomePage extends Component {
 
     userInfoLayout = () => {
         const {userInfo} = this.props
-        let schoolName = '', userAvatar = '', userName = '', albums = ''
+        let schoolName = '', userName = '', albums = ''
         if (userInfo.userRole === 1) {
             if (userInfo.parent) {
                 schoolName = userInfo.parent.schoolName
-                userAvatar = userInfo.parent.parentsPhoto
                 userName = userInfo.parent.parentsName
             }
         } else if (userInfo.userRole === 2) {
             if (userInfo.teacher) {
                 schoolName = userInfo.teacher.schoolName
-                userAvatar = userInfo.teacher.teacherPhoto
                 userName = userInfo.teacher.teacherName
             }
         }
@@ -308,10 +305,10 @@ class HomePage extends Component {
             <div>
                 <div className='home-top-school-text'>{schoolName}</div>
                 <div className='home-top-msg-root'>
-                    {isObjEmpty(userAvatar) ?
+                    {isObjEmpty(userInfo.userAvatar) ?
                         <Avatar size={50} icon='user'/> :
                         <img
-                            src={userAvatar}
+                            src={userInfo.userAvatar}
                             width={50} height={50} className="img-circle"
                             style={{border: '3px solid #ffffff'}}/>
                     }

+ 0 - 73
frontend/wechat-web/src/modules/homework/HomeWorkDetail.jsx

@@ -1,73 +0,0 @@
-/**
- * Created by RaoMeng on 2019/1/14
- * Desc: 作业详情
- */
-
-import React, {Component} from 'react'
-import {Toast} from 'antd-mobile'
-import {isObjEmpty} from "../../utils/common";
-import {fetchGet} from "../../utils/fetchRequest";
-import {API} from "../../configs/api.config";
-
-class HomeWorkDetail extends Component {
-
-    constructor() {
-        super()
-
-        this.state = {}
-    }
-
-    componentDidMount() {
-        document.title = '作业详情'
-
-        if (this.props.match.params) {
-            this.workId = this.props.match.params.id
-            this.role = this.props.match.params.role
-        }
-
-        this.obtainDetail()
-    }
-
-    componentWillUnmount() {
-        Toast.hide()
-    }
-
-    render() {
-        return (
-            <div className='common-flex-column'>
-                <div className='common-flex-row-12'>
-                    {isObjEmpty(userInfo.userAvatar) ?
-                        <Avatar size={60} icon='user'/> :
-                        <img
-                            src={this.props.userInfo.userAvatar}
-                            width={60} height={60} className="img-circle"
-                            style={{border: '3px solid #ffffff'}}/>
-                    }
-                    <div className='common-flex-column-y-center'>
-                        <span></span>
-                        <span></span>
-                    </div>
-                </div>
-            </div>
-        )
-    }
-
-    obtainDetail = () => {
-        fetchGet(API.homeWorkDetail, {
-            notifyId: this.workId,
-            userId: this.props.userInfo.userId
-        }).then(response => {
-
-        }).catch(error => {
-
-        })
-    }
-}
-
-let mapStateToProps = (state) => ({
-    userInfo: {...state.redUserInfo},
-})
-
-let mapDispatchToProps = (dispatch) => ({})
-
-export default connect(mapStateToProps, mapDispatchToProps)(HomeWorkDetail)

+ 2 - 5
frontend/wechat-web/src/modules/user/UserInfo.js

@@ -60,21 +60,18 @@ class UserInfo extends Component {
     //显示顶部个人信息
     showUserInfo() {
         const {userInfo} = this.props
-        let userAvatar = ''
         let userName = ''
 
         if (this.type == 1) {
-            userAvatar = userInfo.teacher.teacherPhoto
             userName = userInfo.teacher.teacherName
         } else if (this.type == 2) {
-            userAvatar = userInfo.parent.parentsPhoto
             userName = userInfo.parent.parentsName
         }
         return <div className='user-row'>
-            {isObjEmpty(userAvatar) ?
+            {isObjEmpty(userInfo.userAvatar) ?
                 <Avatar size={50} icon='user'/> :
                 <img className='user-info-avatar' onClick={this.onAvatarClick}
-                     src={userAvatar}/>}
+                     src={userInfo.userAvatar}/>}
             <div className="flex_row_center user-info-msg">
                 <span>{userName}</span>
             </div>

+ 1 - 0
frontend/wechat-web/src/redux/reducers/redUserInfo.js

@@ -56,6 +56,7 @@ const initListState = {
 
     userOpenid: '',
     userRole: 0,
+    userAvatar: '',
     teacher: '',
     parent: '',
     user: {