Commit edfae242 by 姜雷

Merge branch 'develop' into 'test'

Develop See merge request !3
parents e4a5eb04 ce2cf6d4
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
"private": true, "private": true,
"description": "", "description": "",
"scripts": { "scripts": {
"build:weapp": "npx @tarojs/cli build --type weapp", "build:weapp": "cross-env NODE_ENV=product npx @tarojs/cli build --type weapp",
"build:swan": "npx @tarojs/cli build --type swan", "build:swan": "npx @tarojs/cli build --type swan",
"build:alipay": "npx @tarojs/cli build --type alipay", "build:alipay": "npx @tarojs/cli build --type alipay",
"build:tt": "npx @tarojs/cli build --type tt", "build:tt": "npx @tarojs/cli build --type tt",
"build:h5": "npx @tarojs/cli build --type h5", "build:h5": "npx @tarojs/cli build --type h5",
"build:rn": "npx @tarojs/cli build --type rn", "build:rn": "npx @tarojs/cli build --type rn",
"dev:weapp": "npm run build:weapp -- --watch", "dev:weapp": "npx @tarojs/cli build --type weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch", "dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch", "dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch", "dev:tt": "npm run build:tt -- --watch",
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"babel-plugin-transform-jsx-stylesheet": "^0.6.5", "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-taro": "1.2.13", "eslint-config-taro": "1.2.13",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
......
...@@ -16,7 +16,11 @@ import UserHeaderF from '../../images/home/img_girl_touxiang@2x.png'; ...@@ -16,7 +16,11 @@ import UserHeaderF from '../../images/home/img_girl_touxiang@2x.png';
import './Home.scss'; import './Home.scss';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { UserState } from '../../store/rootReducers/userinfo'; import {
UserState,
updateUserInfo,
INITIAL_STATE as userINitState,
} from '../../store/rootReducers/userinfo';
import { fetchBeanCount } from '../../api/bean'; import { fetchBeanCount } from '../../api/bean';
import { fetchAnn, SectionItem } from '../../api/announcement'; import { fetchAnn, SectionItem } from '../../api/announcement';
import { appLogout } from '../../api/customer'; import { appLogout } from '../../api/customer';
...@@ -24,20 +28,32 @@ import { appLogout } from '../../api/customer'; ...@@ -24,20 +28,32 @@ import { appLogout } from '../../api/customer';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
}; };
type PageDispatchProps = {
updateUserInfo: (e: UserState) => void;
};
type PageState = { type PageState = {
barMenuVisiable: boolean; barMenuVisiable: boolean;
commBean: number; commBean: number;
hairDryerBean: number; hairDryerBean: number;
annItem: SectionItem; annItem: SectionItem;
}; };
type IProps = PageStateProps & PageDispatchProps;
interface Home { interface Home {
props: PageStateProps; props: IProps;
state: PageState; state: PageState;
} }
@connect(({ userinfo }) => ({ @connect(
({ userinfo }) => ({
userinfo, userinfo,
})) }),
dispatch => ({
updateUserInfo(entity: UserState) {
dispatch(updateUserInfo(entity));
},
}),
)
class Home extends Component { class Home extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -95,51 +111,6 @@ class Home extends Component { ...@@ -95,51 +111,6 @@ class Home extends Component {
} }
}) })
.catch(err => { .catch(err => {
// this.setState({
// annItem: {
// id: 896,
// styleType: 'ANNOUNCEMENT',
// name: '公告1',
// titleTypeRemark: '无',
// titleType: 'NONE',
// titleContent: '',
// sort: 3,
// updateTime: 1528770103000,
// itemsCount: 10,
// items: [
// {
// id: 301070,
// title: 'ASFDSGSD大苏打',
// multiImageType: 'SINGLE',
// source: '关机开不开地方',
// linkUrls: ['sqwerqwerqwefsf'],
// linkType: 'DEFAULT',
// jumpUrl: '',
// urlParameters: {},
// sort: 1,
// loadAd: false,
// mandatoryPrompt: false,
// createTime: '2018-06-01 10:41:11',
// updateTime: '2019-01-25 09:43:17',
// },
// {
// id: 301073,
// title: '啊实打实的阿斯顿',
// multiImageType: 'SINGLE',
// source: '个撒大',
// linkUrls: ['sqwerqwerqwefsf'],
// linkType: 'DEFAULT',
// jumpUrl: '',
// urlParameters: {},
// sort: 2,
// loadAd: false,
// mandatoryPrompt: false,
// createTime: '2018-06-12 10:52:15',
// updateTime: '2019-01-25 09:47:39',
// },
// ],
// },
// });
console.error(err); console.error(err);
}); });
} }
...@@ -179,8 +150,10 @@ class Home extends Component { ...@@ -179,8 +150,10 @@ class Home extends Component {
})); }));
} }
logoutHandle() { logoutHandle() {
const { updateUserInfo } = this.props;
appLogout() appLogout()
.then(() => { .then(() => {
updateUserInfo(userINitState);
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/index/index', url: '/pages/index/index',
}); });
......
...@@ -94,6 +94,7 @@ class Login extends Component { ...@@ -94,6 +94,7 @@ class Login extends Component {
placeholder='请输入账号手机号' placeholder='请输入账号手机号'
type='number' type='number'
value={account} value={account}
maxLength={11}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) => {
this.setState({ this.setState({
account: value, account: value,
...@@ -107,6 +108,7 @@ class Login extends Component { ...@@ -107,6 +108,7 @@ class Login extends Component {
password password
placeholder='请输入密码' placeholder='请输入密码'
value={pwd} value={pwd}
maxLength={20}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) => {
this.setState({ this.setState({
pwd: value, pwd: value,
......
...@@ -78,29 +78,6 @@ class Register extends Component { ...@@ -78,29 +78,6 @@ class Register extends Component {
sex: value, sex: value,
}); });
} }
getVcode() {
const { cellphone } = this.state;
if (cellphone.length == 11) {
// getVcode({
// tel: cellphone,
// })
// .then(res => {
// console.log(res);
// Taro.showToast({
// title: res.msg,
// mask: true,
// });
// })
// .catch(console.error);
this.refs.Vcode.countStart();
} else {
Taro.showToast({
title: '输入正确的手机号',
icon: 'none',
mask: true,
});
}
}
validateRegisterEntity(): boolean { validateRegisterEntity(): boolean {
const { name, cellphone, pwd, checkPwd } = this.state; const { name, cellphone, pwd, checkPwd } = this.state;
...@@ -157,6 +134,7 @@ class Register extends Component { ...@@ -157,6 +134,7 @@ class Register extends Component {
const { name, cellphone, pwd, sex, vcode } = this.state; const { name, cellphone, pwd, sex, vcode } = this.state;
const { const {
userinfo: { areaId, areaName }, userinfo: { areaId, areaName },
updateUserInfo,
} = this.props; } = this.props;
wxUserRegister({ wxUserRegister({
areaId: areaId, areaId: areaId,
...@@ -169,6 +147,7 @@ class Register extends Component { ...@@ -169,6 +147,7 @@ class Register extends Component {
}) })
.then(res => { .then(res => {
const { register, wxToken, ...userInfo } = res.data; const { register, wxToken, ...userInfo } = res.data;
console.log(userInfo);
updateUserInfo({ updateUserInfo({
...userInfo, ...userInfo,
token: wxToken, token: wxToken,
......
...@@ -35,7 +35,7 @@ export class UserState { ...@@ -35,7 +35,7 @@ export class UserState {
version?: string; version?: string;
} }
const INITIAL_STATE = { export const INITIAL_STATE = {
login: false, login: false,
areaId: undefined, areaId: undefined,
areaName: '', areaName: '',
......
...@@ -2003,6 +2003,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: ...@@ -2003,6 +2003,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1" safe-buffer "^5.0.1"
sha.js "^2.4.8" sha.js "^2.4.8"
cross-env@^5.2.0:
version "5.2.0"
resolved "http://registry.npm.taobao.org/cross-env/download/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
dependencies:
cross-spawn "^6.0.5"
is-windows "^1.0.0"
cross-spawn@^3.0.0: cross-spawn@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
...@@ -2018,7 +2025,7 @@ cross-spawn@^5.0.1, cross-spawn@^5.1.0: ...@@ -2018,7 +2025,7 @@ cross-spawn@^5.0.1, cross-spawn@^5.1.0:
shebang-command "^1.2.0" shebang-command "^1.2.0"
which "^1.2.9" which "^1.2.9"
cross-spawn@^6.0.0: cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5" version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
dependencies: dependencies:
...@@ -3868,7 +3875,7 @@ is-utf8@^0.2.0: ...@@ -3868,7 +3875,7 @@ is-utf8@^0.2.0:
version "0.2.1" version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
is-windows@^1.0.2: is-windows@^1.0.0, is-windows@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
......
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