feat: update of partner
This commit is contained in:
@ -139,7 +139,11 @@ export const requestAnchorList = async (data: GetAnchorListRequest) => {
|
||||
return http.post<GetAnchorListResponse>(API.GET_ANCHOR_LIST, { data });
|
||||
};
|
||||
|
||||
export const getMaterialShareMessage = async (profile?: MaterialProfile | null, needShareCode: boolean = true) => {
|
||||
export const getMaterialShareMessage = async (
|
||||
profile?: MaterialProfile | null,
|
||||
needShareCode: boolean = true,
|
||||
inviteCode?: string
|
||||
) => {
|
||||
if (!profile) {
|
||||
return null;
|
||||
}
|
||||
@ -149,7 +153,12 @@ export const getMaterialShareMessage = async (profile?: MaterialProfile | null,
|
||||
const title = `${name} ${workedSecCategoryStr ? `播过 ${workedSecCategoryStr}` : ''}`.trim();
|
||||
return {
|
||||
title,
|
||||
path: getJumpUrl(PageUrl.MaterialView, { shareCode, resumeId: id, source: MaterialViewSource.Share }),
|
||||
path: getJumpUrl(PageUrl.MaterialView, {
|
||||
shareCode,
|
||||
resumeId: id,
|
||||
source: MaterialViewSource.Share,
|
||||
c: inviteCode,
|
||||
}),
|
||||
};
|
||||
} catch (error: unknown) {
|
||||
const e = error as HttpError;
|
||||
|
||||
@ -1,7 +1,110 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
import { CacheKey } from '@/constants/cache-key';
|
||||
import http from '@/http';
|
||||
import { API } from '@/http/api';
|
||||
import store from '@/store';
|
||||
import { setInviteCode } from '@/store/actions/partner';
|
||||
import {
|
||||
GetProfitRequest,
|
||||
InviteUserInfo,
|
||||
PartnerInviteCode,
|
||||
PartnerProfitItem,
|
||||
PartnerProfitsState,
|
||||
} from '@/types/partner';
|
||||
import { requestUserInfo } from '@/utils/user';
|
||||
|
||||
export const getInviteCodeFromQuery = (query: Record<string, string>): string | undefined => {
|
||||
if (query) {
|
||||
if (query.scene) {
|
||||
return query.scene.replace('c%3D', '');
|
||||
}
|
||||
if (query.c) {
|
||||
return query.c;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const getInviteCodeFromQueryAndUpdate = (query: Record<string, string>) => {
|
||||
const code = getInviteCodeFromQuery(query);
|
||||
if (!code) {
|
||||
return;
|
||||
}
|
||||
console.log('get code', code);
|
||||
requestUserInfo(code);
|
||||
};
|
||||
|
||||
export const getPartnerBannerClose = (): boolean => Taro.getStorageSync(CacheKey.CLOSE_PARTNER_BANNER);
|
||||
|
||||
export const setPartnerBannerClose = () => Taro.setStorageSync(CacheKey.CLOSE_PARTNER_BANNER, true);
|
||||
|
||||
export const becomePartner = async () => {
|
||||
await http.post(API.BECOME_PARTNER);
|
||||
await getInviteCode();
|
||||
};
|
||||
export const getPartnerQrcode = async () => {
|
||||
return await http.post(API.PARTNER_QRCODE, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
};
|
||||
export const getPartnerProfitStat = async () => {
|
||||
return await http.post<PartnerProfitsState>(API.GET_PROFIT_STAT);
|
||||
};
|
||||
export const getPartnerInviteList = async () => {
|
||||
return await http.post<InviteUserInfo[]>(API.GET_INVITE_LIST);
|
||||
};
|
||||
export const dispatchUpdateInviteCode = (code: string) => store.dispatch(setInviteCode(code));
|
||||
export const getInviteCode = async () => {
|
||||
const { inviteCode } = await http.post<PartnerInviteCode>(API.GET_INVITE_CODE);
|
||||
dispatchUpdateInviteCode(inviteCode);
|
||||
return inviteCode;
|
||||
};
|
||||
export const getProfitList = async (data: GetProfitRequest) => {
|
||||
return await http.post<PartnerProfitItem[]>(API.GET_PROFIT_LIST, { data });
|
||||
};
|
||||
export const formatMoney = (cents: number) => {
|
||||
if (!cents) {
|
||||
return '0';
|
||||
}
|
||||
const yuan = cents / 100;
|
||||
return yuan.toFixed(2);
|
||||
};
|
||||
export function formatTimestamp(timestamp: string): string {
|
||||
// 将字符串时间戳转换为数字类型
|
||||
const time = Number(timestamp);
|
||||
|
||||
// 创建 Date 对象
|
||||
const date = new Date(time);
|
||||
|
||||
// 获取年、月、日、时、分、秒
|
||||
const YYYY = date.getFullYear();
|
||||
const MM = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
|
||||
const DD = String(date.getDate()).padStart(2, '0');
|
||||
const HH = String(date.getHours()).padStart(2, '0');
|
||||
const mm = String(date.getMinutes()).padStart(2, '0');
|
||||
const ss = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
// 拼接成所需的格式
|
||||
return `${YYYY}.${MM}.${DD} ${HH}:${mm}:${ss}`;
|
||||
}
|
||||
|
||||
export function formatUserId(input: string): string {
|
||||
const length = input.length;
|
||||
|
||||
// 如果长度小于8,隐藏最后4位
|
||||
if (length < 8) {
|
||||
const beforeMask = input.slice(0, length - 4); // 前部分
|
||||
const maskedPart = '****'; // 替换最后4位为星号
|
||||
return beforeMask + maskedPart;
|
||||
}
|
||||
|
||||
// 如果长度大于或等于8,隐藏倒数第五位到倒数第二位
|
||||
const start = length - 8; // 倒数第八个字符的索引
|
||||
const beforeMask = input.slice(0, start); // 前部分
|
||||
const maskedPart = '****'; // 替换倒数第五位到倒数第二位为星号
|
||||
const afterMask = input.slice(start + 4); // 后部分
|
||||
|
||||
// 拼接结果
|
||||
return beforeMask + maskedPart + afterMask;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ export async function requestAllBuyProduct(productCode: ProductType) {
|
||||
|
||||
export async function requestCsQrCode(_type: QrCodeType) {
|
||||
const result = await http.post<CustomerServiceInfo>(API.CS_QR_CODE);
|
||||
return `${DOMAIN}/${result.vxQrCode}`;
|
||||
return result.vxQrCode;
|
||||
}
|
||||
|
||||
export async function requestCreatePayInfo(params: Omit<CreatePayInfoRequest, 'payChannel' | 'payType' | 'userId'>) {
|
||||
|
||||
@ -15,10 +15,11 @@ const getRandomCount = () => {
|
||||
return (seed % 300) + 500;
|
||||
};
|
||||
|
||||
export const getCommonShareMessage = (useCapture: boolean = true): ShareAppMessageReturn => {
|
||||
export const getCommonShareMessage = (useCapture: boolean = true, inviteCode?: string): ShareAppMessageReturn => {
|
||||
console.log('share share message', getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined));
|
||||
return {
|
||||
title: `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
||||
path: getJumpUrl(PageUrl.Job),
|
||||
path: getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined),
|
||||
imageUrl: useCapture ? undefined : imageUrl,
|
||||
};
|
||||
};
|
||||
|
||||
@ -33,6 +33,8 @@ export const isValidUserInfo = (info: UserInfo) => !!info.userId;
|
||||
export const isNeedLogin = (info: UserInfo) => !info.isBindPhone;
|
||||
// export const isNeedLogin = (info: UserInfo) => !info.isBindPhone || info.userId === '534740874077898752';
|
||||
|
||||
export const isNeedPhone = (info: UserInfo) => isNeedLogin(info) || !info.phone;
|
||||
|
||||
export const updateLastLoginTime = () => {
|
||||
lastOpenMiniProgramTime = Taro.getStorageSync<number>(CacheKey.LAST_OPEN_MINI_PROGRAM_TIME) ?? null;
|
||||
const now = Date.now();
|
||||
@ -98,8 +100,8 @@ export const ensureUserInfo = async (info: UserInfo, toast = true) => {
|
||||
|
||||
export const dispatchUpdateUser = (userInfo: Partial<UserInfo>) => store.dispatch(setUserInfo(userInfo));
|
||||
|
||||
export async function requestUserInfo() {
|
||||
const userInfo = await http.post<UserInfo>(API.USER);
|
||||
export async function requestUserInfo(inviteCode?: string) {
|
||||
const userInfo = await http.post<UserInfo>(API.USER, { data: inviteCode ? { inviteCode } : {} });
|
||||
dispatchUpdateUser(userInfo);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user