Commit 677d4b5d by 姜雷

Merge branch 'develop' into test

parents fd0a61ad 1fb6838a
import { baseFetch } from './index'; import { baseFetch, ResponseDataEntity } from './index';
export const fetchAllArea = () => export type Area = {
id: number;
areaName: string;
initial?: string;
};
export const fetchAllArea = (): Promise<ResponseDataEntity<Area[]>> =>
baseFetch({ baseFetch({
url: '/area/queryAreaList', url: '/area/queryAreaList',
}); });
...@@ -35,7 +35,16 @@ export const changePwdByCellphone = (data: PwdParams) => ...@@ -35,7 +35,16 @@ export const changePwdByCellphone = (data: PwdParams) =>
data: data, data: data,
}); });
type RegisiterPramas = {}; type RegisiterPramas = {
code: string;
areaId: number;
areaName: string;
customerName: string;
customerPhone: string;
customerSex: string;
password: string;
verificationCode: string;
};
// type RegisiterReponseData = {}; // type RegisiterReponseData = {};
export const wxUserRegister = (entity: RegisiterPramas) => export const wxUserRegister = (entity: RegisiterPramas) =>
......
...@@ -38,6 +38,7 @@ class App extends Component { ...@@ -38,6 +38,7 @@ class App extends Component {
'pages/Order/OrderDetail/OrderDetail', 'pages/Order/OrderDetail/OrderDetail',
'pages/SelectCampus/SelectCampus', 'pages/SelectCampus/SelectCampus',
'pages/Content/Content', 'pages/Content/Content',
'pages/WebPage/WebPage',
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',
......
...@@ -133,7 +133,7 @@ class BarCode extends Component { ...@@ -133,7 +133,7 @@ class BarCode extends Component {
this.fetchOrder(res.data[0].id); this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true }); this.setState({ showPayOrder: true });
} else { } else {
this.drawBarCode(false); this.drawBarCode();
} }
}) })
.catch(err => { .catch(err => {
......
...@@ -43,7 +43,7 @@ class Feedback extends Component<PageProps, PageState> { ...@@ -43,7 +43,7 @@ class Feedback extends Component<PageProps, PageState> {
feedbackHandle() { feedbackHandle() {
Taro.showLoading(); Taro.showLoading();
const { feedbackContent } = this.state; const { feedbackContent } = this.state;
if (feedbackContent && feedbackContent.length > 5) { if (feedbackContent && feedbackContent.length >= 5) {
const { const {
areaId, areaId,
areaName, areaName,
......
...@@ -14,6 +14,7 @@ type PageDispatchProps = { ...@@ -14,6 +14,7 @@ type PageDispatchProps = {
}; };
type PageState = { type PageState = {
fetching: boolean;
account: string; account: string;
pwd: string; pwd: string;
}; };
...@@ -39,6 +40,7 @@ class Login extends Component { ...@@ -39,6 +40,7 @@ class Login extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
fetching: false,
account: '', account: '',
pwd: '', pwd: '',
}; };
...@@ -64,7 +66,11 @@ class Login extends Component { ...@@ -64,7 +66,11 @@ class Login extends Component {
} }
loginHandle(): void { loginHandle(): void {
if (this.state.fetching) return;
if (this.validataLoginData()) { if (this.validataLoginData()) {
this.setState({
fetching: true,
});
const { updateUserInfo, userinfo } = this.props; const { updateUserInfo, userinfo } = this.props;
const { account, pwd } = this.state; const { account, pwd } = this.state;
console.log('in loginHandle'); console.log('in loginHandle');
...@@ -77,19 +83,29 @@ class Login extends Component { ...@@ -77,19 +83,29 @@ class Login extends Component {
const data = res.data; const data = res.data;
console.log(data); console.log(data);
updateUserInfo(data); updateUserInfo(data);
Taro.redirectTo({ Taro.reLaunch({
url: '/pages/Home/Home', url: '/pages/Home/Home',
}); });
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
if (err.code && err.code === NotRegisterCode) { if (err.code && err.code === NotRegisterCode) {
updateUserInfo({ updateUserInfo({
customerPhone: account, customerPhone: account,
}); });
setTimeout(() => {
this.setState({
fetching: false,
});
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/Register/Register', url: '/pages/Register/Register',
}); });
}, 2000);
} else {
this.setState({
fetching: false,
});
} }
}); });
} }
......
...@@ -28,6 +28,7 @@ type PageDispatchProps = { ...@@ -28,6 +28,7 @@ type PageDispatchProps = {
}; };
type PageState = { type PageState = {
fetching: boolean;
name: string; name: string;
cellphone: string; cellphone: string;
vcode: string; vcode: string;
...@@ -64,6 +65,7 @@ class Register extends Component { ...@@ -64,6 +65,7 @@ class Register extends Component {
super(props); super(props);
const { customerPhone } = props.userinfo; const { customerPhone } = props.userinfo;
this.state = { this.state = {
fetching: false,
name: '', name: '',
cellphone: customerPhone, cellphone: customerPhone,
vcode: '', vcode: '',
...@@ -148,13 +150,21 @@ class Register extends Component { ...@@ -148,13 +150,21 @@ class Register extends Component {
} }
getRegister() { getRegister() {
if (this.state.fetching) return;
if (this.validateRegisterEntity()) { if (this.validateRegisterEntity()) {
this.setState({
fetching: true,
});
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, updateUserInfo,
} = this.props; } = this.props;
Taro.login()
.then(res => res.code)
.then(code => {
wxUserRegister({ wxUserRegister({
code: code,
areaId: areaId, areaId: areaId,
areaName: areaName, areaName: areaName,
customerName: name, customerName: name,
...@@ -174,11 +184,18 @@ class Register extends Component { ...@@ -174,11 +184,18 @@ class Register extends Component {
title: '注册成功', title: '注册成功',
}); });
setTimeout(() => { setTimeout(() => {
Taro.redirectTo({ Taro.reLaunch({
url: '/pages/Home/Home', url: '/pages/Home/Home',
}); });
}, 2000); }, 2000);
}) })
.catch(err => {
console.log(err);
this.setState({
fetching: false,
});
});
})
.catch(console.log); .catch(console.log);
} }
} }
...@@ -207,6 +224,15 @@ class Register extends Component { ...@@ -207,6 +224,15 @@ class Register extends Component {
})); }));
} }
goAgreementPage(e) {
e.stopPropagation();
Taro.navigateTo({
url:
'/pages/WebPage/WebPage?url=' +
encodeURIComponent('https://api.dcrym.com/dcwap/agreement.html'),
});
}
render() { render() {
const { const {
name, name,
...@@ -355,7 +381,9 @@ class Register extends Component { ...@@ -355,7 +381,9 @@ class Register extends Component {
<Image className='registerBox-agreeCheck' src={agreeNotIcon} /> <Image className='registerBox-agreeCheck' src={agreeNotIcon} />
)} )}
<Text>同意条款</Text> <Text>同意条款</Text>
<Text className='service-deal'>《多彩校园服务协议》</Text> <Text className='service-deal' onClick={this.goAgreementPage}>
《多彩校园服务协议》
</Text>
</View> </View>
{agree ? ( {agree ? (
<Button className='registerBox-button' onClick={this.getRegister}> <Button className='registerBox-button' onClick={this.getRegister}>
......
...@@ -88,4 +88,7 @@ ...@@ -88,4 +88,7 @@
border-bottom: 2px solid #ebebeb; border-bottom: 2px solid #ebebeb;
word-break: break-all; word-break: break-all;
} }
.locationItem:last-child {
border-bottom: none;
}
} }
...@@ -5,17 +5,11 @@ import { connect } from '@tarojs/redux'; ...@@ -5,17 +5,11 @@ 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 { fetchAllArea } from '../../api/area'; import { fetchAllArea, Area } from '../../api/area';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import './SelectCampus.scss'; import './SelectCampus.scss';
type Area = {
id: number;
areaName: string;
initial?: string;
};
type AreaList = Array<{ type AreaList = Array<{
firstPin: string; firstPin: string;
children: Array<Area>; children: Array<Area>;
...@@ -80,6 +74,34 @@ class SelectCampus extends Component { ...@@ -80,6 +74,34 @@ class SelectCampus extends Component {
fetchAllArea() fetchAllArea()
.then(res => { .then(res => {
console.log(res); console.log(res);
let initialList = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
let campusIndexArr: Array<string> = []; let campusIndexArr: Array<string> = [];
let campusList: AreaList = []; let campusList: AreaList = [];
res.data.map((area: Area) => { res.data.map((area: Area) => {
...@@ -89,11 +111,12 @@ class SelectCampus extends Component { ...@@ -89,11 +111,12 @@ class SelectCampus extends Component {
if (index > -1) { if (index > -1) {
campusList[index].children.push(area); campusList[index].children.push(area);
} else { } else {
campusIndexArr.push(firstPin); let index = initialList.indexOf(firstPin);
campusList.push({ campusIndexArr[index] = firstPin;
campusList[index] = {
firstPin: firstPin, firstPin: firstPin,
children: [area], children: [area],
}); };
} }
} }
}); });
...@@ -190,14 +213,16 @@ class SelectCampus extends Component { ...@@ -190,14 +213,16 @@ class SelectCampus extends Component {
</View> </View>
</View> </View>
<View className='infoBar'> <View className='infoBar'>
{pinList.map(item => ( {pinList.map(item =>
item ? (
<View <View
key={item} key={item}
className='infoItem' className='infoItem'
onClick={() => this.showToastHandle(item)}> onClick={() => this.showToastHandle(item)}>
{item} {item}
</View> </View>
))} ) : null,
)}
</View> </View>
<View className={showToast ? 'show br8 infoToast' : 'br8 infoToast'}> <View className={showToast ? 'show br8 infoToast' : 'br8 infoToast'}>
{localText} {localText}
...@@ -207,7 +232,8 @@ class SelectCampus extends Component { ...@@ -207,7 +232,8 @@ class SelectCampus extends Component {
className='locationList' className='locationList'
scrollIntoView={localText} scrollIntoView={localText}
scrollWithAnimation> scrollWithAnimation>
{filterList.map(campusItem => ( {filterList.map(campusItem =>
campusItem ? (
<View key={campusItem.firstPin} className='locationArea'> <View key={campusItem.firstPin} className='locationArea'>
<View id={campusItem.firstPin} className='locationTitle'> <View id={campusItem.firstPin} className='locationTitle'>
{campusItem.firstPin} {campusItem.firstPin}
...@@ -222,7 +248,8 @@ class SelectCampus extends Component { ...@@ -222,7 +248,8 @@ class SelectCampus extends Component {
</View> </View>
))} ))}
</View> </View>
))} ) : null,
)}
</ScrollView> </ScrollView>
</View> </View>
); );
......
import { Component } from '@tarojs/taro';
import { ComponentClass } from 'react';
import { WebView } from '@tarojs/components';
type PageState = {
linkUrl: string;
};
interface WebPage {
state: PageState;
}
class WebPage extends Component {
constructor(props) {
super(props);
this.state = {
linkUrl: '',
};
}
componentWillMount() {
console.log(this.$router.params);
const { url } = this.$router.params;
if (url) {
this.setState({
linkUrl: url,
});
}
}
render() {
const { linkUrl } = this.state;
return linkUrl && <WebView src={linkUrl} />;
}
}
export default WebPage as ComponentClass<any, PageState>;
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