Commit bb2c94dd by 姜雷

修改测试环境地址

parents 0a44ce3a d6447b62
{
"name": "wx-school-app",
"version": "1.0.6",
"private": true,
"description": "",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.2.13",
"@tarojs/components": "1.2.13",
"@tarojs/redux": "1.2.13",
"@tarojs/redux-h5": "1.2.13",
"@tarojs/router": "1.2.13",
"@tarojs/taro": "1.2.13",
"@tarojs/taro-alipay": "1.2.13",
"@tarojs/taro-h5": "1.2.13",
"@tarojs/taro-swan": "1.2.13",
"@tarojs/taro-tt": "1.2.13",
"@tarojs/taro-weapp": "1.2.13",
"crypto-js": "^3.1.9-1",
"jsbarcode": "^3.11.0",
"nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9",
"npm": "^6.8.0",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"wxbarcode": "^1.0.2"
},
"devDependencies": {
"@tarojs/cli": "^1.2.13",
"@tarojs/plugin-babel": "1.2.13",
"@tarojs/plugin-csso": "1.2.13",
"@tarojs/plugin-sass": "1.2.13",
"@tarojs/plugin-uglifyjs": "1.2.13",
"@tarojs/webpack-runner": "1.2.13",
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-config-taro": "1.2.13",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.2.13",
"eslint-plugin-typescript": "^0.12.0",
"typescript": "^3.0.1"
}
"name": "wx-school-app",
"version": "1.0.6",
"private": true,
"description": "",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.3.4",
"@tarojs/components": "1.3.4",
"@tarojs/redux": "1.3.4",
"@tarojs/redux-h5": "1.3.4",
"@tarojs/router": "1.3.4",
"@tarojs/taro": "1.3.4",
"@tarojs/taro-alipay": "1.3.4",
"@tarojs/taro-h5": "1.3.4",
"@tarojs/taro-swan": "1.3.4",
"@tarojs/taro-tt": "1.3.4",
"@tarojs/taro-weapp": "1.3.4",
"crypto-js": "^3.1.9-1",
"jsbarcode": "^3.11.0",
"nerv-devtools": "^1.4.3",
"nervjs": "^1.4.3",
"npm": "^6.8.0",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"wxbarcode": "^1.0.2"
},
"devDependencies": {
"@tarojs/plugin-babel": "1.3.4",
"@tarojs/plugin-csso": "1.3.4",
"@tarojs/plugin-sass": "1.3.4",
"@tarojs/plugin-uglifyjs": "1.3.4",
"@tarojs/webpack-runner": "1.3.4",
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-config-taro": "1.3.4",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.3.4",
"eslint-plugin-typescript": "^0.12.0",
"typescript": "^3.0.1"
}
}
import { ResponseDataEntity, baseFetch, customerFetch } from './index';
import { number } from 'prop-types';
export type PayConfigParams = {
areaId: number;
customerId: number;
};
export type PayTypeVo = {
/** id */
id: number;
/** name */
name: string;
};
export type PayConfig = {
id: number;
giveId: number; //赠送服务id
giveMoney: number; // 赠送金额
giveName: string; // 赠送服务名称
rechargeMoney: number; // 充值金额
};
type PayConfigResponse = {
isFirstRecharge: number;
listPayList: PayTypeVo[];
listRechargeConfDetail: PayConfig[];
};
export const fetchPayConfig = (
params: PayConfigParams,
): Promise<ResponseDataEntity<PayConfigResponse>> =>
baseFetch({
url: '/dcxy/api/paymentAndActiveConf/getRechargeConf',
data: params,
});
type RechargeOrderParams = {
customerId: number;
id: number;
isFirstRecharge: number;
rechargeType: string;
};
export const rechargeOrder = (
params: RechargeOrderParams,
): Promise<{
canCall: number;
code: number;
msg: string;
outTradeNo: string;
payStr: string;
}> =>
customerFetch({
url: '/dcxy/app/rechargeOrder/rechargeOrder/smallProPay',
method: 'POST',
data: params,
});
......@@ -41,6 +41,7 @@ class App extends Component {
'pages/WebPage/WebPage',
'pages/Shower/Shower',
'pages/WaterDispenser/WaterDispenser',
'pages/Account/Account',
],
window: {
backgroundTextStyle: 'light',
......
import { useEffect, useState } from '@tarojs/taro';
import { fetchBeanCount } from '@/api/bean';
import { CustomerBeanAccountVo } from '@/api/baseClass';
import { Service } from '@/api/home';
import { Customer } from '@/types/Customer/Customer';
export enum BeanType {
aimi = 'aimi',
common = 'common',
shower = 'shower',
hairDryer = 'hairDryer',
water = 'water',
}
type BeanAccount = {
money: number;
serviceId: string;
};
let initBeanList: BeanAccount[] = [];
const useAllBeanCount = (
userinfo: Customer,
serviceList: Service[],
): [BeanAccount[], (userinfo: Customer) => void] => {
const [filterBeanList, setFilterBeanList] = useState(initBeanList);
const getFilterBeanList = (
beanAccount: CustomerBeanAccountVo[],
): BeanAccount[] => {
let aimiItem = beanAccount.find(item => item.serviceId === '0');
let cfItem = beanAccount.find(
item => item.serviceId === '4' || item.serviceId === '12',
);
let xyItem = beanAccount.find(
item => item.serviceId === '5' || item.serviceId === '10',
);
let ysItem = beanAccount.find(
item =>
item.serviceId === '3' ||
item.serviceId === '11' ||
item.serviceId === '9',
);
let commonItem = beanAccount.find(item => item.serviceId === '0');
let beanMap = {
[BeanType.aimi]: aimiItem ? aimiItem.money : 0,
[BeanType.common]: commonItem ? commonItem.money : 0,
};
for (let index = 0; index < serviceList.length; index++) {
const service = serviceList[index];
if (
service.serviceId === 3 ||
service.serviceId === 11 ||
service.serviceId === 9
) {
beanMap[BeanType.water] = ysItem ? ysItem.money : 0;
} else if (service.serviceId === 4 || service.serviceId === 12) {
beanMap[BeanType.hairDryer] = cfItem ? cfItem.money : 0;
} else if (service.serviceId === 5 || service.serviceId === 10) {
beanMap[BeanType.shower] = xyItem ? xyItem.money : 0;
}
}
let arr: BeanAccount[] = Object.keys(beanMap).map(k => ({
serviceId: k,
money: beanMap[k],
}));
return arr;
};
const fetchDate = (userinfo: Customer) => {
fetchBeanCount({
id: userinfo.customerId,
areaId: userinfo.areaId,
customerPhone: userinfo.customerPhone,
serviceIdList: [],
})
.then(res => {
const data = res.data;
let list = getFilterBeanList(data);
setFilterBeanList(list);
})
.catch(console.error);
};
useEffect(() => {
fetchDate(userinfo);
}, [userinfo]);
return [filterBeanList, fetchDate];
};
export default useAllBeanCount;
import { useState, useEffect } from '@tarojs/taro';
import { fetchPayConfig, PayConfig, PayTypeVo } from '@/api/account';
let initPayConfigList: PayConfig[] = [];
let initPaywayList: PayTypeVo[] = [];
const usePaywayList = (areaId: number, customerId: number) => {
const [paywayList, setPaywayList] = useState(initPaywayList);
const [payConfigList, setPayConfigList] = useState(initPayConfigList);
const [isFirstRecharge, setIsFirstRecharge] = useState(0);
const fetchDate = (areaId: number, customerId: number) => {
fetchPayConfig({
areaId,
customerId,
})
.then(res => {
console.log(res);
const {
isFirstRecharge,
listPayList,
listRechargeConfDetail,
} = res.data;
setPayConfigList(listRechargeConfDetail);
setPaywayList(listPayList);
setIsFirstRecharge(isFirstRecharge);
})
.catch(console.error);
};
useEffect(() => {
fetchDate(areaId, customerId);
}, [areaId, customerId]);
return {
isFirstRecharge,
paywayList,
payConfigList,
};
};
export default usePaywayList;
import { Customer } from '@/types/Customer/Customer';
import { useEffect, useState } from '@tarojs/taro';
import { fetchPayOrder, fetchOrderDetailAndPay } from '@/api/order';
const useWaitPayOrderState = (userinfo: Customer) => {
const [payOrderState, setPayOrderState] = useState(false);
const [accountList, setAccountList] = useState([]);
const [orderInfo, setOrderInfo] = useState(null);
const [payInfos, setPayInfos] = useState(null);
useEffect(() => {
fetchPayOrder({
customerId: userinfo.customerId,
})
.then(res => {
if (res.data.length) {
fetchOrderDetailAndPay({ id: res.data[0].id })
.then(({ accounts, orderInfo, payInfos }) => {
setAccountList(accounts);
setOrderInfo(orderInfo);
setPayInfos(payInfos);
})
.catch(err => {
console.log(err);
});
setPayOrderState(true);
}
})
.catch(err => {
console.log(err);
});
}, [userinfo]);
return {
payOrderState,
accountList,
orderInfo,
payInfos,
};
};
export default useWaitPayOrderState;
.Account {
.Account-Card-warp {
padding: 40px 32px;
border-bottom: 1px solid #eee;
.Account-Card {
position: relative;
height: 360px;
.Account-Card-Aimi {
padding: 60px 80px 36px;
color: #fff;
.Account-Card-Aimi-label {
font-size: 24px;
margin-bottom: 16px;
}
.Account-Card-Aimi-num {
font-size: 44px;
}
}
.Account-line {
width: 252px;
border-bottom: 1px solid #b5bffa;
margin-left: 40px;
}
.Account-Card-Bean {
padding: 30px 40px 0;
display: flex;
flex-flow: wrap;
font-size: 24px;
color: #fff;
.Account-Card-BeanItem {
width: 40%;
display: flex;
align-items: center;
margin: 0 5% 16px;
.Account-Card-BeanIcon {
width: 24px;
height: 24px;
margin-right: 16px;
}
.Account-Card-BeanCount {
width: 105px;
font-size: 28px;
}
}
}
}
}
.Account-Money {
padding: 60px 32px 20px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.Account-Money-Item {
box-sizing: border-box;
width: 218px;
height: 160px;
line-height: 160px;
text-align: center;
border: 4px solid #e6ebfd;
border-radius: 24px;
margin-bottom: 20px;
&.selected {
background-color: #6180f4;
border-color: #6180f4;
color: #fff;
}
}
}
.Account-Payway {
padding: 0 32px;
.Account-Payway-Item {
display: flex;
align-items: center;
.Account-Payway-Item-icon {
width: 56px;
height: 56px;
margin-right: 20px;
}
.Account-Payway-Item-name {
flex: 1;
}
.Account-Payway-Item-state {
width: 40px;
height: 40px;
margin-right: 18px;
}
}
}
.Account-Paybtn {
margin: 60px 32px 0;
}
}
import './Account.scss';
import AccountCardBg from '../../images/account/bg_zhanghu@2x.png';
import TBeanIcon from '../../images/home/icon_tongyongdou@2x.png';
import HBeanIcon from '../../images/home/icon_chuifengdou@2x.png';
import WBeanIcon from '../../images/home/ic_yinshui@2x.png';
import SBeanIcon from '../../images/home/ic_xiyu@2x.png';
import WechatIcon from '../../images/payway/img_wechat@2x.png';
import PaySelectedIcon from '../../images/payway/pc_sel_icon@2x.png';
import radioIcon from '../../images/login/pc_nor_icon@2x.png';
import { View, Button, Image, Text } from '@tarojs/components';
import Taro, { useState } from '@tarojs/taro';
import { useSelector } from '@tarojs/redux';
import { Customer } from '@/types/Customer/Customer';
import { Service } from '@/api/home';
import useRechargePay from '@/hooks/useRechargePay';
import useAllBeanCount, { BeanType } from '@/hooks/useAllBeanCount';
import { rechargeOrder } from '@/api/account';
import AES from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
import ECBmode from 'crypto-js/mode-ecb';
import PaddingPkcs7 from 'crypto-js/pad-pkcs7';
enum PaywayCode {
wx = 2,
}
export const AccountComponent = () => {
const [payConfigId, setPayConfigId] = useState(0);
const [paywayId, setPaywayId] = useState(PaywayCode.wx);
const userinfo = useSelector(
(state: { userinfo: Customer }) => state.userinfo,
);
const serviceList = useSelector(
(state: { serviceList: Service[] }) => state.serviceList,
);
const { paywayList, payConfigList, isFirstRecharge } = useRechargePay(
userinfo.areaId,
userinfo.customerId,
);
const [filterBeanList, fetchNewBeanList] = useAllBeanCount(
userinfo,
serviceList,
);
const clickPayBtn = () => {
if (!payConfigId) {
Taro.showToast({
title: '请选择充值金额',
icon: 'none',
});
return;
}
if (!paywayId) {
Taro.showToast({
title: '请选择支付方式',
icon: 'none',
});
return;
}
console.log('in recharge');
rechargeOrder({
id: payConfigId,
customerId: userinfo.customerId,
isFirstRecharge: isFirstRecharge,
rechargeType: paywayId.toString(),
})
.then(res => {
const { canCall, payStr } = res;
console.log(res);
if (canCall) {
if (payStr) {
const key = userinfo.customerId.toString().padEnd(16, '0');
const payData = JSON.parse(
AES.decrypt(payStr, Utf8.parse(key), {
mode: ECBmode,
padding: PaddingPkcs7,
}).toString(Utf8),
);
console.log(payData);
Taro.requestPayment({
timeStamp: payData.msg.timeStamp.toString(),
nonceStr: payData.msg.nonceStr,
package: payData.msg.package,
signType: payData.msg.signType,
paySign: payData.msg.paySign,
})
.then(res => {
console.log(res);
fetchNewBeanList(userinfo);
})
.catch(err => {
Taro.showToast({
title: err.msg || '发起支付失败',
icon: 'none',
});
});
}
} else {
Taro.showToast({
title: res.msg,
icon: 'none',
});
}
})
.catch(err => {
Taro.showToast({
title: err.msg || '呼起失败!',
icon: 'none',
});
});
};
return (
<View className='Account'>
<View className='Account-Card-warp'>
<View className='Account-Card'>
<Image className='bg' src={AccountCardBg} />
<View className='Account-Card-Aimi'>
<View className='Account-Card-Aimi-label'>艾米余额</View>
{filterBeanList.length &&
filterBeanList.map(beanItem =>
beanItem.serviceId === BeanType.aimi ? (
<View
key={beanItem.serviceId}
className='Account-Card-Aimi-num'>
{beanItem.money.toFixed(2)}
</View>
) : null,
)}
</View>
<View className='Account-line' />
<View className='Account-Card-Bean'>
{filterBeanList.length &&
filterBeanList.map(beanItem =>
beanItem.serviceId === BeanType.common ? (
<View
key={beanItem.serviceId}
className='Account-Card-BeanItem'>
<Image className='Account-Card-BeanIcon' src={TBeanIcon} />
<Text>通用豆:</Text>
<Text className='Account-Card-BeanCount'>
{beanItem.money ? beanItem.money.toFixed(2) : '0.00'}
</Text>
</View>
) : beanItem.serviceId === BeanType.water ? (
<View
key={beanItem.serviceId}
className='Account-Card-BeanItem'>
<Image className='Account-Card-BeanIcon' src={WBeanIcon} />
<Text>饮水豆:</Text>
<Text className='Account-Card-BeanCount'>
{beanItem.money ? beanItem.money.toFixed(2) : '0.00'}
</Text>
</View>
) : beanItem.serviceId === BeanType.hairDryer ? (
<View
key={beanItem.serviceId}
className='Account-Card-BeanItem'>
<Image className='Account-Card-BeanIcon' src={HBeanIcon} />
<Text>吹风豆:</Text>
<Text className='Account-Card-BeanCount'>
{beanItem.money ? beanItem.money.toFixed(2) : '0.00'}
</Text>
</View>
) : beanItem.serviceId === BeanType.shower ? (
<View
key={beanItem.serviceId}
className='Account-Card-BeanItem'>
<Image className='Account-Card-BeanIcon' src={SBeanIcon} />
<Text>洗浴豆:</Text>
<Text className='Account-Card-BeanCount'>
{beanItem.money ? beanItem.money.toFixed(2) : '0.00'}
</Text>
</View>
) : null,
)}
</View>
</View>
</View>
<View className='Account-Money'>
{payConfigList.map(item => (
<View
key={item.id}
className={`Account-Money-Item ${
payConfigId === item.id ? 'selected' : ''
}`}
onClick={() => setPayConfigId(item.id)}>
{item.rechargeMoney.toFixed(2)}
</View>
))}
</View>
<View className='Account-Payway'>
{paywayList.map(item =>
item.id === 2 ? (
<View
key={item.id}
className='Account-Payway-Item'
onClick={() => setPaywayId(item.id)}>
<Image className='Account-Payway-Item-icon' src={WechatIcon} />
<View className='Account-Payway-Item-name'>{item.name}</View>
{paywayId === item.id ? (
<Image
className='Account-Payway-Item-state'
src={PaySelectedIcon}
/>
) : (
<Image className='Account-Payway-Item-state' src={radioIcon} />
)}
</View>
) : null,
)}
</View>
<Button className='Account-Paybtn' onClick={clickPayBtn}>
确定充值
</Button>
</View>
);
};
......@@ -30,77 +30,60 @@
.Home-UserBox {
position: relative;
// height: 390px;
padding: 0 0 40px;
margin: 0 32px;
height: 320px;
padding: 0 32px;
// margin: 0 32px;
box-sizing: content-box;
.bg {
height: 390px;
&.big {
height: 428px;
background-color: #eee;
.Home-UserBox-content {
position: relative;
width: 100%;
height: 100%;
z-index: 0;
overflow: hidden;
.bg {
height: 390px;
}
}
.Home-UserBox-Setting {
position: absolute;
right: 28px;
top: 22px;
width: 38px;
height: 38px;
}
.Home-UserBox-info {
padding: 80px 88px 20px 76px;
display: flex;
justify-content: space-between;
color: #333;
}
.Home-UserBox-name {
font-size: 44px;
margin-bottom: 8px;
}
.Home-UserBox-tel {
font-size: 32px;
margin-bottom: 8px;
}
.Home-UserBox-addr {
font-size: 24px;
}
.Home-UserBox-headimg {
width: 100px;
height: 100px;
border-radius: 50%;
border: 10px solid #c8ccfc;
}
.Home-UserBox-line {
width: 620px;
border-top: 1px solid #d7daff;
margin: 0 auto;
}
.Home-UserBox-Bean {
padding: 32px 40px 70px;
display: flex;
flex-flow: wrap;
font-size: 24px;
color: #666;
.Home-UserBox-BeanItem {
width: 40%;
.Home-UserBox-Setting {
position: absolute;
right: 28px;
top: 22px;
width: 38px;
height: 38px;
}
.Home-UserBox-info {
padding: 80px 88px 20px 76px;
display: flex;
align-items: center;
margin: 0 5%;
justify-content: space-between;
color: #333;
}
.Home-UserBox-BeanIcon {
width: 24px;
height: 24px;
margin-right: 12px;
.Home-UserBox-name {
font-size: 44px;
margin-bottom: 8px;
}
.Home-UserBox-BeanCount {
font-size: 28px;
color: #333;
.Home-UserBox-tel {
font-size: 32px;
margin-bottom: 8px;
}
.Home-UserBox-addr {
font-size: 24px;
}
.Home-UserBox-headimg {
width: 100px;
height: 100px;
border-radius: 50%;
border: 10px solid #c8ccfc;
}
.Home-UserBox-line {
width: 620px;
border-top: 1px solid #d7daff;
margin: 0 auto;
}
}
.Home-UserBox-Order {
position: absolute;
left: 50%;
bottom: 0px;
bottom: -40px;
transform: translate(-50%);
width: 572px;
height: 80px;
......@@ -109,41 +92,43 @@
border-radius: 50px;
display: flex;
overflow: hidden;
}
.Home-UserBox-Order-text {
flex: 1;
text-align: center;
color: #fff;
font-size: 24px;
}
.Home-UserBox-Order-right {
background-color: #375ef1;
width: 212px;
display: flex;
justify-content: center;
align-items: center;
}
.Home-UserBox-Order-icon {
width: 40px;
height: 20px;
.Home-UserBox-Order-text {
position: relative;
flex: 1;
text-align: center;
color: #fff;
font-size: 24px;
&:first-child::after {
content: ' ';
position: absolute;
height: 44px;
width: 1px;
background-color: #abbcf9;
right: 0;
top: 18px;
}
}
}
}
.Home-Service-List {
display: flex;
flex-flow: wrap;
justify-content: space-between;
.Home-Service {
padding-top: 40px;
.Home-Service-List {
margin-top: 20px;
}
&.normal,
&.block {
padding: 0 32px;
margin: 20px auto;
}
&.big {
width: 686px;
margin: 20px auto 0;
display: flex;
flex-flow: wrap;
justify-content: space-between;
.Home-Service-List {
margin-top: 20px;
}
&.normal,
&.block {
padding: 0 32px;
margin: 20px auto;
}
&.big {
width: 686px;
margin: 20px auto 0;
}
}
}
.Home-Announcement {
......
......@@ -238,7 +238,7 @@ class OrderList extends Component {
/>
))
: allList.map((allItem, index) => (
<View key={index} className='OrderList-Group'>
<View key={allItem.groupName} className='OrderList-Group'>
<View className='OrderList-GroupTitle'>
<View className='OrderList-GroupName'>
{allItem.groupName}
......
......@@ -29,6 +29,10 @@ import OrderTitle from '../Order/components/OrderTitle/OrderTitle';
import OrderInfo from '../Order/components/OrderInfo/OrderInfo';
import OrderPayway from '../Order/components/OrderPayway/OrderPayway';
enum BlueToothError {
BlueToothNotOpen = 'BlueToothNotOpen',
}
type DeviceInfo = {
deviceId: string;
uuid: string;
......@@ -392,7 +396,7 @@ class Shower extends Component {
}
warnBluetoothOpen() {
Taro.showModal({
return Taro.showModal({
title: '警告',
content: '为保障正常使用,请打开蓝牙功能',
});
......@@ -448,10 +452,12 @@ class Shower extends Component {
if (isOnlyBluetooth) {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
}, 10000);
} else {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
}, 5000);
}
Taro.onBluetoothDeviceFound(res => {
......@@ -478,8 +484,24 @@ class Shower extends Component {
});
} else {
Taro.hideLoading();
this.warnBluetoothOpen();
throw '未开启蓝牙';
return this.warnBluetoothOpen().then(res => {
if (res.confirm) {
const { isOnlyBluetooth } = this.props.bluetoothDevice;
if (!isOnlyBluetooth) {
Taro.showLoading({
title: '开启中',
mask: true,
});
return new Promise((resolve, reject) => {
setTimeout(() => {
this.sendStartShower();
reject();
}, 5000);
});
}
}
throw BlueToothError.BlueToothNotOpen;
});
}
}
......
......@@ -284,11 +284,11 @@ class WaterDispenser extends Component {
});
}
getSelectedEquipment(data: DeviceInfo) {
getSelectedEquipment = (data: DeviceInfo) => {
this.setState({
deviceInfo: data,
});
}
};
waterBeginning() {
Taro.showLoading();
......
......@@ -2,9 +2,11 @@ import { combineReducers } from 'redux';
import userinfo from './rootReducers/userinfo';
import OrderList from '../pages/Order/OrderList/store';
import ShowerReducer from '@/pages/Shower/store';
import serviceList from './rootReducers/service';
export default combineReducers({
userinfo,
OrderList,
Shower: ShowerReducer,
serviceList,
});
import Action from '../../types/Store/Actions';
import { Service } from '@/api/home';
const INITIAL_STATE: Service[] = [];
export type ServiceState = StoreState<{ list: Service[] }>;
export const updateServiceList = (entity: Service[]): Action => ({
type: 'UPDATE_SERVICE_LIST',
payload: entity,
});
export default function serviceList(
state: Service[] = INITIAL_STATE,
actions: Action,
): Service[] {
switch (actions.type) {
case 'UPDATE_SERVICE_LIST':
return actions.payload;
default:
return state;
}
}
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