Skip to content

Commit

Permalink
sm opt
Browse files Browse the repository at this point in the history
  • Loading branch information
minooo committed Mar 9, 2018
1 parent cb8c2c2 commit 577c796
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
28 changes: 20 additions & 8 deletions components/1-02-Form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component, Fragment } from "react";
import { Input, Select, Button, message, Alert } from "antd";
import { withRouter } from "next/router";
import { isMobile, isName, http, setCookie } from "@utils";
import { isMobile, isName, http, setCookie, cache } from "@utils";

@withRouter
export default class extends Component {
Expand Down Expand Up @@ -111,13 +111,25 @@ export default class extends Component {
if (response.code === 200 && response.success) {
const { token } = response.data;
setCookie("token", token, 1); // 有效期1天
router.push(
{
pathname: "/1-loan/4-apply-loan",
query: { name, money, mobile, genre }
},
"/loan/apply"
);
cache.setItem("userPhone", mobile);
setTimeout(() => {
http
.get("member/base_profile")
.then(response => {
if (response.code === 200 && response.success) {
if (response.data && response.data.base) {
cache.setItem("userName", response.data.base.username || response.data.base.phone)
router.push(
{
pathname: "/1-loan/4-apply-loan",
query: { name, money, mobile, genre }
},
"/loan/apply"
);
}
}
})
}, 10)
} else {
this.onErrMsg(response.msg || "抱歉,请求出错。");
}
Expand Down
19 changes: 14 additions & 5 deletions pages/1-loan/4-apply-loan.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from "react-redux";
import Router from "next/router";
import uuid from "uuid/v4";
import { message } from "antd";
import { http } from "@utils";
import { http, cache } from "@utils";
import { getUser, getUserOther } from "@actions";
import reduxPage from "@reduxPage";
import {
Expand Down Expand Up @@ -45,21 +45,31 @@ export default class extends Component {
focus: 0
};
componentDidMount() {
const { getUser, getUserOther, user, userOther, url: { query } } = this.props;
const { getUser, getUserOther, url: { query } } = this.props;
if (!query || !query.mobile) {
Router.replace({ pathname: "/index" }, "/")
return
}
if (!user || !userOther) {
http
http
.get("member/base_profile")
.then(response => {
if (response.code === 200 && response.success) {
getUser(response.data);
if (response.data && response.data.base) {
cache.setItem("userId", response.data.base.idNum)
cache.setItem("userName", response.data.base.username || response.data.base.phone)
}
http
.get("member/other_profile")
.then(response => {
if (response.code === 200 && response.success) {
getUserOther(response.data);
cache.setItem(
"userJob",
response.data &&
response.data.info &&
response.data.info.identity_status
);
} else {
message.error(response.msg || "抱歉,请求出错。");
}
Expand All @@ -74,7 +84,6 @@ export default class extends Component {
.catch(() => {
message.error("抱歉,网络异常,请稍后再试!");
});
}
}
onNextOne = param => {
this.goNext("base", param, 1);
Expand Down
3 changes: 3 additions & 0 deletions static/styles/common/base/plugin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
font-size: 14px;
height: 38px;
}
.ant-btn-lg {
height: 38px;
}
.ant-radio-inner:after {
border-radius: 4px;
}
Expand Down

0 comments on commit 577c796

Please sign in to comment.