This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import request from '@/utils/request.js';
|
||||
import { useAssetStore } from '@/store/asset.js';
|
||||
import { useUserStore } from '@/store/user.js';
|
||||
import { getSessionContext, isCurrentSession } from '@/utils/session-context.js';
|
||||
|
||||
export const normalizeAssetInfo = (data = {}) => ({
|
||||
...data,
|
||||
@@ -56,11 +59,23 @@ export const hasActiveOrPendingPackage = async (identifier) => {
|
||||
|
||||
export const assetApi = {
|
||||
getInfo(identifier) {
|
||||
const context = getSessionContext();
|
||||
const userStore = useUserStore();
|
||||
const phoneRevision = userStore.state.phoneRevision;
|
||||
return request({
|
||||
url: '/api/c/v1/asset/info',
|
||||
method: 'GET',
|
||||
data: { identifier }
|
||||
}).then(normalizeAssetInfo);
|
||||
}).then((response) => {
|
||||
const data = normalizeAssetInfo(response);
|
||||
if (identifier === context.identifier && isCurrentSession(context)) {
|
||||
useAssetStore().receiveExpiryReminder(context, data.expiry_reminder);
|
||||
if (phoneRevision === userStore.state.phoneRevision && typeof data.bound_phone === 'string') {
|
||||
userStore.setCustomerPhone(data.bound_phone);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
getPackageHistory(identifier, page, page_size, params = {}) {
|
||||
|
||||
@@ -30,7 +30,8 @@ export const authApi = {
|
||||
return request({
|
||||
url: '/api/c/v1/auth/bind-phone',
|
||||
method: 'POST',
|
||||
data: { phone, code }
|
||||
data: { phone, code },
|
||||
showError: false
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export const notificationApi = {
|
||||
markAllRead() {
|
||||
return request({
|
||||
url: '/api/c/v1/notifications/read-all',
|
||||
method: 'PUT'
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user