wechatqrcode/scan 实现扫普通链接二维码 接收q参数

This commit is contained in:
wkj 2024-01-23 17:55:06 +08:00
parent 5cb96d2110
commit 6209a692d2
19 changed files with 237 additions and 284 deletions

View File

@ -63,7 +63,7 @@ export async function createWechatQrCode(options, context) {
self.config.qrCodePrefix)) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
appId = self.id;
appType = 'wechatMpDomainUrl';
break;
@ -115,7 +115,7 @@ export async function createWechatQrCode(options, context) {
appId = self.id;
if (self.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -135,7 +135,7 @@ export async function createWechatQrCode(options, context) {
appId = mpApp.id;
if (mpApp.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${mpApp.config.qrCodePrefix}/${id}`;
url = `${mpApp.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -170,40 +170,6 @@ export async function createWechatQrCode(options, context) {
switch (type) {
case 'wechatMpWxaCode': {
assert(applicationType === 'wechatMp' && config.type === 'wechatMp');
const config2 = config;
const { appId, appSecret } = config2;
// if (process.env.OAK_PLATFORM === 'web') {
// Object.assign(data, {
// buffer: 'develop环境下无法真实获取二维码数据',
// });
// }
// else {
// // 小程序码去实时获取(暂时不考虑缓存)
// const wechatInstance = WechatSDK.getInstance(
// appId,
// 'wechatMp',
// appSecret
// ) as WechatMpInstance;
// const envVersionVersionDict = {
// development: 'develop',
// staging: 'trial',
// production: 'release',
// };
// const buffer = await wechatInstance.getMpUnlimitWxaCode({
// scene: shrinkUuidTo32Bytes(id),
// envVersion:
// envVersionVersionDict[
// process.env
// .NODE_ENV as keyof typeof envVersionVersionDict
// ] as 'release',
// page: 'pages/wechatQrCode/scan/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
// });
// // 把arrayBuffer转成字符串返回
// const str = String.fromCharCode(...new Uint8Array(buffer));
// Object.assign(data, {
// buffer: str,
// });
// }
break;
}
case 'wechatPublicForMp':

View File

@ -62,7 +62,7 @@ const triggers = [
self.config.qrCodePrefix)) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
appId = self.id;
appType = 'wechatMpDomainUrl';
break;
@ -114,7 +114,7 @@ const triggers = [
appId = self.id;
if (self.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -134,7 +134,7 @@ const triggers = [
appId = mpApp.id;
if (mpApp.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${mpApp.config.qrCodePrefix}/${id}`;
url = `${mpApp.config.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
}
else {
appType = 'wechatMpWxaCode';

View File

@ -66,7 +66,7 @@ async function createWechatQrCode(options, context) {
self.config.qrCodePrefix)) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${(0, uuid_2.shrinkUuidTo32Bytes)(id)}`;
appId = self.id;
appType = 'wechatMpDomainUrl';
break;
@ -118,7 +118,7 @@ async function createWechatQrCode(options, context) {
appId = self.id;
if (self.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${(0, uuid_2.shrinkUuidTo32Bytes)(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -138,7 +138,7 @@ async function createWechatQrCode(options, context) {
appId = mpApp.id;
if (mpApp.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${mpApp.config.qrCodePrefix}/${id}`;
url = `${mpApp.config.qrCodePrefix}/${(0, uuid_2.shrinkUuidTo32Bytes)(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -173,40 +173,6 @@ async function createWechatQrCode(options, context) {
switch (type) {
case 'wechatMpWxaCode': {
(0, assert_1.assert)(applicationType === 'wechatMp' && config.type === 'wechatMp');
const config2 = config;
const { appId, appSecret } = config2;
// if (process.env.OAK_PLATFORM === 'web') {
// Object.assign(data, {
// buffer: 'develop环境下无法真实获取二维码数据',
// });
// }
// else {
// // 小程序码去实时获取(暂时不考虑缓存)
// const wechatInstance = WechatSDK.getInstance(
// appId,
// 'wechatMp',
// appSecret
// ) as WechatMpInstance;
// const envVersionVersionDict = {
// development: 'develop',
// staging: 'trial',
// production: 'release',
// };
// const buffer = await wechatInstance.getMpUnlimitWxaCode({
// scene: shrinkUuidTo32Bytes(id),
// envVersion:
// envVersionVersionDict[
// process.env
// .NODE_ENV as keyof typeof envVersionVersionDict
// ] as 'release',
// page: 'pages/wechatQrCode/scan/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
// });
// // 把arrayBuffer转成字符串返回
// const str = String.fromCharCode(...new Uint8Array(buffer));
// Object.assign(data, {
// buffer: str,
// });
// }
break;
}
case 'wechatPublicForMp':

View File

@ -64,7 +64,7 @@ const triggers = [
self.config.qrCodePrefix)) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${(0, uuid_1.shrinkUuidTo32Bytes)(id)}`;
appId = self.id;
appType = 'wechatMpDomainUrl';
break;
@ -116,7 +116,7 @@ const triggers = [
appId = self.id;
if (self.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${self.config.qrCodePrefix}/${id}`;
url = `${self.config.qrCodePrefix}/${(0, uuid_1.shrinkUuidTo32Bytes)(id)}`;
}
else {
appType = 'wechatMpWxaCode';
@ -136,7 +136,7 @@ const triggers = [
appId = mpApp.id;
if (mpApp.config.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${mpApp.config.qrCodePrefix}/${id}`;
url = `${mpApp.config.qrCodePrefix}/${(0, uuid_1.shrinkUuidTo32Bytes)(id)}`;
}
else {
appType = 'wechatMpWxaCode';

View File

@ -21,15 +21,29 @@ import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
* @param context
* @returns
*/
export async function createWechatQrCode<ED extends EntityDict, T extends keyof ED, Cxt extends BackendRuntimeContext<ED>>(options: {
entity: T;
entityId: string;
tag?: string;
permanent?: boolean;
type?: QrCodeType;
props: WechatQrCodeProps;
}, context: Cxt) {
const { entity, entityId, tag, permanent = false, props, type: qrCodeType } = options;
export async function createWechatQrCode<
ED extends EntityDict,
T extends keyof ED,
Cxt extends BackendRuntimeContext<ED>
>(
options: {
entity: T;
entityId: string;
tag?: string;
permanent?: boolean;
type?: QrCodeType;
props: WechatQrCodeProps;
},
context: Cxt
) {
const {
entity,
entityId,
tag,
permanent = false,
props,
type: qrCodeType,
} = options;
const applicationId = context.getApplicationId();
assert(applicationId);
const [system] = await context.select(
@ -51,7 +65,7 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
filter: {
application$system: {
id: applicationId,
}
},
},
},
{
@ -59,37 +73,40 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
}
);
let appId: string = '', appType: QrCodeType | undefined = undefined;
let appId: string = '',
appType: QrCodeType | undefined = undefined;
let url: string | undefined = undefined;
const { application$system: applications, config: sysConfig } = system as {
application$system: Application[];
config: SysConfig;
};
if (!applications || applications?.length === 0) {
throw new Error(
'无法生成二维码找不到此system下的应用信息'
);
throw new Error('无法生成二维码找不到此system下的应用信息');
}
const id = generateNewId();
if (qrCodeType) {
switch (qrCodeType) {
case 'wechatPublic':
{
const self = applications.find((ele) => ele.type === 'wechatPublic');
if (
!(
self && self!.type === 'wechatPublic' &&
(self!.config as WechatPublicConfig).isService
)
) {
throw new Error('无法生成公众号二维码,服务号未正确配置');
}
appId = self.id;
appType = 'wechatPublic';
break;
case 'wechatPublic': {
const self = applications.find(
(ele) => ele.type === 'wechatPublic'
);
if (
!(
self &&
self!.type === 'wechatPublic' &&
(self!.config as WechatPublicConfig).isService
)
) {
throw new Error('无法生成公众号二维码,服务号未正确配置');
}
appId = self.id;
appType = 'wechatPublic';
break;
}
case 'wechatMpDomainUrl': {
const self = applications.find((ele) => ele.type === 'wechatMp');
const self = applications.find(
(ele) => ele.type === 'wechatMp'
);
if (
!(
self!.type === 'wechatMp' &&
@ -98,13 +115,15 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${(self!.config as WechatMpConfig).qrCodePrefix}/${id}`;
url = `${(self!.config as WechatMpConfig).qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
appId = self!.id;
appType = 'wechatMpDomainUrl';
break;
}
case 'wechatMpWxaCode': {
const self = applications.find((ele) => ele.type === 'wechatMp');
const self = applications.find(
(ele) => ele.type === 'wechatMp'
);
if (self!.type !== 'wechatMp') {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
@ -113,19 +132,27 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
break;
}
case 'wechatPublicForMp': {
const self = applications.find((ele) => ele.type === 'wechatPublic');
const self = applications.find(
(ele) => ele.type === 'wechatPublic'
);
if (
!(
self && self!.type === 'wechatPublic' &&
self &&
self!.type === 'wechatPublic' &&
(self!.config as WechatPublicConfig).isService
)
) {
throw new Error('无法生成公众号-小程序二维码,服务号未正确配置');
throw new Error(
'无法生成公众号-小程序二维码,服务号未正确配置'
);
}
const selfMp = applications.find((ele) => ele.type === 'wechatMp');
const selfMp = applications.find(
(ele) => ele.type === 'wechatMp'
);
if (
!(
selfMp && (selfMp!.config as WechatMpConfig).appId &&
selfMp &&
(selfMp!.config as WechatMpConfig).appId &&
(selfMp!.config as WechatMpConfig).appSecret
)
) {
@ -159,8 +186,9 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
appId = self.id;
if ((self!.config as WechatMpConfig).qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${(self!.config as WechatMpConfig).qrCodePrefix
}/${id}`;
url = `${
(self!.config as WechatMpConfig).qrCodePrefix
}/${shrinkUuidTo32Bytes(id)}`;
} else {
appType = 'wechatMpWxaCode';
}
@ -182,8 +210,9 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
appId = mpApp.id;
if ((mpApp!.config as WechatMpConfig).qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${(mpApp!.config as WechatMpConfig).qrCodePrefix
}/${id}`;
url = `${
(mpApp!.config as WechatMpConfig).qrCodePrefix
}/${shrinkUuidTo32Bytes(id)}`;
} else {
appType = 'wechatMpWxaCode';
}
@ -194,7 +223,9 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
}
if (!appId || !appType) {
throw new Error('无法生成二维码找不到此system下的服务号或者小程序信息');
throw new Error(
'无法生成二维码找不到此system下的服务号或者小程序信息'
);
}
const data: CreateWechatQrcodeData = {
@ -208,7 +239,7 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
permanent,
url,
expired: false,
expiresAt: Date.now() + 2592000 * 1000, // wecharQrCode里的过期时间都放到最大由上层关联对象来主动过期by Xc, 20230131)
expiresAt: Date.now() + 2592000 * 1000, // wecharQrCode里的过期时间都放到最大由上层关联对象来主动过期by Xc, 20230131)
props,
};
@ -228,58 +259,20 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
assert(
applicationType === 'wechatMp' && config!.type === 'wechatMp'
);
const config2 = config as WechatMpConfig;
const { appId, appSecret } = config2;
// if (process.env.OAK_PLATFORM === 'web') {
// Object.assign(data, {
// buffer: 'develop环境下无法真实获取二维码数据',
// });
// }
// else {
// // 小程序码去实时获取(暂时不考虑缓存)
// const wechatInstance = WechatSDK.getInstance(
// appId,
// 'wechatMp',
// appSecret
// ) as WechatMpInstance;
// const envVersionVersionDict = {
// development: 'develop',
// staging: 'trial',
// production: 'release',
// };
// const buffer = await wechatInstance.getMpUnlimitWxaCode({
// scene: shrinkUuidTo32Bytes(id),
// envVersion:
// envVersionVersionDict[
// process.env
// .NODE_ENV as keyof typeof envVersionVersionDict
// ] as 'release',
// page: 'pages/wechatQrCode/scan/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
// });
// // 把arrayBuffer转成字符串返回
// const str = String.fromCharCode(...new Uint8Array(buffer));
// Object.assign(data, {
// buffer: str,
// });
// }
break;
}
case 'wechatPublicForMp':
case 'wechatPublic': {
assert(
applicationType === 'wechatPublic' &&
config!.type === 'wechatPublic'
config!.type === 'wechatPublic'
);
if (process.env.OAK_PLATFORM === 'web') {
Object.assign(data, {
ticket: 'develop环境下无法真实获取二维码数据',
url: `http://localhost:3000/wechatQrCode/scan?scene=${shrinkUuidTo32Bytes(id)}`,
});
}
else {
} else {
const config2 = config as WechatPublicConfig;
const { appId, appSecret } = config2;
const wechatInstance = WechatSDK.getInstance(
@ -294,8 +287,8 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
expireSeconds: 2592000,
});
Object.assign(data, {
ticket: result?.ticket,
url: result?.url,
ticket: result.ticket,
url: result.url,
});
}
break;
@ -315,9 +308,7 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
action: 'create',
data,
},
{
dontCollect: true,
}
{}
);
}

View File

@ -133,7 +133,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'application
),
});
}
if (id && oakFullpath) {
if (id) {
return (
<Tabs
tabPosition="left"
@ -141,7 +141,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'application
setTabKey(key);
}}
items={items}
style={{ height: 520 }}
style={{ minHeight: 520 }}
/>
);
}

View File

@ -43,9 +43,10 @@ export default function WechatMp(props: {
layout="vertical"
style={{ marginTop: 10 }}
>
<Form.Item label="appId"
//name="appId"
>
<Form.Item
label="appId"
//name="appId"
>
<>
<Input
placeholder="请输入appId"
@ -57,9 +58,10 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="appSecret"
//name="appSecret"
>
<Form.Item
label="appSecret"
//name="appSecret"
>
<>
<Input
placeholder="请输入appSecret"
@ -71,9 +73,10 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="原始ID"
//name="originalId"
>
<Form.Item
label="原始ID"
//name="originalId"
>
<>
<Input
placeholder="请输入原始ID"
@ -85,12 +88,14 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="qrCodePrefix"
// name="qrCodePrefix"
>
<Form.Item
label="普通链接二维码规则"
tooltip="扫普通链接二维码打开小程序,如原有二维码链接为 http://www.qq.com/a/123456 其中12345为uuid则可配置规则 http://www.qq.com/a/ 。 请在输入框中填写 http://www.qq.com/a ,系统将在生成二维码时,在链接末尾加上'/'和uuid从而实现扫码打开小程序的规则。"
// name="qrCodePrefix"
>
<>
<Input
placeholder="请输入qrCodePrefix"
placeholder="请输入普通链接二维码规则"
type="text"
value={config?.qrCodePrefix}
onChange={(e) =>
@ -111,8 +116,9 @@ export default function WechatMp(props: {
layout="vertical"
style={{ marginTop: 10 }}
>
<Form.Item label="服务器地址(URL)"
//name="url"
<Form.Item
label="服务器地址(URL)"
//name="url"
>
<>
<Input
@ -125,9 +131,10 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="令牌(Token)"
//name="token"
>
<Form.Item
label="令牌(Token)"
//name="token"
>
<>
<Input
placeholder="请输入令牌(Token)"
@ -141,7 +148,7 @@ export default function WechatMp(props: {
</Form.Item>
<Form.Item
label="消息加解密密钥(EncodingAESKey)"
// name="encodingAESKey"
// name="encodingAESKey"
tooltip="消息加解密密钥将用于消息体加解密过程。具体功能请参见微信文档"
>
<>
@ -158,9 +165,10 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="消息加解密方式"
//name="mode"
>
<Form.Item
label="消息加解密方式"
//name="mode"
>
<>
<Select
placeholder="请选择消息加解密方式"
@ -185,9 +193,10 @@ export default function WechatMp(props: {
/>
</>
</Form.Item>
<Form.Item label="数据格式"
//name="dataFormat"
>
<Form.Item
label="数据格式"
//name="dataFormat"
>
<>
<Select
placeholder="请选择消息加解密方式"

View File

@ -15,7 +15,7 @@ export default function render(
{
searchValue: string;
nameLabel: string;
list: RowWithActions<EntityDict, 'userEntityGrant'>[];
list: RowWithActions<EntityDict, 'parasite'>[];
},
{
cancel: () => void;
@ -31,10 +31,10 @@ export default function render(
nameLabel,
} = props.data;
const { pageSize, total, currentPage } = oakPagination || {};
const { t, setPageSize, setCurrentPage, updateItem, execute, getQrCode } = props.methods;
const { t, setPageSize, setCurrentPage, updateItem, execute, getQrCode } =
props.methods;
const [qrCodeOpen, setQrCodeOpen] = useState(false);
const [parasiteId, setParasiteId] = useState('');
return (
@ -55,7 +55,7 @@ export default function render(
dataIndex: ['user', 'nickname'],
title: nameLabel || '名称',
render: (value, record, index) => {
return value !== 'shadow_user' && value || '--';
return (value !== 'shadow_user' && value) || '--';
},
},
{

View File

@ -3,7 +3,7 @@
height: 100%;
.tabLabel {
writing-mode: vertical-rl;
// writing-mode: vertical-rl;
letter-spacing: .2rem;
}
}

View File

@ -5,8 +5,8 @@
"chooseExpiresAt": "请选择有效时长",
"expiresHelp": "支持分钟、小时选择",
"helpRule": "当一次分享多个权限时,可规定单个用户(对多个权限)的认领规则",
"helpMutiple": "是否允许多个用户来认领",
"shareCode": "请将二维码发给待分享权限的用户使用微信扫描",
"helpMultiple": "是否允许多个用户来认领",
"shareCode": "请将二维码发给待认领权限的用户,让他们使用微信扫描。",
"unit": {
"hour": "小时",
"minute": "分钟"

View File

@ -83,10 +83,7 @@ export default function render(
</>
) : (
<Form labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}>
<Form.Item
label={t('userEntityGrant:attr.relationIds')}
required
>
<Form.Item label={t('userEntityGrant:attr.relationIds')} required>
<Checkbox.Group
value={relationIds || []}
onChange={(val) => {
@ -106,14 +103,18 @@ export default function render(
help={t('helpRule')}
>
<Radio.Group
value={rule as EntityDict['userEntityGrant']['OpSchema']['rule']}
onChange={({ target }) => update({ rule: target.value as EntityDict['userEntityGrant']['OpSchema']['rule']})}
options={rules.map(
(ele) => ({
value: ele,
label: t(`userEntityGrant:v.rule.${ele}`)
value={
rule as EntityDict['userEntityGrant']['OpSchema']['rule']
}
onChange={({ target }) =>
update({
rule: target.value as EntityDict['userEntityGrant']['OpSchema']['rule'],
})
)}
}
options={rules.map((ele) => ({
value: ele,
label: t(`userEntityGrant:v.rule.${ele}`),
}))}
/>
</Form.Item>
)}
@ -121,7 +122,7 @@ export default function render(
<Form.Item
label={t('multiple')}
required
help={t('helpMutiple')}
help={t('helpMultiple')}
>
<Switch
checked={multiple || false}

View File

@ -128,7 +128,7 @@ export default function render(
<Form.Item
label={t('multiple')}
required
help={t('helpMutiple')}
help={t('helpMultiple')}
>
<Switch
checked={multiple || false}

View File

@ -96,25 +96,9 @@ export default function Render(
key: 'item-1',
children: <div className={Style.container}></div>,
},
{
label: '手机号',
key: 'item-2',
children: (
<ByMobile
allowUpdateName={allowUpdateName}
allowUpdateNickname={allowUpdateNickname}
passwordRequire={passwordRequire}
entity={entity}
entityId={entityId}
relations={relations}
oakPath="$userRelation-upsert-by-mobile"
oakAutoUnmount={true}
/>
),
},
{
label: '二维码',
key: 'item-3',
key: 'item-2',
children: (
<ByUserEntityGrant
entity={entity}
@ -130,15 +114,31 @@ export default function Render(
/>
),
},
{
label: '手机号',
key: 'item-3',
children: (
<ByMobile
allowUpdateName={allowUpdateName}
allowUpdateNickname={allowUpdateNickname}
passwordRequire={passwordRequire}
entity={entity}
entityId={entityId}
relations={relations}
oakPath="$userRelation-upsert-by-mobile"
oakAutoUnmount={true}
/>
),
},
];
const items2: typeof items = [];
if (grantByEmail) {
items2.push(items[0]);
}
if (grantByMobile) {
if (grantByUserEntityGrant) {
items2.push(items[1]);
}
if (grantByUserEntityGrant) {
if (grantByMobile) {
items2.push(items[2]);
}
SubPart = <Tabs items={items2} />;

View File

@ -94,22 +94,9 @@ export default function Render(
key: 'item-1',
children: <div className={Style.container}></div>,
},
{
label: '手机号',
key: 'item-2',
children: (
<ByMobile
entity={entity}
entityId={entityId}
relations={relations}
oakPath="$userRelation-upsert-by-mobile"
oakAutoUnmount={true}
/>
),
},
{
label: '二维码',
key: 'item-3',
key: 'item-2',
children: (
<ByUserEntityGrant
entity={entity}
@ -125,15 +112,28 @@ export default function Render(
/>
),
},
{
label: '手机号',
key: 'item-3',
children: (
<ByMobile
entity={entity}
entityId={entityId}
relations={relations}
oakPath="$userRelation-upsert-by-mobile"
oakAutoUnmount={true}
/>
),
},
];
const items2: typeof items = [];
if (grantByEmail) {
items2.push(items[0]);
}
if (grantByMobile) {
if (grantByUserEntityGrant) {
items2.push(items[1]);
}
if (grantByUserEntityGrant) {
if (grantByMobile) {
items2.push(items[2]);
}
SubPart = (

View File

@ -17,6 +17,7 @@ export default OakComponent({
isList: true,
properties: {
scene: '',
q: '',
},
data: {
loading: false,
@ -37,8 +38,17 @@ export default OakComponent({
filters: [
{
filter() {
const scene = decodeURIComponent(this.props.scene!);
const uuid = scene && expandUuidTo36Bytes(scene!);
let uuid;
if (this.props.scene) {
// 小程序码扫码
const scene = decodeURIComponent(this.props.scene!);
uuid = expandUuidTo36Bytes(scene!);
} else if (this.props.q) {
// 普通链接二维码扫码
const q = decodeURIComponent(this.props.q!);
uuid = expandUuidTo36Bytes(q!);
}
return {
id: uuid! || 'illegal',
};

View File

@ -362,8 +362,8 @@ const i18ns: I18n[] = [
"chooseExpiresAt": "请选择有效时长",
"expiresHelp": "支持分钟、小时选择",
"helpRule": "当一次分享多个权限时,可规定单个用户(对多个权限)的认领规则",
"helpMutiple": "是否允许多个用户来认领",
"shareCode": "请将二维码发给待分享权限的用户使用微信扫描",
"helpMultiple": "是否允许多个用户来认领",
"shareCode": "请将二维码发给待认领权限的用户,让他们使用微信扫描。",
"unit": {
"hour": "小时",
"minute": "分钟"

View File

@ -37,12 +37,17 @@ export interface Schema extends EntityShape {
type Action = 'claim' | 'disable';
const entityDesc: EntityDesc<Schema, Action, '', {
type: Schema['type'];
qrCodeType: QrCodeType;
rule: Schema['rule'];
ruleOnRow: Schema['ruleOnRow'];
}> = {
const entityDesc: EntityDesc<
Schema,
Action,
'',
{
type: Schema['type'];
qrCodeType: QrCodeType;
rule: Schema['rule'];
ruleOnRow: Schema['ruleOnRow'];
}
> = {
locales: {
zh_CN: {
name: '用户授权',
@ -76,7 +81,7 @@ const entityDesc: EntityDesc<Schema, Action, '', {
},
qrCodeType: {
webForWechatPublic: '网站引流到公众号',
wechatMpDomainUrl: '小程序url码',
wechatMpDomainUrl: '小程序普通链接二维码',
wechatMpWxaCode: '小程序码',
wechatPublic: '公众号关注码',
wechatPublicForMp: '公众号回复小程序码',
@ -84,12 +89,12 @@ const entityDesc: EntityDesc<Schema, Action, '', {
rule: {
single: '单选',
all: '全选',
free: '自由选择'
free: '自由选择',
},
ruleOnRow: {
single: '单选',
all: '全选',
free: '自由选择'
free: '自由选择',
},
},
},
@ -103,7 +108,7 @@ const entityDesc: EntityDesc<Schema, Action, '', {
},
{
name: 'expiresAt',
}
},
],
},
],

View File

@ -28,9 +28,14 @@ export interface Schema extends EntityShape {
props: WechatQrCodeProps;
}
const entityDesc: EntityDesc<Schema, '', '', {
type: QrCodeType,
}> = {
const entityDesc: EntityDesc<
Schema,
'',
'',
{
type: QrCodeType;
}
> = {
locales: {
zh_CN: {
name: '微信识别码',
@ -53,12 +58,12 @@ const entityDesc: EntityDesc<Schema, '', '', {
v: {
type: {
webForWechatPublic: '网站引流到公众号',
wechatMpDomainUrl: '小程序url码',
wechatMpDomainUrl: '小程序普通链接二维码',
wechatMpWxaCode: '小程序码',
wechatPublic: '公众号关注码',
wechatPublicForMp: '公众号回复小程序码',
}
}
},
},
},
},
indexes: [
@ -73,7 +78,7 @@ const entityDesc: EntityDesc<Schema, '', '', {
},
{
name: 'tag',
}
},
],
},
{
@ -95,5 +100,5 @@ const entityDesc: EntityDesc<Schema, '', '', {
},
],
},
]
],
};

View File

@ -13,7 +13,7 @@ import { Config as SysConfig, QrCodeType } from '../types/Config';
const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
{
name: '当生成wechatQrCode时,调用外部接口完善数据',
name: '当生成wechatQrCode时, 调用外部接口完善数据',
entity: 'wechatQrCode',
action: 'create',
when: 'before',
@ -87,7 +87,7 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
) {
throw new Error('无法生成小程序地址码,未配置跳转前缀');
}
url = `${(self!.config as WechatMpConfig).qrCodePrefix}/${id}`;
url = `${(self!.config as WechatMpConfig).qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
appId = self!.id;
appType = 'wechatMpDomainUrl';
break;
@ -148,8 +148,10 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
appId = self.id;
if ((self!.config as WechatMpConfig).qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${(self!.config as WechatMpConfig).qrCodePrefix
}/${id}`;
url = `${
(self!.config as WechatMpConfig)
.qrCodePrefix
}/${shrinkUuidTo32Bytes(id)}`;
} else {
appType = 'wechatMpWxaCode';
}
@ -169,10 +171,10 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
);
if (mpApp) {
appId = mpApp.id;
if ((mpApp!.config as WechatMpConfig).qrCodePrefix) {
const mpConfig = mpApp!.config as WechatMpConfig;
if (mpConfig?.qrCodePrefix) {
appType = 'wechatMpDomainUrl';
url = `${(mpApp!.config as WechatMpConfig).qrCodePrefix
}/${id}`;
url = `${mpConfig.qrCodePrefix}/${shrinkUuidTo32Bytes(id)}`;
} else {
appType = 'wechatMpWxaCode';
}
@ -198,11 +200,9 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
}
if (!wechatQrCode.type) {
Object.assign(
updateData, {
Object.assign(updateData, {
type: appType,
}
)
});
}
// 直接创建
@ -248,8 +248,8 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
expireSeconds: 2592000,
});
Object.assign(updateData, {
ticket: result?.ticket,
url: result?.url,
ticket: result.ticket,
url: result.url,
});
}
break;