Commit 611f7adf by 姜雷

干衣机修改

parent a38c3b9b
...@@ -19,6 +19,9 @@ type Params = { ...@@ -19,6 +19,9 @@ type Params = {
smaproPrepayConfigId: number; smaproPrepayConfigId: number;
// 预付配置id // 预付配置id
smaproPrepayConfigIds?: number[];
// 预付配置id集合,serviceId为30或者31时才需传
areaId: number; areaId: number;
// 区域id // 区域id
......
...@@ -54,9 +54,18 @@ type SmaproPrepayConfig = { ...@@ -54,9 +54,18 @@ type SmaproPrepayConfig = {
id: number; id: number;
// 会员id // 会员id
isMajor: number;
// 是否主要功能 1:主要功能;2:附加功能
isOpen: number; isOpen: number;
// 是否开启 // 是否开启
isShowRate: number;
// 是否显示费率 0:否;1:是。默认1
name: string;
// 名称
operateId: number; operateId: number;
// 运营商id // 运营商id
...@@ -77,6 +86,8 @@ type SmaproPrepayConfig = { ...@@ -77,6 +86,8 @@ type SmaproPrepayConfig = {
updateAt: string; updateAt: string;
// 更新时间 // 更新时间
duration: number;
}; };
type ResponseData = { type ResponseData = {
deviceInfoResponse: DeviceInfoResponse; deviceInfoResponse: DeviceInfoResponse;
......
...@@ -35,6 +35,9 @@ class App extends Component { ...@@ -35,6 +35,9 @@ class App extends Component {
navigationBarTitleText: 'WeChat', navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black', navigationBarTextStyle: 'black',
}, },
networkTimeout: {
connectSocket: 600000,
},
}; };
// 在 App 类中的 render() 函数没有实际作用 // 在 App 类中的 render() 函数没有实际作用
......
.Connect { .Connect {
.state {
height: 0;
overflow: hidden;
}
.Connect-title {
font-size: 34rpx;
height: 102rpx;
line-height: 102rpx;
text-align: center;
border-bottom: 1rpx dotted #f8f8f8;
}
.Connect-Pay {
border-top: 20rpx solid #f8f8f8;
padding: 0 35rpx;
.Connect-Pay-title {
padding: 40rpx 0 30rpx;
font-size: 34rpx;
border-bottom: 1rpx solid #e8e8e8;
}
.Connect-Pay-titleTip {
color: #999;
}
.Connect-Pay-content {
padding: 10rpx 0;
}
.Connect-Pay-item {
display: flex;
align-items: center;
height: 80rpx;
font-size: 28rpx;
.Connect-Pay-itemName {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.Connect-Pay-itemTime {
width: 170rpx;
text-align: right;
color: #999;
}
.Connect-Pay-itemPrice {
width: 175rpx;
text-align: right;
}
.Connect-Pay-itemSelect {
margin-left: 50rpx;
width: 40rpx;
height: 40rpx;
.Connect-Pay-itemSelecticon {
width: 40rpx;
height: 40rpx;
}
}
}
}
.Connect-info { .Connect-info {
padding: 40px 32px; padding: 40px 32px;
font-size: 28px; font-size: 28px;
...@@ -47,6 +103,11 @@ ...@@ -47,6 +103,11 @@
border-radius: 30px; border-radius: 30px;
vertical-align: middle; vertical-align: middle;
} }
.Connect-tip3 {
padding: 26rpx 48rpx;
font-size: 26rpx;
color: #ff4b4b;
}
.Connect-money { .Connect-money {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
...@@ -54,6 +115,7 @@ ...@@ -54,6 +115,7 @@
margin: 0 auto; margin: 0 auto;
.Connect-money-item { .Connect-money-item {
display: flex; display: flex;
flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
text-align: center; text-align: center;
...@@ -64,6 +126,12 @@ ...@@ -64,6 +126,12 @@
border: 1px solid #ccc; border: 1px solid #ccc;
margin-bottom: 16px; margin-bottom: 16px;
margin-right: 16px; margin-right: 16px;
.time {
font-size: 30px;
}
.money {
font-size: 36px;
}
&.seleted { &.seleted {
border-color: #6180f4; border-color: #6180f4;
color: #6180f4; color: #6180f4;
......
import Taro, { Component, Config } from '@tarojs/taro'; import Taro, { Component, Config } from '@tarojs/taro';
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { View, Text, Button, ScrollView } from '@tarojs/components'; import { View, Text, Button, ScrollView, Image } from '@tarojs/components';
import { getPayOrder } from '../../api/Order/pay'; import { getPayOrder } from '../../api/Order/pay';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { import {
...@@ -18,6 +18,10 @@ import PaddingPkcs7 from 'crypto-js/pad-pkcs7'; ...@@ -18,6 +18,10 @@ import PaddingPkcs7 from 'crypto-js/pad-pkcs7';
import './connect.scss'; import './connect.scss';
import { str2ab, ab2str } from '@/utils/arrayBuffer'; import { str2ab, ab2str } from '@/utils/arrayBuffer';
import { DRY_SOCKET_URL } from '@/constants'; import { DRY_SOCKET_URL } from '@/constants';
import selectIcon from '../../images/select_icon1@2x.png';
import selectedIcon from '../../images/selected_icon1@2x.png';
import select2Icon from '../../images/select_icon2@2x.png';
import selected2Icon from '../../images/selected_icon2@2x.png';
enum ContorlCode { enum ContorlCode {
using = '1', using = '1',
...@@ -61,6 +65,7 @@ type DeviceInfo = { ...@@ -61,6 +65,7 @@ type DeviceInfo = {
type PageStateProps = { type PageStateProps = {
device: Device; device: Device;
prepayConfig: PrepayConfig[]; prepayConfig: PrepayConfig[];
addprepayConfig: PrepayConfig[];
userinfo: Customer; userinfo: Customer;
}; };
...@@ -68,6 +73,8 @@ type PageDispatchProps = {}; ...@@ -68,6 +73,8 @@ type PageDispatchProps = {};
type PageState = { type PageState = {
payId: undefined | number; payId: undefined | number;
payIds: number[];
payMoney: number;
bluetoothState: boolean; bluetoothState: boolean;
deviceInfo: DeviceInfo; deviceInfo: DeviceInfo;
sockedDone: boolean; sockedDone: boolean;
...@@ -90,10 +97,18 @@ const StopCode = 1000; ...@@ -90,10 +97,18 @@ const StopCode = 1000;
let timer: NodeJS.Timeout | null = null; let timer: NodeJS.Timeout | null = null;
let reConnectting: boolean = false; let reConnectting: boolean = false;
let socketTask: Taro.SocketTask | null = null; let socketTask: Taro.SocketTask | null = null;
let liveTimer: NodeJS.Timeout | null = null;
let msgList: Message[] = [];
let msgindex: number = 0;
let currentThis: Connect | null = null;
@connect(({ device, prepayConfig, userinfo }) => ({ @connect(({ device, prepayConfig, userinfo }) => ({
device, device,
prepayConfig, // prepayConfig: prepayConfig,
prepayConfig: prepayConfig.filter((item: PrepayConfig) => item.isMajor === 1),
addprepayConfig: prepayConfig.filter(
(item: PrepayConfig) => item.isMajor === 2
),
userinfo, userinfo,
})) }))
class Connect extends Component { class Connect extends Component {
...@@ -104,8 +119,10 @@ class Connect extends Component { ...@@ -104,8 +119,10 @@ class Connect extends Component {
super(props); super(props);
this.state = { this.state = {
payId: undefined, payId: undefined,
payIds: [],
payMoney: 0,
bluetoothState: false, bluetoothState: false,
sockedDone: false, sockedDone: socketTask ? true : false,
deviceDone: false, deviceDone: false,
showerState: false, showerState: false,
deviceInfo: { deviceInfo: {
...@@ -127,106 +144,155 @@ class Connect extends Component { ...@@ -127,106 +144,155 @@ class Connect extends Component {
const { prepayConfig } = this.props; const { prepayConfig } = this.props;
if (prepayConfig.length) { if (prepayConfig.length) {
this.setState({ this.setState(
payId: prepayConfig[0].id, {
}); payId: prepayConfig[0].id,
},
() => {
this.getPayMoney();
}
);
} }
this.checkBluetoothAndWs(); this.checkBluetoothAndWs();
currentThis = this;
} }
componentWillUnmount() { componentWillUnmount() {
// this.closeBluetooth(); // this.closeBluetooth();
// this.closeDeviceSocket(); // this.closeDeviceSocket();
msgList = [];
msgindex = 0;
currentThis = null;
} }
connectDeviceSocket() { connectDeviceSocket() {
this.addMessageItem({ const { device } = this.props;
type: MessageType.info, const { canPay } = this.state;
text: '服务器连接中...', // if (socketTask) return;
}); // this.addMessageItem({
Taro.connectSocket({ url: DRY_SOCKET_URL }).then(task => { // type: MessageType.info,
socketTask = task; // text: '服务器连接中...',
task.onOpen(() => { // });
this.addMessageItem({ if (msgindex) return;
type: MessageType.success,
text: '服务器连接成功', // Taro.closeSocket()
}); // .catch(err => {
console.log('onOpen'); // console.log(err);
if (reConnectting) { // })
this.reConnectDeviceSocket(true); // .then(() => {
}
this.setState({ // })
sockedDone: true, let connectHandle;
}); if (socketTask) {
task.send({ data: str2ab('{}') }); connectHandle = new Promise(resolve => resolve(socketTask));
this.sendDeviceCode(); } else {
}); connectHandle = Taro.connectSocket({
task.onMessage(res => { url: DRY_SOCKET_URL,
this.addMessageItem({ timeout: 1200000,
type: MessageType.info, }).then(task => {
text: '正在与设备通信...', socketTask = task;
task.onOpen(() => {
this.addMessageItem({
type: MessageType.success,
text: '服务器连接成功',
});
this.addConnectMsg();
liveTimer = setInterval(() => {
task.send({ data: str2ab('{}') });
}, 20000);
console.log('onOpen');
if (reConnectting) {
this.reConnectDeviceSocket(true);
}
this.setState({
sockedDone: true,
});
task.send({ data: str2ab('{}') });
this.sendDeviceCode();
}); });
const msg: string = ab2str(res.data); task.onMessage(res => {
console.log('获取socket消息: ', msg); const msg: string = ab2str(res.data);
const msgObj: UploadMessage = JSON.parse(msg); console.log('获取socket消息: ', msg);
if (msgObj.type === 1) { console.log('状态: ', canPay, device.isOnlyBluetooth);
if (msgObj.data.length > 20) { const msgObj: UploadMessage = JSON.parse(msg);
for ( if (msgObj.type === 1) {
let index = 0; if (msgObj.data.length > 20) {
index <= Math.floor(msgObj.data.length / 20); for (
index++ let index = 0;
) { index <= Math.floor(msgObj.data.length / 20);
let str = msgObj.data.substring(index * 20, (index + 1) * 20); index++
this.sendMessageToDevice(str); ) {
let str = msgObj.data.substring(index * 20, (index + 1) * 20);
this.sendMessageToDevice(str);
}
} else {
this.sendMessageToDevice(msgObj.data);
}
} else if (msgObj.type === 0) {
if (msgObj.contorlCode === ContorlCode.using) {
Taro.showModal({
title: '提示',
content: '设备正在使用',
});
} else if (msgObj.contorlCode === ContorlCode.broken) {
Taro.showModal({
title: '提示',
content: '设备已损坏',
});
} else if (msgObj.contorlCode === ContorlCode.usable) {
console.log('in setState', currentThis.canPay);
currentThis && currentThis.setState({ canPay: true });
} else if (msgObj.contorlCode === ContorlCode.opened) {
Taro.showModal({
title: '提示',
content: '设备已启动',
});
} else {
} }
} else { } else {
this.sendMessageToDevice(msgObj.data);
} }
} else if (msgObj.type === 0) { });
if (msgObj.contorlCode === ContorlCode.using) { task.onClose(e => {
Taro.showModal({ if (msgindex !== 0) {
title: '提示', this.addMessageItem({
content: '设备正在使用', type: MessageType.error,
}); text: '服务器连接失败,请稍后扫码重试',
} else if (msgObj.contorlCode === ContorlCode.broken) {
Taro.showModal({
title: '提示',
content: '设备已损坏',
});
} else if (msgObj.contorlCode === ContorlCode.usable) {
this.setState({
canPay: true,
});
} else if (msgObj.contorlCode === ContorlCode.opened) {
Taro.showModal({
title: '提示',
content: '设备已启动',
}); });
}
console.log('socked关闭', e, reConnectting, timer);
this.setState({
sockedDone: false,
});
liveTimer && clearInterval(liveTimer);
socketTask = null;
liveTimer = null;
if (e.code === StopCode) {
console.log('正确结束socket连接');
} else { } else {
console.log('开始重连socket');
this.reConnectDeviceSocket(false);
} }
} else {
}
});
task.onClose(e => {
this.addMessageItem({
type: MessageType.error,
text: '服务器连接失败,请稍后扫码重试',
}); });
console.log('socked关闭', e, reConnectting, timer);
this.setState({
sockedDone: false,
});
socketTask = null;
if (e.code === StopCode) {
console.log('正确结束socket连接');
} else {
console.log('开始重连socket');
this.reConnectDeviceSocket(false);
}
}); });
}
connectHandle.then(() => {
console.log('socket done');
}); });
} }
addConnectMsg() {
const { sockedDone, deviceDone } = this.state;
if (sockedDone && deviceDone) {
if (msgindex === 0) {
this.addMessageItem({
type: MessageType.info,
text: '正在与设备通信...',
});
}
msgindex++;
}
}
reConnectDeviceSocket(cancel: boolean) { reConnectDeviceSocket(cancel: boolean) {
if (cancel) { if (cancel) {
timer && clearTimeout(timer); timer && clearTimeout(timer);
...@@ -383,7 +449,9 @@ class Connect extends Component { ...@@ -383,7 +449,9 @@ class Connect extends Component {
console.log('in startDevicesDiscovery', this.checkBluetoothState()); console.log('in startDevicesDiscovery', this.checkBluetoothState());
if (this.checkBluetoothState()) { if (this.checkBluetoothState()) {
return Taro.startBluetoothDevicesDiscovery() return Taro.startBluetoothDevicesDiscovery({
// services: ['00001103-0000-1000-8000-00805f9b34fb'],
})
.then(() => { .then(() => {
const { const {
code, code,
...@@ -455,7 +523,7 @@ class Connect extends Component { ...@@ -455,7 +523,7 @@ class Connect extends Component {
} }
createConnection(deviceId: string) { createConnection(deviceId: string) {
const { userinfo } = this.props; const { userinfo, device } = this.props;
console.log(deviceId); console.log(deviceId);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
Taro.createBLEConnection({ Taro.createBLEConnection({
...@@ -476,19 +544,21 @@ class Connect extends Component { ...@@ -476,19 +544,21 @@ class Connect extends Component {
this.closeBluetoothConnection(); this.closeBluetoothConnection();
} else { } else {
if ( if (
datastr.substring(0, 1) === '{' && (datastr.substring(0, 1) === '{' &&
datastr.substring(datastr.length - 1, datastr.length) === '}' datastr.substring(datastr.length - 1, datastr.length) === '}') ||
(datastr.substring(0, 1) === '<' &&
datastr.substring(datastr.length - 1, datastr.length) === '>')
) { ) {
console.log('<---发送完整数据: ', datastr); console.log('<---发送完整数据: ', datastr);
if (socketTask) { if (socketTask) {
let sendData: UploadMessage = { let sendData: UploadMessage = {
deviceCode: deviceId, deviceCode: device.code,
userId: userinfo.customerId.toString(), userId: userinfo.customerId.toString(),
type: 1, type: 1,
data: datastr, data: datastr,
}; };
socketTask.send({ socketTask.send({
data: JSON.stringify(sendData), data: str2ab(JSON.stringify(sendData)),
success: msg => { success: msg => {
console.log('发送完整数据:', msg, '--->'); console.log('发送完整数据:', msg, '--->');
}, },
...@@ -497,23 +567,28 @@ class Connect extends Component { ...@@ -497,23 +567,28 @@ class Connect extends Component {
}, },
}); });
} }
} else if (datastr.substring(0, 1) === '{') { } else if (
datastr.substring(0, 1) === '{' ||
datastr.substring(0, 1) === '<'
) {
abStr = datastr; abStr = datastr;
} else if ( } else if (
abStr.length && (abStr.length &&
datastr.substring(datastr.length - 1, datastr.length) === '}' datastr.substring(datastr.length - 1, datastr.length) === '}') ||
(abStr.length &&
datastr.substring(datastr.length - 1, datastr.length) === '>')
) { ) {
abStr += datastr; abStr += datastr;
console.log('<---发送完整数据: ', abStr); console.log('<---发送完整数据: ', abStr);
let sendData: UploadMessage = { let sendData: UploadMessage = {
deviceCode: deviceId, deviceCode: device.code,
userId: userinfo.customerId.toString(), userId: userinfo.customerId.toString(),
type: 1, type: 1,
data: abStr, data: abStr,
}; };
if (socketTask) { if (socketTask) {
socketTask.send({ socketTask.send({
data: JSON.stringify(sendData), data: str2ab(JSON.stringify(sendData)),
success: msg => { success: msg => {
console.log('发送完整数据:', msg, '--->'); console.log('发送完整数据:', msg, '--->');
}, },
...@@ -523,8 +598,9 @@ class Connect extends Component { ...@@ -523,8 +598,9 @@ class Connect extends Component {
}); });
} }
abStr = ''; abStr = '';
} else { } else if (abStr.length) {
console.log('弃掉数据:', datastr); console.log('追加数据:', datastr);
abStr += datastr;
} }
} }
}); });
...@@ -589,6 +665,7 @@ class Connect extends Component { ...@@ -589,6 +665,7 @@ class Connect extends Component {
deviceId: string; deviceId: string;
serviceId: string; serviceId: string;
}) { }) {
console.log(deviceId, serviceId);
return Taro.getBLEDeviceCharacteristics({ return Taro.getBLEDeviceCharacteristics({
deviceId, deviceId,
serviceId, serviceId,
...@@ -604,7 +681,7 @@ class Connect extends Component { ...@@ -604,7 +681,7 @@ class Connect extends Component {
if (charc.properties.write) { if (charc.properties.write) {
writeId = charc.uuid; writeId = charc.uuid;
} }
if (charc.properties.write) { if (charc.properties.read) {
readId = charc.uuid; readId = charc.uuid;
} }
} }
...@@ -617,6 +694,7 @@ class Connect extends Component { ...@@ -617,6 +694,7 @@ class Connect extends Component {
} }
openNotify({ notifyId, writeId, readId }) { openNotify({ notifyId, writeId, readId }) {
console.log(notifyId, writeId, readId);
this.setState(({ deviceInfo }: PageState) => ({ this.setState(({ deviceInfo }: PageState) => ({
deviceInfo: { deviceInfo: {
...deviceInfo, ...deviceInfo,
...@@ -697,6 +775,7 @@ class Connect extends Component { ...@@ -697,6 +775,7 @@ class Connect extends Component {
type: MessageType.success, type: MessageType.success,
text: '蓝牙连接成功', text: '蓝牙连接成功',
}); });
this.addConnectMsg();
this.sendDeviceCode(); this.sendDeviceCode();
// if (!reConnect) { // if (!reConnect) {
// setTimeout(() => { // setTimeout(() => {
...@@ -740,11 +819,60 @@ class Connect extends Component { ...@@ -740,11 +819,60 @@ class Connect extends Component {
} }
selectPayConfig(id: number) { selectPayConfig(id: number) {
if (id === this.state.payId) return;
this.setState(
{
payId: id,
},
() => {
this.getPayMoney();
}
);
}
getPayMoney() {
let money = 0;
if (this.state.payId) {
let payConfig = this.props.prepayConfig.find(
payConfig => payConfig.id === this.state.payId
);
money += payConfig ? payConfig.prepayMoney : 0;
}
if (this.state.payIds.length) {
this.props.addprepayConfig
.filter(payConfig => this.state.payIds.includes(payConfig.id))
.map(payConfig => {
money += payConfig.prepayMoney;
return payConfig;
});
}
this.setState({ this.setState({
payId: id, payMoney: money,
}); });
} }
checkAddPayConfig(id: number) {
let index = this.state.payIds.findIndex(payId => payId === id);
let payIds: number[] = [];
if (index === -1) {
payIds = [...this.state.payIds, id];
} else {
payIds = [
...this.state.payIds.slice(0, index),
...this.state.payIds.slice(index + 1),
];
}
this.setState(
{
payIds,
},
() => {
this.getPayMoney();
}
);
}
showerPayHandle() { showerPayHandle() {
this.closeBluetooth(); this.closeBluetooth();
return Taro.showModal({ return Taro.showModal({
...@@ -762,7 +890,7 @@ class Connect extends Component { ...@@ -762,7 +890,7 @@ class Connect extends Component {
device, device,
userinfo: { customerId }, userinfo: { customerId },
} = this.props; } = this.props;
const { payId, deviceDone, sockedDone } = this.state; const { payId, payIds, deviceDone, sockedDone } = this.state;
if (payId) { if (payId) {
if (device.isOnlyBluetooth && device.isOnlyBluetooth === 1) { if (device.isOnlyBluetooth && device.isOnlyBluetooth === 1) {
console.log(deviceDone, sockedDone); console.log(deviceDone, sockedDone);
...@@ -777,6 +905,7 @@ class Connect extends Component { ...@@ -777,6 +905,7 @@ class Connect extends Component {
serviceId: device.serviceId, serviceId: device.serviceId,
smaproCustomerId: customerId, smaproCustomerId: customerId,
smaproPrepayConfigId: payId, smaproPrepayConfigId: payId,
smaproPrepayConfigIds: [...payIds, payId],
areaId: device.areaId, areaId: device.areaId,
areaName: device.areaName, areaName: device.areaName,
}; };
...@@ -839,24 +968,31 @@ class Connect extends Component { ...@@ -839,24 +968,31 @@ class Connect extends Component {
} }
} }
gobackHandle() { changePageState(state: boolean) {
if (this.checkIsShower()) { if (state) {
setTimeout(() => { Taro.setNavigationBarTitle({
Taro.navigateTo({ title: '设备使用',
url: '/pages/index/index?', // 需要问号不然回到首页可以取到业务参数 });
});
}, 2000);
setTimeout(() => {
this.closeBluetooth();
this.closeDeviceSocket();
}, 10000);
} else { } else {
setTimeout(() => { Taro.setNavigationBarTitle({
Taro.navigateTo({ title: '设备连接',
url: '/pages/index/index?', // 需要问号不然回到首页可以取到业务参数 });
});
}, 2000);
} }
this.setState({
canPay: state,
});
}
gobackHandle() {
msgList = [];
setTimeout(() => {
this.setState({
canPay: false,
});
Taro.redirectTo({
url: '/pages/index/index?', // 需要问号不然回到首页可以取到业务参数
});
}, 2000);
} }
getPhoneHandle(e) { getPhoneHandle(e) {
...@@ -872,116 +1008,152 @@ class Connect extends Component { ...@@ -872,116 +1008,152 @@ class Connect extends Component {
} }
addMessageItem(msg: Message) { addMessageItem(msg: Message) {
msgList.push(msg);
this.setState({ this.setState({
messageQueue: [...this.state.messageQueue, msg], messageQueue: [...msgList],
lastMessage: 'Connect-Message-item' + this.state.messageQueue.length, lastMessage: 'Connect-Message-item' + msgList.length,
}); });
} }
render() { render() {
const { device, prepayConfig, userinfo } = this.props; const { device, prepayConfig, addprepayConfig, userinfo } = this.props;
const { payId, messageQueue, lastMessage, canPay } = this.state; const {
return device.isOnlyBluetooth && !canPay ? ( payId,
payIds,
messageQueue,
lastMessage,
canPay,
payMoney,
} = this.state;
console.log(canPay, device.isOnlyBluetooth);
return (
<View className="Connect"> <View className="Connect">
<View className="Connect-info"> <View className="state">{canPay}</View>
<View className="Connect-info-item"> {/* <Button onClick={() => currentThis.gobackHandle()}>重载</Button> */}
<Text>服务类型</Text> {device.isOnlyBluetooth && canPay ? (
<Text>{device.serviceName ? device.serviceName : ''}</Text> <View>
</View> <View className="Connect-title">{`${
<View className="Connect-info-item"> device.serviceName ? device.serviceName : ''
<Text>设备编号</Text> } ${device.code ? device.code : ''}(${device.position})`}</View>
<Text>{device.code ? device.code : ''}</Text> <View className="Connect-tip3">
</View> 说明:请在1分钟内选择功能并进行支付;支付后30秒内设备没有正常启动,重新扫码后无需支付可自动开启设备。
<View className="Connect-info-item">
<Text>设备位置</Text>
<Text className="Connect-info-position">{device.position}</Text>
</View>
</View>
<ScrollView
scroll-y
scroll-into-view={lastMessage}
className="Connect-Message">
{messageQueue.map((item, index) => (
<View
key={'Connect-Message-item' + index}
id={'Connect-Message-item' + index}
className={'Connect-Message-item ' + item.type}>
{item.text}
</View> </View>
))} <View className="Connect-Pay">
</ScrollView> <View className="Connect-Pay-title">
<View className="Connect-tip2"> 请选择主功能
{device.refundMode === DeviceRefundMode.notRefund <Text className="Connect-Pay-titleTip">(只能选择一个)</Text>
? '说明:设备成功开启后,未使用金额将不会退换!' </View>
: '说明:如本次预付款未全部使用,系统将在使用结束后半小时内自动退还剩余金额,请留意查收!'} <View className="Connect-Pay-content">
</View> {prepayConfig &&
</View> prepayConfig.length &&
) : ( prepayConfig.map(payConfig => (
<View className="Connect"> <View
<View className="Connect-info"> className="Connect-Pay-item"
<View className="Connect-info-item"> key="id"
<Text>服务类型</Text> onClick={() => this.selectPayConfig(payConfig.id)}>
<Text>{device.serviceName ? device.serviceName : ''}</Text> <View className="Connect-Pay-itemName">
</View> {payConfig.name}
<View className="Connect-info-item"> </View>
<Text>设备编号</Text> <View className="Connect-Pay-itemTime">
<Text>{device.code ? device.code : ''}</Text> {payConfig.duration}分钟
</View> </View>
<View className="Connect-info-item"> <View className="Connect-Pay-itemPrice">
<Text>设备位置</Text> {payConfig.prepayMoney.toFixed(2)}
<Text className="Connect-info-position">{device.position}</Text> </View>
</View> <View className="Connect-Pay-itemSelect">
{device.rates.length && ( {payId === payConfig.id ? (
<View className="Connect-info-item"> <Image
<Text>适用费率</Text> className="Connect-Pay-itemSelecticon"
<View className="Connect-info-rate"> src={selectedIcon}></Image>
{device.rates.map(item => ( ) : (
<View key="name" className="Connect-info-rate-item"> <Image
<Text className="Connect-info-rate-name"> className="Connect-Pay-itemSelecticon"
{item.duration}分钟 src={selectIcon}></Image>
</Text> )}
<Text className="Connect-info-rate-mark"> </View>
{item.money} </View>
</Text> ))}
</View>
))}
</View> </View>
</View> </View>
)} <View className="Connect-Pay">
</View> <View className="Connect-Pay-title">请选择附加功能</View>
<View className="Connect-tip"> <View className="Connect-Pay-content">
{device.refundMode === DeviceRefundMode.notRefund {addprepayConfig &&
? '温馨提示:设备成功开启后,未使用金额将不会退换!' addprepayConfig.length &&
: '温馨提示:如本次预付款未全部使用,系统将在使用结束后半小时内自动退还剩余金额,请留意查收!'} addprepayConfig.map(payConfig => (
</View> <View
<View className="Connect-money"> className="Connect-Pay-item"
{prepayConfig && key="id"
prepayConfig.length && onClick={() => this.checkAddPayConfig(payConfig.id)}>
prepayConfig.map(payConfig => ( <View className="Connect-Pay-itemName">
<View {payConfig.name}
key="id" </View>
className={`Connect-money-item ${ <View className="Connect-Pay-itemPrice">
payConfig.id == payId ? 'seleted' : '' {payConfig.prepayMoney.toFixed(2)}
}`} </View>
onClick={() => this.selectPayConfig(payConfig.id)}> <View className="Connect-Pay-itemSelect">
{payConfig.prepayMoney} {payIds.find(id => id === payConfig.id) ? (
<Image
className="Connect-Pay-itemSelecticon"
src={selected2Icon}></Image>
) : (
<Image
className="Connect-Pay-itemSelecticon"
src={select2Icon}></Image>
)}
</View>
</View>
))}
</View> </View>
))} </View>
</View> {userinfo.isAuth ? (
{userinfo.isAuth ? ( <Button className="Connect-btn" onClick={this.payHandle}>
<Button className="Connect-btn" onClick={this.payHandle}> 确定支付 共{payMoney.toFixed(2)}
确定支付 </Button>
</Button> ) : (
<Button
className="Connect-btn"
open-type="getPhoneNumber"
onGetphonenumber={this.getPhoneHandle}>
确定支付 共{payMoney.toFixed(2)}
</Button>
)}
</View>
) : ( ) : (
<Button <View>
className="Connect-btn" <View className="Connect-info">
open-type="getPhoneNumber" <View className="Connect-info-item">
onGetphonenumber={this.getPhoneHandle}> <Text>服务类型</Text>
确定支付 <Text>{device.serviceName ? device.serviceName : ''}</Text>
</Button> </View>
<View className="Connect-info-item">
<Text>设备编号</Text>
<Text>{device.code ? device.code : ''}</Text>
</View>
<View className="Connect-info-item">
<Text>设备位置</Text>
<Text className="Connect-info-position">{device.position}</Text>
</View>
</View>
<ScrollView
scroll-y
scroll-into-view={lastMessage}
className="Connect-Message">
{messageQueue.map((item, index) => (
<View
key={'Connect-Message-item' + index}
id={'Connect-Message-item' + index}
className={'Connect-Message-item ' + item.type}>
{item.text}
</View>
))}
</ScrollView>
<View className="Connect-tip2">
说明:如果在1分钟内没有跳转到支付页面,请开启手机蓝牙后再次微信扫码。
</View>
</View>
)} )}
<ad unit-id="adunit-8d48f17389f7e2aa"></ad>
</View> </View>
); );
} }
......
...@@ -5,9 +5,18 @@ export type PrepayConfig = { ...@@ -5,9 +5,18 @@ export type PrepayConfig = {
id: number; id: number;
// 会员id // 会员id
isMajor: number;
// 是否主要功能 1:主要功能;2:附加功能
isOpen: number; isOpen: number;
// 是否开启 // 是否开启
isShowRate: number;
// 是否显示费率 0:否;1:是。默认1
name: string;
// 名称
operateId: number; operateId: number;
// 运营商id // 运营商id
...@@ -28,6 +37,8 @@ export type PrepayConfig = { ...@@ -28,6 +37,8 @@ export type PrepayConfig = {
updateAt: string; updateAt: string;
// 更新时间 // 更新时间
duration: number;
}; };
export default PrepayConfig; export default PrepayConfig;
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