调整小程序授权页

This commit is contained in:
Wang Kejun 2023-11-07 20:49:22 +08:00
parent 93aa4afc48
commit b9d046d385
5 changed files with 86 additions and 101 deletions

View File

@ -1,11 +1,5 @@
<!-- index.wxml -->
<view class="qrcode_view">
<!-- <view class="row">
<text class="text">分享权限</text>
<view class="icon-view">
<g-icon name="person_add" size="30" />
</view>
</view> -->
<view class="col">
<block wx:if="{{oakLoading}}">
<l-loading show="{{true}}" type="circle"></l-loading>

View File

@ -10,7 +10,10 @@
"l-list": "@oak-frontend-base/miniprogram_npm/lin-ui/list/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-checkbox-group": "@oak-frontend-base/miniprogram_npm/lin-ui/checkbox-group/index",
"l-checkbox": "@oak-frontend-base/miniprogram_npm/lin-ui/checkbox/index",
"l-counter": "@oak-frontend-base/miniprogram_npm/lin-ui/counter/index",
"userEntityGrant-detail": "../../../../pages/userEntityGrant/detail/index"
"l-switch": "@oak-frontend-base/miniprogram_npm/lin-ui/switch/index",
"userEntityGrant-share": "../../../userEntityGrant/share/index"
}
}

View File

