code refactor
This commit is contained in:
@@ -5,6 +5,8 @@ const baseProxyUrlPath = '/proxy';
|
||||
const baseAmapApiProxyUrlPath = '/_AMapService';
|
||||
const apiNotFoundErrorCode = 100001;
|
||||
const validatorErrorCode = 200000;
|
||||
const userEmailNotVerifiedErrorCode = 201020;
|
||||
const transactionPictureNotFoundErrorCode = 211001;
|
||||
const googleMapJavascriptUrl = 'https://maps.googleapis.com/maps/api/js';
|
||||
const baiduMapJavascriptUrl = 'https://api.map.baidu.com/api?v=3.0';
|
||||
const amapJavascriptUrl = 'https://webapi.amap.com/maps?v=2.0';
|
||||
@@ -145,6 +147,8 @@ export default {
|
||||
baseAmapApiProxyUrlPath: baseAmapApiProxyUrlPath,
|
||||
apiNotFoundErrorCode: apiNotFoundErrorCode,
|
||||
validatorErrorCode: validatorErrorCode,
|
||||
userEmailNotVerifiedErrorCode: userEmailNotVerifiedErrorCode,
|
||||
transactionPictureNotFoundErrorCode: transactionPictureNotFoundErrorCode,
|
||||
specifiedApiNotFoundErrors: specifiedApiNotFoundErrors,
|
||||
parameterizedErrors: parameterizedErrors,
|
||||
googleMapJavascriptUrl: googleMapJavascriptUrl,
|
||||
|
||||
@@ -175,6 +175,7 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import assetConstants from '@/consts/asset.js';
|
||||
import apiConstants from '@/consts/api.js';
|
||||
import {
|
||||
isUserRegistrationEnabled,
|
||||
isUserForgetPasswordEnabled,
|
||||
@@ -314,7 +315,7 @@ export default {
|
||||
}).catch(error => {
|
||||
self.logining = false;
|
||||
|
||||
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === 201020 && error.error.context && error.error.context.email) {
|
||||
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === apiConstants.userEmailNotVerifiedErrorCode && error.error.context && error.error.context.email) {
|
||||
self.$router.push(`/verify_email?email=${encodeURIComponent(error.error.context.email)}&emailSent=${error.error.context.hasValidEmailVerifyToken || false}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -395,6 +395,7 @@ import fileConstants from '@/consts/file.js';
|
||||
import categoryConstants from '@/consts/category.js';
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
import templateConstants from '@/consts/template.js';
|
||||
import apiConstants from '@/consts/api.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import {
|
||||
isArray,
|
||||
@@ -1161,7 +1162,7 @@ export default {
|
||||
self.removingPictureId = '';
|
||||
self.submitting = false;
|
||||
}).catch(error => {
|
||||
if (error.error && error.error.errorCode === 211001) {
|
||||
if (error.error && error.error.errorCode === apiConstants.transactionPictureNotFoundErrorCode) {
|
||||
for (let i = 0; i < self.transaction.pictures.length; i++) {
|
||||
if (self.transaction.pictures[i].pictureId === pictureInfo.pictureId) {
|
||||
self.transaction.pictures.splice(i, 1);
|
||||
|
||||
@@ -184,6 +184,7 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import assetConstants from '@/consts/asset.js';
|
||||
import apiConstants from '@/consts/api.js';
|
||||
import {
|
||||
isUserRegistrationEnabled,
|
||||
isUserForgetPasswordEnabled,
|
||||
@@ -324,7 +325,7 @@ export default {
|
||||
self.logining = false;
|
||||
self.$hideLoading();
|
||||
|
||||
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === 201020 && error.error.context && error.error.context.email) {
|
||||
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === apiConstants.userEmailNotVerifiedErrorCode && error.error.context && error.error.context.email) {
|
||||
self.resendVerifyEmail = error.error.context.email;
|
||||
self.hasValidEmailVerifyToken = error.error.context.hasValidEmailVerifyToken || false;
|
||||
self.currentPasswordForResendVerifyEmail = '';
|
||||
|
||||
@@ -435,6 +435,7 @@ import fileConstants from '@/consts/file.js';
|
||||
import categoryConstants from '@/consts/category.js';
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
import templateConstants from '@/consts/template.js';
|
||||
import apiConstants from '@/consts/api.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import {
|
||||
isArray,
|
||||
@@ -1220,7 +1221,7 @@ export default {
|
||||
self.removingPictureId = '';
|
||||
self.submitting = false;
|
||||
}).catch(error => {
|
||||
if (error.error && error.error.errorCode === 211001) {
|
||||
if (error.error && error.error.errorCode === apiConstants.transactionPictureNotFoundErrorCode) {
|
||||
for (let i = 0; i < self.transaction.pictures.length; i++) {
|
||||
if (self.transaction.pictures[i].pictureId === pictureInfo.pictureId) {
|
||||
self.transaction.pictures.splice(i, 1);
|
||||
|
||||
Reference in New Issue
Block a user