Commit 25a0bf16 by 姜雷

添加设备连接页面

parent 1c50ca0f
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"requirePragma": false,
"proseWrap": "preserve"
}
import { baseFetch, ResponseDataEntity } from '.';
import { Rate } from '../types/Device/Device';
export enum ScanTrigger {
false = 0,
true = 1,
}
type Params = {
customerId: number;
equipmentNum: string;
serviceId: number;
isScanTrigger: ScanTrigger;
};
type DeviceInfoResponse = {
code: string;
......@@ -29,7 +36,7 @@ type DeviceInfoResponse = {
positionId: string;
// 位置id
rates: RateInfoResponse[];
rates: Rate[];
// 是否纯蓝牙设备 1:是,0:否
isOnlyBluetooth: number;
......@@ -40,13 +47,6 @@ type DeviceInfoResponse = {
// 区域名称
areaName: string;
};
type RateInfoResponse = {
mark: string;
// 费率描述
name: string;
// 费率名称
};
type SmaproPrepayConfig = {
createAt: string;
// 创建时间
......@@ -84,7 +84,7 @@ type ResponseData = {
};
export const getDeviceConfig = (
entity: Params,
entity: Params
): Promise<ResponseDataEntity<ResponseData>> =>
baseFetch({
url: '/smapro/prepay/config/wxmini',
......
......@@ -27,6 +27,7 @@ class App extends Component {
'pages/scanEnter/scanEnter',
'pages/index/index',
'pages/pay/pay',
'pages/connect/connect',
],
window: {
backgroundTextStyle: 'light',
......
.Connect {
.Connect-info {
padding: 40px 32px;
font-size: 28px;
color: #333;
padding-bottom: 30px;
border-bottom: 1px dotted #e1e1e1;
.Connect-info-item {
line-height: 60px;
display: flex;
justify-content: space-between;
.Connect-info-rate {
line-height: 40px;
.Connect-info-rate-item {
display: flex;
}
.Connect-info-rate-name {
margin-right: 5px;
}
.Connect-info-rate-mark {
width: 250px;
text-align: right;
}
}
.Connect-info-position {
text-align: right;
width: 500px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.Connect-tip {
margin: 38px 32px 30px;
color: #ff4b4b;
font-size: 24px;
line-height: 34px;
}
.Connect-tip2 {
padding: 36px 22px;
margin: 38px 32px 30px;
color: #999;
font-size: 24px;
line-height: 30px;
border: 1px solid #a4a4a4;
border-radius: 30px;
vertical-align: middle;
}
.Connect-money {
display: flex;
flex-wrap: wrap;
width: 714px;
margin: 0 auto;
.Connect-money-item {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
width: 218px;
height: 110px;
font-size: 28px;
border-radius: 24px;
border: 1px solid #ccc;
margin-bottom: 16px;
margin-right: 16px;
&.seleted {
border-color: #6180f4;
color: #6180f4;
}
}
}
.Connect-btn {
margin: 20px 32px 80px;
}
.Connect-Message {
box-sizing: border-box;
width: 100%;
padding: 50px 42px;
font-size: 26px;
height: 440px;
overflow-y: auto;
.Connect-Message-item {
margin-bottom: 28px;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.info {
color: #1596e0;
}
.success {
color: #15e0ae;
}
.error {
color: #ec2929;
}
}
}
import { ComponentClass } from "react";
import Taro, { Component, Config } from "@tarojs/taro";
import { View, Image } from "@tarojs/components";
import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro';
import { View, Image } from '@tarojs/components';
import scanIcon from "../../images/icon_s@2x.png";
import "./index.scss";
import { registerAndLogin } from "../../api/customer";
import { getDeviceConfig } from "../../api/device";
import { UserState, updateUserInfo } from "../../store/rootReducers/userinfo";
import { connect } from "@tarojs/redux";
import { Customer } from "../../types/Customer/Customer";
import './index.scss';
import { registerAndLogin } from '../../api/customer';
import { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer';
import {
DeviceState,
updateDeviceData,
resetDeviceData
} from "../../store/rootReducers/device";
import PrepayConfig from "../../types/Order/Order";
import { updatePayData } from "../../store/rootReducers/prepayConfig";
import { getPathParams } from "@/utils/path";
resetDeviceData,
} from '../../store/rootReducers/device';
import PrepayConfig from '../../types/Order/Order';
import { updatePayData } from '../../store/rootReducers/prepayConfig';
import { getPathParams } from '@/utils/path';
type DeviceEntity = {
serviceId: number;
......@@ -50,7 +48,7 @@ interface Index {
@connect(
({ userinfo }) => ({
userinfo
userinfo,
}),
dispatch => ({
updateUserInfo(data: UserState) {
......@@ -64,18 +62,18 @@ interface Index {
},
resetDeviceData() {
dispatch(resetDeviceData());
}
},
})
)
class Index extends Component {
config: Config = {
navigationBarTitleText: "多彩自助服务"
navigationBarTitleText: '多彩自助服务',
};
constructor(props) {
super(props);
this.state = {
errorText: ""
errorText: '',
};
}
......@@ -85,15 +83,15 @@ class Index extends Component {
let queryArr = Object.keys(this.$router.params);
console.log(this.$router.params);
let scene: string = queryArr.length > 0 ? queryArr[0] : "";
console.log("scene:", scene);
let scene: string = queryArr.length > 0 ? queryArr[0] : '';
console.log('scene:', scene);
if (codeStr) {
// Taro.showLoading();
let params = getPathParams(codeStr);
console.log("code", params);
if (params["code"]) {
let entity = this.getDeviceEntity(params["code"]);
console.log('code', params);
if (params['code']) {
let entity = this.getDeviceEntity(params['code']);
if (entity) {
this.getDeviceConfigHandle(entity);
}
......@@ -108,7 +106,7 @@ class Index extends Component {
}
} else {
Taro.redirectTo({
url: "/pages/scanEnter/scanEnter"
url: '/pages/scanEnter/scanEnter',
});
}
});
......@@ -119,7 +117,7 @@ class Index extends Component {
let equipmentNum = paramStr.slice(2);
return {
serviceId,
equipmentNum
equipmentNum,
};
}
......@@ -127,18 +125,18 @@ class Index extends Component {
const { updateUserInfo } = this.props;
return Taro.login().then(res => {
console.log("login info:", res);
console.log('login info:', res);
const { code } = res;
return registerAndLogin({
code
code,
// userName: '',
}).then(res => {
const { token, customerId, isAuth } = res;
updateUserInfo({
token,
customerId,
isAuth
isAuth,
});
});
});
......@@ -147,24 +145,24 @@ class Index extends Component {
scanHandle() {
Taro.scanCode({
onlyFromCamera: true,
scanType: ["qrCode"]
scanType: ['qrCode'],
})
.then(res => {
console.log(res);
const { path, result } = res;
if (path) {
let queryArr = path.split("?");
let queryStr = queryArr.length >= 2 ? queryArr[1] : "";
let queryArr = path.split('?');
let queryStr = queryArr.length >= 2 ? queryArr[1] : '';
console.log(result, queryArr, queryStr);
const entity = this.getDeviceEntity(queryStr);
this.getDeviceConfigHandle(entity);
} else {
Taro.showToast({
title: "请扫描正确的小程序",
icon: "none"
title: '请扫描正确的小程序',
icon: 'none',
});
this.setState({
errorText: "请扫描正确的小程序"
errorText: '请扫描正确的小程序',
});
}
})
......@@ -179,19 +177,20 @@ class Index extends Component {
userinfo,
updateDeviceData,
updatePayData,
resetDeviceData
resetDeviceData,
} = this.props;
return getDeviceConfig({
customerId: userinfo.customerId,
equipmentNum: equipmentNum,
serviceId: serviceId
serviceId: serviceId,
isScanTrigger: ScanTrigger.false,
})
.then(res => {
Taro.hideLoading();
console.log(res);
const { deviceInfoResponse, prepayConfigs } = res;
if (deviceInfoResponse.isUsed) {
console.log("设备使用中");
console.log('设备使用中');
return;
}
if (deviceInfoResponse) {
......@@ -205,18 +204,16 @@ class Index extends Component {
} else {
updatePayData([]);
}
Taro.redirectTo({
url: "/pages/pay/pay"
});
this.goNextPage(serviceId);
})
.catch(err => {
console.error(err);
Taro.showToast({
title: err.msg || "请扫描正确的设备码",
icon: "none"
title: err.msg || '请扫描正确的设备码',
icon: 'none',
});
this.setState({
errorText: err.msg || "请扫描正确的设备码"
errorText: err.msg || '请扫描正确的设备码',
});
});
}
......@@ -235,14 +232,26 @@ class Index extends Component {
scanErrorWeQRcode() {
Taro.showToast({
title: "请扫描正确的小程序",
icon: "none"
title: '请扫描正确的小程序',
icon: 'none',
});
this.setState({
errorText: "请扫描正确的小程序"
errorText: '请扫描正确的小程序',
});
}
goNextPage(serviceId: number) {
if (serviceId === 30 || serviceId === 31) {
Taro.redirectTo({
url: '/pages/connect/connect',
});
} else {
Taro.redirectTo({
url: '/pages/pay/pay',
});
}
}
render() {
const { errorText } = this.state;
return (
......
import { ComponentClass } from "react";
import Taro, { Component, Config } from "@tarojs/taro";
import { View, Image } from "@tarojs/components";
import scanIcon from "../../images/icon_s@2x.png";
import "./scanEnter.scss";
import { registerAndLogin } from "../../api/customer";
import { getDeviceConfig } from "../../api/device";
import { UserState, updateUserInfo } from "../../store/rootReducers/userinfo";
import { connect } from "@tarojs/redux";
import { Customer } from "../../types/Customer/Customer";
import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro';
import { View, Image } from '@tarojs/components';
import scanIcon from '../../images/icon_s@2x.png';
import './scanEnter.scss';
import { registerAndLogin } from '../../api/customer';
import { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer';
import {
DeviceState,
updateDeviceData,
resetDeviceData
} from "../../store/rootReducers/device";
import PrepayConfig from "../../types/Order/Order";
import { updatePayData } from "../../store/rootReducers/prepayConfig";
import { getPathParams } from "@/utils/path";
resetDeviceData,
} from '../../store/rootReducers/device';
import PrepayConfig from '../../types/Order/Order';
import { updatePayData } from '../../store/rootReducers/prepayConfig';
import { getPathParams } from '@/utils/path';
type DeviceEntity = {
serviceId: number;
......@@ -47,7 +47,7 @@ interface ScanEnter {
@connect(
({ userinfo }) => ({
userinfo
userinfo,
}),
dispatch => ({
updateUserInfo(data: UserState) {
......@@ -61,12 +61,12 @@ interface ScanEnter {
},
resetDeviceData() {
dispatch(resetDeviceData());
}
},
})
)
class ScanEnter extends Component {
config: Config = {
navigationBarTitleText: "多彩自助服务"
navigationBarTitleText: '多彩自助服务',
};
componentWillMount() {
......@@ -90,7 +90,7 @@ class ScanEnter extends Component {
let equipmentNum = paramStr.slice(2);
return {
serviceId,
equipmentNum
equipmentNum,
};
}
......@@ -98,17 +98,17 @@ class ScanEnter extends Component {
const { updateUserInfo } = this.props;
return Taro.login().then(res => {
console.log("login info:", res);
console.log('login info:', res);
const { code } = res;
return registerAndLogin({
code
code,
// userName: '',
}).then(res => {
const { token, customerId, isAuth } = res;
updateUserInfo({
token,
customerId,
isAuth
isAuth,
});
});
});
......@@ -117,26 +117,26 @@ class ScanEnter extends Component {
scanHandle() {
Taro.scanCode({
onlyFromCamera: true,
scanType: ["qrCode"]
scanType: ['qrCode'],
})
.then(res => {
console.log(res);
const { path, result } = res;
let param = getPathParams(result);
if (path) {
let queryArr = path.split("?");
let queryStr = queryArr.length >= 2 ? queryArr[1] : "";
let queryArr = path.split('?');
let queryStr = queryArr.length >= 2 ? queryArr[1] : '';
console.log(result, queryArr, queryStr);
const entity = this.getDeviceEntity(queryStr);
this.getDeviceConfigHandle(entity);
} else if (param["code"]) {
console.log(param["code"]);
const entity = this.getDeviceEntity(param["code"]);
} else if (param['code']) {
console.log(param['code']);
const entity = this.getDeviceEntity(param['code']);
this.getDeviceConfigHandle(entity);
} else {
Taro.showToast({
title: "请扫描正确的小程序",
icon: "none"
title: '请扫描正确的小程序',
icon: 'none',
});
}
})
......@@ -151,19 +151,20 @@ class ScanEnter extends Component {
userinfo,
updateDeviceData,
updatePayData,
resetDeviceData
resetDeviceData,
} = this.props;
return getDeviceConfig({
customerId: userinfo.customerId,
equipmentNum: equipmentNum,
serviceId: serviceId
serviceId: serviceId,
isScanTrigger: ScanTrigger.true,
})
.then(res => {
Taro.hideLoading();
console.log(res);
const { deviceInfoResponse, prepayConfigs } = res;
if (deviceInfoResponse.isUsed) {
console.log("设备使用中");
console.log('设备使用中');
return;
}
if (deviceInfoResponse) {
......@@ -177,15 +178,13 @@ class ScanEnter extends Component {
} else {
updatePayData([]);
}
Taro.navigateTo({
url: "/pages/pay/pay"
});
this.goNextPage(serviceId);
})
.catch(err => {
console.error(err);
Taro.showToast({
title: err.msg || "请扫描正确的设备码",
icon: "none"
title: err.msg || '请扫描正确的设备码',
icon: 'none',
});
});
}
......@@ -202,6 +201,18 @@ class ScanEnter extends Component {
this.scanHandle();
}
goNextPage(serviceId: number) {
if (serviceId === 30 || serviceId === 31) {
Taro.redirectTo({
url: '/pages/connect/connect',
});
} else {
Taro.redirectTo({
url: '/pages/pay/pay',
});
}
}
render() {
return (
<View className="ScanEnter">
......
......@@ -2,10 +2,25 @@ export enum DeviceRefundMode {
needRefund = 1,
notRefund = 2,
}
export enum OnlyBluetooth {
false = 0,
true = 1,
}
export type Rate = {
mark: string;
// 费率描述
name: string;
// 费率名称
duration: number;
// 消费时长,单位分钟
money: number;
// 费率金额
};
export type Device = {
refundMode: DeviceRefundMode;
originCode: string;
......@@ -20,7 +35,7 @@ export type Device = {
rates: Rate[];
serviceId: number;
serviceName: string;
isOnlyBluetooth: number;
isOnlyBluetooth: OnlyBluetooth;
areaId: number;
areaName: string;
};
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