Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
error => {
console.log('err' + error) // for debug
Toast.fail({
message: error.message,
duration: 1.5 * 1000
})
return Promise.reject(error)
}
)
response => {
const res = response.data
if (res.errno === 501) {
Toast.fail('请登录');
setTimeout(() => {
window.location = '#/login/'
}, 1500)
return Promise.reject('error')
} else if (res.errno === 502) {
Toast.fail('网站内部错误,请联系网站维护人员')
return Promise.reject('error')
} if (res.errno === 401) {
Toast.fail('参数不对');
return Promise.reject('error')
} if (res.errno === 402) {
Toast.fail('参数值不对');
return Promise.reject('error')
} else if (res.errno !== 0) {
// 非5xx的错误属于业务错误,留给具体页面处理
return Promise.reject(response)
} else {
return response
}
}, error => {
console.log('err' + error)// for debug
const res = response.data
if (res.errno === 501) {
Toast.fail('请登录');
setTimeout(() => {
window.location = '#/login/'
}, 1500)
return Promise.reject('error')
} else if (res.errno === 502) {
Toast.fail('网站内部错误,请联系网站维护人员')
return Promise.reject('error')
} if (res.errno === 401) {
Toast.fail('参数不对');
return Promise.reject('error')
} if (res.errno === 402) {
Toast.fail('参数值不对');
return Promise.reject('error')
} else if (res.errno !== 0) {
// 非5xx的错误属于业务错误,留给具体页面处理
return Promise.reject(response)
} else {
return response
}
}, error => {
console.log('err' + error)// for debug
.then(response => {
if (response.status === 200) {
if (response.data.code === 200 || !response.data.code) {
// 请求成功
resolve(response.data);
} else {
// 请求错误
reject(response.data);
}
} else {
// 服务器错误
Toast.fail('服务器错误!');
reject(response.data);
}
})
.catch(error => {
onSubmit() {
const {AddressId, CartId, CouponId, UserCouponId} = getLocalStorage('AddressId', 'CartId', 'CouponId', 'UserCouponId');
if (AddressId === null) {
Toast.fail('请设置收货地址');
return;
}
this.isDisabled = true;
orderSubmit({
addressId: AddressId,
cartId: CartId,
couponId: CouponId,
userCouponId: UserCouponId,
grouponLinkId: 0,
grouponRulesId: 0,
message: this.message
}).then(res => {
async onCutCart(item) {
if (item.num > 1) {
let res = await apiCutCart(item.productId, "cut");
if (res.data.code === 0) {
console.log("减少成功");
Toast.success("减少成功");
item.num--;
} else {
Toast.fail(res.data.msg);
}
this.onCalAllCoach();
}
},
onCalAllCoach() {
break;
case 404:
break;
case 740: {
Toast.fail('优惠券已经领取过');
break;
}
case 501: {
Toast.fail('请登录');
setTimeout(() => {
window.location = '#/login/'
}, 1500)
break;
}
default:
Toast.fail(res.data.errmsg)
}
return Promise.reject(res);
}
return res;
},
error => {
const flag = Array.isArray(res.data.data) && res.data.data.length;
Dialog.alert({
message: flag ? res.data.data[0].message : res.data.message
});
break;
}
case 401:
break;
case 404:
break;
case 740: {
Toast.fail('优惠券已经领取过');
break;
}
case 501: {
Toast.fail('请登录');
setTimeout(() => {
window.location = '#/login/'
}, 1500)
break;
}
default:
Toast.fail(res.data.errmsg)
}
return Promise.reject(res);
}
return res;
},
error => {
error => {
Toast.fail("加载超时");
return Promise.reject(error);
}
);
}).catch(error => {
Toast.fail(error.data.errmsg);
});
},