Commit 72200187 by 姜雷

完善部分请求逻辑

parent 7fb9bf61
import { baseFetch } from './index';
export const fetchAllArea = () =>
baseFetch({
url: '/area/queryAreaList',
});
import { CustomerBeanAccountVo, AccountParams } from './baseClass';
import { customerFetch, ResponseDataEntity } from '.';
export const fetchBeanCount = (
data: AccountParams,
): Promise<ResponseDataEntity<CustomerBeanAccountVo[]>> =>
customerFetch({
url: '/customerAccount/queryAccount',
method: 'POST',
data: data,
});
import createFetch from './index';
import { BASE_SERVER_URL } from '../constants/index';
const fetch = createFetch(BASE_SERVER_URL + '/dcxy/api');
export const fetchAllCampus = () =>
fetch({
url: '/campus/all',
});
import { customerFetch, ResponseDataEntity } from '.';
import { LoginInfoVo } from './baseClass';
export class LoginParams {
/** 登陆标识 */
token?: string;
/** 账号 */
loginAccount?: string;
/** 密码 */
passWord?: string;
}
export const appLogin = (data: LoginParams) =>
customerFetch({
url: '/app/customer/login',
data: data,
});
export class PwdParams {
/** 账号 */
loginAccount: string;
/** 密码 */
password: string;
/** 验证码 */
verification: string;
}
export const changePwdByCellphone = (data: PwdParams) =>
customerFetch({
url: `/app/customer/apwd/${data.loginAccount}/${data.password}/${
data.verification
}`,
method: 'PUT',
});
import Taro, { request } from '@tarojs/taro'; import Taro, { request } from '@tarojs/taro';
import store from '../store/index'; import store from '../store/index';
import {
OLD_BASE_SERVER_URL,
BASE_SERVER_URL,
CUSTOMER_SERVER_URL,
} from '../constants/index';
export type ResponseDataEntity<T> = { export type ResponseDataEntity<T> = {
code: number; code: number;
...@@ -14,7 +19,7 @@ type ResponseEntity = { ...@@ -14,7 +19,7 @@ type ResponseEntity = {
}; };
const createFetch = (basePath: string) => { const createFetch = (basePath: string) => {
return (entity: request.Param): Promise<ResponseEntity> => { return (entity: request.Param) => {
const token = store.getState().userinfo.token; const token = store.getState().userinfo.token;
return Taro.request({ return Taro.request({
...entity, ...entity,
...@@ -37,4 +42,8 @@ const createFetch = (basePath: string) => { ...@@ -37,4 +42,8 @@ const createFetch = (basePath: string) => {
}; };
}; };
export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL);
export const baseFetch = createFetch(BASE_SERVER_URL);
export const customerFetch = createFetch(CUSTOMER_SERVER_URL);
export default createFetch; export default createFetch;
import createFetch, { ResponseDataEntity } from './index'; import { ConsumeOrderResponse } from './baseClass';
import { CUSTOMER_SERVER_URL } from '../constants/index'; import { customerFetch, ResponseDataEntity } from './index';
const fetch = createFetch(CUSTOMER_SERVER_URL); export class Params {
export class AllParams {
/** 会员id */ /** 会员id */
customerId: number; customerId: number;
/** 订单状态 1未支付 2已支付 为空时查询的全部 */
orderState?: string;
/** 最后一页最后一条订单ID */ /** 最后一页最后一条订单ID */
lastOrderId?: number; lastOrderId?: number;
/** 每页条数 */ /** 每页条数 */
pageSize?: number; pageSize?: number;
} }
export const fetchAllOrder = (params: AllParams) => export const fetchAllOrder = (params: Params) =>
fetch({ customerFetch({
url: '/consumeOrder/pageAllList', url: '/consumeOrder/pageAllList',
data: params, data: params,
}); });
export const fetchOrder = (params: AllParams) => export const fetchPayOrder = (
fetch({ params: Params,
): Promise<ResponseDataEntity<ConsumeOrderResponse>> =>
customerFetch({
url: '/consumeOrder/pageList', url: '/consumeOrder/pageList',
data: { data: {
...params, ...params,
...@@ -31,7 +33,7 @@ type DetailParams = { ...@@ -31,7 +33,7 @@ type DetailParams = {
id: number; id: number;
}; };
export const fetchOrderDetail = (data: DetailParams) => export const fetchOrderDetail = (data: DetailParams) =>
fetch({ customerFetch({
url: '/consumeOrder/getDetail', url: '/consumeOrder/getDetail',
data: data, data: data,
}); });
import createFetch, { ResponseDataEntity } from './index'; import { oldBaseFetch, baseFetch, ResponseDataEntity } from './index';
import { BASE_SERVER_URL } from '../constants/index';
const fetch = createFetch(BASE_SERVER_URL + '/wx/api');
type LoginPramas = { type LoginPramas = {
code: string; code: string;
}; };
...@@ -14,24 +12,31 @@ export interface LoginReponse extends ResponseDataEntity<LoginReponseData> { ...@@ -14,24 +12,31 @@ export interface LoginReponse extends ResponseDataEntity<LoginReponseData> {
} }
export const login = (data: LoginPramas) => export const login = (data: LoginPramas) =>
fetch({ oldBaseFetch({
url: '/user/login2', url: '/wx/api/user/login2',
data: data, data: data,
}); });
export const fetchValidateCode = () => export const fetchValidateCode = () =>
fetch({ oldBaseFetch({
url: '/getValidateCode', url: '/wx/api/getValidateCode',
}); });
export const getImageVcode = () => type ImageVcodePramas = {
fetch({ effective?: number;
url: '/getImageValidateCode', loginName: string;
codeNum?: number;
};
export const getImageVcode = (data: ImageVcodePramas) =>
baseFetch({
url: `/common/getCode?loginName=${data.loginName}&codeNum=4`,
method: 'POST',
data: data,
}); });
export const getVcode = entity => export const getVcode = entity =>
fetch({ oldBaseFetch({
url: '/getValidateCode', url: '/wx/api/getValidateCode',
method: 'POST', method: 'POST',
data: entity, data: entity,
}); });
...@@ -40,8 +45,8 @@ type RegisiterPramas = {}; ...@@ -40,8 +45,8 @@ type RegisiterPramas = {};
// type RegisiterReponseData = {}; // type RegisiterReponseData = {};
export const fetchWxUserRegister = (entity: RegisiterPramas) => export const fetchWxUserRegister = (entity: RegisiterPramas) =>
fetch({ baseFetch({
url: '/user/regisiter2', url: '/wx/api/user/regisiter2',
method: 'POST', method: 'POST',
data: entity, data: entity,
}); });
...@@ -24,9 +24,9 @@ class App extends Component { ...@@ -24,9 +24,9 @@ class App extends Component {
*/ */
config: Config = { config: Config = {
pages: [ pages: [
'pages/index/index',
'pages/Order/OrderPay/OrderPay', 'pages/Order/OrderPay/OrderPay',
'pages/Order/OrderList/OrderList', 'pages/Order/OrderList/OrderList',
'pages/index/index',
'pages/BarCode/BarCode', 'pages/BarCode/BarCode',
'pages/Home/Home', 'pages/Home/Home',
'pages/Announcement/Announcement', 'pages/Announcement/Announcement',
......
.Modal {
.mask {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
background-color: rgba(25, 25, 25, 0.2);
z-index: 99;
}
.Modal-Dialog {
position: absolute;
top: 208px;
left: 50%;
transform: translate(-50%);
width: 540px;
background-color: #fff;
border-radius: 24px;
z-index: 100;
}
.Modal-title {
box-sizing: border-box;
padding: 0 20px;
height: 88px;
line-height: 88px;
width: 100%;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 32px;
border-bottom: 1px solid #eee;
}
.Modal-body {
padding: 30px 26px;
}
.Modal-footer {
border-top: 1px solid #eee;
display: flex;
height: 88px;
line-height: 88px;
.Modal-footerItem {
width: 100%;
text-align: center;
font-size: 32px;
color: #666;
}
.Modal-footerItem.cancel {
box-sizing: border-box;
border-right: 1px solid #eee;
}
.Modal-footerItem.confirm {
color: #6180f4;
}
}
}
import { Component } from '@tarojs/taro';
import { ComponentClass } from 'react';
import { View } from '@tarojs/components';
import './Modal.scss';
type PageOwnProps = {
children?: JSX.Element | JSX.Element[] | string;
visiabled: boolean;
title: string;
onCancel: () => void;
onSubmit: () => void;
};
type PageState = {};
interface Modal {
props: PageOwnProps;
state: PageState;
}
class Modal extends Component {
static externalClasses = ['body-class'];
static defaultProps = {
visiabled: false,
title: '提示',
};
cancelHandle() {
const { onCancel } = this.props;
onCancel && onCancel();
}
submitHandle() {
const { onSubmit } = this.props;
onSubmit && onSubmit();
}
render() {
const { visiabled, title } = this.props;
return visiabled ? (
<View className='Modal'>
<View className='mask' />
<View className='Modal-Dialog'>
<View className='Modal-title'>{title}</View>
<View className='Modal-body body-class'>{this.props.children}</View>
<View className='Modal-footer'>
<View
className='Modal-footerItem cancel'
onClick={this.cancelHandle}>
取消
</View>
<View
className='Modal-footerItem confirm'
onClick={this.submitHandle}>
确定
</View>
</View>
</View>
</View>
) : null;
}
}
export default Modal as ComponentClass<PageOwnProps, PageState>;
.Vcode-Content {
.Vcode-Content-box {
display: flex;
justify-content: space-between;
height: 76px;
}
.Vcode-input {
width: 308px;
height: 76px;
line-height: 76px;
text-align: center;
background-color: #e6ebfd;
border-radius: 12px;
}
.Vcode-canvas {
width: 146px;
height: 76px;
background-color: #6180f4;
border-radius: 12px;
overflow: hidden;
}
}
.Vcode.Counting { .Vcode.Counting {
color: #999; color: #999;
} }
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import Taro, { Component } from '@tarojs/taro'; import Taro, { Component } from '@tarojs/taro';
import { View } from '@tarojs/components'; import { View, Input, Canvas } from '@tarojs/components';
import { getVcode, getImageVcode } from '../../api/wx';
import Modal from '../Modal/Modal';
import './Vcode.scss'; import './Vcode.scss';
import { getVcode } from '../../api/wx'; import { ResponseDataEntity } from 'src/api';
type PageOwnProps = { type PageOwnProps = {
text?: string; text?: string;
...@@ -14,6 +15,9 @@ type PageState = { ...@@ -14,6 +15,9 @@ type PageState = {
counting: boolean; counting: boolean;
count: number; count: number;
timer: number | null; timer: number | null;
showImgBox: boolean;
vcode: number | null;
inputCode: string;
}; };
interface Vcode { interface Vcode {
...@@ -32,6 +36,9 @@ class Vcode extends Component { ...@@ -32,6 +36,9 @@ class Vcode extends Component {
counting: false, counting: false,
count: 10, count: 10,
timer: null, timer: null,
showImgBox: false,
vcode: null,
inputCode: '',
}; };
} }
...@@ -42,9 +49,58 @@ class Vcode extends Component { ...@@ -42,9 +49,58 @@ class Vcode extends Component {
} }
} }
clickHandle() { showImgCode() {
const { cellphone } = this.props; const { cellphone } = this.props;
if (cellphone && cellphone.length == 11) { if (cellphone && cellphone.length == 11) {
getImageVcode({
loginName: cellphone,
})
.then((res: ResponseDataEntity<number>) => {
const { data } = res;
this.setState({
vcode: data,
});
this.renderImg(data);
})
.catch(console.error);
this.setState({
showImgBox: true,
});
this.renderImg(1234);
} else {
Taro.showToast({
title: '输入正确的手机号',
icon: 'none',
mask: true,
});
}
}
closeImageBox() {
const ctx = Taro.createCanvasContext('Vcode', this);
ctx.setFillStyle('#6180f4');
ctx.fillRect(0, 0, 73, 38);
ctx.draw();
this.setState({
showImgBox: false,
});
}
renderImg(vcode: number) {
const ctx = Taro.createCanvasContext('Vcode', this);
ctx.setFillStyle('#6180f4');
ctx.fillRect(0, 0, 73, 38);
ctx.font = '26px arial';
// ctx.font('normal', '500', 26, 'arial');
ctx.setFillStyle('#fff');
ctx.fillText(vcode.toString(), 10, 30, 146); //画布上添加验证码
ctx.draw();
}
clickHandle() {
const { vcode, inputCode } = this.state;
if (vcode && vcode.toString() == inputCode) {
const { cellphone } = this.props;
getVcode({ getVcode({
tel: cellphone, tel: cellphone,
}) })
...@@ -54,13 +110,17 @@ class Vcode extends Component { ...@@ -54,13 +110,17 @@ class Vcode extends Component {
title: res.msg, title: res.msg,
mask: true, mask: true,
}); });
this.setState({
vcode: null,
inputCode: '',
showImgBox: false,
});
}) })
.catch(console.error); .catch(console.error);
} else { } else {
Taro.showToast({ Taro.showToast({
title: '输入正确的手机号', title: '请输入正确的验证码',
icon: 'none', icon: 'none',
mask: true,
}); });
} }
} }
...@@ -90,12 +150,38 @@ class Vcode extends Component { ...@@ -90,12 +150,38 @@ class Vcode extends Component {
} }
render() { render() {
const { defaultText, counting, count } = this.state; const { defaultText, counting, count, showImgBox, inputCode } = this.state;
return counting ? ( return (
<View className='vcode-classname Vcode Counting'>{`${count}S后重发`}</View> <View>
) : ( {counting ? (
<View className='vcode-classname Vcode' onClick={this.clickHandle}> <View className='vcode-classname Vcode Counting'>{`${count}S后重发`}</View>
{defaultText} ) : (
<View className='vcode-classname Vcode' onClick={this.showImgCode}>
{defaultText}
</View>
)}
<Modal
visiabled={showImgBox}
title='请输入图形验证码'
onCancel={this.closeImageBox}
onSubmit={this.clickHandle}
body-class='Vcode-Content'>
<View className='Vcode-Content-box'>
<Input
className='Vcode-input'
type='number'
maxLength={4}
value={inputCode}
onInput={({ detail: { value } }) => {
this.setState({
inputCode: value,
});
return value;
}}
/>
<Canvas className='Vcode-canvas' canvasId='Vcode' />
</View>
</Modal>
</View> </View>
); );
} }
......
export const APP_ID = 'wxf5912b79bba23663'; export const APP_ID = 'wxf5912b79bba23663';
export const BASE_SERVER_URL = 'https://ex-dev-selfbase.168cad.top';
export const CUSTOMER_SERVER_URL = 'http://ex-dev-dcxy-customer-app.168cad.top'; export const OLD_BASE_SERVER_URL = 'https://ex-dev-selfbase.168cad.top';
export const BASE_SERVER_URL = 'https://ex-dev-dcxy-base-app.168cad.top';
export const CUSTOMER_SERVER_URL =
'https://ex-dev-dcxy-customer-app.168cad.top';
...@@ -7,16 +7,26 @@ import RefreshIcon from '../../images/barcode/icon_shuaxin@2x.png'; ...@@ -7,16 +7,26 @@ import RefreshIcon from '../../images/barcode/icon_shuaxin@2x.png';
import wxbarcode from 'wxbarcode'; import wxbarcode from 'wxbarcode';
import './BarCode.scss'; import './BarCode.scss';
import { UserState } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux';
type PageStateProps = {
userinfo: UserState;
};
type PageOwnProps = {}; type PageOwnProps = {};
type PageState = { type PageState = {
showBig: boolean; showBig: boolean;
}; };
type IProps = PageStateProps & PageOwnProps;
interface BarCode { interface BarCode {
props: PageOwnProps; props: IProps;
state: PageState; state: PageState;
} }
@connect(({ userinfo }) => ({
userinfo,
}))
class BarCode extends Component { class BarCode extends Component {
constructor(props: PageOwnProps) { constructor(props: PageOwnProps) {
super(props); super(props);
...@@ -26,14 +36,16 @@ class BarCode extends Component { ...@@ -26,14 +36,16 @@ class BarCode extends Component {
} }
componentWillMount() { componentWillMount() {
wxbarcode.barcode('BarCode', '12345678901234567', 646, 188); const { userinfo } = this.props;
wxbarcode.barcode('BarCode', userinfo.idBar, 646, 188);
} }
drawBarCode(showBig: boolean) { drawBarCode(showBig: boolean) {
const { userinfo } = this.props;
if (showBig) { if (showBig) {
wxbarcode.barcode('BarCode', '12345678901234567', 646, 188); wxbarcode.barcode('BarCode', userinfo.idBar, 646, 188);
} else { } else {
wxbarcode.barcode('BarCode', '12345678901234567', 700, 364); wxbarcode.barcode('BarCode', userinfo.idBar, 700, 364);
} }
} }
......
...@@ -15,8 +15,56 @@ import UserHeaderM from '../../images/home/img_boy_touxiang@2x.png'; ...@@ -15,8 +15,56 @@ import UserHeaderM from '../../images/home/img_boy_touxiang@2x.png';
import UserHeaderF from '../../images/home/img_girl_touxiang@2x.png'; import UserHeaderF from '../../images/home/img_girl_touxiang@2x.png';
import './Home.scss'; import './Home.scss';
import { connect } from '@tarojs/redux';
import { UserState } from '../../store/rootReducers/userinfo';
import { fetchBeanCount } from '../../api/bean';
type PageStateProps = {
userinfo: UserState;
};
type PageState = {
commBean: number;
hairDryerBean: number;
};
interface Home {
props: PageStateProps;
state: PageState;
}
@connect(({ userinfo }) => ({
userinfo,
}))
class Home extends Component { class Home extends Component {
constructor(props) {
super(props);
this.state = {
commBean: 0.0,
hairDryerBean: 0.0,
};
}
componentWillMount() {
const { userinfo } = this.props;
fetchBeanCount({
id: userinfo.customerId,
areaId: userinfo.areaId,
customerPhone: userinfo.customerPhone,
serviceIdList: [],
})
.then(res => {
const data = res.data;
let commBeanItem = data.find(item => item.serviceId === '1');
let hairDryerBeanItem = data.find(item => item.serviceId === '1');
let commBean = commBeanItem ? commBeanItem.money : 0.0;
let hairDryerBean = hairDryerBeanItem ? hairDryerBeanItem.money : 0.0;
this.setState({
commBean,
hairDryerBean,
});
})
.catch(console.error);
}
goSetting() { goSetting() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/UserSetting/UserSetting', url: '/pages/UserSetting/UserSetting',
...@@ -34,7 +82,15 @@ class Home extends Component { ...@@ -34,7 +82,15 @@ class Home extends Component {
}); });
} }
goBarCode() {
Taro.navigateTo({
url: '/pages/BarCode/BarCode',
});
}
render() { render() {
const { userinfo } = this.props;
const { commBean, hairDryerBean } = this.state;
return ( return (
<View className='Home'> <View className='Home'>
<View className='Home-UserBox'> <View className='Home-UserBox'>
...@@ -46,33 +102,37 @@ class Home extends Component { ...@@ -46,33 +102,37 @@ class Home extends Component {
<Image className='bg' src={UserBoxBg} /> <Image className='bg' src={UserBoxBg} />
<View className='Home-UserBox-info'> <View className='Home-UserBox-info'>
<View className='Home-UserBox-other'> <View className='Home-UserBox-other'>
<View className='Home-UserBox-name'>中小</View> <View className='Home-UserBox-name'>{userinfo.customerName}</View>
<View className='Home-UserBox-tel'>16878964216</View> <View className='Home-UserBox-tel'>{userinfo.customerPhone}</View>
<View className='Home-UserBox-addr'>成都师范学校-温江小区</View> <View className='Home-UserBox-addr'>{userinfo.areaName}</View>
</View> </View>
<Image className='Home-UserBox-headimg' src={UserHeaderM} /> {userinfo.customerSex === '2' ? (
<Image className='Home-UserBox-headimg' src={UserHeaderM} />
) : (
<Image className='Home-UserBox-headimg' src={UserHeaderF} />
)}
</View> </View>
<View className='Home-UserBox-line' /> <View className='Home-UserBox-line' />
<View className='Home-UserBox-Bean'> <View className='Home-UserBox-Bean'>
<View className='Home-UserBox-BeanItem'> <View className='Home-UserBox-BeanItem'>
<Image className='Home-UserBox-BeanIcon' src={HBeanIcon} /> <Image className='Home-UserBox-BeanIcon' src={HBeanIcon} />
<Text>吹风豆:</Text> <Text>吹风豆:</Text>
<Text className='Home-UserBox-BeanCount'>2.35</Text> <Text className='Home-UserBox-BeanCount'>{hairDryerBean}</Text>
</View> </View>
<View className='Home-UserBox-BeanItem'> <View className='Home-UserBox-BeanItem'>
<Image className='Home-UserBox-BeanIcon' src={TBeanIcon} /> <Image className='Home-UserBox-BeanIcon' src={TBeanIcon} />
<Text>通用豆:</Text> <Text>通用豆:</Text>
<Text className='Home-UserBox-BeanCount'>2.35</Text> <Text className='Home-UserBox-BeanCount'>{commBean}</Text>
</View> </View>
</View> </View>
<View className='Home-UserBox-Order'> <View className='Home-UserBox-Order'>
<Text className='Home-UserBox-Order-text'>我的订单</Text> <Text className='Home-UserBox-Order-text'>我的订单</Text>
<View className='Home-UserBox-Order-right'> <View className='Home-UserBox-Order-right' onClick={this.goOrder}>
<Image className='Home-UserBox-Order-icon' src={ArrowIcon} /> <Image className='Home-UserBox-Order-icon' src={ArrowIcon} />
</View> </View>
</View> </View>
</View> </View>
<View className='Home-HairDryer'> <View className='Home-HairDryer' onClick={this.goBarCode}>
<Image className='bg' src={HairDryerBg} /> <Image className='bg' src={HairDryerBg} />
<View className='Home-HairDryer-shadow' /> <View className='Home-HairDryer-shadow' />
<View className='Home-HairDryer-text'> <View className='Home-HairDryer-text'>
...@@ -99,4 +159,4 @@ class Home extends Component { ...@@ -99,4 +159,4 @@ class Home extends Component {
} }
} }
export default Home as ComponentClass; export default Home as ComponentClass<PageStateProps, PageState>;
...@@ -3,6 +3,14 @@ import Taro, { Component, Config } from '@tarojs/taro'; ...@@ -3,6 +3,14 @@ import Taro, { Component, Config } from '@tarojs/taro';
import { View, Button, Text, Input, Navigator } from '@tarojs/components'; import { View, Button, Text, Input, Navigator } from '@tarojs/components';
import './Login.scss'; import './Login.scss';
import { appLogin } from '../../api/customer';
import { connect } from '@tarojs/redux';
import { updateUserInfo } from '../../store/rootReducers/userinfo';
import { LoginInfoVo } from '../../api/baseClass';
type PageDispatchProps = {
updateUserInfo: (e: LoginInfoVo) => void;
};
type PageState = { type PageState = {
account: string; account: string;
...@@ -10,9 +18,18 @@ type PageState = { ...@@ -10,9 +18,18 @@ type PageState = {
}; };
interface Login { interface Login {
props: PageDispatchProps;
state: PageState; state: PageState;
} }
@connect(
() => ({}),
dispatch => ({
updateUserInfo(data: LoginInfoVo) {
dispatch(updateUserInfo(data));
},
}),
)
class Login extends Component { class Login extends Component {
config: Config = { config: Config = {
navigationBarTitleText: '多彩校园', navigationBarTitleText: '多彩校园',
...@@ -26,11 +43,47 @@ class Login extends Component { ...@@ -26,11 +43,47 @@ class Login extends Component {
}; };
} }
loginHandle() { validataLoginData(): boolean {
console.log('in loginHandle'); const { account, pwd } = this.state;
if (!account || account.length !== 11) {
Taro.showToast({
title: '请输入手机号码',
icon: 'none',
});
return false;
}
if (!pwd || pwd.length < 6) {
Taro.showToast({
title: '请输入密码',
icon: 'none',
});
return false;
}
return true;
}
loginHandle(): void {
if (this.validataLoginData()) {
const { account, pwd } = this.state;
console.log('in loginHandle');
appLogin({
loginAccount: account,
passWord: pwd,
})
.then(res => {
const data = res.data;
console.log(data);
this.props.updateUserInfo(data);
Taro.navigateTo({
url: '/pages/Home/Home',
});
})
.catch(console.error);
}
} }
render() { render() {
const { account, pwd } = this.state;
return ( return (
<View className='Login'> <View className='Login'>
<View className='Login-title'>欢迎来到多彩校园</View> <View className='Login-title'>欢迎来到多彩校园</View>
...@@ -39,12 +92,27 @@ class Login extends Component { ...@@ -39,12 +92,27 @@ class Login extends Component {
className='Login-input' className='Login-input'
placeholder-class='Login-input-placeholder' placeholder-class='Login-input-placeholder'
placeholder='请输入账号手机号' placeholder='请输入账号手机号'
type='number'
value={account}
onInput={({ detail: { value } }) => {
this.setState({
account: value,
});
return value;
}}
/> />
<Input <Input
className='Login-input' className='Login-input'
placeholder-class='Login-input-placeholder' placeholder-class='Login-input-placeholder'
password password
placeholder='请输入密码' placeholder='请输入密码'
value={pwd}
onInput={({ detail: { value } }) => {
this.setState({
pwd: value,
});
return value;
}}
/> />
</View> </View>
...@@ -71,4 +139,4 @@ class Login extends Component { ...@@ -71,4 +139,4 @@ class Login extends Component {
} }
} }
export default Login as ComponentClass<{}, PageState>; export default Login as ComponentClass<PageDispatchProps, PageState>;
...@@ -9,10 +9,12 @@ import './OrderList.scss'; ...@@ -9,10 +9,12 @@ import './OrderList.scss';
import { toggleOrderState } from './actions'; import { toggleOrderState } from './actions';
import { StoreState } from './store'; import { StoreState } from './store';
import { fetchAllOrder } from '../../../api/order'; import { fetchAllOrder, fetchPayOrder } from '../../../api/order';
import { UserState } from '../../../store/rootReducers/userinfo';
type PageStateProps = { type PageStateProps = {
orderList: StoreState; orderList: StoreState;
userinfo: UserState;
}; };
type PageDispatchProps = { type PageDispatchProps = {
toggleOrderState: (state: String) => void; toggleOrderState: (state: String) => void;
...@@ -27,8 +29,9 @@ interface OrderList { ...@@ -27,8 +29,9 @@ interface OrderList {
} }
@connect( @connect(
({ OrderList }) => ({ ({ OrderList, userinfo }) => ({
orderList: OrderList, orderList: OrderList,
userinfo,
}), }),
dispatch => ({ dispatch => ({
toggleOrderState(state: String) { toggleOrderState(state: String) {
...@@ -43,6 +46,33 @@ class OrderList extends Component { ...@@ -43,6 +46,33 @@ class OrderList extends Component {
constructor(props: PageProps) { constructor(props: PageProps) {
super(props); super(props);
} }
componentWillMount() {
this.getPayOrderHandle();
}
getPayOrderHandle(lastOrderId?: number) {
const { userinfo } = this.props;
fetchPayOrder(
lastOrderId
? {
customerId: userinfo.customerId,
pageSize: 10,
lastOrderId,
}
: {
customerId: userinfo.customerId,
pageSize: 10,
},
)
.then(res => {
console.log(res);
})
.catch(console.error);
}
getAllOrderHandle() {}
goPayPage(data) { goPayPage(data) {
this.$preload(data); this.$preload(data);
Taro.navigateTo({ Taro.navigateTo({
......
...@@ -7,6 +7,7 @@ import pwdShowIcon from '../../images/login/setting_see_icon@2x.png'; ...@@ -7,6 +7,7 @@ import pwdShowIcon from '../../images/login/setting_see_icon@2x.png';
import ToastBox from '../../components/ToastBox/ToastBox'; import ToastBox from '../../components/ToastBox/ToastBox';
import './ResetPwd.scss'; import './ResetPwd.scss';
import { changePwdByCellphone } from '../../api/customer';
type PageOwnProps = {}; type PageOwnProps = {};
type PageState = { type PageState = {
...@@ -30,7 +31,7 @@ class ResetPwd extends Component { ...@@ -30,7 +31,7 @@ class ResetPwd extends Component {
constructor(props: PageOwnProps) { constructor(props: PageOwnProps) {
super(props); super(props);
this.state = { this.state = {
cellphone: '', cellphone: '18108096099',
vcode: '', vcode: '',
pwd: '', pwd: '',
checkPwd: '', checkPwd: '',
...@@ -90,13 +91,23 @@ class ResetPwd extends Component { ...@@ -90,13 +91,23 @@ class ResetPwd extends Component {
return true; return true;
} }
resetPwd() { resetPwd() {
// this.refs.ToastBox.showToast('修改成功');
if (this.validatePwdForm()) { if (this.validatePwdForm()) {
console.log('回到登陆'); const { cellphone, pwd, vcode } = this.state;
changePwdByCellphone({
Taro.redirectTo({ loginAccount: cellphone,
url: '/pages/Login/Login', password: pwd,
}); verification: vcode,
})
.then(() => {
this.refs.ToastBox.showToast('修改成功');
console.log('回到登陆');
setTimeout(() => {
Taro.redirectTo({
url: '/pages/Login/Login',
});
}, 2000);
})
.catch(console.error);
} }
} }
render() { render() {
...@@ -129,6 +140,12 @@ class ResetPwd extends Component { ...@@ -129,6 +140,12 @@ class ResetPwd extends Component {
placeholder='请输入验证码' placeholder='请输入验证码'
maxLength={6} maxLength={6}
value={vcode} value={vcode}
onInput={({ detail: { value } }) => {
this.setState({
vcode: value,
});
return value;
}}
/> />
<Vcode <Vcode
vcode-classname='registerBox-getVcode' vcode-classname='registerBox-getVcode'
......
...@@ -4,24 +4,34 @@ import { connect } from '@tarojs/redux'; ...@@ -4,24 +4,34 @@ import { connect } from '@tarojs/redux';
import { View, Text, Input, Image, ScrollView } from '@tarojs/components'; import { View, Text, Input, Image, ScrollView } from '@tarojs/components';
import SearchIcon from '../../images/login/icon_search@2x.png'; import SearchIcon from '../../images/login/icon_search@2x.png';
import { Campus, CampusList } from '../../types/Campus/Campus';
import { fetchAllCampus } from '../../api/campus'; import { fetchAllArea } from '../../api/area';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import User from 'src/types/User/User';
import './SelectCampus.scss'; import './SelectCampus.scss';
type Area = {
id: number;
areaName: string;
initial?: string;
};
type AreaList = Array<{
firstPin: string;
children: Array<Area>;
}>;
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
}; };
type PageDispatchProps = { type PageDispatchProps = {
updateUserInfo: (e: User) => void; updateUserInfo: (e: UserState) => void;
}; };
type PageState = { type PageState = {
campusList: CampusList; pinList: Array<string>;
filterList: CampusList; campusList: AreaList;
filterList: AreaList;
filterName: string; filterName: string;
showToast: boolean; showToast: boolean;
localText: string; localText: string;
...@@ -39,7 +49,7 @@ interface SelectCampus { ...@@ -39,7 +49,7 @@ interface SelectCampus {
userinfo, userinfo,
}), }),
dispatch => ({ dispatch => ({
updateUserInfo(entity: User) { updateUserInfo(entity: UserState) {
dispatch(updateUserInfo(entity)); dispatch(updateUserInfo(entity));
}, },
}), }),
...@@ -53,6 +63,7 @@ class SelectCampus extends Component { ...@@ -53,6 +63,7 @@ class SelectCampus extends Component {
super(props); super(props);
this.state = { this.state = {
filterName: '', filterName: '',
pinList: [],
campusList: [], campusList: [],
filterList: [], filterList: [],
showToast: false, showToast: false,
...@@ -66,22 +77,22 @@ class SelectCampus extends Component { ...@@ -66,22 +77,22 @@ class SelectCampus extends Component {
} }
getList() { getList() {
fetchAllCampus() fetchAllArea()
.then(res => { .then(res => {
console.log(res); console.log(res);
let campusIndexArr: Array<string> = []; let campusIndexArr: Array<string> = [];
let campusList: CampusList = []; let campusList: AreaList = [];
res.data.map((campus: Campus) => { res.data.map((area: Area) => {
let firstPin = campus.firstPin; let firstPin = area.initial;
if (firstPin) { if (firstPin) {
let index = campusIndexArr.indexOf(firstPin); let index = campusIndexArr.indexOf(firstPin);
if (index > -1) { if (index > -1) {
campusList[index].children.push(campus); campusList[index].children.push(area);
} else { } else {
campusIndexArr.push(firstPin); campusIndexArr.push(firstPin);
campusList.push({ campusList.push({
firstPin: firstPin, firstPin: firstPin,
children: [campus], children: [area],
}); });
} }
} }
...@@ -89,6 +100,7 @@ class SelectCampus extends Component { ...@@ -89,6 +100,7 @@ class SelectCampus extends Component {
this.setState({ this.setState({
campusList: campusList, campusList: campusList,
filterList: campusList, filterList: campusList,
pinList: campusIndexArr,
}); });
}) })
.catch(err => { .catch(err => {
...@@ -99,21 +111,18 @@ class SelectCampus extends Component { ...@@ -99,21 +111,18 @@ class SelectCampus extends Component {
searchList() { searchList() {
let { filterName, campusList } = this.state; let { filterName, campusList } = this.state;
if (filterName) { if (filterName) {
const filterList = campusList.reduce( const filterList = campusList.reduce((totalArr: AreaList, campusItem) => {
(totalArr: CampusList, campusItem) => { let arr = campusItem.children.filter(
let arr = campusItem.children.filter( i => i.areaName.indexOf(filterName) > -1,
i => i.name.indexOf(filterName) > -1, );
); if (arr.length > 0) {
if (arr.length > 0) { totalArr.push({
totalArr.push({ firstPin: campusItem.firstPin,
firstPin: campusItem.firstPin, children: arr,
children: arr, });
}); }
} return totalArr;
return totalArr; }, []);
},
[],
);
this.setState({ this.setState({
filterList: filterList, filterList: filterList,
}); });
...@@ -144,21 +153,18 @@ class SelectCampus extends Component { ...@@ -144,21 +153,18 @@ class SelectCampus extends Component {
} }
bindCampus({ target: { dataset } }) { bindCampus({ target: { dataset } }) {
const { const { id, areaName }: Area = dataset.campus;
campus: { id, name, schoolId },
} = dataset;
this.props.updateUserInfo({ this.props.updateUserInfo({
campusId: id, areaId: id,
campusName: name, areaName: areaName,
schoolId: schoolId,
}); });
Taro.navigateBack(); Taro.navigateBack();
} }
render() { render() {
const { const {
campusList, pinList,
filterList, filterList,
filterName, filterName,
showToast, showToast,
...@@ -184,12 +190,12 @@ class SelectCampus extends Component { ...@@ -184,12 +190,12 @@ class SelectCampus extends Component {
</View> </View>
</View> </View>
<View className='infoBar'> <View className='infoBar'>
{campusList.map(item => ( {pinList.map(item => (
<View <View
key={item.firstPin} key={item}
className='infoItem' className='infoItem'
onClick={() => this.showToastHandle(item.firstPin)}> onClick={() => this.showToastHandle(item)}>
{item.firstPin} {item}
</View> </View>
))} ))}
</View> </View>
...@@ -212,7 +218,7 @@ class SelectCampus extends Component { ...@@ -212,7 +218,7 @@ class SelectCampus extends Component {
className='locationItem' className='locationItem'
data-campus={campus} data-campus={campus}
onClick={this.bindCampus}> onClick={this.bindCampus}>
{campus.name} {campus.areaName}
</View> </View>
))} ))}
</View> </View>
......
import User from '../../types/User/User';
import Action from '../../types/Store/Actions'; import Action from '../../types/Store/Actions';
export interface UserState extends User { export class UserState {
login?: boolean; login?: boolean;
areaId?: number;
areaName?: string;
birthDay?: string;
createAt?: string;
createLoginDate?: string;
customerHead?: string;
customerId?: number;
customerName?: string;
customerPhone?: string;
customerSex?: string;
customerType?: string;
email?: string;
entranceDate?: string;
hardwareAccount?: string;
hardwarePwd?: string;
hardwareState?: string;
hardwarelastDate?: string;
idBar?: string;
idCard?: string;
isFirstRecharge?: number;
lastLoginDate?: string;
loginAccount?: string;
loginPwd?: string;
loginPwdSalt?: string;
loginState?: string;
state?: string;
studentNo?: string;
token?: string; token?: string;
updateAt?: string;
updateLoginDate?: string;
version?: string;
} }
const INITIAL_STATE = { const INITIAL_STATE = {
login: false, login: false,
areaId: undefined,
areaName: '',
birthDay: '',
createAt: '',
createLoginDate: '',
customerHead: '',
customerId: undefined,
customerName: '',
customerPhone: '',
customerSex: '',
customerType: '',
email: '',
entranceDate: '',
hardwareAccount: '',
hardwarePwd: '',
hardwareState: '',
hardwarelastDate: '',
idBar: '',
idCard: '',
isFirstRecharge: undefined,
lastLoginDate: '',
loginAccount: '',
loginPwd: '',
loginPwdSalt: '',
loginState: '',
state: '',
studentNo: '',
token: '', token: '',
id: '', updateAt: '',
campusId: null, updateLoginDate: '',
campusName: '', version: '',
schoolId: null,
name: '',
headPic: '',
}; };
export const updateUserInfo = (entity: User): Action => ({ export const updateUserInfo = (entity: UserState): Action => ({
type: 'UPDATE_USERINFO', type: 'UPDATE_USERINFO',
payload: entity, payload: entity,
}); });
......
type User = {
id?: string;
campusId?: number | null;
campusName?: string;
schoolId?: number | null;
name?: string;
headPic?: string;
};
export default User;
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