Commit 7f26b12b by 姜雷

添加订单逻辑

parent 72200187
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
"@tarojs/taro-swan": "1.2.13", "@tarojs/taro-swan": "1.2.13",
"@tarojs/taro-tt": "1.2.13", "@tarojs/taro-tt": "1.2.13",
"@tarojs/taro-weapp": "1.2.13", "@tarojs/taro-weapp": "1.2.13",
"crypto-js": "^3.1.9-1",
"jsbarcode": "^3.11.0", "jsbarcode": "^3.11.0",
"nerv-devtools": "^1.3.9", "nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9", "nervjs": "^1.3.9",
......
import { schoolMainFetch, ResponseDataEntity } from '.';
class Parmas {
campusId: number;
customerId: number;
}
export class SectionItem {
id: number;
styleType: string;
name: string;
titleTypeRemark: string;
titleType: string;
titleContent: string;
sort: number;
updateTime: number;
itemsCount: number;
items: AnnItem[];
}
class Response {
campusId: number;
sections: SectionItem[];
}
export const fetchAnn = (data: Parmas) =>
schoolMainFetch({
url: `/dcxy/app/homepage/campus/${data.campusId}/publishedSections/${
data.customerId
}`,
}).then((res: ResponseDataEntity<Response>) => {
const data = res.data;
return data.sections.find(item => item.styleType == 'ANNOUNCEMENT');
});
class AllParmas {
campusId: number;
sectionId: number;
}
class AnnItem {
id: number;
title: string;
multiImageType: '';
source: string;
linkUrls: string[];
linkType: 'DEFAULT';
jumpUrl: string;
urlParameters: {};
sort: number;
enabled?: boolean;
loadAd: boolean;
mandatoryPrompt: boolean;
effectTime?: number;
expirationTime?: number;
createTime: string;
updateTime: string;
}
class AllResponse {
pageNum: number;
pageSize: number;
pages: number;
total: number;
list: AnnItem[];
attached: null;
}
export const fetchAllAnn = (
data: AllParmas,
): Promise<ResponseDataEntity<AllResponse>> =>
schoolMainFetch({
url: `/dcxy/app/homepage/campus/${data.campusId}/publishedItems/${
data.sectionId
}`,
});
...@@ -2015,3 +2015,259 @@ declare namespace API { ...@@ -2015,3 +2015,259 @@ declare namespace API {
} }
} }
} }
declare namespace defs {
export class BarrageEntity {
/** createdate */
createdate?: string;
/** deletestate */
deletestate?: string;
/** id */
id?: number;
/** picurl */
picurl?: string;
/** time */
time?: number;
/** type */
type?: string;
/** updatedate */
updatedate?: string;
/** url */
url?: string;
}
export class JtSynchronOrderVo {
/** 订单内容 */
orderContent?: string;
/** 订单金额 */
orderMoney?: number;
/** 订单编号 */
orderNum?: string;
}
export class JtSynchronPwdVo {
/** 会员电话 */
cellphone?: string;
/** 会员密码 */
password?: string;
}
}
declare namespace API {
/**
* 校区页面管理
*/
export namespace campusPageSection {
/**
* 获取动态码
* /dcxy/app/homepage/campus/getDynamicCode
*/
export namespace getDynamicCode {
export class Params {
/** 账号 */
account: string;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 获取会员APP的版本信息
* /dcxy/app/homepage/campus/getcustomerAppVersion
*/
export namespace getcustomerAppVersion {
export class Params {
/** 会员ID,必须为大于0的整数 */
campusId: string;
/** 会员ID,必须为大于0的整数 */
customerId: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 校区模式
* /dcxy/app/homepage/campus/model/{customerId}
*/
export namespace getModel {
export class Params {
/** 会员ID,必须为大于0的整数 */
customerId: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 版块条目页面上的广告点击接口
* /dcxy/app/homepage/campus/section/itemAd/click
*/
export namespace clickItemAd {
export class Params {
/** 访问页名称,必填项 */
pageName: string;
}
export type Response = any;
export const init: Response;
export function request(params: Params): Promise<any>;
}
/**
* 校园页面版块条目点击接口
* /dcxy/app/homepage/campus/section/{itemId}/click
*/
export namespace clickItem {
export class Params {
/** 版块条目ID,必须为大于0的整数 */
itemId: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 校区页面公告强弹禁用接口
* /dcxy/app/homepage/campus/{campusId}/disableMandatoryPrompt/{customerId}/section/{itemId}/{disable}
*/
export namespace disableMandatoryPrompt {
export class Params {
/** 校区ID,必须为大于0的整数 */
campusId: number;
/** 用户ID,必须为大于0的整数 */
customerId: number;
/** 条目ID,必须为大于0的整数 */
itemId: number;
/** 公告强弹禁用标志,必须为布尔类型 */
disable: boolean;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 获取校区下的app闪图接口
* /dcxy/app/homepage/campus/{campusId}/getBarrage
*/
export namespace getBarrage {
export class Params {
/** 校区ID,必须为大于0的整数 */
campusId: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 校区页面已发布版块所有可用条目列表获取接口
* /dcxy/app/homepage/campus/{campusId}/publishedItems/{sectionId}
*/
export namespace publishedItems {
export class Params {
/** 校区ID,必须为大于0的整数 */
campusId: number;
/** 版块ID,必须为大于0的整数 */
sectionId: number;
/** 首页公告版块ID,必须为大于0的整数 */
pageSectionId?: number;
/** 页码,必须为大于0的整数 */
pageNum?: number;
/** 页大小,必须为大于0的整数 */
pageSize?: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
/**
* 校区页面已发布版块列表获取接口
* /dcxy/app/homepage/campus/{campusId}/publishedSections/{customerId}
*/
export namespace publishedSections {
export class Params {
/** 校区ID,必须为大于0的整数 */
campusId: number;
/** 用户ID,必须为大于0的整数 */
customerId: number;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
}
/**
* 精图接口
*/
export namespace jt {
/**
* 精图订单同步接口
* /dcxy/app/jt/order/data
*/
export namespace synOrder {
export class Params {}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(
params: Params,
bodyParams: defs.JtSynchronOrderVo,
): Promise<defs.ServerResponse>;
}
/**
* 精图RSA密码同步接口
* /dcxy/app/jt/password/data
*/
export namespace synJtPwd {
export class Params {}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(
params: Params,
bodyParams: defs.JtSynchronPwdVo,
): Promise<defs.ServerResponse>;
}
/**
* 校区页面已发布版块列表获取接口
* /dcxy/app/jt/urlAdress/{customerId}
*/
export namespace urlAdress {
export class Params {
/** customerId必须为大于0的整数 */
customerId: string;
}
export type Response = defs.ServerResponse;
export const init: Response;
export function request(params: Params): Promise<defs.ServerResponse>;
}
}
}
...@@ -981,3 +981,47 @@ export class SingleOrderRspData { ...@@ -981,3 +981,47 @@ export class SingleOrderRspData {
/** settleTime */ /** settleTime */
settleTime = ''; settleTime = '';
} }
export class BarrageEntity {
/** createdate */
createdate = '';
/** deletestate */
deletestate = '';
/** id */
id = undefined;
/** picurl */
picurl = '';
/** time */
time = undefined;
/** type */
type = '';
/** updatedate */
updatedate = '';
/** url */
url = '';
}
export class JtSynchronOrderVo {
/** 订单内容 */
orderContent = '';
/** 订单金额 */
orderMoney = undefined;
/** 订单编号 */
orderNum = '';
}
export class JtSynchronPwdVo {
/** 会员电话 */
cellphone = '';
/** 会员密码 */
password = '';
}
...@@ -3,18 +3,24 @@ import { LoginInfoVo } from './baseClass'; ...@@ -3,18 +3,24 @@ import { LoginInfoVo } from './baseClass';
export class LoginParams { export class LoginParams {
/** 登陆标识 */ /** 登陆标识 */
token?: string; code?: string;
/** 账号 */ /** 账号 */
loginAccount?: string; loginAccount?: string;
/** 密码 */ /** 密码 */
passWord?: string; password?: string;
} }
export const appLogin = (data: LoginParams) => export const appLogin = (data: LoginParams) =>
customerFetch({ customerFetch({
url: '/app/customer/login', url: '/dcxy/wechat/applet/login/',
method: 'POST',
data: data, data: data,
}); });
export const appLogout = () =>
customerFetch({
url: '/app/customer/login/out',
});
export class PwdParams { export class PwdParams {
/** 账号 */ /** 账号 */
loginAccount: string; loginAccount: string;
...@@ -30,3 +36,13 @@ export const changePwdByCellphone = (data: PwdParams) => ...@@ -30,3 +36,13 @@ export const changePwdByCellphone = (data: PwdParams) =>
}`, }`,
method: 'PUT', method: 'PUT',
}); });
type RegisiterPramas = {};
// type RegisiterReponseData = {};
export const wxUserRegister = (entity: RegisiterPramas) =>
customerFetch({
url: '/dcxy/wechat/applet/register/',
method: 'POST',
data: entity,
});
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
OLD_BASE_SERVER_URL, OLD_BASE_SERVER_URL,
BASE_SERVER_URL, BASE_SERVER_URL,
CUSTOMER_SERVER_URL, CUSTOMER_SERVER_URL,
SCHOOL_MAIN_URL,
} from '../constants/index'; } from '../constants/index';
export type ResponseDataEntity<T> = { export type ResponseDataEntity<T> = {
...@@ -45,5 +46,6 @@ const createFetch = (basePath: string) => { ...@@ -45,5 +46,6 @@ const createFetch = (basePath: string) => {
export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL); export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL);
export const baseFetch = createFetch(BASE_SERVER_URL); export const baseFetch = createFetch(BASE_SERVER_URL);
export const customerFetch = createFetch(CUSTOMER_SERVER_URL); export const customerFetch = createFetch(CUSTOMER_SERVER_URL);
export const schoolMainFetch = createFetch(SCHOOL_MAIN_URL);
export default createFetch; export default createFetch;
import { ConsumeOrderResponse } from './baseClass'; import { ConsumeOrderResponse, ConsumeOrder } from './baseClass';
import { customerFetch, ResponseDataEntity } from './index'; import { customerFetch, ResponseDataEntity } from './index';
export class Params { export class Params {
...@@ -20,7 +20,7 @@ export const fetchAllOrder = (params: Params) => ...@@ -20,7 +20,7 @@ export const fetchAllOrder = (params: Params) =>
export const fetchPayOrder = ( export const fetchPayOrder = (
params: Params, params: Params,
): Promise<ResponseDataEntity<ConsumeOrderResponse>> => ): Promise<ResponseDataEntity<ConsumeOrder[]>> =>
customerFetch({ customerFetch({
url: '/consumeOrder/pageList', url: '/consumeOrder/pageList',
data: { data: {
...@@ -37,3 +37,35 @@ export const fetchOrderDetail = (data: DetailParams) => ...@@ -37,3 +37,35 @@ export const fetchOrderDetail = (data: DetailParams) =>
url: '/consumeOrder/getDetail', url: '/consumeOrder/getDetail',
data: data, data: data,
}); });
export const fetchOrderDetailAndPay = (data: DetailParams) =>
customerFetch({
url: '/consumeOrder/getOrderDetailAndPay',
data: data,
});
type DeductionParams = {
orderId: number;
payType: string;
paymentConfId: number;
};
export const fetchDeductionInfo = (data: DeductionParams) =>
customerFetch({
url: '/consumeOrder/getDeductionInfo',
data: data,
});
type ConfirmpayParams = {
orderId: number;
payType: string;
activeId?: number;
callType: string;
paymentConfId: number;
returnUrl: string;
[propName: string]: any;
};
export const confirmPay = (data: ConfirmpayParams) =>
customerFetch({
url: '/consumeOrder/confirmPay',
data: data,
});
import { oldBaseFetch, baseFetch, ResponseDataEntity } from './index'; import { oldBaseFetch, baseFetch, ResponseDataEntity } from './index';
import { UserState } from '../store/rootReducers/userinfo';
type LoginPramas = { type LoginPramas = {
code: string; code: string;
}; };
type LoginReponseData = { type LoginReponseData = {
registed: boolean; register: boolean;
token: string; wxToken: string;
}; } & UserState;
export interface LoginReponse extends ResponseDataEntity<LoginReponseData> { export interface LoginReponse extends ResponseDataEntity<LoginReponseData> {
data: LoginReponseData; data: LoginReponseData;
} }
...@@ -46,7 +47,7 @@ type RegisiterPramas = {}; ...@@ -46,7 +47,7 @@ type RegisiterPramas = {};
export const fetchWxUserRegister = (entity: RegisiterPramas) => export const fetchWxUserRegister = (entity: RegisiterPramas) =>
baseFetch({ baseFetch({
url: '/wx/api/user/regisiter2', url: '/dcxy/wechat/applet/register/',
method: 'POST', method: 'POST',
data: entity, data: entity,
}); });
...@@ -4,3 +4,4 @@ export const OLD_BASE_SERVER_URL = 'https://ex-dev-selfbase.168cad.top'; ...@@ -4,3 +4,4 @@ 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 BASE_SERVER_URL = 'https://ex-dev-dcxy-base-app.168cad.top';
export const CUSTOMER_SERVER_URL = export const CUSTOMER_SERVER_URL =
'https://ex-dev-dcxy-customer-app.168cad.top'; 'https://ex-dev-dcxy-customer-app.168cad.top';
export const SCHOOL_MAIN_URL = 'http://internal-dev-school-main.168cad.top';
...@@ -18,6 +18,8 @@ import './Home.scss'; ...@@ -18,6 +18,8 @@ import './Home.scss';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { UserState } from '../../store/rootReducers/userinfo'; import { UserState } from '../../store/rootReducers/userinfo';
import { fetchBeanCount } from '../../api/bean'; import { fetchBeanCount } from '../../api/bean';
import { fetchAnn, SectionItem } from '../../api/announcement';
import { appLogout } from '../../api/customer';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
...@@ -25,6 +27,7 @@ type PageStateProps = { ...@@ -25,6 +27,7 @@ type PageStateProps = {
type PageState = { type PageState = {
commBean: number; commBean: number;
hairDryerBean: number; hairDryerBean: number;
annItem: SectionItem;
}; };
interface Home { interface Home {
...@@ -40,10 +43,25 @@ class Home extends Component { ...@@ -40,10 +43,25 @@ class Home extends Component {
this.state = { this.state = {
commBean: 0.0, commBean: 0.0,
hairDryerBean: 0.0, hairDryerBean: 0.0,
annItem: {
id: 0,
styleType: '',
name: '',
titleTypeRemark: '',
titleType: '',
titleContent: '',
sort: 0,
updateTime: 0,
itemsCount: 0,
items: [],
},
}; };
} }
componentWillMount() { componentWillMount() {
this.getInitData();
}
getInitData() {
const { userinfo } = this.props; const { userinfo } = this.props;
fetchBeanCount({ fetchBeanCount({
id: userinfo.customerId, id: userinfo.customerId,
...@@ -63,6 +81,18 @@ class Home extends Component { ...@@ -63,6 +81,18 @@ class Home extends Component {
}); });
}) })
.catch(console.error); .catch(console.error);
fetchAnn({
campusId: userinfo.areaId,
customerId: userinfo.customerId,
})
.then(res => {
if (res) {
this.setState({
annItem: res,
});
}
})
.catch(console.error);
} }
goSetting() { goSetting() {
...@@ -87,17 +117,26 @@ class Home extends Component { ...@@ -87,17 +117,26 @@ class Home extends Component {
url: '/pages/BarCode/BarCode', url: '/pages/BarCode/BarCode',
}); });
} }
logoutHandle() {
appLogout()
.then(() => {
Taro.redirectTo({
url: '/pages/index/index',
});
})
.catch(console.log);
}
render() { render() {
const { userinfo } = this.props; const { userinfo } = this.props;
const { commBean, hairDryerBean } = this.state; const { commBean, hairDryerBean, annItem } = this.state;
return ( return (
<View className='Home'> <View className='Home'>
<View className='Home-UserBox'> <View className='Home-UserBox'>
<Image <Image
className='Home-UserBox-Setting' className='Home-UserBox-Setting'
src={SettingIcon} src={SettingIcon}
onClick={this.goSetting} onClick={this.logoutHandle}
/> />
<Image className='bg' src={UserBoxBg} /> <Image className='bg' src={UserBoxBg} />
<View className='Home-UserBox-info'> <View className='Home-UserBox-info'>
...@@ -107,9 +146,9 @@ class Home extends Component { ...@@ -107,9 +146,9 @@ class Home extends Component {
<View className='Home-UserBox-addr'>{userinfo.areaName}</View> <View className='Home-UserBox-addr'>{userinfo.areaName}</View>
</View> </View>
{userinfo.customerSex === '2' ? ( {userinfo.customerSex === '2' ? (
<Image className='Home-UserBox-headimg' src={UserHeaderM} />
) : (
<Image className='Home-UserBox-headimg' src={UserHeaderF} /> <Image className='Home-UserBox-headimg' src={UserHeaderF} />
) : (
<Image className='Home-UserBox-headimg' src={UserHeaderM} />
)} )}
</View> </View>
<View className='Home-UserBox-line' /> <View className='Home-UserBox-line' />
...@@ -140,6 +179,7 @@ class Home extends Component { ...@@ -140,6 +179,7 @@ class Home extends Component {
<Image className='Home-HairDryer-arrow' src={HairDryerArr} /> <Image className='Home-HairDryer-arrow' src={HairDryerArr} />
</View> </View>
</View> </View>
{annItem.id ? (
<View className='Home-Announcement'> <View className='Home-Announcement'>
<Image className='bg' src={AnnouncementBg} /> <Image className='bg' src={AnnouncementBg} />
<View className='Home-Announcement-title'> <View className='Home-Announcement-title'>
...@@ -154,6 +194,7 @@ class Home extends Component { ...@@ -154,6 +194,7 @@ class Home extends Component {
<Text className='ContentDate'>2019-02-22</Text> <Text className='ContentDate'>2019-02-22</Text>
</View> </View>
</View> </View>
) : null}
</View> </View>
); );
} }
......
...@@ -38,8 +38,8 @@ class Login extends Component { ...@@ -38,8 +38,8 @@ class Login extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
account: '', account: '15928189723',
pwd: '', pwd: '123456',
}; };
} }
...@@ -68,7 +68,7 @@ class Login extends Component { ...@@ -68,7 +68,7 @@ class Login extends Component {
console.log('in loginHandle'); console.log('in loginHandle');
appLogin({ appLogin({
loginAccount: account, loginAccount: account,
passWord: pwd, password: pwd,
}) })
.then(res => { .then(res => {
const data = res.data; const data = res.data;
......
...@@ -7,42 +7,163 @@ import OrderInfo from '../components/OrderInfo/OrderInfo'; ...@@ -7,42 +7,163 @@ import OrderInfo from '../components/OrderInfo/OrderInfo';
import comLogo from '../../../images/order/pay_logo_icon@2x.png'; import comLogo from '../../../images/order/pay_logo_icon@2x.png';
import './OrderDetail.scss'; import './OrderDetail.scss';
import { fetchOrderDetail, fetchOrderDetailAndPay } from '../../../api/order';
import { PayType, getPayType } from '../../../utils/payType';
type pageProps = {}; type pageProps = {};
type PageState = {
actualMoney: 0;
areaId: 0;
areaName: string;
consumeType: string;
createAt: string;
customerCellphone: string;
customerId: 0;
customerName: string;
deductionBean: 0;
deductionMoney: 0;
equipmentNum: string;
equipmentPosition: string;
id: 0;
operateId: 0;
operateName: string;
operationMode: string;
orderName: string;
orderNumber: string;
orderState: string;
outTradeNo: string;
payType: PayType;
payableMoney: 0;
serviceId: 0;
serviceName: string;
thirdDiscountMoney: 0;
thirdTradeNumber: string;
updateDate: string;
};
interface OrderDetail {
props: pageProps;
state: PageState;
}
class OrderDetail extends Component { class OrderDetail extends Component {
config: Config = { config: Config = {
navigationBarTitleText: '订单详情', navigationBarTitleText: '订单详情',
}; };
constructor(props) {
super(props);
this.state = {
actualMoney: 0,
areaId: 0,
areaName: '',
consumeType: '',
createAt: '',
customerCellphone: '',
customerId: 0,
customerName: '',
deductionBean: 0,
deductionMoney: 0,
equipmentNum: '',
equipmentPosition: '',
id: 0,
operateId: 0,
operateName: '',
operationMode: '',
orderName: '',
orderNumber: '',
orderState: '',
outTradeNo: '',
payType: '',
payableMoney: 0,
serviceId: 0,
serviceName: '',
thirdDiscountMoney: 0,
thirdTradeNumber: '',
updateDate: '',
};
}
componentWillMount() {
console.log('preload: ', this.$router.preload);
const data = this.$router.preload;
this.setState({
...data,
});
// this.getDetailInfo(id);
}
getDetailInfo(id: number) {
return fetchOrderDetailAndPay({
id: id,
})
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
}
render() { render() {
const {
actualMoney,
payableMoney,
deductionBean,
payType,
createAt,
thirdTradeNumber,
serviceName,
orderNumber,
areaName,
equipmentNum,
equipmentPosition,
deductionMoney,
} = this.state;
const payTypeName = getPayType(payType);
return ( return (
<View className='OrderDetail'> <View className='OrderDetail'>
<OrderTitle /> <OrderTitle price={payableMoney} />
<OrderInfo /> <OrderInfo
serviceName={serviceName}
createAt={createAt}
orderNumber={orderNumber}
areaName={areaName}
equipmentNum={equipmentNum}
equipmentPosition={equipmentPosition}
/>
<View className='OrderDetail-line' /> <View className='OrderDetail-line' />
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>支付金额</Text> <Text>支付金额</Text>
<Text>0.08</Text> <Text>{actualMoney.toFixed(2)}</Text>
</View> </View>
{deductionBean ? (
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>通用豆抵扣</Text> <Text>通用豆抵扣</Text>
<Text>0.03</Text> <Text>{deductionBean.toFixed(2)}</Text>
</View> </View>
) : null}
{deductionMoney ? (
<View className='OrderDetail-payinfo'>
<Text>艾米抵扣</Text>
<Text>{deductionMoney.toFixed(2)}</Text>
</View>
) : null}
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>支付方式</Text> <Text>支付方式</Text>
<Text>微信</Text> <Text>{payTypeName}</Text>
</View> </View>
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>支付时间</Text> <Text>支付时间</Text>
<Text>2018-12-05 </Text> <Text>{createAt}</Text>
</View> </View>
{thirdTradeNumber ? (
<View className='OrderDetail-payinfo'> <View className='OrderDetail-payinfo'>
<Text>交易单号</Text> <Text>交易单号</Text>
<Text>1256456165158485146</Text> <Text>{thirdTradeNumber}</Text>
</View> </View>
) : null}
</View> </View>
); );
} }
} }
export default OrderDetail as ComponentClass<pageProps>; export default OrderDetail as ComponentClass<pageProps, PageState>;
...@@ -29,4 +29,28 @@ ...@@ -29,4 +29,28 @@
padding-top: 80px; padding-top: 80px;
background-color: #eee; background-color: #eee;
} }
.OrderList-Group {
margin-bottom: 22px;
.OrderList-GroupTitle {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 22px;
color: #666;
padding: 0 24px;
}
.OrderList-GroupName {
padding: 0 26px;
height: 44px;
line-height: 44px;
margin-bottom: 10px;
background-color: #fff;
border-radius: 8px;
font-size: 24px;
color: #333;
}
}
.OrderList-Group:first-child {
margin-top: 9px;
}
} }
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro'; import Taro, { Component, Config } from '@tarojs/taro';
import { View, Button, Text, ScrollView } from '@tarojs/components'; import { View, Text, ScrollView } from '@tarojs/components';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import OrderItem from '../components/OrderItem/OrderItem'; import OrderItem from '../components/OrderItem/OrderItem';
import './OrderList.scss'; import './OrderList.scss';
import { toggleOrderState } from './actions'; import {
toggleOrderState,
updatePayOrderList,
updateAllOrderList,
} from './actions';
import { StoreState } from './store'; import { StoreState } from './store';
import { fetchAllOrder, fetchPayOrder } from '../../../api/order'; import { fetchAllOrder, fetchPayOrder } from '../../../api/order';
import { UserState } from '../../../store/rootReducers/userinfo'; import { UserState } from '../../../store/rootReducers/userinfo';
import { ConsumeOrder } from '../../../api/baseClass';
import Order, { AllOrderItem } from '../../../types/Order/Order';
type PageStateProps = { type PageStateProps = {
orderList: StoreState; orderList: StoreState;
...@@ -18,6 +24,8 @@ type PageStateProps = { ...@@ -18,6 +24,8 @@ type PageStateProps = {
}; };
type PageDispatchProps = { type PageDispatchProps = {
toggleOrderState: (state: String) => void; toggleOrderState: (state: String) => void;
updatePayOrder: (list: Order[]) => void;
updateAllOrder: (list: AllOrderItem[]) => void;
}; };
type PageOwnProps = {}; type PageOwnProps = {};
...@@ -37,6 +45,12 @@ interface OrderList { ...@@ -37,6 +45,12 @@ interface OrderList {
toggleOrderState(state: String) { toggleOrderState(state: String) {
dispatch(toggleOrderState(state)); dispatch(toggleOrderState(state));
}, },
updatePayOrder(data: Order[]) {
dispatch(updatePayOrderList(data));
},
updateAllOrder(data: AllOrderItem[]) {
dispatch(updateAllOrderList(data));
},
}), }),
) )
class OrderList extends Component { class OrderList extends Component {
...@@ -52,7 +66,7 @@ class OrderList extends Component { ...@@ -52,7 +66,7 @@ class OrderList extends Component {
} }
getPayOrderHandle(lastOrderId?: number) { getPayOrderHandle(lastOrderId?: number) {
const { userinfo } = this.props; const { userinfo, updatePayOrder } = this.props;
fetchPayOrder( fetchPayOrder(
lastOrderId lastOrderId
? { ? {
...@@ -67,23 +81,65 @@ class OrderList extends Component { ...@@ -67,23 +81,65 @@ class OrderList extends Component {
) )
.then(res => { .then(res => {
console.log(res); console.log(res);
updatePayOrder(res.data);
}) })
.catch(console.error); .catch(console.error);
} }
getAllOrderHandle() {} getAllOrderHandle(lastOrderId?: number) {
const {
userinfo: { customerId },
updateAllOrder,
} = this.props;
fetchAllOrder(
lastOrderId
? {
customerId: customerId,
pageSize: 10,
lastOrderId,
}
: {
customerId: customerId,
pageSize: 10,
},
)
.then(res => {
console.log(res);
updateAllOrder(res.data);
})
.catch(console.error);
}
goPayPage(data) { goPayPage(data) {
this.$preload(data); this.$preload({ id: data.id });
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/Order/OrderPay/OrderPay', url: '/pages/Order/OrderPay/OrderPay',
}); });
} }
goDetail(data) {
this.$preload(data);
Taro.navigateTo({
url: '/pages/Order/OrderDetail/OrderDetail',
});
}
render() { toggleStateHandle(type: string) {
const { const {
orderList: { orderState },
toggleOrderState, toggleOrderState,
orderList: { payList, allList },
} = this.props;
if (type === '1' && payList.length === 0) {
this.getPayOrderHandle();
}
if (type === 'all' && allList.length === 0) {
this.getAllOrderHandle();
}
toggleOrderState(type);
}
render() {
const {
orderList: { orderState, payList, allList },
} = this.props; } = this.props;
return ( return (
...@@ -91,12 +147,12 @@ class OrderList extends Component { ...@@ -91,12 +147,12 @@ class OrderList extends Component {
<View className='Tab'> <View className='Tab'>
<Text <Text
className={`Tab-item ${orderState === '1' ? 'active' : ''}`} className={`Tab-item ${orderState === '1' ? 'active' : ''}`}
onClick={() => toggleOrderState('1')}> onClick={() => this.toggleStateHandle('1')}>
待付款 待付款
</Text> </Text>
<Text <Text
className={`Tab-item ${orderState === 'all' ? 'active' : ''}`} className={`Tab-item ${orderState === 'all' ? 'active' : ''}`}
onClick={() => toggleOrderState('all')}> onClick={() => this.toggleStateHandle('all')}>
全部 全部
</Text> </Text>
</View> </View>
...@@ -105,42 +161,33 @@ class OrderList extends Component { ...@@ -105,42 +161,33 @@ class OrderList extends Component {
scrollY scrollY
scrollWithAnimation scrollWithAnimation
scrollTop={0}> scrollTop={0}>
{orderState === '1'
? payList.map(order => (
<OrderItem <OrderItem
data={{ id: 1, orderState: '1' }} key={order.id}
onPayHandle={this.goPayPage} data={order}
/> onGoDetail={this.goDetail}
<OrderItem
data={{ id: 1, orderState: '1' }}
onPayHandle={this.goPayPage}
/>{' '}
<OrderItem
data={{ id: 1, orderState: 'all' }}
onPayHandle={this.goPayPage}
/>
<OrderItem
data={{ id: 1, orderState: '1' }}
onPayHandle={this.goPayPage}
/>
<OrderItem
data={{ id: 1, orderState: '1' }}
onPayHandle={this.goPayPage}
/>
<OrderItem
data={{ id: 1, orderState: 'all' }}
onPayHandle={this.goPayPage}
/>
<OrderItem
data={{ id: 1, orderState: '1' }}
onPayHandle={this.goPayPage}
/>{' '}
<OrderItem
data={{ id: 1, orderState: 'all' }}
onPayHandle={this.goPayPage} onPayHandle={this.goPayPage}
/> />
))
: allList.map((allItem, index) => (
<View key={index} className='OrderList-Group'>
<View className='OrderList-GroupTitle'>
<View className='OrderList-GroupName'>
{allItem.groupName}
</View>
{index === 0 && <Text>只保留最近三个月消费订单数据</Text>}
</View>
{allItem.data.map(order => (
<OrderItem <OrderItem
data={{ id: 1, orderState: '1' }} key={order.id}
data={order}
onGoDetail={this.goDetail}
onPayHandle={this.goPayPage} onPayHandle={this.goPayPage}
/> />
))}
</View>
))}
</ScrollView> </ScrollView>
</View> </View>
); );
......
import Actions from '../../../types/Store/Actions'; import Actions from '../../../types/Store/Actions';
import Order, { AllOrderItem } from '../../../types/Order/Order';
export const TOGGLE_ORDER_STATE = 'TOGGLE_ORDER_STATE'; export const TOGGLE_ORDER_STATE = 'TOGGLE_ORDER_STATE';
export const UPDATE_PAY_LIST = 'UPDATE_PAY_LIST';
export const UPDATE_ALL_LIST = 'UPDATE_ALL_LIST';
export const toggleOrderState = (state: String): Actions => ({ export const toggleOrderState = (state: String): Actions => ({
type: TOGGLE_ORDER_STATE, type: TOGGLE_ORDER_STATE,
payload: state, payload: state,
}); });
export const updatePayOrderList = (state: Order[]): Actions => ({
type: UPDATE_PAY_LIST,
payload: state,
});
export const updateAllOrderList = (state: AllOrderItem[]): Actions => ({
type: UPDATE_ALL_LIST,
payload: state,
});
import Actions from '../../../types/Store/Actions'; import Actions from '../../../types/Store/Actions';
import Order from '../../../types/Order/Order'; import Order from '../../../types/Order/Order';
import { TOGGLE_ORDER_STATE } from './actions'; import {
TOGGLE_ORDER_STATE,
UPDATE_PAY_LIST,
UPDATE_ALL_LIST,
} from './actions';
export interface StoreState { export interface StoreState {
orderState: String; orderState: String;
...@@ -24,7 +28,16 @@ export default function OrderList( ...@@ -24,7 +28,16 @@ export default function OrderList(
...state, ...state,
orderState: actions.payload, orderState: actions.payload,
}; };
case UPDATE_PAY_LIST:
return {
...state,
payList: actions.payload,
};
case UPDATE_ALL_LIST:
return {
...state,
allList: actions.payload,
};
default: default:
return state; return state;
} }
......
...@@ -4,37 +4,57 @@ import { View, Text } from '@tarojs/components'; ...@@ -4,37 +4,57 @@ import { View, Text } from '@tarojs/components';
import './OrderInfo.scss'; import './OrderInfo.scss';
type PageProps = {
serviceName: string;
createAt: string;
orderNumber: string;
areaName: string;
equipmentNum: string;
equipmentPosition: string;
};
interface OrderInfo {
props: PageProps;
}
class OrderInfo extends Component { class OrderInfo extends Component {
render() { render() {
const {
serviceName,
createAt,
orderNumber,
areaName,
equipmentNum,
equipmentPosition,
} = this.props;
return ( return (
<View> <View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>商品说明</Text> <Text>商品说明</Text>
<Text>吹风消费</Text> <Text>{serviceName ? serviceName : ''}</Text>
</View> </View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>消费时间</Text> <Text>消费时间</Text>
<Text>2018-12-05 23:59:59</Text> <Text>{createAt}</Text>
</View> </View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>订单号</Text> <Text>订单号</Text>
<Text>gfj23oi234kjf34ihruih</Text> <Text>{orderNumber}</Text>
</View> </View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>所属区域</Text> <Text>所属区域</Text>
<Text>成都师范学院</Text> <Text>{areaName}</Text>
</View> </View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>设备编号</Text> <Text>设备编号</Text>
<Text>SN10000089078</Text> <Text>{equipmentNum}</Text>
</View> </View>
<View className='OrderDetail-info'> <View className='OrderDetail-info'>
<Text>设备位置</Text> <Text>设备位置</Text>
<Text>天信元A幢1栋2302门口</Text> <Text>{equipmentPosition ? equipmentPosition : ''}</Text>
</View> </View>
</View> </View>
); );
} }
} }
export default OrderInfo as ComponentClass; export default OrderInfo as ComponentClass<PageProps>;
...@@ -3,15 +3,12 @@ import Taro, { Component } from '@tarojs/taro'; ...@@ -3,15 +3,12 @@ import Taro, { Component } from '@tarojs/taro';
import { View, Text, Image } from '@tarojs/components'; import { View, Text, Image } from '@tarojs/components';
import payDoneImg from '../../../../images/order/dingdan_yiwancheng_img@2x.png'; import payDoneImg from '../../../../images/order/dingdan_yiwancheng_img@2x.png';
import './OrderItem.scss'; import './OrderItem.scss';
import Order from '../../../../types/Order/Order';
type OrderItemProps = {
id: number;
orderState: string;
};
type PageOwnProps = { type PageOwnProps = {
data: OrderItemProps; data: Order;
onPayHandle: (data: OrderItemProps) => void; onPayHandle: (data: Order) => void;
onGoDetail: (data: Order) => void;
}; };
type PageState = {}; type PageState = {};
...@@ -24,29 +21,60 @@ class OrderItem extends Component { ...@@ -24,29 +21,60 @@ class OrderItem extends Component {
static defaultProps = { static defaultProps = {
data: { data: {
id: 0, id: 0,
orderNumber: '',
orderName: '',
customerId: 0,
customerName: '',
customerCellphone: '',
serviceId: 0,
serviceName: '',
areaId: 0,
areaName: '',
operateId: 0,
operateName: '',
equipmentNum: '',
equipmentPosition: '',
orderState: '1', orderState: '1',
payableMoney: 0,
actualMoney: 0,
thirdDiscountMoney: 0,
deductionBean: 0,
deductionMoney: 0,
payType: '',
consumeType: '',
operationMode: '1',
thirdTradeNumber: '',
outTradeNo: '',
createAt: '',
updateDate: '',
}, },
}; };
clickHandle() { payHandle() {
const { onPayHandle, data } = this.props; const { onPayHandle, data } = this.props;
onPayHandle(data); onPayHandle(data);
} }
detailHandle() {
const { onGoDetail, data } = this.props;
if (data.orderState === '1') return;
onGoDetail(data);
}
render() { render() {
const { const {
data: { orderState }, data: { orderState, createAt, serviceName, payableMoney },
} = this.props; } = this.props;
return ( return (
<View className='OrderItem'> <View className='OrderItem' onClick={this.detailHandle}>
<View className='OrderItem-text'> <View className='OrderItem-text'>
<Text>消费说明:</Text> <Text>消费说明:</Text>
<Text>饮水消费</Text> <Text>{serviceName ? serviceName : ''}</Text>
</View> </View>
<View className='OrderItem-text'> <View className='OrderItem-text'>
<Text>消费时间:</Text> <Text>消费时间:</Text>
<Text>2018-12-01 17:30:23</Text> <Text>{createAt}</Text>
{orderState === '1' ? ( {orderState === '1' ? (
<View className='OrderItem-toPay' onClick={this.clickHandle}> <View className='OrderItem-toPay' onClick={this.payHandle}>
去支付 > 去支付 >
</View> </View>
) : ( ) : (
...@@ -55,7 +83,7 @@ class OrderItem extends Component { ...@@ -55,7 +83,7 @@ class OrderItem extends Component {
</View> </View>
<View <View
className={`OrderItem-price ${orderState === '1' ? 'topay' : ''}`}> className={`OrderItem-price ${orderState === '1' ? 'topay' : ''}`}>
0.12 {payableMoney}
</View> </View>
</View> </View>
); );
......
...@@ -5,17 +5,23 @@ import { View, Text, Image } from '@tarojs/components'; ...@@ -5,17 +5,23 @@ import { View, Text, Image } from '@tarojs/components';
import comLogo from '../../../../images/order/pay_logo_icon@2x.png'; import comLogo from '../../../../images/order/pay_logo_icon@2x.png';
import './OrderTitle.scss'; import './OrderTitle.scss';
type PageProps = {}; type PageProps = {
price: number;
};
interface OrderTitle {
props: PageProps;
}
class OrderTitle extends Component { class OrderTitle extends Component {
render() { render() {
const { price } = this.props;
return ( return (
<View className='OrderTitle'> <View className='OrderTitle'>
<View className='OrderTitle-name'> <View className='OrderTitle-name'>
<Image className='OrderTitle-icon' src={comLogo} /> <Image className='OrderTitle-icon' src={comLogo} />
<Text>成都多彩任意门科技有限公司</Text> <Text>成都多彩任意门科技有限公司</Text>
</View> </View>
<View className='OrderTitle-price'>-0.12</View> <View className='OrderTitle-price'>-{price}</View>
</View> </View>
); );
} }
......
...@@ -15,14 +15,15 @@ import './Register.scss'; ...@@ -15,14 +15,15 @@ import './Register.scss';
import agreeIcon from '../../images/login/icon_zhuce_sel@2x.png'; import agreeIcon from '../../images/login/icon_zhuce_sel@2x.png';
import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png'; import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { UserState } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { getVcode, fetchWxUserRegister } from '../../api/wx'; import { getVcode, fetchWxUserRegister } from '../../api/wx';
import { wxUserRegister } from '../../api/customer';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
}; };
type PageDispatchProps = { type PageDispatchProps = {
// updateUserInfo: (e: User) => void; updateUserInfo: (e: UserState) => void;
}; };
type PageState = { type PageState = {
...@@ -43,9 +44,16 @@ interface Register { ...@@ -43,9 +44,16 @@ interface Register {
state: PageState; state: PageState;
} }
@connect(({ userinfo }) => ({ @connect(
({ userinfo }) => ({
userinfo, userinfo,
})) }),
dispatch => ({
updateUserInfo(entity: UserState) {
dispatch(updateUserInfo(entity));
},
}),
)
class Register extends Component { class Register extends Component {
config: Config = { config: Config = {
navigationBarTitleText: '注册', navigationBarTitleText: '注册',
...@@ -59,7 +67,7 @@ class Register extends Component { ...@@ -59,7 +67,7 @@ class Register extends Component {
vcode: '', vcode: '',
pwd: '123456', pwd: '123456',
checkPwd: '123456', checkPwd: '123456',
sex: 'Male', sex: '1',
agree: false, agree: false,
showPwd: false, showPwd: false,
showCheckPwd: false, showCheckPwd: false,
...@@ -98,7 +106,7 @@ class Register extends Component { ...@@ -98,7 +106,7 @@ class Register extends Component {
validateRegisterEntity(): boolean { validateRegisterEntity(): boolean {
const { name, cellphone, pwd, checkPwd } = this.state; const { name, cellphone, pwd, checkPwd } = this.state;
const { const {
userinfo: { campusId }, userinfo: { areaId },
} = this.props; } = this.props;
if (!name) { if (!name) {
Taro.showToast({ Taro.showToast({
...@@ -135,7 +143,7 @@ class Register extends Component { ...@@ -135,7 +143,7 @@ class Register extends Component {
}); });
return false; return false;
} }
if (!campusId) { if (!areaId) {
Taro.showToast({ Taro.showToast({
title: '请选择所属校区', title: '请选择所属校区',
icon: 'none', icon: 'none',
...@@ -147,18 +155,35 @@ class Register extends Component { ...@@ -147,18 +155,35 @@ class Register extends Component {
getRegister() { getRegister() {
if (this.validateRegisterEntity()) { if (this.validateRegisterEntity()) {
const { name, cellphone, pwd, sex } = this.state; const { name, cellphone, pwd, sex, vcode } = this.state;
const { const {
userinfo: { campusId, schoolId }, userinfo: { areaId, areaName },
} = this.props; } = this.props;
fetchWxUserRegister({ wxUserRegister({
cellphone, areaId: areaId,
campusId, areaName: areaName,
name, customerName: name,
pwd, customerPhone: cellphone,
schoolId, customerSex: sex,
sex, password: pwd,
verificationCode: vcode,
})
.then(res => {
const { register, wxToken, ...userInfo } = res.data;
updateUserInfo({
...userInfo,
token: wxToken,
});
Taro.showToast({
title: '注册成功',
}); });
setTimeout(() => {
Taro.redirectTo({
url: '/pages/Home/Home',
});
}, 2000);
})
.catch(console.log);
} }
} }
...@@ -221,18 +246,16 @@ class Register extends Component { ...@@ -221,18 +246,16 @@ class Register extends Component {
maxLength={20} maxLength={20}
/> />
<View className='loginBox-input sexBox'> <View className='loginBox-input sexBox'>
<View <View className='sexBox-item' onClick={() => this.setSex('2')}>
className='sexBox-item' {sex === '2' ? (
onClick={() => this.setSex('Female')}>
{sex === 'Female' ? (
<Image className='sexBox-icon' src={radioCheckIcon} /> <Image className='sexBox-icon' src={radioCheckIcon} />
) : ( ) : (
<Image className='sexBox-icon' src={radioIcon} /> <Image className='sexBox-icon' src={radioIcon} />
)} )}
<Text></Text> <Text></Text>
</View> </View>
<View className='sexBox-item' onClick={() => this.setSex('Male')}> <View className='sexBox-item' onClick={() => this.setSex('1')}>
{sex === 'Male' ? ( {sex === '1' ? (
<Image className='sexBox-icon' src={radioCheckIcon} /> <Image className='sexBox-icon' src={radioCheckIcon} />
) : ( ) : (
<Image className='sexBox-icon' src={radioIcon} /> <Image className='sexBox-icon' src={radioIcon} />
...@@ -264,6 +287,12 @@ class Register extends Component { ...@@ -264,6 +287,12 @@ class Register 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'
...@@ -322,8 +351,8 @@ class Register extends Component { ...@@ -322,8 +351,8 @@ class Register extends Component {
<Text className='registerBox-text'>区域信息</Text> <Text className='registerBox-text'>区域信息</Text>
</View> </View>
<View className='registerBox-item' onClick={this.navToCampus}> <View className='registerBox-item' onClick={this.navToCampus}>
{userinfo.campusId ? ( {userinfo.areaId ? (
<Text>{userinfo.campusName}</Text> <Text>{userinfo.areaName}</Text>
) : ( ) : (
<Text className='noVlaue'>请填写真实区域信息</Text> <Text className='noVlaue'>请填写真实区域信息</Text>
)} )}
......
...@@ -3,18 +3,21 @@ import Taro, { Component, Config } from '@tarojs/taro'; ...@@ -3,18 +3,21 @@ import Taro, { Component, Config } from '@tarojs/taro';
import { View } from '@tarojs/components'; import { View } from '@tarojs/components';
import './index.scss'; import './index.scss';
import { login, LoginReponse } from '../../api/wx'; import { LoginReponse, login } from '../../api/wx';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo'; import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo';
import { appLogin } from '../../api/customer';
type PageDispatchProps = { type PageDispatchProps = {
updateUserInfo: (e: UserState) => void; updateUserInfo: (e: UserState | { token: string }) => void;
}; };
type PageOwnProps = {}; type PageOwnProps = {};
type PageState = {}; type PageState = {
errorText: string;
};
type IProps = PageDispatchProps & PageOwnProps; type IProps = PageDispatchProps & PageOwnProps;
...@@ -36,11 +39,14 @@ class Index extends Component { ...@@ -36,11 +39,14 @@ class Index extends Component {
constructor(props: IProps) { constructor(props: IProps) {
super(props); super(props);
this.state = {
errorText: '',
};
} }
componentWillMount() { componentWillMount() {
Taro.showLoading(); Taro.showLoading();
this.checkUser(); this.loginHandle();
} }
checkUser() { checkUser() {
...@@ -49,7 +55,6 @@ class Index extends Component { ...@@ -49,7 +55,6 @@ class Index extends Component {
}) })
.then(res => { .then(res => {
const data = res.data; const data = res.data;
const userInfo = Taro.getStorageSync('userInfo');
console.log('token ' + data); console.log('token ' + data);
}) })
.catch(() => { .catch(() => {
...@@ -62,20 +67,24 @@ class Index extends Component { ...@@ -62,20 +67,24 @@ class Index extends Component {
Taro.login() Taro.login()
.then(res => { .then(res => {
console.log(res); console.log(res);
login({ appLogin({
code: res.code, code: res.code,
}) })
.then((res: LoginReponse) => { .then((res: LoginReponse) => {
const { registed, token } = res.data; const { register, wxToken, ...userInfo } = res.data;
if (registed) { console.log(wxToken);
Taro.setStorage({ key: 'token', data: token });
Taro.setStorage({ key: 'userInfo', data: token }); if (register) {
updateUserInfo({
...userInfo,
token: wxToken,
});
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/Home/Home', url: '/pages/Home/Home',
}); });
} else { } else {
updateUserInfo({ updateUserInfo({
token: token, token: wxToken,
}); });
Taro.hideLoading(); Taro.hideLoading();
Taro.redirectTo({ Taro.redirectTo({
...@@ -85,6 +94,9 @@ class Index extends Component { ...@@ -85,6 +94,9 @@ class Index extends Component {
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
this.setState({
errorText: err.msg,
});
}); });
}) })
.catch(err => { .catch(err => {
...@@ -93,7 +105,8 @@ class Index extends Component { ...@@ -93,7 +105,8 @@ class Index extends Component {
} }
render() { render() {
return <View className='Index' />; const { errorText } = this.state;
return <View className='Index'>{errorText}</View>;
} }
} }
......
...@@ -2,13 +2,13 @@ import Action from '../../types/Store/Actions'; ...@@ -2,13 +2,13 @@ import Action from '../../types/Store/Actions';
export class UserState { export class UserState {
login?: boolean; login?: boolean;
areaId?: number; areaId: number;
areaName?: string; areaName?: string;
birthDay?: string; birthDay?: string;
createAt?: string; createAt?: string;
createLoginDate?: string; createLoginDate?: string;
customerHead?: string; customerHead?: string;
customerId?: number; customerId: number;
customerName?: string; customerName?: string;
customerPhone?: string; customerPhone?: string;
customerSex?: string; customerSex?: string;
...@@ -19,7 +19,7 @@ export class UserState { ...@@ -19,7 +19,7 @@ export class UserState {
hardwarePwd?: string; hardwarePwd?: string;
hardwareState?: string; hardwareState?: string;
hardwarelastDate?: string; hardwarelastDate?: string;
idBar?: string; idBar: string;
idCard?: string; idCard?: string;
isFirstRecharge?: number; isFirstRecharge?: number;
lastLoginDate?: string; lastLoginDate?: string;
......
type Order = { type Order = {
actualMoney: Number; actualMoney: number;
areaId: Number; areaId: number;
areaName: String; areaName: string;
consumeType: String; consumeType: string;
createAt: String; createAt: string;
customerCellphone: String; customerCellphone: string;
customerId: Number; customerId: number;
customerName: String; customerName: string;
deductionBean: Number; deductionBean: number;
deductionMoney: Number; deductionMoney: number;
equipmentNum: String; equipmentNum: string;
equipmentPosition: String; equipmentPosition: string;
id: Number; id: number;
operateId: Number; operateId: number;
operateName: String; operateName: string;
operationMode: String; operationMode: string;
orderNumber: String; orderNumber: string;
orderState: String; orderState: string;
outTradeNo: String; outTradeNo: string;
payType: String; payType: string;
payableMoney: Number; payableMoney: number;
serviceId: Number; serviceId: number;
serviceName: String; serviceName: string;
thirdDiscountMoney: Number; thirdDiscountMoney: number;
thirdTradeNumber: String; thirdTradeNumber: string;
updateDate: String; updateDate: string;
};
export type AllOrderItem = {
groupName: string;
data: Order[];
}; };
export default Order; export default Order;
/**
* 1:线下支付 2:微信支付 3 :支付宝支付 4:京东支付 5:招行一网通支付 6:艾米币 7:专用豆 8通用豆
*/
export type PayType = '' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
const payTypeList = [
{ value: '1', name: '线下支付' },
{ value: '2', name: '微信支付' },
{ value: '3', name: '支付宝支付' },
{ value: '4', name: '京东支付' },
{ value: '5', name: '招行一网通支付' },
{ value: '6', name: '艾米币' },
{ value: '7', name: '专用豆' },
{ value: '8', name: '通用豆' },
{ value: '9', name: '系统计扣' },
];
export const getPayType = (type: string) => {
let item = payTypeList.find(item => item.value === type);
return item ? item.name : '';
};
...@@ -2044,6 +2044,10 @@ crypto-browserify@^3.11.0: ...@@ -2044,6 +2044,10 @@ crypto-browserify@^3.11.0:
randombytes "^2.0.0" randombytes "^2.0.0"
randomfill "^1.0.3" randomfill "^1.0.3"
crypto-js@^3.1.9-1:
version "3.1.9-1"
resolved "http://registry.npm.taobao.org/crypto-js/download/crypto-js-3.1.9-1.tgz#fda19e761fc077e01ffbfdc6e9fdfc59e8806cd8"
crypto-random-string@^1.0.0: crypto-random-string@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "http://registry.npm.taobao.org/crypto-random-string/download/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" resolved "http://registry.npm.taobao.org/crypto-random-string/download/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
...@@ -2179,7 +2183,7 @@ debug@^3.1.0, debug@^3.2.5, debug@^3.2.6: ...@@ -2179,7 +2183,7 @@ debug@^3.1.0, debug@^3.2.5, debug@^3.2.6:
dependencies: dependencies:
ms "^2.1.1" ms "^2.1.1"
debuglog@*, debuglog@^1.0.1: debuglog@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "http://registry.npm.taobao.org/debuglog/download/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" resolved "http://registry.npm.taobao.org/debuglog/download/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
...@@ -3555,7 +3559,7 @@ import-local@^2.0.0: ...@@ -3555,7 +3559,7 @@ import-local@^2.0.0:
pkg-dir "^3.0.0" pkg-dir "^3.0.0"
resolve-cwd "^2.0.0" resolve-cwd "^2.0.0"
imurmurhash@*, imurmurhash@^0.1.4: imurmurhash@^0.1.4:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
...@@ -4131,7 +4135,7 @@ libnpm@^2.0.1: ...@@ -4131,7 +4135,7 @@ libnpm@^2.0.1:
read-package-json "^2.0.13" read-package-json "^2.0.13"
stringify-package "^1.0.0" stringify-package "^1.0.0"
libnpmaccess@*, libnpmaccess@^3.0.1: libnpmaccess@^3.0.1:
version "3.0.1" version "3.0.1"
resolved "http://registry.npm.taobao.org/libnpmaccess/download/libnpmaccess-3.0.1.tgz#5b3a9de621f293d425191aa2e779102f84167fa8" resolved "http://registry.npm.taobao.org/libnpmaccess/download/libnpmaccess-3.0.1.tgz#5b3a9de621f293d425191aa2e779102f84167fa8"
dependencies: dependencies:
...@@ -4157,7 +4161,7 @@ libnpmhook@^5.0.2: ...@@ -4157,7 +4161,7 @@ libnpmhook@^5.0.2:
get-stream "^4.0.0" get-stream "^4.0.0"
npm-registry-fetch "^3.8.0" npm-registry-fetch "^3.8.0"
libnpmorg@*, libnpmorg@^1.0.0: libnpmorg@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "http://registry.npm.taobao.org/libnpmorg/download/libnpmorg-1.0.0.tgz#979b868c48ba28c5820e3bb9d9e73c883c16a232" resolved "http://registry.npm.taobao.org/libnpmorg/download/libnpmorg-1.0.0.tgz#979b868c48ba28c5820e3bb9d9e73c883c16a232"
dependencies: dependencies:
...@@ -4180,7 +4184,7 @@ libnpmpublish@^1.1.0: ...@@ -4180,7 +4184,7 @@ libnpmpublish@^1.1.0:
semver "^5.5.1" semver "^5.5.1"
ssri "^6.0.1" ssri "^6.0.1"
libnpmsearch@*, libnpmsearch@^2.0.0: libnpmsearch@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "http://registry.npm.taobao.org/libnpmsearch/download/libnpmsearch-2.0.0.tgz#de05af47ada81554a5f64276a69599070d4a5685" resolved "http://registry.npm.taobao.org/libnpmsearch/download/libnpmsearch-2.0.0.tgz#de05af47ada81554a5f64276a69599070d4a5685"
dependencies: dependencies:
...@@ -4188,7 +4192,7 @@ libnpmsearch@*, libnpmsearch@^2.0.0: ...@@ -4188,7 +4192,7 @@ libnpmsearch@*, libnpmsearch@^2.0.0:
get-stream "^4.0.0" get-stream "^4.0.0"
npm-registry-fetch "^3.8.0" npm-registry-fetch "^3.8.0"
libnpmteam@*, libnpmteam@^1.0.1: libnpmteam@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "http://registry.npm.taobao.org/libnpmteam/download/libnpmteam-1.0.1.tgz#ff704b1b6c06ea674b3b1101ac3e305f5114f213" resolved "http://registry.npm.taobao.org/libnpmteam/download/libnpmteam-1.0.1.tgz#ff704b1b6c06ea674b3b1101ac3e305f5114f213"
dependencies: dependencies:
...@@ -4288,10 +4292,6 @@ lodash._basecopy@^3.0.0: ...@@ -4288,10 +4292,6 @@ lodash._basecopy@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
lodash._baseindexof@*:
version "3.1.0"
resolved "http://registry.npm.taobao.org/lodash._baseindexof/download/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
lodash._baseuniq@~4.6.0: lodash._baseuniq@~4.6.0:
version "4.6.0" version "4.6.0"
resolved "http://registry.npm.taobao.org/lodash._baseuniq/download/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" resolved "http://registry.npm.taobao.org/lodash._baseuniq/download/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
...@@ -4299,14 +4299,10 @@ lodash._baseuniq@~4.6.0: ...@@ -4299,14 +4299,10 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0" lodash._createset "~4.0.0"
lodash._root "~3.0.0" lodash._root "~3.0.0"
lodash._bindcallback@*, lodash._bindcallback@^3.0.0: lodash._bindcallback@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "http://registry.npm.taobao.org/lodash._bindcallback/download/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" resolved "http://registry.npm.taobao.org/lodash._bindcallback/download/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
lodash._cacheindexof@*:
version "3.0.2"
resolved "http://registry.npm.taobao.org/lodash._cacheindexof/download/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
lodash._createassigner@^3.0.0: lodash._createassigner@^3.0.0:
version "3.1.1" version "3.1.1"
resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11"
...@@ -4315,17 +4311,11 @@ lodash._createassigner@^3.0.0: ...@@ -4315,17 +4311,11 @@ lodash._createassigner@^3.0.0:
lodash._isiterateecall "^3.0.0" lodash._isiterateecall "^3.0.0"
lodash.restparam "^3.0.0" lodash.restparam "^3.0.0"
lodash._createcache@*:
version "3.1.2"
resolved "http://registry.npm.taobao.org/lodash._createcache/download/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0: lodash._createset@~4.0.0:
version "4.0.3" version "4.0.3"
resolved "http://registry.npm.taobao.org/lodash._createset/download/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" resolved "http://registry.npm.taobao.org/lodash._createset/download/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
lodash._getnative@*, lodash._getnative@^3.0.0: lodash._getnative@^3.0.0:
version "3.9.1" version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
...@@ -4388,7 +4378,7 @@ lodash.mergewith@^4.6.0: ...@@ -4388,7 +4378,7 @@ lodash.mergewith@^4.6.0:
version "4.6.1" version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927" resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
lodash.restparam@*, lodash.restparam@^3.0.0: lodash.restparam@^3.0.0:
version "3.6.1" version "3.6.1"
resolved "http://registry.npm.taobao.org/lodash.restparam/download/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" resolved "http://registry.npm.taobao.org/lodash.restparam/download/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
...@@ -5045,7 +5035,7 @@ npm-pick-manifest@^2.2.3: ...@@ -5045,7 +5035,7 @@ npm-pick-manifest@^2.2.3:
npm-package-arg "^6.0.0" npm-package-arg "^6.0.0"
semver "^5.4.1" semver "^5.4.1"
npm-profile@*, npm-profile@^4.0.1: npm-profile@^4.0.1:
version "4.0.1" version "4.0.1"
resolved "http://registry.npm.taobao.org/npm-profile/download/npm-profile-4.0.1.tgz#d350f7a5e6b60691c7168fbb8392c3603583f5aa" resolved "http://registry.npm.taobao.org/npm-profile/download/npm-profile-4.0.1.tgz#d350f7a5e6b60691c7168fbb8392c3603583f5aa"
dependencies: dependencies:
...@@ -6047,7 +6037,7 @@ readable-stream@~1.1.10: ...@@ -6047,7 +6037,7 @@ readable-stream@~1.1.10:
isarray "0.0.1" isarray "0.0.1"
string_decoder "~0.10.x" string_decoder "~0.10.x"
readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0: readdir-scoped-modules@^1.0.0:
version "1.0.2" version "1.0.2"
resolved "http://registry.npm.taobao.org/readdir-scoped-modules/download/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747" resolved "http://registry.npm.taobao.org/readdir-scoped-modules/download/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
dependencies: dependencies:
......
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