Commit cb285263 by 姜雷

Merge branch 'test'

parents 28674a32 5426891e
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"requirePragma": false,
"proseWrap": "preserve"
}
{ {
"name": "wx-school-app-public", "name": "wx-school-app-public",
"version": "1.0.11", "version": "1.0.12",
"private": true, "private": true,
"description": "", "description": "",
"scripts": { "scripts": {
......
...@@ -24,6 +24,8 @@ type Params = { ...@@ -24,6 +24,8 @@ type Params = {
areaName: string; areaName: string;
// 区域名称 // 区域名称
duration?: number;
}; };
type ResponseData = { type ResponseData = {
outTradeNo: string; outTradeNo: string;
...@@ -33,7 +35,7 @@ type ResponseData = { ...@@ -33,7 +35,7 @@ type ResponseData = {
// 微信小程序端支付信息 // 微信小程序端支付信息
}; };
export const getPayOrder = ( export const getPayOrder = (
entity: Params, entity: Params
): Promise<ResponseDataEntity<ResponseData>> => ): Promise<ResponseDataEntity<ResponseData>> =>
baseFetch({ baseFetch({
url: '/smapro/prepay/order/wx/apply/pay', url: '/smapro/prepay/order/wx/apply/pay',
......
import { baseFetch, ResponseDataEntity } from '.'; import { baseFetch, ResponseDataEntity } from '.';
import { Rate } from '../types/Device/Device';
export enum ScanTrigger {
false = 0,
true = 1,
}
type Params = { type Params = {
customerId: number; customerId: number;
equipmentNum: string; equipmentNum: string;
serviceId: number; serviceId: number;
isScanTrigger: ScanTrigger;
}; };
type DeviceInfoResponse = { type DeviceInfoResponse = {
code: string; code: string;
...@@ -29,7 +36,7 @@ type DeviceInfoResponse = { ...@@ -29,7 +36,7 @@ type DeviceInfoResponse = {
positionId: string; positionId: string;
// 位置id // 位置id
rates: RateInfoResponse[]; rates: Rate[];
// 是否纯蓝牙设备 1:是,0:否 // 是否纯蓝牙设备 1:是,0:否
isOnlyBluetooth: number; isOnlyBluetooth: number;
...@@ -40,13 +47,6 @@ type DeviceInfoResponse = { ...@@ -40,13 +47,6 @@ type DeviceInfoResponse = {
// 区域名称 // 区域名称
areaName: string; areaName: string;
}; };
type RateInfoResponse = {
mark: string;
// 费率描述
name: string;
// 费率名称
};
type SmaproPrepayConfig = { type SmaproPrepayConfig = {
createAt: string; createAt: string;
// 创建时间 // 创建时间
...@@ -84,7 +84,7 @@ type ResponseData = { ...@@ -84,7 +84,7 @@ type ResponseData = {
}; };
export const getDeviceConfig = ( export const getDeviceConfig = (
entity: Params, entity: Params
): Promise<ResponseDataEntity<ResponseData>> => ): Promise<ResponseDataEntity<ResponseData>> =>
baseFetch({ baseFetch({
url: '/smapro/prepay/config/wxmini', url: '/smapro/prepay/config/wxmini',
......
...@@ -27,6 +27,7 @@ class App extends Component { ...@@ -27,6 +27,7 @@ class App extends Component {
'pages/scanEnter/scanEnter', 'pages/scanEnter/scanEnter',
'pages/index/index', 'pages/index/index',
'pages/pay/pay', 'pages/pay/pay',
'pages/connect/connect',
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',
......
...@@ -4,3 +4,4 @@ export const NotRegisterCode = 1005; ...@@ -4,3 +4,4 @@ export const NotRegisterCode = 1005;
export const BASE_SERVER_URL = 'https://dcxy-smapro-app.dcrym.com'; export const BASE_SERVER_URL = 'https://dcxy-smapro-app.dcrym.com';
export const SOCKET_URL = 'wss://shower-wss1.dcrym.com:9443/ws'; export const SOCKET_URL = 'wss://shower-wss1.dcrym.com:9443/ws';
export const DRY_SOCKET_URL = 'wss://share-device-manager.dcrym.com:9443';
.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;
}
}
}
...@@ -2,11 +2,9 @@ import { ComponentClass } from 'react'; ...@@ -2,11 +2,9 @@ import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro'; import Taro, { Component, Config } from '@tarojs/taro';
import { View, Image } from '@tarojs/components'; import { View, Image } from '@tarojs/components';
import scanIcon from '../../images/icon_s@2x.png';
import './index.scss'; import './index.scss';
import { registerAndLogin } from '../../api/customer'; import { registerAndLogin } from '../../api/customer';
import { getDeviceConfig } from '../../api/device'; import { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer'; import { Customer } from '../../types/Customer/Customer';
...@@ -17,6 +15,7 @@ import { ...@@ -17,6 +15,7 @@ import {
} from '../../store/rootReducers/device'; } from '../../store/rootReducers/device';
import PrepayConfig from '../../types/Order/Order'; import PrepayConfig from '../../types/Order/Order';
import { updatePayData } from '../../store/rootReducers/prepayConfig'; import { updatePayData } from '../../store/rootReducers/prepayConfig';
import { getPathParams } from '@/utils/path';
type DeviceEntity = { type DeviceEntity = {
serviceId: number; serviceId: number;
...@@ -64,7 +63,7 @@ interface Index { ...@@ -64,7 +63,7 @@ interface Index {
resetDeviceData() { resetDeviceData() {
dispatch(resetDeviceData()); dispatch(resetDeviceData());
}, },
}), })
) )
class Index extends Component { class Index extends Component {
config: Config = { config: Config = {
...@@ -80,13 +79,26 @@ class Index extends Component { ...@@ -80,13 +79,26 @@ class Index extends Component {
componentWillMount() { componentWillMount() {
this.loginHandle().then(() => { this.loginHandle().then(() => {
let codeStr = this.$router.params.q;
let queryArr = Object.keys(this.$router.params); let queryArr = Object.keys(this.$router.params);
console.log(this.$router.params); console.log(this.$router.params);
let scene: string = queryArr.length > 0 ? queryArr[0] : ''; let scene: string = queryArr.length > 0 ? queryArr[0] : '';
console.log('scene:', scene); console.log('scene:', scene);
if (scene) { if (codeStr) {
// Taro.showLoading();
let params = getPathParams(codeStr);
console.log('code', params);
if (params['code']) {
let entity = this.getDeviceEntity(params['code']);
if (entity) {
this.getDeviceConfigHandle(entity);
}
} else {
this.scanErrorWeQRcode();
}
} else if (scene) {
Taro.showLoading(); Taro.showLoading();
let entity = this.getDeviceEntity(scene); let entity = this.getDeviceEntity(scene);
if (entity) { if (entity) {
...@@ -171,6 +183,7 @@ class Index extends Component { ...@@ -171,6 +183,7 @@ class Index extends Component {
customerId: userinfo.customerId, customerId: userinfo.customerId,
equipmentNum: equipmentNum, equipmentNum: equipmentNum,
serviceId: serviceId, serviceId: serviceId,
isScanTrigger: ScanTrigger.false,
}) })
.then(res => { .then(res => {
Taro.hideLoading(); Taro.hideLoading();
...@@ -191,9 +204,7 @@ class Index extends Component { ...@@ -191,9 +204,7 @@ class Index extends Component {
} else { } else {
updatePayData([]); updatePayData([]);
} }
Taro.redirectTo({ this.goNextPage(serviceId);
url: '/pages/pay/pay',
});
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
...@@ -219,10 +230,32 @@ class Index extends Component { ...@@ -219,10 +230,32 @@ class Index extends Component {
this.scanHandle(); this.scanHandle();
} }
scanErrorWeQRcode() {
Taro.showToast({
title: '请扫描正确的小程序',
icon: 'none',
});
this.setState({
errorText: '请扫描正确的小程序',
});
}
goNextPage(serviceId: number) {
if (serviceId === 30 || serviceId === 31) {
Taro.redirectTo({
url: '/pages/connect/connect',
});
} else {
Taro.redirectTo({
url: '/pages/pay/pay',
});
}
}
render() { render() {
const { errorText } = this.state; const { errorText } = this.state;
return ( return (
<View className='index'> <View className="index">
{errorText} {errorText}
{/* <Button {/* <Button
className='scan-icon' className='scan-icon'
......
...@@ -857,7 +857,7 @@ class Pay extends Component { ...@@ -857,7 +857,7 @@ class Pay extends Component {
<Text>适用费率</Text> <Text>适用费率</Text>
<View className='Pay-info-rate'> <View className='Pay-info-rate'>
{device.rates.map(item => ( {device.rates.map(item => (
<View key={item.name} className='Pay-info-rate-item'> <View key='name' className='Pay-info-rate-item'>
<Text className='Pay-info-rate-name'>{item.name}</Text> <Text className='Pay-info-rate-name'>{item.name}</Text>
<Text className='Pay-info-rate-mark'>{item.mark}</Text> <Text className='Pay-info-rate-mark'>{item.mark}</Text>
</View> </View>
...@@ -884,7 +884,7 @@ class Pay extends Component { ...@@ -884,7 +884,7 @@ class Pay extends Component {
prepayConfig.length && prepayConfig.length &&
prepayConfig.map(payConfig => ( prepayConfig.map(payConfig => (
<View <View
key={payConfig.id} key='id'
className={`Pay-money-item ${ className={`Pay-money-item ${
payConfig.id == payId ? 'seleted' : '' payConfig.id == payId ? 'seleted' : ''
}`} }`}
......
...@@ -6,7 +6,7 @@ import scanIcon from '../../images/icon_s@2x.png'; ...@@ -6,7 +6,7 @@ import scanIcon from '../../images/icon_s@2x.png';
import './scanEnter.scss'; import './scanEnter.scss';
import { registerAndLogin } from '../../api/customer'; import { registerAndLogin } from '../../api/customer';
import { getDeviceConfig } from '../../api/device'; import { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer'; import { Customer } from '../../types/Customer/Customer';
...@@ -17,6 +17,7 @@ import { ...@@ -17,6 +17,7 @@ import {
} from '../../store/rootReducers/device'; } from '../../store/rootReducers/device';
import PrepayConfig from '../../types/Order/Order'; import PrepayConfig from '../../types/Order/Order';
import { updatePayData } from '../../store/rootReducers/prepayConfig'; import { updatePayData } from '../../store/rootReducers/prepayConfig';
import { getPathParams } from '@/utils/path';
type DeviceEntity = { type DeviceEntity = {
serviceId: number; serviceId: number;
...@@ -61,7 +62,7 @@ interface ScanEnter { ...@@ -61,7 +62,7 @@ interface ScanEnter {
resetDeviceData() { resetDeviceData() {
dispatch(resetDeviceData()); dispatch(resetDeviceData());
}, },
}), })
) )
class ScanEnter extends Component { class ScanEnter extends Component {
config: Config = { config: Config = {
...@@ -121,12 +122,17 @@ class ScanEnter extends Component { ...@@ -121,12 +122,17 @@ class ScanEnter extends Component {
.then(res => { .then(res => {
console.log(res); console.log(res);
const { path, result } = res; const { path, result } = res;
let param = getPathParams(result);
if (path) { if (path) {
let queryArr = path.split('?'); let queryArr = path.split('?');
let queryStr = queryArr.length >= 2 ? queryArr[1] : ''; let queryStr = queryArr.length >= 2 ? queryArr[1] : '';
console.log(result, queryArr, queryStr); console.log(result, queryArr, queryStr);
const entity = this.getDeviceEntity(queryStr); const entity = this.getDeviceEntity(queryStr);
this.getDeviceConfigHandle(entity); this.getDeviceConfigHandle(entity);
} else if (param['code']) {
console.log(param['code']);
const entity = this.getDeviceEntity(param['code']);
this.getDeviceConfigHandle(entity);
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请扫描正确的小程序', title: '请扫描正确的小程序',
...@@ -151,6 +157,7 @@ class ScanEnter extends Component { ...@@ -151,6 +157,7 @@ class ScanEnter extends Component {
customerId: userinfo.customerId, customerId: userinfo.customerId,
equipmentNum: equipmentNum, equipmentNum: equipmentNum,
serviceId: serviceId, serviceId: serviceId,
isScanTrigger: ScanTrigger.true,
}) })
.then(res => { .then(res => {
Taro.hideLoading(); Taro.hideLoading();
...@@ -171,9 +178,7 @@ class ScanEnter extends Component { ...@@ -171,9 +178,7 @@ class ScanEnter extends Component {
} else { } else {
updatePayData([]); updatePayData([]);
} }
Taro.navigateTo({ this.goNextPage(serviceId);
url: '/pages/pay/pay',
});
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
...@@ -196,20 +201,32 @@ class ScanEnter extends Component { ...@@ -196,20 +201,32 @@ class ScanEnter extends Component {
this.scanHandle(); this.scanHandle();
} }
goNextPage(serviceId: number) {
if (serviceId === 30 || serviceId === 31) {
Taro.redirectTo({
url: '/pages/connect/connect',
});
} else {
Taro.redirectTo({
url: '/pages/pay/pay',
});
}
}
render() { render() {
return ( return (
<View className='ScanEnter'> <View className="ScanEnter">
{/* <Button {/* <Button
className='scan-icon' className='scan-icon'
onGetUserInfo={this.getUserInfoHandle} onGetUserInfo={this.getUserInfoHandle}
open-type='getUserInfo'> open-type='getUserInfo'>
<Image src={scanIcon} /> <Image src={scanIcon} />
</Button> */} </Button> */}
<View className='scan-icon' onClick={this.clickHandle}> <View className="scan-icon" onClick={this.clickHandle}>
<Image src={scanIcon} /> <Image src={scanIcon} />
</View> </View>
<View className='scan-text'>马上扫一扫</View> <View className="scan-text">马上扫一扫</View>
<View className='scan-text'>使用多彩自助服务</View> <View className="scan-text">使用多彩自助服务</View>
</View> </View>
); );
} }
......
...@@ -2,10 +2,25 @@ export enum DeviceRefundMode { ...@@ -2,10 +2,25 @@ export enum DeviceRefundMode {
needRefund = 1, needRefund = 1,
notRefund = 2, notRefund = 2,
} }
export enum OnlyBluetooth {
false = 0,
true = 1,
}
export type Rate = { export type Rate = {
mark: string; mark: string;
// 费率描述
name: string; name: string;
// 费率名称
duration: number;
// 消费时长,单位分钟
money: number;
// 费率金额
}; };
export type Device = { export type Device = {
refundMode: DeviceRefundMode; refundMode: DeviceRefundMode;
originCode: string; originCode: string;
...@@ -20,7 +35,7 @@ export type Device = { ...@@ -20,7 +35,7 @@ export type Device = {
rates: Rate[]; rates: Rate[];
serviceId: number; serviceId: number;
serviceName: string; serviceName: string;
isOnlyBluetooth: number; isOnlyBluetooth: OnlyBluetooth;
areaId: number; areaId: number;
areaName: string; areaName: string;
}; };
export const getPathParams = (path: string) => {
let paramsArr = decodeURIComponent(path).split("?");
if (paramsArr.length > 1) {
let params = {};
paramsArr = paramsArr[1].split("&");
for (let index = 0; index < paramsArr.length; index++) {
const element = paramsArr[index].split("=");
if (element.length) {
params[element[0]] = element[1];
}
}
return params;
} else {
return {};
}
};
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