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({
url: '/area/queryAreaList',
});
......@@ -35,7 +35,16 @@ export const changePwdByCellphone = (data: PwdParams) =>
data: data,
});
type RegisiterPramas = {};
type RegisiterPramas = {
code: string;
areaId: number;
areaName: string;
customerName: string;
customerPhone: string;
customerSex: string;
password: string;
verificationCode: string;
};
// type RegisiterReponseData = {};
export const wxUserRegister = (entity: RegisiterPramas) =>
......
......@@ -38,6 +38,7 @@ class App extends Component {
'pages/Order/OrderDetail/OrderDetail',
'pages/SelectCampus/SelectCampus',
'pages/Content/Content',
'pages/WebPage/WebPage',
],
window: {
backgroundTextStyle: 'light',
......
......@@ -133,7 +133,7 @@ class BarCode extends Component {
this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true });
} else {
this.drawBarCode(false);
this.drawBarCode();
}
})
.catch(err => {
......
......@@ -43,7 +43,7 @@ class Feedback extends Component<PageProps, PageState> {
feedbackHandle() {
Taro.showLoading();
const { feedbackContent } = this.state;
if (feedbackContent && feedbackContent.length > 5) {
if (feedbackContent && feedbackContent.length >= 5) {
const {
areaId,
areaName,
......
......@@ -14,6 +14,7 @@ type PageDispatchProps = {
};
type PageState = {
fetching: boolean;
account: string;
pwd: string;
};
......@@ -39,6 +40,7 @@ class Login extends Component {
constructor(props) {
super(props);
this.state = {
fetching: false,
account: '',
pwd: '',
};
......@@ -64,7 +66,11 @@ class Login extends Component {
}
loginHandle(): void {
if (this.state.fetching) return;
if (this.validataLoginData()) {
this.setState({
fetching: true,
});
const { updateUserInfo, userinfo } = this.props;
const { account, pwd } = this.state;
console.log('in loginHandle');
......@@ -77,18 +83,28 @@ class Login extends Component {
const data = res.data;
console.log(data);
updateUserInfo(data);
Taro.redirectTo({
Taro.reLaunch({
url: '/pages/Home/Home',
});
})
.catch(err => {
console.log(err);
if (err.code && err.code === NotRegisterCode) {
updateUserInfo({
customerPhone: account,
});
Taro.navigateTo({
url: '/pages/Register/Register',
setTimeout(() => {
this.setState({
fetching: false,
});
Taro.navigateTo({
url: '/pages/Register/Register',
});
}, 2000);
} else {
this.setState({
fetching: false,
});
}
});
......
......@@ -28,6 +28,7 @@ type PageDispatchProps = {
};
type PageState = {
fetching: boolean;
name: string;
cellphone: string;
vcode: string;
......@@ -64,6 +65,7 @@ class Register extends Component {
super(props);
const { customerPhone } = props.userinfo;
this.state = {
fetching: false,
name: '',
cellphone: customerPhone,
vcode: '',
......@@ -148,36 +150,51 @@ class Register extends Component {
}
getRegister() {
if (this.state.fetching) return;
if (this.validateRegisterEntity()) {
this.setState({
fetching: true,
});
const { name, cellphone, pwd, sex, vcode } = this.state;
const {
userinfo: { areaId, areaName },
updateUserInfo,
} = this.props;
wxUserRegister({
areaId: areaId,
areaName: areaName,
customerName: name,
customerPhone: cellphone,
customerSex: sex,
password: pwd,
verificationCode: vcode,
})
.then(res => {
const { register, wxToken, ...userInfo } = res.data;
console.log(userInfo);
updateUserInfo({
...userInfo,
token: wxToken,
});
Taro.showToast({
title: '注册成功',
});
setTimeout(() => {
Taro.redirectTo({
url: '/pages/Home/Home',
Taro.login()
.then(res => res.code)
.then(code => {
wxUserRegister({
code: code,
areaId: areaId,
areaName: areaName,
customerName: name,
customerPhone: cellphone,
customerSex: sex,
password: pwd,
verificationCode: vcode,
})
.then(res => {
const { register, wxToken, ...userInfo } = res.data;
console.log(userInfo);
updateUserInfo({
...userInfo,
token: wxToken,
});
Taro.showToast({
title: '注册成功',
});
setTimeout(() => {
Taro.reLaunch({
url: '/pages/Home/Home',
});
}, 2000);
})
.catch(err => {
console.log(err);
this.setState({
fetching: false,
});
});
}, 2000);
})
.catch(console.log);
}
......@@ -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() {
const {
name,
......@@ -355,7 +381,9 @@ class Register extends Component {
<Image className='registerBox-agreeCheck' src={agreeNotIcon} />
)}
<Text>同意条款</Text>
<Text className='service-deal'>《多彩校园服务协议》</Text>
<Text className='service-deal' onClick={this.goAgreementPage}>
《多彩校园服务协议》
</Text>
</View>
{agree ? (
<Button className='registerBox-button' onClick={this.getRegister}>
......
......@@ -88,4 +88,7 @@
border-bottom: 2px solid #ebebeb;
word-break: break-all;
}
.locationItem:last-child {
border-bottom: none;
}
}
......@@ -5,17 +5,11 @@ import { connect } from '@tarojs/redux';
import { View, Text, Input, Image, ScrollView } from '@tarojs/components';
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 './SelectCampus.scss';
type Area = {
id: number;
areaName: string;
initial?: string;
};
type AreaList = Array<{
firstPin: string;
children: Array<Area>;
......@@ -80,6 +74,34 @@ class SelectCampus extends Component {
fetchAllArea()
.then(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 campusList: AreaList = [];
res.data.map((area: Area) => {
......@@ -89,11 +111,12 @@ class SelectCampus extends Component {
if (index > -1) {
campusList[index].children.push(area);
} else {
campusIndexArr.push(firstPin);
campusList.push({
let index = initialList.indexOf(firstPin);
campusIndexArr[index] = firstPin;
campusList[index] = {
firstPin: firstPin,
children: [area],
});
};
}
}
});
......@@ -190,14 +213,16 @@ class SelectCampus extends Component {
</View>
</View>
<View className='infoBar'>
{pinList.map(item => (
<View
key={item}
className='infoItem'
onClick={() => this.showToastHandle(item)}>
{item}
</View>
))}
{pinList.map(item =>
item ? (
<View
key={item}
className='infoItem'
onClick={() => this.showToastHandle(item)}>
{item}
</View>
) : null,
)}
</View>
<View className={showToast ? 'show br8 infoToast' : 'br8 infoToast'}>
{localText}
......@@ -207,22 +232,24 @@ class SelectCampus extends Component {
className='locationList'
scrollIntoView={localText}
scrollWithAnimation>
{filterList.map(campusItem => (
<View key={campusItem.firstPin} className='locationArea'>
<View id={campusItem.firstPin} className='locationTitle'>
{campusItem.firstPin}
</View>
{campusItem.children.map(campus => (
<View
key={campus.id}
className='locationItem'
data-campus={campus}
onClick={this.bindCampus}>
{campus.areaName}
{filterList.map(campusItem =>
campusItem ? (
<View key={campusItem.firstPin} className='locationArea'>
<View id={campusItem.firstPin} className='locationTitle'>
{campusItem.firstPin}
</View>
))}
</View>
))}
{campusItem.children.map(campus => (
<View
key={campus.id}
className='locationItem'
data-campus={campus}
onClick={this.bindCampus}>
{campus.areaName}
</View>
))}
</View>
) : null,
)}
</ScrollView>
</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