Small fix

This commit is contained in:
saplf
2019-09-08 17:37:56 +08:00
parent b65b7c611e
commit 240daa107e
7 changed files with 44 additions and 25 deletions

View File

@@ -111,7 +111,7 @@
"frameworks" : [] /*Native.jsObjective-c APIFrameWorkGameCenter"GameKit.framework"*/
},
"google" : {
"packagename" : "org.faronear.fiv", /*Androidio.dcloud.HelloH5*/
"packagename" : "org.tacever.fiv", /*Androidio.dcloud.HelloH5*/
"keystore" : "unpackage/key/fiv.keystore", /*Android使*/
"password" : "fiv2019lwhx", /*Android使*/
"aliasname" : "fiv", /*Android使*/

View File

@@ -9,8 +9,8 @@ export default {
],
baseURL: 'https://server.fiv.tacever.org/v1',
// baseURL: 'http://yapi.faronear.org/mock/20/v1',
linkAndroid: 'xxx',
linkIOS: '',
linkAndroid: 'https://fivhome.github.io/app/android.apk',
linkIOS: 'https://fivapp.github.io',
linkTelegram: 'https://t.me/fivhome',
linkEmail: 'team-fiv@outlook.com',
};

View File

@@ -19,11 +19,8 @@ const MinePage: React.FC<HomeMineModelState & DispatchProp> = ({
}) => {
useEffect(() => {
if (!data || errorList) {
dispatch({ type: 'homeMine/loadList', payload: false });
}
if (!info || errorBasic) {
dispatch({ type: 'homeMine/loadBasic' });
if (!data || errorList || !info || errorBasic) {
dispatch({ type: 'homeMine/load' });
}
}, []);

View File

@@ -2,6 +2,7 @@ import { Model } from 'dva';
import { Mines, MineBasic } from '@/types/common';
import { getMineList, getMineBasic, refresh, RefreshData } from './service';
import { message } from 'antd';
import { loadMineList } from '@/utils/storage';
export interface HomeMineModelState {
refreshingList: boolean;
@@ -27,6 +28,18 @@ const MineModel: Model = {
} as HomeMineModelState,
effects: {
*load(_, { put, all }) {
const cached = loadMineList();
if (cached && cached.length) {
yield all([
put({ type: 'loadList', payload: false }),
put({ type: 'loadBasic' }),
]);
} else {
yield put({ type: 'refresh' });
}
},
*loadList({ payload: refresh }, { put, call, select }) {
const { refreshingList } = yield select((state: any) => state.homeMine);
if (refreshingList) return;
@@ -81,8 +94,11 @@ const MineModel: Model = {
},
*refresh(_, { put, call, select }) {
const { refreshingBasic } = yield select((state: any) => state.homeMine);
if (refreshingBasic) return;
const {
homeMine: { refreshingBasic, refreshingList },
user: { user },
} = yield select();
if (refreshingBasic || refreshingList || !user) return;
yield put({
type: 'onUpdateState',
@@ -92,7 +108,8 @@ const MineModel: Model = {
errorList: false,
});
try {
const info = (yield call(refresh)) as RefreshData;
const info = (yield call(refresh, user.inviter)) as RefreshData;
if (info && info.basic) {
yield put({
type: 'onUpdateState',
info: info.basic,
@@ -101,6 +118,7 @@ const MineModel: Model = {
refreshingList: false,
errorBasic: false,
});
}
} catch (e) {
message.error(e.message);
yield put({
@@ -108,6 +126,7 @@ const MineModel: Model = {
refreshingBasic: false,
refreshingList: false,
errorBasic: true,
errorList: true,
});
}
},

View File

@@ -39,15 +39,17 @@ export async function getMineList(refresh = false): Promise<Mines> {
throw Error(msg);
}
export async function refresh(): Promise<RefreshData> {
export async function refresh(inviter: string): Promise<RefreshData> {
const {
ok,
data,
msg,
} = await http.get<RefreshData>('/fund/refresh');
if (ok && data) {
storeMineList(data);
return data;
} = await http.get<RefreshData>('/fund/refresh', { inviter });
if (ok) {
if (data && data.list) {
storeMineList(data.list);
}
return data as any;
}
throw Error(msg);
}

View File

@@ -12,6 +12,7 @@ export interface User {
email?: string;
token: string;
inviteCode: string;
inviter: string;
}
export enum SendCodeType {

View File

@@ -97,7 +97,7 @@ async function filter<T>(
function groupUrl(url: string, params?: any): string {
const postfix = _.keys(params || {})
.map(key => `${key}=${encodeURIComponent(params[key]) || ''}`)
.map(key => `${key}=${encodeURIComponent(params[key] || '') || ''}`)
.join('&');
if (!postfix) return url;
return `${url}?${postfix}`;