Commit 4d4316e7 by zhanghaozhe

update formik

parent 192a6a2b
......@@ -2784,6 +2784,7 @@
"version": "10.0.9",
"resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.9.tgz",
"integrity": "sha512-f7MblpE2xoimC4fCMZ9pivmsIn7hyWRIvY75owMDi8pdOSeh+w5tH3r4hBJv/LLrwiMM7cTQURqTPcYoL5pWnw==",
"dev": true,
"requires": {
"@emotion/sheet": "0.9.2",
"@emotion/stylis": "0.8.3",
......@@ -2795,6 +2796,7 @@
"version": "10.0.10",
"resolved": "https://registry.npmjs.org/@emotion/core/-/core-10.0.10.tgz",
"integrity": "sha512-U1aE2cOWUscjc8ZJ3Cx32udOzLeRoJwGxBH93xQD850oQFpwPKZARzdUtdc9SByUOwzSFYxhDhrpXnV34FJmWg==",
"dev": true,
"requires": {
"@emotion/cache": "^10.0.9",
"@emotion/css": "^10.0.9",
......@@ -2807,6 +2809,7 @@
"version": "10.0.12",
"resolved": "https://registry.npmjs.org/@emotion/css/-/css-10.0.12.tgz",
"integrity": "sha512-esET/v6AwYIw5YVo0e1L/bUik7bIMWyK32BudsC/PE5O1rLK3rjiLCOoMVv5GY6+ssuwWVzooGbz79hPvkkmsw==",
"dev": true,
"requires": {
"@emotion/serialize": "^0.11.7",
"@emotion/utils": "0.11.1",
......@@ -2816,7 +2819,8 @@
"@emotion/hash": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.7.1.tgz",
"integrity": "sha512-OYpa/Sg+2GDX+jibUfpZVn1YqSVRpYmTLF2eyAfrFTIJSbwyIrc+YscayoykvaOME/wV4BV0Sa0yqdMrgse6mA=="
"integrity": "sha512-OYpa/Sg+2GDX+jibUfpZVn1YqSVRpYmTLF2eyAfrFTIJSbwyIrc+YscayoykvaOME/wV4BV0Sa0yqdMrgse6mA==",
"dev": true
},
"@emotion/is-prop-valid": {
"version": "0.8.8",
......@@ -2838,12 +2842,14 @@
"@emotion/memoize": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.1.tgz",
"integrity": "sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg=="
"integrity": "sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==",
"dev": true
},
"@emotion/serialize": {
"version": "0.11.7",
"resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.7.tgz",
"integrity": "sha512-GfzJIMue9eIEPFgBL340hBbjfki11vjYkfmY2LXoCDAFPuG6S+hkOlfinRXLnPVlXnKu7WWp587cVa6/xQriNQ==",
"dev": true,
"requires": {
"@emotion/hash": "0.7.1",
"@emotion/memoize": "0.7.1",
......@@ -2855,7 +2861,8 @@
"@emotion/sheet": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.2.tgz",
"integrity": "sha512-pVBLzIbC/QCHDKJF2E82V2H/W/B004mDFQZiyo/MSR+VC4pV5JLG0TF/zgQDFvP3fZL/5RTPGEmXlYJBMUuJ+A=="
"integrity": "sha512-pVBLzIbC/QCHDKJF2E82V2H/W/B004mDFQZiyo/MSR+VC4pV5JLG0TF/zgQDFvP3fZL/5RTPGEmXlYJBMUuJ+A==",
"dev": true
},
"@emotion/styled": {
"version": "10.0.27",
......@@ -2984,22 +2991,26 @@
"@emotion/stylis": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.3.tgz",
"integrity": "sha512-M3nMfJ6ndJMYloSIbYEBq6G3eqoYD41BpDOxreE8j0cb4fzz/5qvmqU9Mb2hzsXcCnIlGlWhS03PCzVGvTAe0Q=="
"integrity": "sha512-M3nMfJ6ndJMYloSIbYEBq6G3eqoYD41BpDOxreE8j0cb4fzz/5qvmqU9Mb2hzsXcCnIlGlWhS03PCzVGvTAe0Q==",
"dev": true
},
"@emotion/unitless": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.3.tgz",
"integrity": "sha512-4zAPlpDEh2VwXswwr/t8xGNDGg8RQiPxtxZ3qQEXyQsBV39ptTdESCjuBvGze1nLMVrxmTIKmnO/nAV8Tqjjzg=="
"integrity": "sha512-4zAPlpDEh2VwXswwr/t8xGNDGg8RQiPxtxZ3qQEXyQsBV39ptTdESCjuBvGze1nLMVrxmTIKmnO/nAV8Tqjjzg==",
"dev": true
},
"@emotion/utils": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.1.tgz",
"integrity": "sha512-8M3VN0hetwhsJ8dH8VkVy7xo5/1VoBsDOk/T4SJOeXwTO1c4uIqVNx2qyecLFnnUWD5vvUqHQ1gASSeUN6zcTg=="
"integrity": "sha512-8M3VN0hetwhsJ8dH8VkVy7xo5/1VoBsDOk/T4SJOeXwTO1c4uIqVNx2qyecLFnnUWD5vvUqHQ1gASSeUN6zcTg==",
"dev": true
},
"@emotion/weak-memoize": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.2.tgz",
"integrity": "sha512-n/VQ4mbfr81aqkx/XmVicOLjviMuy02eenSdJY33SVA7S2J42EU0P1H0mOogfYedb3wXA0d/LVtBrgTSm04WEA=="
"integrity": "sha512-n/VQ4mbfr81aqkx/XmVicOLjviMuy02eenSdJY33SVA7S2J42EU0P1H0mOogfYedb3wXA0d/LVtBrgTSm04WEA==",
"dev": true
},
"@hapi/address": {
"version": "2.1.4",
......@@ -7947,6 +7958,7 @@
"version": "10.0.13",
"resolved": "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.13.tgz",
"integrity": "sha512-w8yukWIYDw2ZUzBo7B9t5jh7wsM4NQWqvuZadW4MhVokgw5wsoBRJ59Sa1hMc3UZiatwb0iBNufmRQZVl77I5Q==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.0.0",
"@emotion/hash": "0.7.1",
......@@ -7963,7 +7975,8 @@
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
}
}
},
......@@ -9303,11 +9316,6 @@
"supports-color": "^5.3.0"
}
},
"change-emitter": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/change-emitter/-/change-emitter-0.1.6.tgz",
"integrity": "sha1-6LL+PX8at9aaMhma/5HqaTFAlRU="
},
"character-entities": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz",
......@@ -19397,13 +19405,116 @@
}
},
"react-spinners": {
"version": "0.5.12",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.5.12.tgz",
"integrity": "sha512-A1UG87Yd+pdmPQKooJoywdmgSGPG6iPcOoMyfki+wxYDNDEYtejAepws+VxTt/GGpb/JRDnll5oNuQoh4nF9JA==",
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.9.0.tgz",
"integrity": "sha512-+x6eD8tn/aYLdxZjNW7fSR1uoAXLb9qq6TFYZR1dFweJvckcf/HfP8Pa/cy5HOvB/cvI4JgrYXTjh2Me3S6Now==",
"requires": {
"@emotion/core": "^10.0.4",
"prop-types": "^15.5.10",
"recompose": "0.27.1 - 0.30.0"
"@emotion/core": "^10.0.15"
},
"dependencies": {
"@emotion/cache": {
"version": "10.0.29",
"resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.29.tgz",
"integrity": "sha512-fU2VtSVlHiF27empSbxi1O2JFdNWZO+2NFHfwO0pxgTep6Xa3uGb+3pVKfLww2l/IBGLNEZl5Xf/++A4wAYDYQ==",
"requires": {
"@emotion/sheet": "0.9.4",
"@emotion/stylis": "0.8.5",
"@emotion/utils": "0.11.3",
"@emotion/weak-memoize": "0.2.5"
}
},
"@emotion/core": {
"version": "10.0.28",
"resolved": "https://registry.npmjs.org/@emotion/core/-/core-10.0.28.tgz",
"integrity": "sha512-pH8UueKYO5jgg0Iq+AmCLxBsvuGtvlmiDCOuv8fGNYn3cowFpLN98L8zO56U0H1PjDIyAlXymgL3Wu7u7v6hbA==",
"requires": {
"@babel/runtime": "^7.5.5",
"@emotion/cache": "^10.0.27",
"@emotion/css": "^10.0.27",
"@emotion/serialize": "^0.11.15",
"@emotion/sheet": "0.9.4",
"@emotion/utils": "0.11.3"
}
},
"@emotion/css": {
"version": "10.0.27",
"resolved": "https://registry.npmjs.org/@emotion/css/-/css-10.0.27.tgz",
"integrity": "sha512-6wZjsvYeBhyZQYNrGoR5yPMYbMBNEnanDrqmsqS1mzDm1cOTu12shvl2j4QHNS36UaTE0USIJawCH9C8oW34Zw==",
"requires": {
"@emotion/serialize": "^0.11.15",
"@emotion/utils": "0.11.3",
"babel-plugin-emotion": "^10.0.27"
}
},
"@emotion/hash": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz",
"integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow=="
},
"@emotion/memoize": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz",
"integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw=="
},
"@emotion/serialize": {
"version": "0.11.16",
"resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.16.tgz",
"integrity": "sha512-G3J4o8by0VRrO+PFeSc3js2myYNOXVJ3Ya+RGVxnshRYgsvErfAOglKAiy1Eo1vhzxqtUvjCyS5gtewzkmvSSg==",
"requires": {
"@emotion/hash": "0.8.0",
"@emotion/memoize": "0.7.4",
"@emotion/unitless": "0.7.5",
"@emotion/utils": "0.11.3",
"csstype": "^2.5.7"
}
},
"@emotion/sheet": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.4.tgz",
"integrity": "sha512-zM9PFmgVSqBw4zL101Q0HrBVTGmpAxFZH/pYx/cjJT5advXguvcgjHFTCaIO3enL/xr89vK2bh0Mfyj9aa0ANA=="
},
"@emotion/stylis": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz",
"integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ=="
},
"@emotion/unitless": {
"version": "0.7.5",
"resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz",
"integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg=="
},
"@emotion/utils": {
"version": "0.11.3",
"resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.3.tgz",
"integrity": "sha512-0o4l6pZC+hI88+bzuaX/6BgOvQVhbt2PfmxauVaYOGgbsAw14wdKyvMCZXnsnsHys94iadcF+RG/wZyx6+ZZBw=="
},
"@emotion/weak-memoize": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz",
"integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA=="
},
"babel-plugin-emotion": {
"version": "10.0.33",
"resolved": "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.33.tgz",
"integrity": "sha512-bxZbTTGz0AJQDHm8k6Rf3RQJ8tX2scsfsRyKVgAbiUPUNIRtlK+7JxP+TAd1kRLABFxe0CFm2VdK4ePkoA9FxQ==",
"requires": {
"@babel/helper-module-imports": "^7.0.0",
"@emotion/hash": "0.8.0",
"@emotion/memoize": "0.7.4",
"@emotion/serialize": "^0.11.16",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"convert-source-map": "^1.5.0",
"escape-string-regexp": "^1.0.5",
"find-root": "^1.1.0",
"source-map": "^0.5.7"
}
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
}
}
},
"react-sticky": {
......@@ -19556,26 +19667,6 @@
"resolve": "^1.1.6"
}
},
"recompose": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/recompose/-/recompose-0.30.0.tgz",
"integrity": "sha512-ZTrzzUDa9AqUIhRk4KmVFihH0rapdCSMFXjhHbNrjAWxBuUD/guYlyysMnuHjlZC/KRiOKRtB4jf96yYSkKE8w==",
"requires": {
"@babel/runtime": "^7.0.0",
"change-emitter": "^0.1.2",
"fbjs": "^0.8.1",
"hoist-non-react-statics": "^2.3.1",
"react-lifecycles-compat": "^3.0.2",
"symbol-observable": "^1.0.4"
},
"dependencies": {
"hoist-non-react-statics": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
}
}
},
"recursive-readdir": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
......
......@@ -88,7 +88,7 @@
"react-mobile-swiper": "^1.1.4",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-spinners": "^0.5.12",
"react-spinners": "^0.9.0",
"react-sticky": "^6.0.3",
"redux": "^4.0.5",
"redux-immutable": "^4.0.0",
......
......@@ -50,7 +50,8 @@ class App extends Component {
firstLoad = true
componentWillMount() {
componentDidMount() {
let url = window.location.href
if (url.indexOf('ccode') > -1) {
if (!getParam('ccode').includes('%')) {
......@@ -61,9 +62,8 @@ class App extends Component {
})
}
}
}
componentDidMount() {
//是否显示宝箱全局入口
this.isShowGlobalEntryInTime()
......
......@@ -23,7 +23,7 @@ class AddressPopup extends Component {
// 获取收货信息
fetchUserAddress = () => {
const { addressInfo } = this.state;
const {addressInfo} = this.state;
http.get(`${API.home}/sys/user_address_info`).then(res => {
const {code, data, msg} = res.data;
if (code === 200) {
......@@ -40,10 +40,10 @@ class AddressPopup extends Component {
}
handleToSubmit = (params = {}) => {
const { successBindAddress } = this.props;
const {successBindAddress} = this.props;
http.post(`${API.home}/sys/update_address`, {
act_type: 'treasure',
...params
...params,
}).then(res => {
const {code, msg} = res.data;
if (code === 200) {
......@@ -55,15 +55,15 @@ class AddressPopup extends Component {
}
render() {
const { isLoading, addressInfo } = this.state;
const {isLoading, addressInfo} = this.state;
const {tip, prize, skip = 'default'} = this.props;
return (
<>
{
isLoading &&
<Formik
initialValues={{
...addressInfo
initialValues={{
...addressInfo,
}}
validate={({name, phone, address}) => {
const errors = {};
......@@ -71,7 +71,7 @@ class AddressPopup extends Component {
if (!name) {
errors.name = '请输入收件人';
}
if(!/^1[3-9]\d{9}$/.test(phone)) {
if (!/^1[3-9]\d{9}$/.test(phone)) {
errors.phone = '请填写正确格式的手机号';
}
if (!address) {
......@@ -85,79 +85,84 @@ class AddressPopup extends Component {
onSubmit={(values) => {
this.handleToSubmit(values);
}}
render={({errors}) => (
<Form className="address-form" data-skip={skip}>
<h2 className="address-form__title">收货信息</h2>
{
prize ? (
<p className='address__prize'>
您抽中了
<span style={{'color': '#FF4000'}}>{prize}</span>
</p>
) : (null)
}
{
tip ? (<div className="address-form__subtitle">{tip}</div>) : (<p className="address-form__desc">请及时填写收货信息,获得实物奖品后将第一时间为您邮寄</p>)
}
<Field
name="name"
render={({ field }) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="收件人"
/>
{
errors.name &&
<p className="address-form__tip">{errors.name}</p>
}
</div>
)}
/>
<Field
name="phone"
render={({ field }) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="联系方式"
/>
{
errors.phone &&
<p className="address-form__tip">{errors.phone}</p>
}
</div>
)}
/>
<Field
name="address"
render={({ field }) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="收货地址"
/>
{
errors.address &&
<p className="address-form__tip">{errors.address}</p>
}
</div>
)}
/>
<button
className="address-form__submit"
data-status="do"
type="submit"
>提交</button>
</Form>
)}
/>
>
{
({errors}) => (
<Form className="address-form" data-skip={skip}>
<h2 className="address-form__title">收货信息</h2>
{
prize ? (
<p className='address__prize'>
您抽中了
<span style={{'color': '#FF4000'}}>{prize}</span>
</p>
) : (null)
}
{
tip ? (<div className="address-form__subtitle">{tip}</div>) : (
<p className="address-form__desc">请及时填写收货信息,获得实物奖品后将第一时间为您邮寄</p>)
}
<Field
name="name"
render={({field}) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="收件人"
/>
{
errors.name &&
<p className="address-form__tip">{errors.name}</p>
}
</div>
)}
/>
<Field
name="phone"
render={({field}) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="联系方式"
/>
{
errors.phone &&
<p className="address-form__tip">{errors.phone}</p>
}
</div>
)}
/>
<Field
name="address"
render={({field}) => (
<div className="address-form__item">
<input
{...field}
className="address-form__ipt"
type="text"
placeholder="收货地址"
/>
{
errors.address &&
<p className="address-form__tip">{errors.address}</p>
}
</div>
)}
/>
<button
className="address-form__submit"
data-status="do"
type="submit"
>提交
</button>
</Form>
)
}
</Formik>
}
</>
);
......
......@@ -177,69 +177,72 @@ class BindPhone extends Component {
});
this.toBindPhone();
}}
render={({values: {tel, code}, errors}) => (
<Form className="popup-form" data-skip={skip}>
<h2 className="popup-form__title">绑定手机号</h2>
{
desc &&
<div className="poup-form__desc">{desc}</div>
}
<div className="popup-form__item">
<a className="popup-form__button--num" onClick={this.toFetchCountryNum}>
+{country.num}
<i className="iconfont iconiconfront-69"/>
</a>
<Field
name="tel"
render={({field}) => {
return (
<input
{...field}
className="popup-form__ipt"
data-type="tel"
type="text"
placeholder="请填写手机号"
/>
);
}}
/>
</div>
<CaptchaAli getInstance={this.getCaptchaInstance} onVerify={this.onVerify} mb={15}/>
<div className="popup-form__item">
<Field
name="code"
render={({field}) => {
return (
<input
{...field}
className="popup-form__ipt popup-form__ipt--left"
type="text"
placeholder="输入验证码"
/>
);
}}
/>
>
{
({values: {tel, code}, errors}) => (
<Form className="popup-form" data-skip={skip}>
<h2 className="popup-form__title">绑定手机号</h2>
{
desc &&
<div className="poup-form__desc">{desc}</div>
}
<div className="popup-form__item">
<a className="popup-form__button--num" onClick={this.toFetchCountryNum}>
+{country.num}
<i className="iconfont iconiconfront-69"/>
</a>
<Field
name="tel"
render={({field}) => {
return (
<input
{...field}
className="popup-form__ipt"
data-type="tel"
type="text"
placeholder="请填写手机号"
/>
);
}}
/>
</div>
<CaptchaAli getInstance={this.getCaptchaInstance} onVerify={this.onVerify} mb={15}/>
<div className="popup-form__item">
<Field
name="code"
render={({field}) => {
return (
<input
{...field}
className="popup-form__ipt popup-form__ipt--left"
type="text"
placeholder="输入验证码"
/>
);
}}
/>
<button
className="popup-form__button--code"
data-status={(validate && !isTimer) ? 'do' : ''}
type="button"
onClick={() => this.handleToSend({tel, code})}
>
{
isTimer ? `重新发送${seconds}s` : '发送验证码'
}
</button>
</div>
<button
className="popup-form__button--code"
data-status={(validate && !isTimer) ? 'do' : ''}
type="button"
onClick={() => this.handleToSend({tel, code})}
className="popup-form__button--bundle"
data-status={(tel && code && isEmpty(errors)) ? 'do' : 'done'}
type="submit"
>
{
isTimer ? `重新发送${seconds}s` : '发送验证码'
}
完成绑定
</button>
</div>
<button
className="popup-form__button--bundle"
data-status={(tel && code && isEmpty(errors)) ? 'do' : 'done'}
type="submit"
>
完成绑定
</button>
</Form>
)}
/>
</Form>
)
}
</Formik>
)
}
}
......
......@@ -24,7 +24,7 @@ class AddressPopup extends Component {
// 获取收货信息
fetchUserAddress = () => {
const { addressInfo } = this.state;
const {addressInfo} = this.state;
http.get(`${API.home}/sys/user_address_info`).then(res => {
const {code, data, msg} = res.data;
if (code === 200) {
......@@ -41,7 +41,7 @@ class AddressPopup extends Component {
}
handleToSubmit = (params = {}) => {
const { handleToHide } = this.props;
const {handleToHide} = this.props;
http.post(`${API.home}/sys/collect_info`, params).then(res => {
const {code, msg} = res.data;
if (code === 200) {
......@@ -53,15 +53,15 @@ class AddressPopup extends Component {
}
render() {
const { isLoading, addressInfo } = this.state;
const {isLoading, addressInfo} = this.state;
const {tip, prize} = this.props;
return (
<>
{
isLoading &&
<Formik
initialValues={{
...addressInfo
initialValues={{
...addressInfo,
}}
validate={({name, phone, address}) => {
const errors = {};
......@@ -69,7 +69,7 @@ class AddressPopup extends Component {
if (!name) {
errors.name = '请输入收件人';
}
if(!/^1[3-9]\d{9}$/.test(phone)) {
if (!/^1[3-9]\d{9}$/.test(phone)) {
errors.phone = '请填写正确格式的手机号';
}
if (!address) {
......@@ -83,7 +83,8 @@ class AddressPopup extends Component {
onSubmit={(values) => {
this.handleToSubmit(values);
}}
render={({errors}) => (
>
{({errors}) => (
<Form className="address-form">
{
prize ? (
......@@ -91,11 +92,13 @@ class AddressPopup extends Component {
) : (null)
}
{
tip ? (<p className="address-form__desc">{tip}</p>) : (<p className="address-form__desc">请及时填写收货信息,获得实物奖品后将第一时间为您邮寄</p>)
tip ? (<p className="address-form__desc">{tip}</p>) : (
<p className="address-form__desc">请及时填写收货信息,获得实物奖品后将第一时间为您邮寄</p>)
}
<Field
<Field
name="name"
render={({ field }) => (
>
{({field}) => (
<div className="address-form__item">
<input
{...field}
......@@ -109,10 +112,11 @@ class AddressPopup extends Component {
}
</div>
)}
/>
<Field
</Field>
<Field
name="phone"
render={({ field }) => (
>
{({field}) => (
<div className="address-form__item">
<input
{...field}
......@@ -126,10 +130,11 @@ class AddressPopup extends Component {
}
</div>
)}
/>
<Field
</Field>
<Field
name="address"
render={({ field }) => (
>
{({field}) => (
<div className="address-form__item">
<input
{...field}
......@@ -143,15 +148,16 @@ class AddressPopup extends Component {
}
</div>
)}
/>
<button
className="address-form__submit"
</Field>
<button
className="address-form__submit"
data-status="do"
type="submit"
>提交</button>
>提交
</button>
</Form>
)}
/>
</Formik>
}
</>
);
......
......@@ -20,11 +20,11 @@ class BargainBindPhone extends Component {
}
// 获取短信验证码
handleToSendCode = ({ mobile }) => {
const { country: { num = 86 } } = this.props;
let { isTimer, seconds } = this.state;
if(!isTimer) {
if(!/^\d+$/.test(mobile)){
handleToSendCode = ({mobile}) => {
const {country: {num = 86}} = this.props;
let {isTimer, seconds} = this.state;
if (!isTimer) {
if (!/^\d+$/.test(mobile)) {
Toast.info('请输入正确的手机号');
return;
}
......@@ -34,29 +34,29 @@ class BargainBindPhone extends Component {
`${API['passport-api']}/m/personal/bindPhoneSendCode`,
{
area_code: `00${num}`,
phone_num: mobile
}
phone_num: mobile,
},
).then(res => {
const { errno, msg } = res.data;
if(errno === 200) {
const {errno, msg} = res.data;
if (errno === 200) {
Toast.info('验证码发送成功', 2, null, false);
// 倒计时
this.timer = window.setInterval(() => {
if (seconds <= 0) {
window.clearInterval(this.timer);
this.setState({
isTimer: false,
seconds: 60
seconds: 60,
});
}else {
} else {
this.setState({
isTimer: true,
seconds: --seconds
seconds: --seconds,
});
}
}, 1000);
}else {
} else {
Toast.info(msg);
}
});
......@@ -65,7 +65,7 @@ class BargainBindPhone extends Component {
// 绑定手机号
handleToBindPhone = ({code, mobile}) => {
const { country: { num = 86}, handleToBargain, confirmBindPhone } = this.props;
const {country: {num = 86}, handleToBargain, confirmBindPhone} = this.props;
if (!mobile) {
Toast.info('请填手机号码');
return;
......@@ -87,34 +87,34 @@ class BargainBindPhone extends Component {
{
...params,
type: 1,
is_valid: 1
}
is_valid: 1,
},
).then(res => {
const { errno, data, msg } = res.data;
if(errno === 200) {
if(data.tip_info) {
const {errno, data, msg} = res.data;
if (errno === 200) {
if (data.tip_info) {
confirmBindPhone(params, data.tip_info);
}else {
} else {
handleToBargain();
}
}else {
} else {
Toast.info(msg);
}
});
}
render() {
const { country: { num = '86' } } = this.props;
const { isTimer, seconds } = this.state;
const {country: {num = '86'}} = this.props;
const {isTimer, seconds} = this.state;
return (
<Formik
initialValues={{
mobile: '',
code: ''
code: '',
}}
validate={({mobile, code}) => {
const errors = {};
if(!/^\d+$/.test(mobile)) {
if (!/^\d+$/.test(mobile)) {
errors.mobile = '请填写正确格式的手机号';
}
if (!/[0-9]{6}/.test(code)) {
......@@ -122,10 +122,11 @@ class BargainBindPhone extends Component {
}
return errors;
}}
onSubmit={(values, { setStatus, setSubmitting }) => {
onSubmit={(values, {setStatus, setSubmitting}) => {
this.handleToBindPhone(values);
}}
render={({values: {mobile, code}, errors}) => (
>
{({values: {mobile, code}, errors}) => (
<Form className="bargain-bind-phone">
<h2 className="bargain-bind-phone__title">绑定手机,先砍一刀</h2>
<div className="bargain-bind-phone__item">
......@@ -138,52 +139,53 @@ class BargainBindPhone extends Component {
</Link>
<Field
name="mobile"
render={({field}) => (
<input
>
{({field}) => (
<input
{...field}
className="bargain-bind-phone__ipt"
type="tel"
placeholder='手机号'
placeholder='手机号'
maxLength={11}
/>
)}
/>
</Field>
</div>
<div className="bargain-bind-phone__item">
<Field
name="code"
render={({field}) => (
<input
<Field name="code">
{({field}) => (
<input
{...field}
type="tel"
placeholder='验证码'
maxLength={6}
/>
)}
/>
</Field>
{errors.mobile}
<button
<button
type="button"
className={classnames(
'bargain-bind-phone__button--send',
{
'active': mobile && errors.mobile === undefined
}
'active': mobile && errors.mobile === undefined,
},
)}
disabled={!(mobile && errors.mobile === undefined)}
onClick={() => this.handleToSendCode({mobile})}
>
{isTimer? `重新发送${seconds}s` : '发送验证码'}
{isTimer ? `重新发送${seconds}s` : '发送验证码'}
</button>
</div>
<button
<button
type="submit"
className="bargain-bind-phone__button--bargain"
disabled={!(mobile && code && JSON.stringify(errors) === '{}')}
>先砍一刀</button>
>先砍一刀
</button>
</Form>
)}
/>
</Formik>
)
}
}
......
......@@ -31,12 +31,12 @@ class RedPacket extends PureComponent {
shareInfo: {
url: '',
share_code: '',
command: '【七月在线送你一个红包】https://www.julyedu.com/'
command: '【七月在线送你一个红包】https://www.julyedu.com/',
},
doneInfo: { //领取后的状态,1:领取成功,2:领取超时
status: 2,
txt: '手机号绑定超时,红包已失效!',
desc: ''
desc: '',
},
money: '', // 红包金额,
endTime: 10, // 手机绑定时限
......@@ -45,7 +45,7 @@ class RedPacket extends PureComponent {
accountInfo: {},
bindInfo: {},
country: {
num: '86'
num: '86',
},
validationData: null,
}
......@@ -80,8 +80,8 @@ class RedPacket extends PureComponent {
`${API.home}/sys/redPacket/split`,
{
action: 'check',
share_code: data.share_code
}
share_code: data.share_code,
},
).then(res => {
const {code, data} = res.data;
if (code === 200) {
......@@ -91,7 +91,7 @@ class RedPacket extends PureComponent {
this.judgeReceiveStatus(data, 8);
} else {
this.setState({
type: 3
type: 3,
});
}
}
......@@ -100,14 +100,14 @@ class RedPacket extends PureComponent {
});
} else {
this.setState({
type: 1
type: 1,
});
window.localStorage.removeItem('redpacket-click');
}
} else {
this.setRelativeCookie()
this.setState({
type: 1
type: 1,
});
}
}
......@@ -130,7 +130,7 @@ class RedPacket extends PureComponent {
const {code, data} = res.data;
if (code === 200) {
this.setState({
shareInfo: share_code ? Object.assign({}, data, {share_code}) : data
shareInfo: share_code ? Object.assign({}, data, {share_code}) : data,
});
}
});
......@@ -143,8 +143,8 @@ class RedPacket extends PureComponent {
if (share_code && share_code !== 'null') {
this.setState({
shareInfo: Object.assign({}, shareInfo, {
share_code
})
share_code,
}),
});
// 检查收否领取过
......@@ -152,8 +152,8 @@ class RedPacket extends PureComponent {
`${API.home}/sys/redPacket/split`,
{
action: 'check',
share_code
}
share_code,
},
).then(res => {
const {code, data} = res.data;
if (code === 200) {
......@@ -161,7 +161,7 @@ class RedPacket extends PureComponent {
// is_overdue 红包是否过期 0-否 1-是
if (data.is_overdue) {
this.setState({
type: 7
type: 7,
});
} else {
......@@ -170,14 +170,14 @@ class RedPacket extends PureComponent {
this.judgeReceiveStatus(data);
} else {
this.setState({
type: browser.isWeixin ? 2 : 3
type: browser.isWeixin ? 2 : 3,
});
}
}
}
if (code === 4030 || code === 4040) {
this.setState({
type: browser.isWeixin ? 2 : 3
type: browser.isWeixin ? 2 : 3,
});
}
});
......@@ -192,8 +192,8 @@ class RedPacket extends PureComponent {
this.setState({
country,
shareInfo: Object.assign({}, shareInfo, {
share_code: country.code
})
share_code: country.code,
}),
});
// 检查收否领取过
......@@ -201,8 +201,8 @@ class RedPacket extends PureComponent {
`${API.home}/sys/redPacket/split`,
{
action: 'check',
share_code: country.code
}
share_code: country.code,
},
).then(res => {
console.log(res);
const {code, data} = res.data;
......@@ -213,7 +213,7 @@ class RedPacket extends PureComponent {
this.judgeReceiveStatus(data, 8);
} else {
this.setState({
type: 3
type: 3,
});
}
......@@ -252,14 +252,14 @@ class RedPacket extends PureComponent {
doneInfo: {
status: 1,
txt,
desc
}
desc,
},
});
} else if (data.receive_status === 2) {
this.setState({
type: bindType,
money: data.amount,
endTime: data.end_time
endTime: data.end_time,
});
this.startCountDown();
} else if (data.receive_status === 3) {
......@@ -268,8 +268,8 @@ class RedPacket extends PureComponent {
doneInfo: {
status: 2,
txt: '手机号绑定超时,红包已失效!',
desc
}
desc,
},
});
}
}
......@@ -287,14 +287,14 @@ class RedPacket extends PureComponent {
if (time <= 0) {
window.clearInterval(this.countdownTimer);
this.setState({
endTime: 0
endTime: 0,
});
}
time -= 1;
minutes = `${Math.floor(time / 60)}`.padStart(2, 0);
seconds = `${(time % 60)}`.padStart(2, 0);
this.setState({
countdown: `${minutes}${seconds}秒`
countdown: `${minutes}${seconds}秒`,
});
}, 1000)
}
......@@ -304,7 +304,7 @@ class RedPacket extends PureComponent {
const {history, userInfo} = this.props;
if (browser.isWeixin) {
this.setState({
type: 2
type: 2,
});
history.push(`/detail?id=${getParam('id')}&wechat=1`);
} else {
......@@ -315,7 +315,7 @@ class RedPacket extends PureComponent {
if (code === 200) {
this.setState({
shareInfo: data,
type: 1
type: 1,
});
}
});
......@@ -332,7 +332,7 @@ class RedPacket extends PureComponent {
// is_follow 是否关注公众号,0否,1是
if (!shareInfo.is_follow) {
this.setState({
type: 11
type: 11,
});
}
}
......@@ -345,8 +345,8 @@ class RedPacket extends PureComponent {
`${API.home}/sys/redPacket/split`,
{
action: 'receive',
share_code
}
share_code,
},
).then(res => {
const {code, data} = res.data;
if (code === 200) {
......@@ -360,7 +360,7 @@ class RedPacket extends PureComponent {
if (data.red_packet_type === 2) {
this.setState({
type: 6,
money: data.amount
money: data.amount,
});
} else if (data.red_packet_type === 1) {
......@@ -369,19 +369,19 @@ class RedPacket extends PureComponent {
if (data.red_packet_type === 1) {
this.setState({
type: 5,
money: data.amount
money: data.amount,
});
} else if (data.red_packet_type === 2) {
this.setState({
type: 6,
money: data.amount
money: data.amount,
});
}
} else if (data.receive_status === 2) {
this.setState({
type: 4,
money: data.amount,
endTime: data.end_time
endTime: data.end_time,
});
this.startCountDown();
} else if (data.receive_status === 3) {
......@@ -390,8 +390,8 @@ class RedPacket extends PureComponent {
doneInfo: {
status: 2,
txt: '手机号绑定超时,红包已失效!',
desc: data.receive_type === 1 ? '越多好友领取,你所得越多!' : data.receive_type === 2 ? '每天只能帮好友领取一次哦~' : ''
}
desc: data.receive_type === 1 ? '越多好友领取,你所得越多!' : data.receive_type === 2 ? '每天只能帮好友领取一次哦~' : '',
},
});
}
}
......@@ -412,8 +412,8 @@ class RedPacket extends PureComponent {
`${API.home}/sys/redPacket/split`,
{
action: 'check',
share_code
}
share_code,
},
).then(res => {
const {code, data} = res.data;
if (code === 200) {
......@@ -423,7 +423,7 @@ class RedPacket extends PureComponent {
this.judgeReceiveStatus(data);
} else {
this.setState({
type: 3
type: 3,
});
}
}
......@@ -434,7 +434,7 @@ class RedPacket extends PureComponent {
history.push(`/detail?id=${getParam('id')}`);
}
this.setState({
type: 0
type: 0,
});
}
}
......@@ -444,21 +444,21 @@ class RedPacket extends PureComponent {
const {type} = this.state;
if (type === 2) {
this.setState({
type: 0
type: 0,
});
}
}
getCaptchaInstance = instance => {
this.setState({
captchaInstance: instance
captchaInstance: instance,
});
}
onVerify = (data) => {
this.setState({
validate: true,
validationData: data
validationData: data,
})
}
......@@ -469,7 +469,7 @@ class RedPacket extends PureComponent {
Toast.info('请重新进行滑块验证', 2, null, false);
captchaInstance.reset();
this.setState({
isFirst: true
isFirst: true,
});
return
}
......@@ -487,8 +487,8 @@ class RedPacket extends PureComponent {
{
area_code: `00${num}`,
phone_num: tel,
...validationData
}
...validationData,
},
).then(res => {
const {errno, msg} = res.data;
if (errno === 200) {
......@@ -500,19 +500,19 @@ class RedPacket extends PureComponent {
window.clearInterval(this.timer);
this.setState({
isTimer: false,
seconds: 60
seconds: 60,
});
} else {
this.setState({
isTimer: true,
seconds: --seconds
seconds: --seconds,
});
}
}, 1000);
// 滑块
this.setState({
isFirst: false
isFirst: false,
})
} else {
Toast.info(msg, 2, null, false);
......@@ -534,19 +534,19 @@ class RedPacket extends PureComponent {
if (data.red_packet_type === 1) {
this.setState({
type: 5,
money: data.amount
money: data.amount,
});
} else if (data.red_packet_type === 2) {
this.setState({
type: 6,
money: data.amount
money: data.amount,
});
}
} else if (data.receive_status === 2) {
this.setState({
type: 4,
money: data.amount,
endTime: data.end_time
endTime: data.end_time,
});
this.startCountDown();
} else if (data.receive_status === 3) {
......@@ -555,8 +555,8 @@ class RedPacket extends PureComponent {
doneInfo: {
status: 2,
txt: '手机号绑定超时,红包已失效!',
desc: data.receive_type === 1 ? '越多好友领取,你所得越多!' : data.receive_type === 2 ? '每天只能帮好友领取一次哦~' : ''
}
desc: data.receive_type === 1 ? '越多好友领取,你所得越多!' : data.receive_type === 2 ? '每天只能帮好友领取一次哦~' : '',
},
});
}
} else {
......@@ -576,8 +576,8 @@ class RedPacket extends PureComponent {
phone_num: tel,
code: code,
type: 1,
is_valid: isValid
}
is_valid: isValid,
},
).then(res => {
const {errno, data, msg} = res.data;
if (errno === 200) {
......@@ -585,7 +585,7 @@ class RedPacket extends PureComponent {
if (data.tip_info) {
this.setState({
type: 10,
bindInfo: data.tip_info
bindInfo: data.tip_info,
})
} else {
this.receviceAfterBind();
......@@ -617,17 +617,17 @@ class RedPacket extends PureComponent {
seconds,
shareInfo: {
command = '',
share_code = ''
share_code = '',
},
money,
doneInfo,
countdown,
endTime,
bindInfo,
country
country,
} = this.state;
const cls = classnames('popup-mask', {
'popup-mask--no': type !== 2
'popup-mask--no': type !== 2,
});
return (
<>
......@@ -667,7 +667,7 @@ class RedPacket extends PureComponent {
<CopyToClipboard
text={command}
onCopy={() => this.setState({
isCopy: true
isCopy: true,
})}
>
<button className="popup-password__button--copy">复制口令</button>
......@@ -699,7 +699,7 @@ class RedPacket extends PureComponent {
history.push(`/detail?id=${getParam('id')}`);
} else {
this.setState({
type: 3
type: 3,
});
window.localStorage.setItem('redpacket-click', 'split');
}
......@@ -707,7 +707,7 @@ class RedPacket extends PureComponent {
this.handleToClose(true);
}
this.setState({
isCopy: false
isCopy: false,
});
}}
/>
......@@ -720,7 +720,7 @@ class RedPacket extends PureComponent {
<Packet
type={3}
packetInfo={{
title: '七月在线给你发了个红包~'
title: '七月在线给你发了个红包~',
}}
handleToClose={() => this.handleToClose(false)}
......@@ -740,10 +740,10 @@ class RedPacket extends PureComponent {
txt: `立即绑定(${countdown})`,
onClick: () => {
this.setState({
type: 8
type: 8,
});
}
}
},
},
}}
handleToClose={() => this.handleToClose(false)}
/>
......@@ -761,8 +761,8 @@ class RedPacket extends PureComponent {
txt: '获取更多奖励',
onClick: () => {
history.push('/ShareCourse');
}
}
},
},
}}
handleToClose={() => {
const isShare = getParam('share_code') ? true : false;
......@@ -784,8 +784,8 @@ class RedPacket extends PureComponent {
txt: '获取更多奖励',
onClick: () => {
history.push('/ShareCourse');
}
}
},
},
}}
handleToClose={() => {
const isShare = getParam('share_code') ? true : false;
......@@ -805,8 +805,8 @@ class RedPacket extends PureComponent {
txt: '获取更多奖励',
onClick: () => {
history.push('/ShareCourse')
}
}
},
},
}}
handleToClose={() => {
const isShare = getParam('share_code') ? true : false;
......@@ -822,7 +822,7 @@ class RedPacket extends PureComponent {
<Formik
initialValues={{
tel: '',
code: ''
code: '',
}}
validate={({tel, code}) => {
const errors = {};
......@@ -840,12 +840,13 @@ class RedPacket extends PureComponent {
onSubmit={(values, {setStatus, setSubmitting}) => {
this.setState({
accountInfo: {
...values
}
...values,
},
});
this.toContinueBind();
}}
render={({values: {tel, code}, errors}) => (
>
{({values: {tel, code}, errors}) => (
<Form className="popup-form__content">
<h4 className="popup-form__title">绑定手机号</h4>
<div className="popup-form__item">
......@@ -857,7 +858,8 @@ class RedPacket extends PureComponent {
</Link>
<Field
name="tel"
render={({field}) => {
>
{({field}) => {
return (
<input
{...field}
......@@ -869,7 +871,7 @@ class RedPacket extends PureComponent {
/>
);
}}
/>
</Field>
</div>
<CaptchaAli getInstance={this.getCaptchaInstance} onVerify={this.onVerify}/>
{
......@@ -896,7 +898,8 @@ class RedPacket extends PureComponent {
<div className="popup-form__item">
<Field
name="code"
render={({field}) => {
>
{({field}) => {
return (
<input
{...field}
......@@ -906,7 +909,7 @@ class RedPacket extends PureComponent {
/>
);
}}
/>
</Field>
<button
className="popup-form__button--code"
data-status={(validate && !isTimer) ? 'do' : ''}
......@@ -930,7 +933,7 @@ class RedPacket extends PureComponent {
}
</Form>
)}
/>
</Formik>
<i
className="popup-password__button--close iconfont iconiconfront-2"
onClick={() => this.handleToClose(false)}
......@@ -1055,7 +1058,7 @@ const Packet = ({type, packetInfo, handleToClose, handleToOpen}) => {
'popup-packet__content--money': type === 5,
'popup-packet__content--fragment': type === 6,
'popup-packet__content--late': type === 7,
}
},
);
const {money, tip = [], btn} = packetInfo;
return (
......
import React, { Component } from 'react';
import { Flex, NavBar, List, InputItem, Button, WhiteSpace, WingBlank, Toast } from 'antd-mobile';
import { Formik, Field, Form, withFormik } from 'formik';
import { InputItem, Button, WingBlank, Toast } from 'antd-mobile';
import { withFormik } from 'formik';
import {HeaderBar} from '../../common';
import { http } from "src/utils";
const InnerForm = ({
values,
errors,
touched,
setFieldValue,
handleBlur,
handleSubmit,
isSubmitting,
}) => (
<form>
<InputItem
......
......@@ -27,9 +27,8 @@ class AccountLogin extends PureComponent {
<HeaderBar arrow={true} title={'登录'}/>
<Header/>
<Form className="login-info">
<FastField
name='account'
render={({field}) => (
<FastField name='account'>
{({field}) => (
<Input
{...field}
type={'text'}
......@@ -42,10 +41,9 @@ class AccountLogin extends PureComponent {
}
/>
)}
/>
<FastField
name='password'
render={({field}) => (
</FastField>
<FastField name='password'>
{({field}) => (
<PasswordInput
{...field}
autoComplete={'on'}
......@@ -55,7 +53,7 @@ class AccountLogin extends PureComponent {
}
/>
)}
/>
</FastField>
<LoginButton active={values.account && values.password && isEmpty(errors)}/>
<Link className={'forgot-password-btn'} to='/passport/forgot-password'>忘记密码</Link>
</Form>
......
......@@ -47,7 +47,8 @@ class BindingTel extends Component {
<Form>
<Field
name='tel'
render={({field, form}) => {
>
{({field, form}) => {
return (
<ClearableInput
{...field}
......@@ -59,10 +60,11 @@ class BindingTel extends Component {
)
}}
/>
</Field>
<Field
name='veriCode'
render={({field}) => {
>
{({field}) => {
return (
<VeriCodeInput
{...field}
......@@ -81,7 +83,7 @@ class BindingTel extends Component {
)
}}
/>
</Field>
<CaptchaAli onVerify={this.onVerify} getInstance={this.getCaptchaInstance} mb={0}/>
<Button className={'complete-btn'}
active={values.tel && values.veriCode && isEmpty(errors)}>完成</Button>
......
......@@ -52,7 +52,8 @@ class ForgotPassword extends Component {
<Form className='forgot-password-form'>
<Field
name={'tel'}
render={({field, form}) => {
>
{({field, form}) => {
return (
<ClearableInput
{...field}
......@@ -63,12 +64,13 @@ class ForgotPassword extends Component {
country={country}
/>)
}}
/>
</Field>
{
this.state.validate &&
<Field
name='veriCode'
render={({field}) => {
>
{({field}) => {
return (
<VeriCodeInput
{...field}
......@@ -86,7 +88,7 @@ class ForgotPassword extends Component {
/>
)
}}
/>
</Field>
}
<OnSubmissionError callback={this.onSubmissionError}/>
<CaptchaAli getInstance={this.getCaptchaInstance} onVerify={this.onVerify}/>
......
......@@ -18,7 +18,7 @@ class Login extends Component {
state = {
validate: null,
captchaInstance: null,
validationData: null
validationData: null,
}
loginWaysClick = method => {
......@@ -29,7 +29,7 @@ class Login extends Component {
let from = location.state && location.state.from || {
pathname: '/',
search: window.location.search,
hash: ''
hash: '',
};
const referrer = document.referrer
const redirectURI = (!/^https?:\/\/m.julyedu.com\/?$/.test(referrer) && referrer) ? referrer : window.location.origin + from.pathname + from.search + from.hash;
......@@ -52,14 +52,14 @@ class Login extends Component {
getCaptchaInstance = instance => {
this.setState({
captchaInstance: instance
captchaInstance: instance,
})
}
onVerify = (data) => {
this.setState({
validationData: data,
validate: true
validate: true,
})
}
......@@ -86,16 +86,15 @@ class Login extends Component {
loginWays,
errors,
values,
country
country,
} = this.props
return (
<div className='login'>
<HeaderBar title={'登录'} arrow={true}/>
<Header/>
<Form className="login-info">
<Field
name='tel'
render={({field}) => (
<Field name='tel'>
{({field}) => (
<Input
{...field}
type={'tel'}
......@@ -105,14 +104,14 @@ class Login extends Component {
id={'tel'}
/>
)}
>
</Field>
{
this.state.validate &&
<Field
type='number'
name='veriCode'
render={({field}) => (
>
{({field}) => (
<VeriCodeInput
{...field}
className={'verification'}
......@@ -127,7 +126,7 @@ class Login extends Component {
country={country}
/>
)}
/>
</Field>
}
<CaptchaAli onVerify={this.onVerify} getInstance={this.getCaptchaInstance}/>
......@@ -147,7 +146,7 @@ class Login extends Component {
const FormikConfig = {
mapPropsToValues: () => ({
tel: '',
veriCode: ''
veriCode: '',
}),
handleSubmit(values, {props}) {
const from = props.location.state && props.location.state.from
......@@ -155,7 +154,7 @@ const FormikConfig = {
phone_num: values.tel,
phone_code: values.veriCode,
area_code: '00' + props.country.num,
redirect: from && encodeURIComponent(window.location.origin + from.pathname + from.search + from.hash)
redirect: from && encodeURIComponent(window.location.origin + from.pathname + from.search + from.hash),
}).then(res => {
if (res.hasError) {
Toast.info(res.msg);
......@@ -176,13 +175,13 @@ const FormikConfig = {
errors.veriCode = '请输入验证码'
}
return errors
}
},
}
export default compose(
connect(
state => ({country: state.country}),
{quickLogin}
{quickLogin},
),
withFormik(FormikConfig),
)(Login)
......@@ -9,7 +9,6 @@ import { HeaderBar } from "src/common"
import { http } from "src/utils"
import { Toast } from "antd-mobile"
import { encrypt } from "src/components/passport/encryption"
import { Link } from "react-router-dom"
import { isEmpty } from "lodash"
import { connect } from "react-redux"
import { setCurrentUser } from 'src/store/userAction'
......@@ -20,30 +19,9 @@ class SetPassword extends Component {
let historyUrl = window.localStorage.getItem('HistoryUrl')
const {history} = this.props
history.push(historyUrl)
// window.localStorage.removeItem('HistoryUrl')
return
}
//
// componentDidMount() {
// const {location} = this.props
// const {action} = this.props.history
// let pathname = location.state && location.state.from && location.state.from.pathname
// let search = location.state && location.state.from && location.state.from.search
//
// console.log(location);
// console.log(location.state);
// console.log(action,pathname,search);
//
// // if(action !== 'PUSH'){
// // let historyUrl = `${pathname}${search}`
// // window.localStorage.setItem('HistoryUrl',historyUrl)
// // }
//
// }
render() {
let {values, errors, location} = this.props
let {from} = location.state || {from: {pathname: '/'}}
......@@ -55,7 +33,8 @@ class SetPassword extends Component {
<Form>
<Field
name='password'
render={({field}) => {
>
{({field}) => {
return (
<PasswordInput
autoComplete={'on'}
......@@ -65,7 +44,7 @@ class SetPassword extends Component {
/>
)
}}
/>
</Field>
<Button className={'btn-active'}
active={values.password && values.agreement && isEmpty(errors)}>完成</Button>
<label htmlFor="agreement" className='user-agreement'>
......
......@@ -171,9 +171,8 @@ class StudentRoot extends PureComponent {
const isSubmit = Object.values(props.values).join('') !== '' && props.errors.tip === undefined;
return (
<Form className="student-form">
<Field
name='tel'
render={({field}) => (
<Field name='tel'>
{({field}) => (
<Input
{...field}
type={'tel'}
......@@ -182,7 +181,7 @@ class StudentRoot extends PureComponent {
country={country}
/>
)}
/>
</Field>
<div className="student-form__item">
<Field
className="student-form__input"
......@@ -199,7 +198,8 @@ class StudentRoot extends PureComponent {
<Field
type='number'
name='code'
render={({field}) => (
>
{({field}) => (
<VeriCodeInput
{...field}
className={'student-form__code'}
......@@ -212,7 +212,7 @@ class StudentRoot extends PureComponent {
country={country}
/>
)}
/>
</Field>
}
<div className="student-form__item">
<label className="student-form__label">学校</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment