Browse Source

通讯录接口对接

RaoMeng 7 years ago
parent
commit
2ff6dded4d

+ 11 - 6
frontend/wechat-web/src/configs/api.config.js

@@ -33,12 +33,6 @@ export const API = {
     PAYMENT_PAYMENT_DETAIL: _baseURL + '/payment/paymentDetails',
     //结束收款
     PAYMENT_ENTPAY: _baseURL + '/payment/endPay',
-    //获取所有老师的电话
-    TEACHER_PHONES_LIST: _baseURL + '/user/getTeacherPhoneList',
-    //获取相应班级老师电话号码
-    GET_TEACHER_PHONES: _baseURL + '/user/getTeacherPhones',
-    //获取班级家长手机号
-    GET_PARENT_PHONES: _baseURL + '/user/getParentPhones',
 
     //校园卡充值
     RECHARGE_FORCARD: _baseURL + '/payCard/reChangeForCard',
@@ -177,6 +171,17 @@ export const API = {
     NOTIFY_LIST_TEACHER: _baseURL + '/wxSchool/notify/notifyListByTeacher',
     //通知公告详情
     NOTIFY_DETAIL: _baseURL + '/wxSchool/notify/getNotifyDetails',
+
+
+    //获取所有老师手机号
+    TEACHER_PHONES_LIST: _baseURL + '/wxSchool/clazz/getAllTeacherBySchool',
+    //获取相应班级老师电话号码
+    GET_TEACHER_PHONES: _baseURL + '/wxSchool/clazz/getTeacherByStuId',
+    //获取所教班级家长手机号
+    GET_PARENT_PHONES_BYTEACHER: _baseURL + '/wxSchool/clazz/selectParentPhoneByTeacher',
+    //获取班级家长手机号
+    GET_PARENT_PHONES: _baseURL + '/wxSchool/clazz/getParentByClazzId',
+
 }
 
 

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

@@ -138,7 +138,7 @@ export default class RouteConfig extends Component {
                     {/*<Route path="/accessnoticedetail/:stuId?" component={AccessNoticeDetail}/>     /!*出入校通知详情*!/*/}
                     <Route path="/accessnoticedetail" component={AccessNoticeDetail}/> {/*出入校通知详情*/}
                     <Route path='/leaveAddC' component={LeaveAddCPage}/>{/*老师请假*/}
-                    <Route path='/leaveAdd' component={LeaveAddPage}/>   {/*学生请假*/}
+                    <Route path='/leaveAdd' component={LeaveAddPage}/> {/*学生请假*/}
                     <Route path='/leaveList/:role' component={LeaveListPage}/>{/*学生请假列表*/}
 
                     {/*刘杰*/}

+ 103 - 53
frontend/wechat-web/src/modules/phonesBook/PhonesList.jsx

@@ -9,16 +9,17 @@ import {List, Skeleton} from 'antd'
 import PhonesItem from "../../components/PhonesItem";
 import 'css/phones.css'
 import {getStrValue, isObjEmpty} from "../../utils/common";
-import {fetchGet} from "../../utils/fetchRequest";
-import {API} from "../../configs/api.config";
+import {fetchGet, fetchPost} from "../../utils/fetchRequest";
+import {_baseURL, API} from "../../configs/api.config";
 import {Toast, SearchBar} from "antd-mobile";
 import RefreshLayout from "../../components/RefreshLayout";
-
+import {connect} from 'react-redux'
 
 const mPageSize = 10
 let mPageIndex = 0
+let mSearchKey = ''
 
-export default class PhonesList extends Component {
+class PhonesList extends Component {
 
     constructor() {
         super()
@@ -28,6 +29,9 @@ export default class PhonesList extends Component {
             classTitle: '',
             isLoading: true,
             isRefreshing: false,
+            searchKey: '',
+            searchText: '',
+            searchHint: '',
         }
     }
 
@@ -38,8 +42,6 @@ export default class PhonesList extends Component {
         this.mType = this.props.match.params.type
         if (this.props.match.params.classId) {
             this.classId = this.props.match.params.classId;
-        } else {
-            this.classId = 10001
         }
         if (this.title) {
             this.setState({
@@ -47,19 +49,34 @@ export default class PhonesList extends Component {
             })
         }
 
-        Toast.loading('', 0)
+        if (this.mType === 'teacher') {
+            this.setState({
+                searchHint: '搜索学生'
+            })
+        } else if (this.mType === 'parent') {
+            this.setState({
+                searchHint: '搜索老师'
+            })
+        }
 
+        Toast.loading('', 0)
         mPageIndex = 0
         this.loadPhones()
     }
 
+    componentWillUnmount() {
+        Toast.hide()
+    }
+
     render() {
-        const {phonesList, classTitle, isLoading, isRefreshing} = this.state
+        const {phonesList, classTitle, isLoading, isRefreshing, searchHint, searchKey, searchText} = this.state
 
         return (
-            <div className='phone-select-root' style={{height:'100%',maxHeight:'100vh'}}>
+            <div className='phone-select-root' style={{height: '100%', maxHeight: '100vh'}}>
                 <div className='common-fixed-top'>
-                    <SearchBar placeholder="搜索家长" maxLength={20}/>
+                    <SearchBar placeholder={searchHint} maxLength={20}
+                               value={searchText} onSubmit={this.searchSubmit}
+                               onChange={this.searchChange} onClear={this.searchClear}/>
                     <div className={isObjEmpty(classTitle) ? 'displayNone' : 'phones-list-header'}>{classTitle}</div>
                     <div className={isObjEmpty(classTitle) ? 'displayNone' : 'gray-line'} style={{height: '1px'}}></div>
                 </div>
@@ -81,6 +98,36 @@ export default class PhonesList extends Component {
         )
     }
 
+    searchChange = (value) => {
+        mSearchKey = value
+        this.setState({
+            searchText: value
+        })
+    }
+
+    searchClear = (e) => {
+        mPageIndex = 0
+        this.setState({
+            isLoading: true,
+            isRefreshing: false,
+            searchText: '',
+            searchKey: ''
+        }, () => {
+            this.loadPhones()
+        })
+    }
+
+    searchSubmit = (value) => {
+        mPageIndex = 0
+        this.setState({
+            isLoading: true,
+            isRefreshing: false,
+            searchKey: value
+        }, () => {
+            this.loadPhones()
+        })
+    }
+
     loadPhones = () => {
         try {
             this.setState({
@@ -92,13 +139,13 @@ export default class PhonesList extends Component {
         if (this.mType == 'parent') {
             this.url = API.GET_TEACHER_PHONES
             this.params = {
-                stuId: this.classId
+                stuId: this.props.userInfo.user.student.stuId
             }
             this.getPhones()
         } else if (this.mType == 'teacher') {
             this.url = API.GET_PARENT_PHONES
             this.params = {
-                schId: this.classId
+                clazzId: this.classId
             }
             this.getPhones()
         } else {
@@ -113,60 +160,55 @@ export default class PhonesList extends Component {
         mPageIndex++
         console.log(mPageIndex)
 
-        const {phonesList} = this.state
+        const {phonesList, searchKey} = this.state
         if (mPageIndex === 1) {
             phonesList.length = 0
         }
 
-        fetchGet(this.url, {
+        fetchPost(this.url, {
             pageIndex: mPageIndex,
             pageSize: mPageSize,
+            selectKey: searchKey,
             ...this.params
         }).then(response => {
             Toast.hide();
 
             if (response && response.data) {
                 if (this.mType == 'parent') {
-                    if (response.data.teachers && response.data.teachers.length > 0) {
-                        response.data.teachers.forEach((item, index) => {
-                            let phoneBean = new PhonesBean()
-
-                            phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
-                            phoneBean.name = getStrValue(item, 'userName')
-                            phoneBean.claName = this.title
-                            phoneBean.children = ['']
-
-                            phoneBean.phone = [getStrValue(item, 'UserPhone')]
-                            phonesList.push(phoneBean)
-                        })
-                    }
+                    response.data.forEach((item, index) => {
+                        let phoneBean = new PhonesBean()
+
+                        phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
+                        phoneBean.icon = _baseURL + getStrValue(item, 'teacherPhoto')
+                        phoneBean.name = getStrValue(item, 'teacherName')
+                        phoneBean.claName = this.title
+                        phoneBean.children = ['']
+
+                        phoneBean.phone = [getStrValue(item, 'userPhone')]
+                        phonesList.push(phoneBean)
+                    })
                 } else if (this.mType == 'teacher') {
-                    if (response.data.students && response.data.students.length > 0) {
-                        response.data.students.forEach((item, index) => {
-                            let phoneBean = new PhonesBean()
-                            let phones = []
-                            phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
-                            phoneBean.name = getStrValue(item, 'stuName')
-                            phoneBean.claName = this.title
-
-                            if (item.parents && item.parents.length > 0) {
-                                item.parents.forEach((ite, ind) => {
-                                    phoneBean.children.push(getStrValue(ite, 'userName'))
-                                    phones.push(getStrValue(ite, 'userPhone'))
-                                })
-                            }
-
-                            // if (phones.length > 0) {
-                            phoneBean.phone = phones
-                            // }
-
-                            phonesList.push(phoneBean)
-                        })
-                    } else {
-                        if (mPageIndex > 1) {
-                            mPageIndex--
+                    response.data.forEach((item, index) => {
+                        let phoneBean = new PhonesBean()
+                        let phones = []
+                        phoneBean.icon = require('imgs/ic_head' + (index % 15 + 1) + '.png')
+                        phoneBean.icon = _baseURL + getStrValue(item, 'stuPhoto')
+                        phoneBean.name = getStrValue(item, 'stuName')
+                        phoneBean.claName = this.title
+
+                        if (item.parentsDOS && item.parentsDOS.length > 0) {
+                            item.parentsDOS.forEach((ite, ind) => {
+                                phoneBean.children.push(getStrValue(ite, 'parentsName'))
+                                phones.push(getStrValue(ite, 'userPhone'))
+                            })
                         }
-                    }
+
+                        // if (phones.length > 0) {
+                        phoneBean.phone = phones
+                        // }
+
+                        phonesList.push(phoneBean)
+                    })
                 }
             } else {
                 if (mPageIndex > 1) {
@@ -197,4 +239,12 @@ export default class PhonesList extends Component {
             })
         })
     }
-}
+}
+
+let mapStateToProps = (state) => ({
+    userInfo: {...state.redUserInfo},
+})
+
+let mapDispatchToProps = (dispatch) => ({})
+
+export default connect(mapStateToProps, mapDispatchToProps)(PhonesList)

+ 67 - 17
frontend/wechat-web/src/modules/phonesBook/PhonesSearch.jsx

@@ -11,19 +11,24 @@ import PhonesItem from "../../components/PhonesItem";
 import {Toast, SearchBar} from "antd-mobile";
 import {List, Skeleton} from 'antd'
 import {API} from "../../configs/api.config";
-import {fetchGet} from "../../utils/fetchRequest";
+import {fetchGet, fetchPost} from "../../utils/fetchRequest";
+import {connect} from 'react-redux'
 
 const mPageSize = 10
 let mPageIndex = 0
+let mSearchKey = ''
 
-export default class PhonesSearch extends Component {
+class PhonesSearch extends Component {
 
     constructor() {
         super()
 
         this.state = {
             isRefreshing: false,
-            phonesList: []
+            phonesList: [],
+            isLoading: false,
+            searchKey: '',
+            searchText: '',
         }
     }
 
@@ -44,28 +49,63 @@ export default class PhonesSearch extends Component {
     }
 
     render() {
-        const {phonesList, isRefreshing} = this.state
+        const {phonesList, isRefreshing, isLoading, searchText} = this.state
 
         return (
             <div className='phone-select-root' style={{height: '100%'}}>
                 <SearchBar placeholder="搜索家长" maxLength={20}
-                           ref={ref => this.searchInput = ref}/>
+                           ref={ref => this.searchInput = ref}
+                           value={searchText} onSubmit={this.searchSubmit}
+                           onChange={this.searchChange} onClear={this.searchClear}
+                           onCancel={this.searchClear}/>
 
                 <RefreshLayout
                     refreshing={isRefreshing}
                     onRefresh={this.loadPhones}>
-                    <List className='phones-list-layout'
-                          dataSource={phonesList}
-                          renderItem={phonesBean => (
-                              <List.Item>
-                                  <PhonesItem phonesBean={phonesBean}/>
-                              </List.Item>
-                          )}/>
+                    <Skeleton loading={isLoading} active paragraph={{rows: 3}}>
+                        <List className='phones-list-layout'
+                              dataSource={phonesList}
+                              renderItem={phonesBean => (
+                                  <List.Item>
+                                      <PhonesItem phonesBean={phonesBean}/>
+                                  </List.Item>
+                              )}/>
+                    </Skeleton>
                 </RefreshLayout>
             </div>
         )
     }
 
+    searchChange = (value) => {
+        mSearchKey = value
+        this.setState({
+            searchText: value
+        })
+    }
+
+
+    searchClear = (e) => {
+        mPageIndex = 0
+        this.setState({
+            isLoading: true,
+            isRefreshing: false,
+            searchText: '',
+            searchKey: ''
+        }, () => {
+            this.loadPhones()
+        })
+    }
+
+    searchSubmit = (value) => {
+        mPageIndex = 0
+        this.setState({
+            isLoading: true,
+            isRefreshing: false,
+            searchKey: value
+        }, () => {
+            this.loadPhones()
+        })
+    }
 
     loadPhones = () => {
         try {
@@ -76,15 +116,15 @@ export default class PhonesSearch extends Component {
         }
 
         if (this.mType == 'parent') {
-            this.url = API.GET_TEACHER_PHONES
+            this.url = API.GET_PARENT_PHONES_BYTEACHER
             this.params = {
-                stuId: this.classId
+                teacherId: this.props.userInfo.user.userFunId
             }
             this.getPhones()
         } else if (this.mType == 'teacher') {
-            this.url = API.GET_PARENT_PHONES
+            this.url = API.TEACHER_PHONES_LIST
             this.params = {
-                schId: this.classId
+                teacherId: this.props.userInfo.user.userFunId
             }
             this.getPhones()
         } else {
@@ -104,7 +144,7 @@ export default class PhonesSearch extends Component {
             phonesList.length = 0
         }
 
-        fetchGet(this.url, {
+        fetchPost(this.url, {
             pageIndex: mPageIndex,
             pageSize: mPageSize,
             ...this.params
@@ -162,6 +202,7 @@ export default class PhonesSearch extends Component {
 
             this.setState({
                 phonesList,
+                isLoading: false,
                 isRefreshing: false,
             })
         }).catch(error => {
@@ -177,8 +218,17 @@ export default class PhonesSearch extends Component {
             }
 
             this.setState({
+                isLoading: false,
                 isRefreshing: false,
             })
         })
     }
 }
+
+let mapStateToProps = (state) => ({
+    userInfo: {...state.redUserInfo},
+})
+
+let mapDispatchToProps = (dispatch) => ({})
+
+export default connect(mapStateToProps, mapDispatchToProps)(PhonesSearch)

+ 5 - 5
frontend/wechat-web/src/modules/phonesBook/PhonesSelect.jsx

@@ -11,7 +11,7 @@ import 'css/phones.css'
 import {List, Icon, Skeleton, message} from 'antd'
 import PhonesItem from "components/PhonesItem";
 import PhonesBean from 'model/PhonesBean'
-import {fetchGet} from "../../utils/fetchRequest";
+import {fetchGet, fetchPost} from "../../utils/fetchRequest";
 import {API} from "../../configs/api.config";
 import {Toast} from "antd-mobile";
 import RefreshLayout from "../../components/RefreshLayout";
@@ -93,7 +93,7 @@ class PhonesSelect extends Component {
                         <div className='phoneListItem'
                              onClick={this.onParentItemClick.bind(this, index)}>
                             <div
-                                className='phoneItemText'>{item.parentName + item.schName}</div>
+                                className='phoneItemText'>{item.gradeName + item.clazzName}</div>
                             <Icon type="right" theme="outlined"/>
                         </div>
                     </List.Item>
@@ -213,8 +213,8 @@ class PhonesSelect extends Component {
             teacherList.length = 0
         }
 
-        fetchGet(API.TEACHER_PHONES_LIST, {
-            roleId: 3,
+        fetchPost(API.TEACHER_PHONES_LIST, {
+            teacherId: this.props.userInfo.user.userFunId,
             pageIndex: mPageIndex,
             pageSize: mPageSize
         }).then(response => {
@@ -262,7 +262,7 @@ class PhonesSelect extends Component {
     onParentItemClick = (index) => {
         const {parentList} = this.state
         let selectItem = parentList[index]
-        this.props.history.push('/phonesList/teacher/' + selectItem.schId + '/' + selectItem.parentName + selectItem.schName)
+        this.props.history.push('/phonesList/teacher/' + selectItem.clazzId + '/' + selectItem.gradeName + selectItem.clazzName)
     }
 
     onTeacherClick = () => {

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

@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import 'css/user-info.css'
 import 'css/phones.css'
-import {Icon, Modal, Upload,Avatar} from "antd";
+import {Icon, Modal, Upload, Avatar} from "antd";
 import icon_userInfo_upload from "../../style/imgs/icon_userInfo_upload.png"
 import {API, _baseURL} from "../../configs/api.config";
 import {Toast} from 'antd-mobile'
@@ -133,7 +133,7 @@ class UserInfo extends Component {
         let userPhone = ''
         if (this.type == 1) {
             userPhone = userInfo.teacher.userPhone
-        }else if (this.type == 2) {
+        } else if (this.type == 2) {
             userPhone = userInfo.parent.userPhone
         }
         return <div className={'user-column'}>
@@ -150,7 +150,7 @@ class UserInfo extends Component {
             </div>
             <div className='gray-line' style={{height: '1px'}}></div>
 
-            {this.type == 1 ? '' : <div>
+            {(this.type == 1 || true) ? '' : <div>
                 <div className='user-info-item-top'>
                     <text className='user-info-item-name'>人脸照</text>
                     <div className='gray-line'