Browse Source

增加支持页面跳转

吕卓 3 years ago
parent
commit
057a330e82

+ 2 - 1
config/webpack.config.js

@@ -32,7 +32,8 @@ const postcssNormalize = require('postcss-normalize');
 const appPackageJson = require(paths.appPackageJson);
 
 // Source maps are resource heavy and can cause out of memory issue for large source files.
-const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
+// const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
+const shouldUseSourceMap = false ; //打包过滤.map文件
 
 const webpackDevClientEntry = require.resolve(
   'react-dev-utils/webpackHotDevClient'

+ 1 - 0
package.json

@@ -114,6 +114,7 @@
     "webpack": "^4.44.2",
     "webpack-cli": "^4.7.2"
   },
+  "homepage": ".", 
   "jest": {
     "roots": [
       "<rootDir>/src"

+ 1 - 1
scripts/devbuild.js

@@ -48,7 +48,7 @@ const argv = process.argv.slice(2);
 const writeStatsJson = argv.indexOf('--stats') !== -1;
 
 // Generate configuration
-const config = configFactory('development');
+const config = configFactory('production');
 
 // We require that you explicitly set browsers and do not fall back to
 // browserslist defaults.

+ 181 - 119
src/App.js

@@ -1,9 +1,9 @@
-import React, { Component , Suspense } from 'react';
+import React, { Component, Suspense } from 'react';
 import ReactDOM from 'react-dom';
 import './App.css';
-import { Menu, Button } from 'antd';
+import { Menu, Button,Result } from 'antd';
 import { $Axios } from './common/publish';
-import { SettingOutlined, DollarCircleOutlined,  } from '@ant-design/icons';
+import { SettingOutlined, DollarCircleOutlined, } from '@ant-design/icons';
 import * as Icons from "@ant-design/icons";
 import {
   MenuUnfoldOutlined,
@@ -15,174 +15,236 @@ export default class App extends React.Component {
     super(props)
     this.state = {
       isLogin: true,
-      current: 'one',
-      arr1 : [
-        { txt : '商户入网' , icon : 'GlobalOutlined' , assembly:'Layout' },
-        { txt : '商户入网列表' , icon : 'SlidersOutlined', assembly:'center-tab'}
+      current: 1,
+      arr1: [
+        { txt: '商户入网', icon: 'GlobalOutlined', assembly: 'Layout' }, //  no  1-0
+        { txt: '商户入网列表', icon: 'SlidersOutlined', assembly: 'center-tab' }   // ok 1-1
       ],
-      arr2 : [
-        { txt : '订单查询' , icon : '', assembly:'Finance-orderQuery'},//ok
-        { txt : '退款查询' , icon : '', assembly:'Refund-inquiry'},  //ok
-        { txt : '账户概览' , icon : '', assembly:'Account-overview'},  //ok
-        { txt : '发起提现' , icon : '', assembly:'Cash-initiated'}, //ok
-        { txt : '提现记录' , icon : '', assembly:'Withdrawal-record'}, //ok
-        { txt : '分账收益记录' , icon : '', assembly:'Income-record'}, //ok
+      arr2: [
+        { txt: '订单查询', icon: '', assembly: 'Finance-orderQuery' },//ok  2-0
+        { txt: '退款查询', icon: '', assembly: 'Refund-inquiry' },  //ok  2-1
+        { txt: '账户概览', icon: '', assembly: 'Account-overview' },  //ok 2-2
+        { txt: '发起提现', icon: '', assembly: 'Cash-initiated' }, //ok 2-3
+        { txt: '提现记录', icon: '', assembly: 'Withdrawal-record' }, //ok 2-4
+        { txt: '分账收益记录', icon: '', assembly: 'Income-record' }, //ok 2-5
         // { txt : 'demo' , icon : '', assembly:'homePage'},
       ],
-      assembly : 'Layout',
-      defaultSelectedKeys : 'Layout',
-      defaultSelectedKeys1 : 'Finance-orderQuery',
-      assembly_cw :  'Finance-orderQuery',
-      user_txt :  {
-        userName : 'xxx',  //名字
-        userJur : 'Y1', //权限
-        userInternet : null, // 用户权限为Y3时 才会出现是否入网字段
-      }
+      assembly: 'Layout',
+      defaultSelectedKeys: 'Layout',
+      assembly_cw: 'Finance-orderQuery',
+      user_txt: {},
+      signout: false,
+      isSignout : 'no'
     }
   }
 
 
   componentDidMount() {
-    this.initJurisdiction()
+    let isSignout = localStorage.getItem('isSignout');
+    let userData = localStorage.getItem('userInformation');
+    // if(isSignout == 'yes' && userData == null){ //拦截是否为刷新页面
+    //   this.setState({
+    //     signout : true
+    //   })
+    // }
+    this.initJurisdiction();
+    // console.log(userData)
   }
-  initJurisdiction(){//初始化用户权限
+  initJurisdiction() {//初始化用户权限
     console.log('----------初始化用户权限---------');
     console.log(process.env.NODE_ENV == 'development' ? '----------开发测试环境----------' : '----------线上生产环境----------')
-    this.autoLogin() //登录查询用户信息
-    let Jur = ['Y1','Y2','Y3']   //Y1为云悦平台权限最高权限  //Y2为商城权限二级权限  // Y3为商户权限属于个人权限
-    let obj = { 
-      appName : 'com.smrongshengtianxia',
-      merchantId : '896582034',
-      id : 2,
-      pfAppName : 'com.chuangyetong' //包名
+    // this.autoLogin() //登录查询用户信息
+    let userData = JSON.parse(localStorage.getItem('userInformation '));
+    let obj = {   //默认信息
+      userName: '测试用户',
+      appName: 'com.smrongshengtianxia',
+      merchantId: '896582034',
+      id: 2,
+      pfAppName: 'com.chuangyetong', //包名
+      Jur : 1,//用户权限
+      pages : '2-0' 
+    }
+    if (userData !== null) {  //能获取用户信息 改变存储信息
+      obj = {
+        userName: userData.userName, //用户名
+        appName: userData.appName,  //appName
+        merchantId: userData.merchantId,  //merchantId
+        id: userData.id,  //id
+        userId: userData.userId,
+        pfAppName: userData.pfAppName, //包名
+        Jur : userData.Jur, //用户权限 1为云悦平台权限最高权限  //2为商城权限二级权限  // 3为商户权限属于个人权限;
+        pages : userData.pages   //支持页面跳转
+      }
+    }
+    let page = obj.pages.split('-');
+    if(page[0] == 1){
+      let arr = this.state.arr1;
+      this.setState({
+        user_txt: obj,
+        current : page[0],
+        assembly : arr.find((item,index) => { return index == page[1]}).assembly
+      })
+    }else{
+      let arr = this.state.arr2;
+      this.setState({
+        user_txt: obj,
+        current : page[0],
+        assembly_cw : arr.find((item,index) => { return index == page[1]}).assembly
+      })
     }
-    localStorage.setItem('userData',JSON.stringify(obj))
+  
+    localStorage.setItem('userData', JSON.stringify(obj))
 
   }
 
-  handleClick(e){
-    this.setState({	
-      current : e.key,
+  handleClick(e) {
+    this.setState({
+      current: e.key,
     });
     this.initassembly()
   }
 
-  toggleCollapsed(e){
+  toggleCollapsed(e) {
     this.setState({
       collapsed: !this.state.collapsed,
     });
   }
 
-  toggleNavs(e){
+  toggleNavs(e) {
     let current = this.state.current;
-    if(current == 'one'){
+    if (current == 'one') {
       this.setState({
         assembly: e.key,
       });
-    }else{
+    } else {
       this.setState({
-        assembly_cw : e.key
+        assembly_cw: e.key
       });
     }
-  
+
   }
-  initassembly(){
+  initassembly() {
     let current = this.state.current;
     let Assembly = null;
-    if(current == 'one'){
+    if (current == 'one') {
       Assembly = React.lazy(() => import(`./component/${this.state.assembly}/${this.state.assembly}.jsx`));
-    }else{
+    } else {
       Assembly = React.lazy(() => import(`./component/${this.state.assembly_cw}/${this.state.assembly_cw}.jsx`));
     }
-    
-    return <Suspense  fallback="" key="dialog"><Assembly refModal={this.state.current} /></Suspense>
+
+    return <Suspense fallback="" key="dialog"><Assembly refModal={this.state.current} /></Suspense>
   }
-  initIcon(item){
+  initIcon(item) {
     let Icon = item.icon;
     return React.createElement(Icons[Icon])
   }
 
-  autoLogin = () => {
-      let url = '/payment/merchant.query.groovy'
-      let param = {
-        appName : '吕卓',
-        action : "queryInfo"
-        
-      }
-      $Axios('post',url,param,(res) => {
-        // console.log(res)
-      })
+  // autoLogin = () => {
+  //     let url = '/payment/merchant.query.groovy'
+  //     let param = {
+  //       appName : '吕卓',
+  //       action : "queryInfo"
+
+  //     }
+  //     $Axios('post',url,param,(res) => {
+  //       // console.log(res)
+  //     })
+  // }
+
+  signout() {
+    localStorage.setItem('isSignout', 'yes')
+    localStorage.removeItem('userInformation') //退出清除用户本地数据
+    localStorage.removeItem('userData') //退出清除用户本地数据
+    this.setState({
+      signout: true
+    });
+    
   }
 
   render() {
-    const { current, arr1, arr2 , user_txt } = this.state;
+    const { current, arr1, arr2, user_txt, signout,assembly,assembly_cw } = this.state;
     const { SubMenu } = Menu;
     return (
       <React.Fragment>
-        {/* {this.state.isLogin ? <Layout></Layout>} */}
-        <div className='wrap'>
-          <div className='header_nav'>
-            <div className='header_title'>商户入网信息管理平台</div>
-            <div className='header_menu'>
-              <div className='head-sj'>
-                <Button type="primary" onClick={this.toggleCollapsed.bind(this)} style={{ marginBottom: 16 }} style={{height:'100%'}}>
-                {React.createElement(this.state.collapsed ? MenuUnfoldOutlined : MenuFoldOutlined)}
-              </Button>
-              </div>
-              <Menu onClick={this.handleClick.bind(this)}  selectedKeys={[current]} mode="horizontal" className='header_navs'>
-                <Menu.Item key="one" icon={<SettingOutlined />}>
-                  高级设置
-                </Menu.Item>
-                <Menu.Item key="tow" icon={<DollarCircleOutlined />}>
-                  财务管理
-                </Menu.Item>
-              </Menu>
-            </div>
-            <div className='header_user'  style={{lineHeight:'60px'}}>
-                <div style={{width:'50%',lineHeight:'60px',display:'inline-block'}}>用户名 : {user_txt.userName}</div>
-                <div style={{width:'50%',lineHeight:'60px',display:'inline-block'}}>
-                  <a>修改密码</a>
-                  <a style={{marginLeft:'10px'}}>退出</a>
-                </div>
-            </div>
+        {
+          signout == true && <div style={{ width: '100%', height: '100%' }}>
+            <Result
+              status="success"
+              title="您已退出登录!"
+              subTitle="You have logged out."
+              // extra={}
+            />
           </div>
-          <div className='main_centers'>
-            {current === 'one' && <Menu
-                className='main_left_nav'
-                defaultSelectedKeys={[this.state.assembly]}
-                mode="inline"
-                theme="dark"
-                inlineCollapsed={this.state.collapsed}
-                onClick={this.toggleNavs.bind(this)}
-              >
-                {current === 'one' && (arr1.map((item,index) =>(
-                  <Menu.Item key={item.assembly} data={item.txt} icon={this.initIcon(item)}>
-                    {item.txt}
-                  </Menu.Item>
-                )))}
-              </Menu>}
-              {current === 'tow' && <Menu
-                className='main_left_nav'
-                defaultSelectedKeys={[this.state.assembly_cw]}
-                mode="inline"
-                theme="dark"
-                inlineCollapsed={this.state.collapsed}
-                onClick={this.toggleNavs.bind(this)}
-              >
-                {current === 'tow' && (arr2.map((item,index) =>(
-                  <Menu.Item key={item.assembly} data={item.txt} icon={<DollarCircleOutlined />}>
-                    {item.txt}
-                  </Menu.Item>
-                )))}
-              </Menu>}
-              
-              <div className='main_right_center'>
-                {
+        }
+        {
+          signout == false && <div style={{ width: '100%', height: '100%' }}>
+            <div className='wrap'>
+              <div className='header_nav'>
+                <div className='header_title'>商户入网信息管理平台</div>
+                <div className='header_menu'>
+                  <div className='head-sj'>
+                    <Button type="primary" onClick={this.toggleCollapsed.bind(this)} style={{ marginBottom: 16 }} style={{ height: '100%' }}>
+                      {React.createElement(this.state.collapsed ? MenuUnfoldOutlined : MenuFoldOutlined)}
+                    </Button>
+                  </div>
+                  <Menu onClick={this.handleClick.bind(this)}  selectedKeys={[current]} mode="horizontal" className='header_navs'>
+                    <Menu.Item key={1} icon={<SettingOutlined />}>
+                      高级设置
+                    </Menu.Item>
+                    <Menu.Item key={2} icon={<DollarCircleOutlined />}>
+                      财务管理
+                    </Menu.Item>
+                  </Menu>
+                </div>
+                <div className='header_user' style={{ lineHeight: '60px' }}>
+                  <div style={{ width: '50%', lineHeight: '60px', display: 'inline-block' }}>用户名 : {user_txt.userName}</div>
+                  <div style={{ width: '50%', lineHeight: '60px', display: 'inline-block' }}>
+                    {/* <a>修改密码</a> */}
+                    <a style={{ marginLeft: '10px' }} onClick={this.signout.bind(this)}>退出</a>
+                  </div>
+                </div>
+              </div>
+              <div className='main_centers'>
+                {current == 1 && <Menu
+                  className='main_left_nav'
+                  defaultSelectedKeys={[this.state.assembly]}
+                  mode="inline"
+                  theme="dark"
+                  key={assembly}
+                  inlineCollapsed={this.state.collapsed}
+                  onClick={this.toggleNavs.bind(this)}
+                >
+                  {current == 1 && (arr1.map((item, index) => (
+                    <Menu.Item key={item.assembly} data={item.txt} icon={this.initIcon(item)}>
+                      {item.txt}
+                    </Menu.Item>
+                  )))}
+                </Menu>}
+                {current == 2 && <Menu
+                  className='main_left_nav'
+                  defaultSelectedKeys={[this.state.assembly_cw]}
+                  mode="inline"
+                  theme="dark"
+                  key={assembly_cw}
+                  inlineCollapsed={this.state.collapsed}
+                  onClick={this.toggleNavs.bind(this)}
+                >
+                  {current == 2 && (arr2.map((item, index) => (
+                    <Menu.Item key={item.assembly} data={item.txt} icon={<DollarCircleOutlined />}>
+                      {item.txt}
+                    </Menu.Item>
+                  )))}
+                </Menu>}
+
+                <div className='main_right_center'>
+                  {
                     this.initassembly()
-                }
+                  }
+                </div>
               </div>
+            </div>
           </div>
-        </div>
+        }
       </React.Fragment>
     )
   }

+ 7 - 6
src/common/publish.js

@@ -51,11 +51,12 @@ Date.prototype.formats = function (fmt) {
 //请求API,json形式
 export function $Axios (method,urls, param, fn, err) {
     let url;
-    if(process.env.NODE_ENV === 'development'){ 
-        url = 'http://paytest.zhongsou.com'//开发测试环境API
-    }else{  
-        url = 'http://pay.zhongsou.com' //生产线上环境API
-    }
+    // if(process.env.NODE_ENV === 'development'){ 
+    //     url = 'http://paytest.zhongsou.com'//开发测试环境API
+    // }else{  
+    //     url = 'http://pay.zhongsou.com' //生产线上环境API
+    // }
+    url = 'http://paytest.zhongsou.com'//开发测试环境API
 	let methods = method.trim()
 	let obj = {
 		method: methods, //请求方式
@@ -86,7 +87,7 @@ export function $Axios (method,urls, param, fn, err) {
 		})
 		.catch((e) => {
 			if (err) err()
-			console.log(e)
+			console.log(JSON.stringify(e))
 		})
 }
 

+ 2 - 2
src/component/Cash-initiated/Cash-initiated.jsx

@@ -30,7 +30,7 @@ export default class AccountOverview extends React.Component {
         let params = {
             action :"queryOpInfo", //提现操作相关信息,可提现金额等
             appName :JSON.parse(localStorage.getItem('userData')).appName, //当前商户的appname,
-            merchantId : JSON.parse(localStorage.getItem('userData')).merchantId//商户ID在第三方的唯一编号,
+            // merchantId : JSON.parse(localStorage.getItem('userData')).merchantId//商户ID在第三方的唯一编号,
         }
         $Axios('get',url,params,(res) => {
             let status = res.data.head.status;
@@ -55,7 +55,7 @@ export default class AccountOverview extends React.Component {
                         let params = {
                             action :"create",//提现
                             appName : JSON.parse(localStorage.getItem('userData')).appName,//当前商户的appname,
-                            merchantId : JSON.parse(localStorage.getItem('userData')).appmerchantIdName,//商户ID在第三方的唯一编号,
+                            // merchantId : JSON.parse(localStorage.getItem('userData')).appmerchantIdName,//商户ID在第三方的唯一编号,
                             withdrawAmount : document.getElementById("je").value,//提现金额以元为单位,默认都是人民币,以元为单位
                             pwd : document.getElementById("pwd").value//String,交易密码
                         }

+ 1 - 1
src/component/Income-record/Income-record.jsx

@@ -110,7 +110,7 @@ export default class IncomeRecord extends React.Component {
         let that_ = this;
         let url = '/payment/spare.bill.list.groovy';
         let params = {
-            userId: '',//当前登陆用户userid
+            userId: JSON.parse(localStorage.getItem('userData')).userId,//当前登陆用户userid
             ownerId:document.getElementById("fzsh").value,//关联分账商户
             status: this.state.status,//分账状态,1:分账成功2:分账中3:分账撤回
             createTimeStart : '',//创建开始时间

+ 1 - 1
src/component/Layout/Layout.jsx

@@ -144,7 +144,7 @@ export default class Layout extends React.Component {
             merchantNo : '249',
             merchantType : '3',
             merchantInfo : {     //原首易信接口参数
-                merchantId : '', //商户在首信易系统的唯一身份标识,商户完成首信易系统注册后可登录商户后台商户服务查看
+                // merchantId : '', //商户在首信易系统的唯一身份标识,商户完成首信易系统注册后可登录商户后台商户服务查看
                 requestId : '', //订单号为商户自行拟定,提交的订单号必须在自身平台交易中唯一。商户平台不能以相同的订单号再次提交。
                 operationType : 'CREATE', // :1:CREATE创建即入网,2:MODIFY更新即修改(审核通过前)
                 notifyUrl : '',//服务器通知:当订单状态发生变更后会向该地址发送五次通知,该地址可以带参数,如:“https://www.5upay.com/callback.action?test=test”.注意:如不填notifyUrl的参数值成功后您的服务器将得不到通知。

+ 2 - 2
src/component/Withdrawal-record/Withdrawal-record.jsx

@@ -117,8 +117,8 @@ export default class WithdrawalRecord extends React.Component {
         let url = '/payment/merchant.order.query.groovy'
         let params = {
             action: "pickupList",//查询商户提现记录
-            // appName : JSON.parse(localStorage.getItem('userData')).appName,testPickUpList
-            appName: 'testPickUpList',
+            appName : JSON.parse(localStorage.getItem('userData')).appName,
+            // appName: 'testPickUpList',
             tradeStatus: this.state.tradeStatus, //提现状态:1处理中PROCESS,2成功SUCCESS,3失败FAIL(inithecancle不统计)
             timeType: this.state.timeType,//为0或不提供此字段,表示不限制,1创建时间,2完成时间
             begTime: this.state.starTime,//"2021-06-3000:00:00",为空或不提供此字段,表示不限制

+ 12 - 5
src/component/center-tab/center-tab.jsx

@@ -1,5 +1,5 @@
 import React, { useState } from 'react';
-import { Spin, Table, Modal , Button  } from 'antd';
+import { Spin, Table, Modal , message  } from 'antd';
 import { $Axios, format } from '../../common/publish';
 import select_data from '../../common/ssq';
 import '../center-tab/center-tab.scss'
@@ -145,7 +145,6 @@ export default class centerTab extends React.Component {
                 let baseInfo = JSON.parse(res.data.body.baseInfo);
                 let merchantInfo = JSON.parse(res.data.body.merchantInfo);
                 let certificateInfo = merchantInfo.certificateInfo;
-                console.log(merchantInfo)
                 let data = [
                     { txt: '签约类型', value: '被分账方' , type : false},
                     { txt: '签约名称', value: baseInfo.signedName , type : false },
@@ -203,10 +202,18 @@ export default class centerTab extends React.Component {
                         isModalVisible: true,
                     })
                 });
+            }else{
+                console.log(123)
+                let txt = res.data.body.msg
+                that_.setState({
+                    isModalVisible: true,
+                })
+                message.error(txt);
             }
-            // console.log(res)
+            console.log(status)
 
         })
+
     }
 
     handleOk_c() {
@@ -407,8 +414,8 @@ export default class centerTab extends React.Component {
                     {
                         (tklodins == true &&  tk_data !== []) && <div style={{maxHeight:'300px',overflow : 'auto'}}>
                             {tk_data.map((item, index) => (
-                                item.type == false ? <div key={index} style={{height:'50px',lineHeight :'50px'}} value={item.value}>{item.txt} : {item.value}</div> : <div key={index} style={{height:'50px',lineHeight :'50px'}} >{item.txt} :  <Button type="primary" onClick={ (e) => this.cktuImg(item.value) } >查看图片</Button></div>
-                               
+                                //item.type == false ? <div key={index} style={{height:'50px',lineHeight :'50px'}} value={item.value}>{item.txt} : {item.value}</div> : <div key={index} style={{height:'50px',lineHeight :'50px'}} >{item.txt} :  <Button type="primary" onClick={ (e) => this.cktuImg(item.value) } >查看图片</Button></div>
+                                <div key={index} style={{height:'50px',lineHeight :'50px'}} value={item.value}>{item.txt} : {item.value}</div>
                             ))}
                          </div>
                     }