Commit 3445931e by 姜雷

调整请求逻辑

parent 11e46672
...@@ -62,7 +62,6 @@ class Index extends Component { ...@@ -62,7 +62,6 @@ class Index extends Component {
componentWillMount() { componentWillMount() {
this.loginHandle().then(() => { this.loginHandle().then(() => {
const { userinfo } = this.props;
let queryArr = Object.keys(this.$router.params); let queryArr = Object.keys(this.$router.params);
console.log(this.$router.params); console.log(this.$router.params);
...@@ -70,22 +69,10 @@ class Index extends Component { ...@@ -70,22 +69,10 @@ class Index extends Component {
console.log('scene:', scene); console.log('scene:', scene);
if (scene) { if (scene) {
Taro.showLoading();
let entity = this.getDeviceEntity(scene); let entity = this.getDeviceEntity(scene);
if (entity) { if (entity) {
getDeviceConfig({ this.getDeviceConfigHandle(entity);
customerId: userinfo.customerId,
...entity,
})
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err);
Taro.showToast({
title: err.msg || '设备码有误',
icon: 'none',
});
});
} }
} }
}); });
...@@ -119,26 +106,41 @@ class Index extends Component { ...@@ -119,26 +106,41 @@ class Index extends Component {
} }
scanHandle() { scanHandle() {
const { userinfo, updateDeviceData, updatePayData } = this.props;
Taro.scanCode({ Taro.scanCode({
onlyFromCamera: true, onlyFromCamera: true,
scanType: ['qrCode'], scanType: ['qrCode'],
}) })
.then(res => { .then(res => {
console.log(res);
const { path, result } = res; const { path, result } = res;
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 { serviceId, equipmentNum } = this.getDeviceEntity(queryStr); const entity = this.getDeviceEntity(queryStr);
this.getDeviceConfigHandle(entity);
} else {
Taro.showToast({
title: '请扫描正确的设备码',
icon: 'none',
});
}
})
.catch(err => {
console.error(err);
});
}
getDeviceConfig({ getDeviceConfigHandle({ equipmentNum, serviceId }: DeviceEntity) {
Taro.showLoading();
const { userinfo, updateDeviceData, updatePayData } = this.props;
return getDeviceConfig({
customerId: userinfo.customerId, customerId: userinfo.customerId,
equipmentNum: equipmentNum, equipmentNum: equipmentNum,
serviceId: serviceId, serviceId: serviceId,
}) })
.then(res => { .then(res => {
Taro.hideLoading();
console.log(res); console.log(res);
const { deviceInfoResponse, prepayConfigs } = res; const { deviceInfoResponse, prepayConfigs } = res;
if (deviceInfoResponse.isUsed) { if (deviceInfoResponse.isUsed) {
...@@ -158,16 +160,6 @@ class Index extends Component { ...@@ -158,16 +160,6 @@ class Index extends Component {
icon: 'none', icon: 'none',
}); });
}); });
} else {
Taro.showToast({
title: '请扫描正确的设备码',
icon: 'none',
});
}
})
.catch(err => {
console.error(err);
});
} }
getUserInfoHandle(res) { getUserInfoHandle(res) {
......
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