Commit 3445931e by 姜雷

调整请求逻辑

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