Commit 9ffcdfc0 by 姜雷

Merge branch 'develop' into test

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