Commit e72c7a08 by 姜雷

添加蓝牙洗浴

parent 70b1cac5
import { baseFetch, ResponseDataEntity } from './index';
import { ResponseDataEntity, smaproFetch } from './index';
export type Area = {
id: number;
......@@ -7,6 +7,6 @@ export type Area = {
};
export const fetchAllArea = (): Promise<ResponseDataEntity<Area[]>> =>
baseFetch({
url: '/area/queryAccessAreaList',
smaproFetch({
url: '/smpro/areaConfigs',
});
import { ResponseDataEntity, smaproFetch } from './index';
export enum ServiceTypeParams {
wechatPublicV = 1,
wechatAppV = 2,
aliPublicV = 3,
aliAppV = 4,
}
export type ServiceParams = {
areaId: number;
type: ServiceTypeParams;
};
export type Service = {
serviceId: number;
serviceName: string;
};
export const fetchAreaService = (
data: ServiceParams,
): Promise<ResponseDataEntity<Service[]>> =>
smaproFetch({
url: `/smpro/areaServiceConfigs/${data.areaId}/${data.type}`,
});
......@@ -8,6 +8,7 @@ import {
SuccessCode,
OLD_BASE_SERVER_URL,
SHOWER_APP_URL,
SMPRO_URL,
} from '../constants/index';
export type ResponseDataEntity<T> = {
......@@ -62,5 +63,6 @@ export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL);
export const customerFetch = createFetch(CUSTOMER_SERVER_URL);
export const schoolMainFetch = createFetch(SCHOOL_MAIN_URL);
export const showerFetch = createFetch(SHOWER_APP_URL);
export const smaproFetch = createFetch(SMPRO_URL);
export default createFetch;
......@@ -42,6 +42,7 @@ type StartParams = {
*/
export const startShowerEquipment = (params: StartParams) =>
showerFetch({
url: '/dcxy/api/shower/devices/inuseByCurrentUser',
url: `/dcxy/api/shower/devices/${params.deviceCode}/beginning`,
method: 'POST',
data: params,
});
......@@ -10,9 +10,9 @@ import './app.scss';
// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释:
if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
require('nerv-devtools');
}
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
// require('nerv-devtools');
// }
class App extends Component {
/**
......
......@@ -10,5 +10,6 @@ export const CUSTOMER_SERVER_URL =
'https://ex-dev-dcxy-customer-app.168cad.top';
export const SCHOOL_MAIN_URL = 'https://internal-dev-school-main.168cad.top';
export const ANN_LINK_URL = 'https://ex-dev-wx.168cad.top/announcement/';
export const SHOWER_APP_URL = 'http://ex-shower-app-server.168cad.top';
export const SOCKET_URL = 'ws://hard-tcp-server.nat123.net:29800';
export const SHOWER_APP_URL = 'http://192.168.3.55:8888';
export const SOCKET_URL = 'ws://192.168.3.55:20003/ws';
export const SMPRO_URL = 'http://192.168.3.55:8555';
......@@ -27,6 +27,7 @@ import { fetchAnn, SectionItem } from '../../api/announcement';
import { appLogout } from '../../api/customer';
import { Customer } from '@/types/Customer/Customer';
import { shareHandle } from '@/common/shareMethod';
import { fetchAreaService, ServiceTypeParams, Service } from '@/api/home';
type PageStateProps = {
userinfo: Customer;
......@@ -40,6 +41,7 @@ type PageState = {
commBean: number;
hairDryerBean: number;
annItem: SectionItem;
serviceList: Service[];
};
type IProps = PageStateProps & PageDispatchProps;
......@@ -64,6 +66,7 @@ class Home extends Component {
barMenuVisiable: false,
commBean: 0.0,
hairDryerBean: 0.0,
serviceList: [],
annItem: {
id: 0,
styleType: '',
......@@ -90,6 +93,7 @@ class Home extends Component {
}
getInitData() {
this.getBeanCountData();
this.getServiceList();
const { userinfo } = this.props;
fetchAnn({
campusId: userinfo.areaId,
......@@ -106,6 +110,21 @@ class Home extends Component {
console.error(err);
});
}
getServiceList() {
const { userinfo } = this.props;
if (userinfo.areaId) {
fetchAreaService({
areaId: userinfo.areaId,
type: ServiceTypeParams.wechatAppV,
}).then(res => {
this.setState({
serviceList: res.data,
});
});
}
}
getBeanCountData() {
const { userinfo } = this.props;
fetchBeanCount({
......@@ -191,7 +210,13 @@ class Home extends Component {
}
render() {
const { userinfo } = this.props;
const { commBean, hairDryerBean, annItem, barMenuVisiable } = this.state;
const {
commBean,
hairDryerBean,
annItem,
barMenuVisiable,
serviceList,
} = this.state;
return (
<View className='Home'>
{barMenuVisiable ? (
......@@ -258,7 +283,13 @@ class Home extends Component {
</View>
</View>
</View>
<View className='Home-Item Home-HairDryer' onClick={this.goBarCode}>
{serviceList.map(service =>
service.serviceId === 4 || service.serviceId === 11 ? (
// 自助吹风
<View
key={service.serviceId}
className='Home-Item Home-HairDryer'
onClick={this.goBarCode}>
<Image className='bg' src={HairDryerBg} />
<View className='Home-HairDryer-shadow' />
<View className='Home-HairDryer-text'>
......@@ -266,7 +297,12 @@ class Home extends Component {
<Image className='Home-Item-arrow' src={HairDryerArr} />
</View>
</View>
<View className='Home-Item Home-Shower' onClick={this.goShower}>
) : service.serviceId === 10 || service.serviceId === 5 ? (
// 自助吹风
<View
key={service.serviceId}
className='Home-Item Home-Shower'
onClick={this.goShower}>
<Image className='bg' src={ShowerIcon} />
<View className='Home-Shower-shadow' />
<View className='Home-Shower-text'>
......@@ -274,6 +310,25 @@ class Home extends Component {
<Image className='Home-Item-arrow' src={HairDryerArr} />
</View>
</View>
) : service.serviceId === 3 || service.serviceId === 11 ? (
// 自助饮水
<View
key={service.serviceId}
className='Home-Item Home-Water'
onClick={this.goBarCode}>
<Image className='bg' src={HairDryerBg} />
<View className='Home-Water-shadow' />
<View className='Home-Water-text'>
饮水
<Image className='Home-Item-arrow' src={HairDryerArr} />
</View>
</View>
) : service.serviceId === 9 ? (
// 壁挂饮水
<View key={service.serviceId} />
) : null,
)}
{annItem.id ? (
<View className='Home-Announcement'>
<Image className='bg' src={AnnouncementBg} />
......
import Actions from '@/types/Store/Actions';
import { BluetoothDevice } from '@/types/Shower/Shower';
export const UPDATE_BLUETOOTH_DEVICE = 'UPDATE_BLUETOOTH_DEVICE';
export const UPDATE_PAY_LIST = 'UPDATE_PAY_LIST';
export const UPDATE_ALL_LIST = 'UPDATE_ALL_LIST';
export type UpdateOrderParams<T> = {
lastOrderId?: number;
list: T[];
};
export const updateBluetoothDevice = (state: BluetoothDevice): Actions => ({
type: UPDATE_BLUETOOTH_DEVICE,
payload: state,
});
import Actions from '@/types/Store/Actions';
import { BluetoothDevice } from '@/types/Shower/Shower';
import { UPDATE_BLUETOOTH_DEVICE } from './actions';
import Taro from '@tarojs/taro';
const storeKey = 'DeviceInfo';
let INITIAL_STATE = {
code: '',
isOnlyBluetooth: undefined,
position: '',
};
try {
var value = Taro.getStorageSync(storeKey);
if (value) {
INITIAL_STATE = value;
}
} catch (e) {
console.error(e);
}
export default function ShowerReducer(
state: StoreState<BluetoothDevice> = INITIAL_STATE,
actions: Actions,
) {
switch (actions.type) {
case UPDATE_BLUETOOTH_DEVICE:
Taro.setStorage({
key: storeKey,
data: actions.payload,
});
return {
...state,
...actions.payload,
};
default:
return state;
}
}
import { combineReducers } from 'redux';
import userinfo from './rootReducers/userinfo';
import OrderList from '../pages/Order/OrderList/store';
import ShowerReducer from '@/pages/Shower/store';
export default combineReducers({
userinfo,
OrderList,
Shower: ShowerReducer,
});
export type BluetoothDevice = {
code: string;
isOnlyBluetooth: number;
position: string;
};
export const ab2str = (buf: ArrayBuffer): string => {
return String.fromCharCode.apply(null, new Int8Array(buf));
};
export const str2ab = (str: string): ArrayBuffer => {
var buf = new ArrayBuffer(str.length);
var bufView = new Int8Array(buf);
for (var i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
};
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