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",
"version": "1.0.11",
"version": "1.0.12",
"private": true,
"description": "",
"scripts": {
......
......@@ -24,6 +24,8 @@ type Params = {
areaName: string;
// 区域名称
duration?: number;
};
type ResponseData = {
outTradeNo: string;
......@@ -33,7 +35,7 @@ type ResponseData = {
// 微信小程序端支付信息
};
export const getPayOrder = (
entity: Params,
entity: Params
): Promise<ResponseDataEntity<ResponseData>> =>
baseFetch({
url: '/smapro/prepay/order/wx/apply/pay',
......
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',
......
......@@ -4,3 +4,4 @@ export const NotRegisterCode = 1005;
export const BASE_SERVER_URL = 'https://dcxy-smapro-app.dcrym.com';
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';
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 { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer';
......@@ -17,6 +15,7 @@ import {
} 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;
......@@ -64,7 +63,7 @@ interface Index {
resetDeviceData() {
dispatch(resetDeviceData());
},
}),
})
)
class Index extends Component {
config: Config = {
......@@ -80,13 +79,26 @@ class Index extends Component {
componentWillMount() {
this.loginHandle().then(() => {
let codeStr = this.$router.params.q;
let queryArr = Object.keys(this.$router.params);
console.log(this.$router.params);
let scene: string = queryArr.length > 0 ? queryArr[0] : '';
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();
let entity = this.getDeviceEntity(scene);
if (entity) {
......@@ -171,6 +183,7 @@ class Index extends Component {
customerId: userinfo.customerId,
equipmentNum: equipmentNum,
serviceId: serviceId,
isScanTrigger: ScanTrigger.false,
})
.then(res => {
Taro.hideLoading();
......@@ -191,9 +204,7 @@ class Index extends Component {
} else {
updatePayData([]);
}
Taro.redirectTo({
url: '/pages/pay/pay',
});
this.goNextPage(serviceId);
})
.catch(err => {
console.error(err);
......@@ -219,10 +230,32 @@ class Index extends Component {
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() {
const { errorText } = this.state;
return (
<View className='index'>
<View className="index">
{errorText}
{/* <Button
className='scan-icon'
......
......@@ -857,7 +857,7 @@ class Pay extends Component {
<Text>适用费率</Text>
<View className='Pay-info-rate'>
{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-mark'>{item.mark}</Text>
</View>
......@@ -884,7 +884,7 @@ class Pay extends Component {
prepayConfig.length &&
prepayConfig.map(payConfig => (
<View
key={payConfig.id}
key='id'
className={`Pay-money-item ${
payConfig.id == payId ? 'seleted' : ''
}`}
......
......@@ -6,7 +6,7 @@ import scanIcon from '../../images/icon_s@2x.png';
import './scanEnter.scss';
import { registerAndLogin } from '../../api/customer';
import { getDeviceConfig } from '../../api/device';
import { getDeviceConfig, ScanTrigger } from '../../api/device';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { connect } from '@tarojs/redux';
import { Customer } from '../../types/Customer/Customer';
......@@ -17,6 +17,7 @@ import {
} 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;
......@@ -61,7 +62,7 @@ interface ScanEnter {
resetDeviceData() {
dispatch(resetDeviceData());
},
}),
})
)
class ScanEnter extends Component {
config: Config = {
......@@ -121,12 +122,17 @@ class ScanEnter extends Component {
.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] : '';
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']);
this.getDeviceConfigHandle(entity);
} else {
Taro.showToast({
title: '请扫描正确的小程序',
......@@ -151,6 +157,7 @@ class ScanEnter extends Component {
customerId: userinfo.customerId,
equipmentNum: equipmentNum,
serviceId: serviceId,
isScanTrigger: ScanTrigger.true,
})
.then(res => {
Taro.hideLoading();
......@@ -171,9 +178,7 @@ class ScanEnter extends Component {
} else {
updatePayData([]);
}
Taro.navigateTo({
url: '/pages/pay/pay',
});
this.goNextPage(serviceId);
})
.catch(err => {
console.error(err);
......@@ -196,20 +201,32 @@ 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'>
<View className="ScanEnter">
{/* <Button
className='scan-icon'
onGetUserInfo={this.getUserInfoHandle}
open-type='getUserInfo'>
<Image src={scanIcon} />
</Button> */}
<View className='scan-icon' onClick={this.clickHandle}>
<View className="scan-icon" onClick={this.clickHandle}>
<Image src={scanIcon} />
</View>
<View className='scan-text'>马上扫一扫</View>
<View className='scan-text'>使用多彩自助服务</View>
<View className="scan-text">马上扫一扫</View>
<View className="scan-text">使用多彩自助服务</View>
</View>
);
}
......
......@@ -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;
};
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