Compare commits
8 Commits
trunk
...
6d76c82e96
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d76c82e96 | |||
| 087e05a9a0 | |||
| aea8323d95 | |||
| 61686950bd | |||
| eea89263f2 | |||
| d0369bab36 | |||
| 898c6ab6ca | |||
| 670a389f12 |
@ -1,19 +1,19 @@
|
||||
import { Button, Canvas } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { openCustomerServiceChat } from '@/utils/common';
|
||||
import { getPartnerQrcode } from '@/utils/partner';
|
||||
import { getCouponQrCode, generateMembershipCoupon } from '@/utils/coupon';
|
||||
import './index.less';
|
||||
|
||||
const PREFIX = 'partner-intro';
|
||||
|
||||
export default function PartnerIntro() {
|
||||
const [posterPath, setPosterPath] = useState('');
|
||||
const getQrcode = async () => {
|
||||
try {
|
||||
const data = await getPartnerQrcode(); // 假设 getPartnerQrcode 返回 ArrayBuffer
|
||||
const { code } = await generateMembershipCoupon();
|
||||
const data = await getCouponQrCode(code);
|
||||
const base64 = Taro.arrayBufferToBase64(data);
|
||||
return `data:image/png;base64,${base64}`;
|
||||
} catch (error) {
|
||||
@ -39,8 +39,6 @@ export default function PartnerIntro() {
|
||||
fileType: 'jpg',
|
||||
});
|
||||
|
||||
setPosterPath(tempFilePath.tempFilePath);
|
||||
|
||||
resolve(tempFilePath.tempFilePath);
|
||||
});
|
||||
} catch (error) {
|
||||
@ -57,21 +55,21 @@ export default function PartnerIntro() {
|
||||
const canvas = res[0].node;
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
canvas.width = 1500;
|
||||
canvas.height = 2668;
|
||||
canvas.width = 550 * 2;
|
||||
canvas.height = 918 * 2;
|
||||
ctx.scale(2, 2);
|
||||
|
||||
// 绘制背景图片
|
||||
const bgImage = canvas.createImage();
|
||||
const poster = 'https://publiccdn.neighbourhood.com.cn/img/poster.png'
|
||||
const poster = 'https://publiccdn.neighbourhood.com.cn/img/share-coupon-poster.png';
|
||||
bgImage.src = poster;
|
||||
bgImage.onload = () => {
|
||||
ctx.drawImage(bgImage, 0, 0, 750, 1334);
|
||||
ctx.drawImage(bgImage, 0, 0, 550, 918);
|
||||
|
||||
const qrCodeImage = canvas.createImage();
|
||||
qrCodeImage.src = qrCode; // 假设 getQrcode() 返回的是二维码图片的路径
|
||||
qrCodeImage.onload = () => {
|
||||
ctx.drawImage(qrCodeImage, 235, 894, 280, 280); // 绘制二维码,位置和大小
|
||||
ctx.drawImage(qrCodeImage, 196, 600, 160, 160); // 绘制二维码,位置和大小
|
||||
saveCanvasToTempFile().then(tempPath => {
|
||||
resolve(tempPath);
|
||||
});
|
||||
@ -84,13 +82,10 @@ export default function PartnerIntro() {
|
||||
});
|
||||
};
|
||||
const savePoster = async () => {
|
||||
let filePath = posterPath;
|
||||
if (!filePath) {
|
||||
Taro.showLoading({ title: '正在生成海报' });
|
||||
const qrCode = await getQrcode();
|
||||
filePath = await drawCanvas(qrCode);
|
||||
const filePath = await drawCanvas(qrCode);
|
||||
Taro.hideLoading();
|
||||
}
|
||||
|
||||
const res = await Taro.getSetting();
|
||||
const hasPermission = res.authSetting['scope.writePhotosAlbum'];
|
||||
@ -144,7 +139,9 @@ export default function PartnerIntro() {
|
||||
<div className={`${PREFIX}__block`}>
|
||||
<div className={`${PREFIX}__title`}>分享方法</div>
|
||||
<div className={`${PREFIX}__card`}>
|
||||
<div className={`${PREFIX}__body`}>分享小程序任意页面到群、朋友圈、好友即可</div>
|
||||
<div className={`${PREFIX}__body`}>
|
||||
点击底部按钮向好友群友赠送会员,或者分享通告列表、通告详情等页面给朋友即可
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`${PREFIX}__block`}>
|
||||
@ -163,10 +160,10 @@ export default function PartnerIntro() {
|
||||
|
||||
<div className={`${PREFIX}__footer`}>
|
||||
<Button className={`${PREFIX}__download-button`} onClick={savePoster}>
|
||||
下载海报
|
||||
朋友圈海报
|
||||
</Button>
|
||||
<Button className={`${PREFIX}__share-button`} openType="share">
|
||||
分享邀请
|
||||
赠送会员给好友
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// export const DOMAIN = 'http://192.168.60.191:8082';
|
||||
// export const DOMAIN = 'http://192.168.60.116:8082';
|
||||
export const DOMAIN = process.env.BRAND === 'dev' ? 'https://dev.neighbourhood.cn' : 'https://neighbourhood.cn';
|
||||
// export const DOMAIN = 'https://dev.neighbourhood.cn';
|
||||
export const BASE_URL = `${DOMAIN}/api`;
|
||||
@ -85,4 +85,7 @@ export enum API {
|
||||
GET_PROFIT_STAT = '/user/profits',
|
||||
WITHDRAW = '/user/withdraw',
|
||||
GET_WITHDRAW_LIST = '/user/withdraw/records',
|
||||
GENERATE_MEMBERSHIP_COUPON = '/coupon/membership/generate',
|
||||
CLAIM_MEMBERSHIP_COUPON = '/coupon/membership/claim',
|
||||
GET_VIP_QRCODE = '/user/getVipQrCode',
|
||||
}
|
||||
|
||||
@ -1 +1,130 @@
|
||||
.give-vip {}
|
||||
@import '@/styles/variables.less';
|
||||
@import '@/styles/common.less';
|
||||
|
||||
.give-vip {
|
||||
padding: 40px 24px 200px 24px;
|
||||
&__hint {
|
||||
font-size: 28px;
|
||||
line-height: 48px;
|
||||
color: @blColorG2;
|
||||
gap: 12px;
|
||||
.flex-row();
|
||||
justify-content: center;
|
||||
}
|
||||
&__icon {
|
||||
width: 65px;
|
||||
height: 65px;
|
||||
}
|
||||
&__title {
|
||||
margin-top: 24px;
|
||||
font-weight: 500;
|
||||
font-size: 40px;
|
||||
line-height: 48px;
|
||||
color: @blColor;
|
||||
text-align: center;
|
||||
flex: 0 1 auto;
|
||||
gap: 12px;
|
||||
.flex-row();
|
||||
justify-content: center;
|
||||
.highlight {
|
||||
margin-left: -12px;
|
||||
display: inline-block;
|
||||
color: @blHighlightColor;
|
||||
}
|
||||
}
|
||||
&__bg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
}
|
||||
&__info {
|
||||
&-block {
|
||||
margin-top: 48px;
|
||||
}
|
||||
&-title {
|
||||
font-weight: 500;
|
||||
font-size: 32px;
|
||||
line-height: 32px;
|
||||
color: #1d2129;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
&-card {
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
border-radius: 24px;
|
||||
padding: 32px;
|
||||
}
|
||||
&-body {
|
||||
font-weight: 400;
|
||||
font-size: 28px;
|
||||
line-height: 40px;
|
||||
color: #333333;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
&-img {
|
||||
width: 100%;
|
||||
height: 614px;
|
||||
}
|
||||
}
|
||||
&__footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
padding: 12px 32px;
|
||||
box-shadow: 0px -4px 20px 0px #00000014;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
&__footer-body {
|
||||
.flex-row();
|
||||
justify-content: center;
|
||||
}
|
||||
&__button {
|
||||
.button(@height: 88px; @fontSize: 32px; @fontWeight: 500; @borderRadius: 44px;);
|
||||
width: 400px;
|
||||
}
|
||||
&__coupon {
|
||||
&-info {
|
||||
position: relative;
|
||||
margin-top: 32px;
|
||||
padding: 24px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 24px;
|
||||
|
||||
.flex-column();
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-weight: 500;
|
||||
font-size: 32px;
|
||||
line-height: 48px;
|
||||
color: @blHighlightColor;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
&-intro {
|
||||
font-size: 28px;
|
||||
line-height: 40px;
|
||||
margin-bottom: 12px;
|
||||
color: @blColor;
|
||||
gap: 4px;
|
||||
.flex-row();
|
||||
.highlight {
|
||||
font-weight: 600;
|
||||
font-size: 32px;
|
||||
line-height: 56px;
|
||||
color: @blHighlightColor;
|
||||
}
|
||||
}
|
||||
&-valid {
|
||||
font-size: 28px;
|
||||
line-height: 40px;
|
||||
|
||||
color: @blColorG2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,103 @@
|
||||
import { Button } from '@taroify/core';
|
||||
import { Image, Button } from '@tarojs/components';
|
||||
import { useLoad } from '@tarojs/taro';
|
||||
|
||||
import { Fragment, useCallback, useState } from 'react';
|
||||
|
||||
import SafeBottomPadding from '@/components/safe-bottom-padding';
|
||||
import { PageUrl } from '@/constants/app';
|
||||
import { logWithPrefix } from '@/utils/common';
|
||||
|
||||
import { claimMembershipCoupon, getCouponCodeFromQuery } from '@/utils/coupon';
|
||||
import { getPageQuery, switchTab } from '@/utils/route';
|
||||
import { formatTime } from '@/utils/time';
|
||||
import './index.less';
|
||||
|
||||
const PREFIX = 'give-vip';
|
||||
const log = logWithPrefix(PREFIX);
|
||||
|
||||
export default function GiveVip() {
|
||||
return <div className={PREFIX}></div>;
|
||||
enum State {
|
||||
PENDING,
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
}
|
||||
export default function GiveVip() {
|
||||
const [state, setState] = useState<State>(State.PENDING);
|
||||
const [expireAt, setExpireAt] = useState('');
|
||||
const [usedBefore, setUsedBefore] = useState(false);
|
||||
const handleNavigate = useCallback(() => {
|
||||
switchTab(PageUrl.Job);
|
||||
}, []);
|
||||
|
||||
useLoad(() => {
|
||||
const query = getPageQuery<{ d: string }>();
|
||||
const code = getCouponCodeFromQuery(query);
|
||||
claimMembershipCoupon(code!)
|
||||
.then(res => {
|
||||
setUsedBefore(res.usedBefore);
|
||||
setExpireAt(res.usageExpireAt);
|
||||
setState(Date.now() > new Date(res.usageExpireAt).getTime() ? State.FAILED : State.SUCCESS);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
setState(State.FAILED);
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={PREFIX}>
|
||||
{state === State.SUCCESS && (
|
||||
<Fragment>
|
||||
<div className={`${PREFIX}__title`}>
|
||||
<Image src="https://publiccdn.neighbourhood.com.cn/img/partner-yes.svg" className={`${PREFIX}__icon`} />
|
||||
<div>{usedBefore ? '宝子,你已经领过了,下周再来' : '宝子,播络会员领取成功'}</div>
|
||||
</div>
|
||||
<div className={`${PREFIX}__coupon-info`}>
|
||||
<Image src="https://publiccdn.neighbourhood.com.cn/img/parnet-share-bg.png" className={`${PREFIX}__bg`} />
|
||||
<div className={`${PREFIX}__coupon-title`}>播络日会员</div>
|
||||
<div className={`${PREFIX}__coupon-intro`}>
|
||||
会员有效期内可增加<div className="highlight">10次</div>报单机会
|
||||
</div>
|
||||
<div className={`${PREFIX}__coupon-valid`}>
|
||||
有效期至:{formatTime(expireAt, 'YYYY/MM/DD HH:mm:ss', false)}
|
||||
</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
)}
|
||||
{state === State.FAILED && (
|
||||
<Fragment>
|
||||
<div className={`${PREFIX}__hint`}>
|
||||
<Image
|
||||
src="https://publiccdn.neighbourhood.com.cn/img/link-invalid.svg"
|
||||
mode="aspectFit"
|
||||
className={`${PREFIX}__icon`}
|
||||
/>
|
||||
<div className={`${PREFIX}__hint-title`}>宝子,链接已失效</div>
|
||||
</div>
|
||||
<div className={`${PREFIX}__title`}>
|
||||
请联系分享人<div className="highlight">再次分享</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
)}
|
||||
<div className={`${PREFIX}__info-block`}>
|
||||
<div className={`${PREFIX}__info-title`}>播络简介</div>
|
||||
<div className={`${PREFIX}__info-card`}>
|
||||
<div className={`${PREFIX}__info-body`}>
|
||||
播络通告整理汇集了本地每日新增带货主播通告,方便大家及时找到高薪工作
|
||||
</div>
|
||||
<Image
|
||||
className={`${PREFIX}__info-img`}
|
||||
src="https://publiccdn.neighbourhood.com.cn/img/partner-share-coupon-img.png"
|
||||
mode="heightFix"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`${PREFIX}__footer`}>
|
||||
<div className={`${PREFIX}__footer-body`}>
|
||||
<Button className={`${PREFIX}__button`} onClick={handleNavigate}>
|
||||
立即使用
|
||||
</Button>
|
||||
</div>
|
||||
<SafeBottomPadding />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -56,7 +56,27 @@
|
||||
&__icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
&__block {
|
||||
margin-top: 24px;
|
||||
.flex-row();
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
&__status {
|
||||
font-size: 28px;
|
||||
line-height: 32px;
|
||||
font-weight: 400;
|
||||
color: @blColorG1;
|
||||
|
||||
&.open {
|
||||
color: @blHighlightColor;
|
||||
}
|
||||
|
||||
&.error {
|
||||
color: #FF5051;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import classNames from 'classnames';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { EventName, OpenSource } from '@/constants/app';
|
||||
import { JOB_MANAGE_STATUS_TITLE_MAP, JobManageStatus } from '@/constants/job';
|
||||
import { JobManageInfo } from '@/types/job';
|
||||
import { getJobLocation, requestJobManageList } from '@/utils/job';
|
||||
import { getPageQuery, navigateBack } from '@/utils/route';
|
||||
@ -15,7 +16,14 @@ import Toast from '@/utils/toast';
|
||||
import './index.less';
|
||||
|
||||
const PREFIX = 'page-job-select-my-publish';
|
||||
|
||||
const STATUS_CLASS_MAP = {
|
||||
[JobManageStatus.WaitVerify]: 'pending',
|
||||
[JobManageStatus.Open]: 'open',
|
||||
[JobManageStatus.Pending]: 'pending',
|
||||
[JobManageStatus.Error]: 'error',
|
||||
[JobManageStatus.Close]: 'close',
|
||||
[JobManageStatus.Expire]: 'close',
|
||||
};
|
||||
export default function JobSelectMyPublish() {
|
||||
const [list, setList] = useState<JobManageInfo[]>([]);
|
||||
const [jobId, setJobId] = useState<string | null>('1');
|
||||
@ -57,6 +65,10 @@ export default function JobSelectMyPublish() {
|
||||
</div>
|
||||
<div className={`${PREFIX}__right`}>
|
||||
<div className={`${PREFIX}__right__time`}>{formatTime(item.updated)}</div>
|
||||
<div className={`${PREFIX}__right__block`}>
|
||||
<div className={classNames(`${PREFIX}__right__status`, { [STATUS_CLASS_MAP[item.status]]: true })}>
|
||||
{JOB_MANAGE_STATUS_TITLE_MAP[item.status]}
|
||||
</div>
|
||||
{item.id === jobId && (
|
||||
<Image
|
||||
mode="aspectFit"
|
||||
@ -66,6 +78,7 @@ export default function JobSelectMyPublish() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</List>
|
||||
</div>
|
||||
|
||||
@ -6,7 +6,9 @@ import { useState } from 'react';
|
||||
import PartnerIntro from '@/components/partner-intro';
|
||||
import PartnerInviteList from '@/components/partner-invite-list';
|
||||
import PartnerProfit from '@/components/partner-profit';
|
||||
import { PageUrl } from '@/constants/app';
|
||||
import useInviteCode from '@/hooks/use-invite-code';
|
||||
import { generateMembershipCoupon } from '@/utils/coupon';
|
||||
import { getCommonShareMessage } from '@/utils/share';
|
||||
import './index.less';
|
||||
|
||||
@ -18,9 +20,17 @@ export default function Partner() {
|
||||
const handleChange = v => {
|
||||
setTab(v);
|
||||
};
|
||||
useShareAppMessage(() => {
|
||||
useShareAppMessage(async () => {
|
||||
console.log('Partner inviteCode', inviteCode);
|
||||
return getCommonShareMessage({ useCapture: false, inviteCode });
|
||||
const { code } = await generateMembershipCoupon();
|
||||
return getCommonShareMessage({
|
||||
useCapture: false,
|
||||
inviteCode,
|
||||
title: '宝子,送你个播络会员,找工作更方便',
|
||||
path: PageUrl.GiveVip,
|
||||
params: { d: code },
|
||||
imageUrl: 'https://publiccdn.neighbourhood.com.cn/img/share-coupon.png',
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
11
src/types/coupon.ts
Normal file
11
src/types/coupon.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export type ClaimMembershipCouponResponse = {
|
||||
code: string;
|
||||
usedBefore: boolean;
|
||||
usageExpireAt: string;
|
||||
};
|
||||
|
||||
export type GenerateMembershipCouponResponse = {
|
||||
code: string;
|
||||
linkExpireAt: string;
|
||||
shareUrl: string;
|
||||
};
|
||||
31
src/utils/coupon.ts
Normal file
31
src/utils/coupon.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import http from '@/http';
|
||||
import { API } from '@/http/api';
|
||||
import { ClaimMembershipCouponResponse, GenerateMembershipCouponResponse } from '@/types/coupon';
|
||||
|
||||
export const generateMembershipCoupon = async () => {
|
||||
return await http.post<GenerateMembershipCouponResponse>(API.GENERATE_MEMBERSHIP_COUPON);
|
||||
};
|
||||
export const claimMembershipCoupon = async (code: string) => {
|
||||
return await http.post<ClaimMembershipCouponResponse>(API.CLAIM_MEMBERSHIP_COUPON, {
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
data: { code },
|
||||
});
|
||||
};
|
||||
export const getCouponQrCode = async (code: string) => {
|
||||
return await http.post(API.GET_VIP_QRCODE, {
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
responseType: 'arraybuffer',
|
||||
data: { code },
|
||||
});
|
||||
};
|
||||
export const getCouponCodeFromQuery = (query: Record<string, string>): string | undefined => {
|
||||
if (query) {
|
||||
if (query.scene) {
|
||||
return query.scene.replace('d%3D', '');
|
||||
}
|
||||
if (query.d) {
|
||||
return query.d;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
@ -20,6 +20,7 @@ interface ShareAppProps {
|
||||
inviteCode?: string;
|
||||
title?: string;
|
||||
path?: PageUrl;
|
||||
imageUrl?: string;
|
||||
params?: Record<string, BL.Anything>;
|
||||
}
|
||||
|
||||
@ -28,6 +29,7 @@ export const getCommonShareMessage = ({
|
||||
inviteCode,
|
||||
title,
|
||||
path,
|
||||
imageUrl: _imageUrl,
|
||||
params = {},
|
||||
}: ShareAppProps = {}): ShareAppMessageReturn => {
|
||||
const inviteParams = inviteCode ? { c: inviteCode } : undefined;
|
||||
@ -36,6 +38,6 @@ export const getCommonShareMessage = ({
|
||||
return {
|
||||
title: title || `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
||||
path: sharePath,
|
||||
imageUrl: useCapture ? undefined : imageUrl,
|
||||
imageUrl: useCapture ? undefined : _imageUrl || imageUrl,
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function formatTime(time: number | string, template = 'YYYY-MM-DD'): string {
|
||||
export function formatTime(time: number | string, template = 'YYYY-MM-DD', toNum = true): string {
|
||||
if (!time) {
|
||||
return '';
|
||||
}
|
||||
if (toNum) {
|
||||
time = Number(time);
|
||||
}
|
||||
return dayjs(time).format(template);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user