@ -22,9 +22,11 @@ export default OakComponent({
qrCodeType: 1,
},
isList: false,
formData: ({ data: userEntityGrant }) => ({
userEntityGrant,
}),
formData({ data: userEntityGrant, props }) {
return {
userEntityGrant,
};
},
properties: {
entity: '' as keyof EntityDict,
entityId: '',
@ -36,7 +38,8 @@ export default OakComponent({
qrCodeType: '' as QrCodeType,
multiple: false,
rule: 'single' as EntityDict['userEntityGrant']['OpSchema']['rule'],
ruleOnRow: 'single' as EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'],
ruleOnRow:
'single' as EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'],
},
data: {
period: 15,
@ -127,12 +130,28 @@ export default OakComponent({
},
setRelation(value: any) {
this.update({
relationIds: [value],
relationIds: value,
});
},
setRelationMp(e: any) {
const { currentKey } = e.detail;
this.setRelation(currentKey);
const { key } = e.detail;
const { userEntityGrant } = this.state;
const relationIds = [...(userEntityGrant.relationIds || [])];
const index = relationIds.findIndex((ele) => ele === key);
if (index > -1) {
relationIds.splice(index, 1);
} else {
relationIds.push(key);
}
// 小程序 多选处理
const newRelations = this.props.relations?.map((ele) =>
Object.assign({}, ele, {
checked: relationIds.includes(ele.id),
})
);
this.setState({ relations: newRelations });
this.setRelation(relationIds);
},
setNumber(value: number) {
this.update({
@ -150,6 +169,20 @@ export default OakComponent({
const { count } = e.detail;
this.setPeriod(count);
},
setMultiple(m: boolean) {
this.setState({ multiple: m });
},
setMultipleMp(e: any) {
const { value } = e.detail;
this.setMultiple(value);
},
setRule(m: string) {
this.setState({ rule: m });
},
setRuleMp(e: any) {
const { currentKey } = e.detail;
this.setRule(currentKey);
},
setUnit(u: Unit) {
const { defaultPeriods } = this.state;
this.setState({ unit: u });
@ -222,10 +255,10 @@ export default OakComponent({
qrCodeType: QrCodeType;
type: EntityDict['userEntityGrant']['Schema']['type'];
relations: EntityDict['relation']['OpSchema'][];
claimUrl: string,
claimUrl: string;
multiple: boolean;
rule: EntityDict['userEntityGrant']['Schema']['rule'];
ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'],
ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'];
}
>
) => React.ReactElement;

View File

@ -1,112 +1,68 @@
<!-- index.wxml -->
<view class="page-body">
<block wx:if="{{!!userEntityGrantId}}">
<l-notice-bar
front-icon-name="notification"
show="{{true}}"
>
<block wx:if="{{!!userEntityGrantId}}">
<l-notice-bar front-icon-name="notification" show="{{true}}">
请通过分享或者截屏二维码方式分享权限
</l-notice-bar>
<view class="ueg-container">
<userEntityGrant-detail
oakId="{{userEntityGrantId}}"
oakAutoUnmount="{{true}}"
oakPath="$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail"
/>
<view
class="share"
>
<l-button
size="medium"
type="success"
open-type="share"
>
<userEntityGrant-share oakId="{{userEntityGrantId}}" oakAutoUnmount="{{true}}" oakPath="$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail" />
<view class="share">
<l-button size="medium" type="success" open-type="share">
分享
</l-button>
</view
</view>
</block>
<block wx:else>
</block>
<block wx:else>
<view class="list-item">
<view class="label">权限</view>
<view class="label">{{t('userEntityGrant:attr.relationIds')}}</view>
<view class="value">
<l-radio-group
placement="row"
l-class="radio-container"
bind:linchange="setRelationMp"
current="{{userEntityGrant.relationId}}"
>
<l-radio
wx:for-items="{{relations}}"
wx:key="index"
key="{{item.id}}"
l-class="radio"
size="48rpx"
>
{{item.display || t(entity + ':r.' + item.name)}}
</l-radio>
</l-radio-group>
<l-checkbox-group placement="row" bind:linchange="setRelationMp">
<l-checkbox wx:for-items="{{relations}}" wx:key="index" key="{{item.id}}" l-class="radio" size="48rpx" checked="{{item.checked}}">
{{item.display || t(entity + ':r.' + item.name)}}
</l-checkbox>
</l-checkbox-group>
</view>
</view>
<view class="list-item">
<view class="label">人次:</view>
<view class="value">
<l-radio-group
placement="row"
l-class="radio-container"
bind:linchange="setNumberMp"
current="{{userEntityGrant.number}}"
>
<l-radio
wx:key="1"
key="1"
size="48rpx"
l-class="radio"
>
单人次
</l-radio>
<l-radio
wx:key="10000"
key="10000"
size="48rpx"
>
不限人次
</l-radio>
</l-radio-group>
<block wx:if="{{userEntityGrant.relationIds && userEntityGrant.relationIds.length > 1}}">
<view class="list-item">
<view class="label">{{t('userEntityGrant:attr.rule')}}</view>
<view class="value">
<l-radio-group placement="row" l-class="radio-container" bind:linchange="setRuleMp" current="{{userEntityGrant.rule}}">
<l-radio wx:for-items="{{rules}}" wx:key="index" key="{{item}}" size="48rpx">
{{t('userEntityGrant:v.rule.' + item)}}
</l-radio>
</l-radio-group>
</view>
</view>
</view>
</block>
<block wx:if="{{ userEntityGrant.type === 'grant' }}">
<view class="list-item">
<view class="label">{{t('multiple')}}</view>
<view class="value">
<l-switch checked="{{ userEntityGrant.multiple || false }}" size="50rpx" bind:linchange="setMultipleMp" />
</view>
</view>
</block>
<view class="list-item">
<view class="label">有效期:</view>
<view class="label">{{t('userEntityGrant:attr.expiresAt')}}</view>
<view class="value-period">
<l-counter
count="{{userEntityGrant.period}}"
max="{{ maxes[unit] }}"
min="1"
round-float="{{true}}"
bind:linchange="setPeriodMp"
/>
<!-- <view style="margin-left: 30rpx">
分钟
</view> -->
<l-counter count="{{userEntityGrant.period}}" max="{{ maxes[unit] }}" min="1" round-float="{{true}}" bind:linchange="setPeriodMp" />
<picker range="{{unitArr}}" range-key="label" value="{{unitIndex}}" bind:change="setUnitMp">
<view class="unit-box">
<view class="unit">
<view class="unit">
{{unitArr[unitIndex].label}}
</view>
<l-icon l-class="icon" name="down" size="18" />
</view>
<l-icon l-class="icon" name="down" size="18" />
</view>
</picker>
</view>
</view>
<view style="flex: 1" />
<l-button
size="long"
type="default"
bind:lintap="confirm"
>
确定
<l-button size="long" type="default" bind:lintap="confirm">
{{t('common::action.confirm')}}
</l-button>
</block>
</view>

View File

@ -65,7 +65,6 @@ export default function render(
style={{ marginBottom: 16 }}
/>
<UserEntityGrantShare
showBack={false}
oakId={userEntityGrantId}
oakAutoUnmount={true}
oakPath="$userRelation/upsert/byUserEntityGrant-userEntityGrant/detail"