Commit 9ffcdfc0 by 姜雷

Merge branch 'develop' into test

parents 18986e20 dad5c835
{ {
"name": "wx-school-app-public", "name": "wx-school-app-public",
"version": "1.0.8", "version": "1.0.9",
"private": true, "private": true,
"description": "", "description": "",
"scripts": { "scripts": {
......
...@@ -77,10 +77,11 @@ class LoginAndScan extends Component { ...@@ -77,10 +77,11 @@ class LoginAndScan extends Component {
code, code,
// userName: '', // userName: '',
}).then(res => { }).then(res => {
const { token, customerId } = res; const { token, customerId, isAuth } = res;
updateUserInfo({ updateUserInfo({
token, token,
customerId, customerId,
isAuth,
}); });
}); });
}); });
......
...@@ -113,15 +113,18 @@ class Index extends Component { ...@@ -113,15 +113,18 @@ class Index extends Component {
const { updateUserInfo } = this.props; const { updateUserInfo } = this.props;
return Taro.login().then(res => { return Taro.login().then(res => {
console.log('login info:', res);
const { code } = res; const { code } = res;
return registerAndLogin({ return registerAndLogin({
code, code,
// userName: '', // userName: '',
}).then(res => { }).then(res => {
const { token, customerId } = res; const { token, customerId, isAuth } = res;
updateUserInfo({ updateUserInfo({
token, token,
customerId, customerId,
isAuth,
}); });
}); });
}); });
...@@ -179,7 +182,7 @@ class Index extends Component { ...@@ -179,7 +182,7 @@ class Index extends Component {
} }
if (deviceInfoResponse) { if (deviceInfoResponse) {
updateDeviceData(deviceInfoResponse); updateDeviceData(deviceInfoResponse);
updateDeviceData({originCode: equipmentNum}); updateDeviceData({ originCode: equipmentNum });
} else { } else {
resetDeviceData(); resetDeviceData();
} }
......
...@@ -86,6 +86,17 @@ class Pay extends Component { ...@@ -86,6 +86,17 @@ class Pay extends Component {
}; };
this.checkBluetoothAndWs(); this.checkBluetoothAndWs();
} }
componentWillMount() {
const { prepayConfig } = this.props;
if (prepayConfig.length) {
this.setState({
payId: prepayConfig[0].id,
});
}
}
componentWillUnmount() { componentWillUnmount() {
// this.closeBluetooth(); // this.closeBluetooth();
// this.closeDeviceSocket(); // this.closeDeviceSocket();
...@@ -379,9 +390,7 @@ class Pay extends Component { ...@@ -379,9 +390,7 @@ class Pay extends Component {
let abStr = ''; let abStr = '';
Taro.onBLECharacteristicValueChange(res => { Taro.onBLECharacteristicValueChange(res => {
console.log( console.log(
`characteristic ${res.characteristicId} has changed, now is ${ `characteristic ${res.characteristicId} has changed, now is ${res.value}`,
res.value
}`,
); );
console.log(res.value); console.log(res.value);
let datastr = ab2str(res.value); let datastr = ab2str(res.value);
...@@ -436,9 +445,7 @@ class Pay extends Component { ...@@ -436,9 +445,7 @@ class Pay extends Component {
Taro.onBLEConnectionStateChange(res => { Taro.onBLEConnectionStateChange(res => {
// const { showerState } = this.state; // const { showerState } = this.state;
console.log( console.log(
`device ${res.deviceId} state has changed, connected: ${ `device ${res.deviceId} state has changed, connected: ${res.connected}`,
res.connected
}`,
); );
if (res.connected) { if (res.connected) {
this.setState({ this.setState({
...@@ -706,7 +713,7 @@ class Pay extends Component { ...@@ -706,7 +713,7 @@ class Pay extends Component {
this.closeBluetooth(); this.closeBluetooth();
return Taro.showModal({ return Taro.showModal({
title: '提示', title: '提示',
content: '设备蓝牙连接失败...请稍后再试', content: '设备蓝牙或网络连接失败...请稍后再试',
showCancel: false, showCancel: false,
}).then(res => { }).then(res => {
console.log(res); console.log(res);
...@@ -714,7 +721,7 @@ class Pay extends Component { ...@@ -714,7 +721,7 @@ class Pay extends Component {
}); });
} }
payHandle() { payHandle(phoneData) {
const { const {
device, device,
userinfo: { customerId }, userinfo: { customerId },
...@@ -729,7 +736,7 @@ class Pay extends Component { ...@@ -729,7 +736,7 @@ class Pay extends Component {
} }
} }
} }
getPayOrder({ let entity = {
equipmentNum: device.originCode, equipmentNum: device.originCode,
equipmentPos: device.position, equipmentPos: device.position,
payType: '2', payType: '2',
...@@ -738,7 +745,11 @@ class Pay extends Component { ...@@ -738,7 +745,11 @@ class Pay extends Component {
smaproPrepayConfigId: payId, smaproPrepayConfigId: payId,
areaId: device.areaId, areaId: device.areaId,
areaName: device.areaName, areaName: device.areaName,
}) };
if (phoneData) {
entity = { ...entity, ...phoneData };
}
getPayOrder(entity)
.then(res => { .then(res => {
console.log('res: ', res); console.log('res: ', res);
...@@ -811,8 +822,20 @@ class Pay extends Component { ...@@ -811,8 +822,20 @@ class Pay extends Component {
} }
} }
getPhoneHandle(e) {
console.log(e);
const { encryptedData, iv } = e.detail;
if (encryptedData && iv) {
console.log('获得手机权限');
this.payHandle({
encryptedData,
iv,
});
}
}
render() { render() {
const { device, prepayConfig } = this.props; const { device, prepayConfig, userinfo } = this.props;
const { payId } = this.state; const { payId } = this.state;
return ( return (
<View className='Pay'> <View className='Pay'>
...@@ -829,6 +852,7 @@ class Pay extends Component { ...@@ -829,6 +852,7 @@ class Pay extends Component {
<Text>设备位置</Text> <Text>设备位置</Text>
<Text className='Pay-info-position'>{device.position}</Text> <Text className='Pay-info-position'>{device.position}</Text>
</View> </View>
{device.rates.length && (
<View className='Pay-info-item'> <View className='Pay-info-item'>
<Text>适用费率</Text> <Text>适用费率</Text>
<View className='Pay-info-rate'> <View className='Pay-info-rate'>
...@@ -848,6 +872,7 @@ class Pay extends Component { ...@@ -848,6 +872,7 @@ class Pay extends Component {
</View> */} </View> */}
</View> </View>
</View> </View>
)}
</View> </View>
<View className='Pay-tip'> <View className='Pay-tip'>
{device.refundMode === DeviceRefundMode.notRefund {device.refundMode === DeviceRefundMode.notRefund
...@@ -872,9 +897,18 @@ class Pay extends Component { ...@@ -872,9 +897,18 @@ class Pay extends Component {
<View className='Pay-money-item'>5.00元</View> <View className='Pay-money-item'>5.00元</View>
<Input className='Pay-money-item' placeholder='输入>0.5数额' /> */} <Input className='Pay-money-item' placeholder='输入>0.5数额' /> */}
</View> </View>
{userinfo.isAuth ? (
<Button className='Pay-btn' onClick={this.payHandle}> <Button className='Pay-btn' onClick={this.payHandle}>
确定支付 确定支付
</Button> </Button>
) : (
<Button
className='Pay-btn'
open-type='getPhoneNumber'
onGetphonenumber={this.getPhoneHandle}>
确定支付
</Button>
)}
</View> </View>
); );
} }
......
...@@ -72,10 +72,8 @@ class ScanEnter extends Component { ...@@ -72,10 +72,8 @@ class ScanEnter extends Component {
this.loginHandle().then(() => { this.loginHandle().then(() => {
// 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 (scene) {
// Taro.showLoading(); // Taro.showLoading();
// let entity = this.getDeviceEntity(scene); // let entity = this.getDeviceEntity(scene);
...@@ -99,15 +97,17 @@ class ScanEnter extends Component { ...@@ -99,15 +97,17 @@ class ScanEnter extends Component {
const { updateUserInfo } = this.props; const { updateUserInfo } = this.props;
return Taro.login().then(res => { return Taro.login().then(res => {
console.log('login info:', res);
const { code } = res; const { code } = res;
return registerAndLogin({ return registerAndLogin({
code, code,
// userName: '', // userName: '',
}).then(res => { }).then(res => {
const { token, customerId } = res; const { token, customerId, isAuth } = res;
updateUserInfo({ updateUserInfo({
token, token,
customerId, customerId,
isAuth,
}); });
}); });
}); });
...@@ -162,7 +162,7 @@ class ScanEnter extends Component { ...@@ -162,7 +162,7 @@ class ScanEnter extends Component {
} }
if (deviceInfoResponse) { if (deviceInfoResponse) {
updateDeviceData(deviceInfoResponse); updateDeviceData(deviceInfoResponse);
updateDeviceData({originCode: equipmentNum}); updateDeviceData({ originCode: equipmentNum });
} else { } else {
resetDeviceData(); resetDeviceData();
} }
......
...@@ -6,6 +6,7 @@ export type UserState = StoreState<Customer & { code: string }>; ...@@ -6,6 +6,7 @@ export type UserState = StoreState<Customer & { code: string }>;
export const INITIAL_STATE = { export const INITIAL_STATE = {
token: '', token: '',
customerId: 0, customerId: 0,
isAuth: false,
}; };
export const updateUserInfo = (entity: UserState): Action => ({ export const updateUserInfo = (entity: UserState): Action => ({
......
export type Customer = { export type Customer = {
token: string; token: string;
customerId: number; customerId: number;
isAuth: boolean;
}; };
export type WechatUserInfo = { export type WechatUserInfo = {
......
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