user/info组件修改:mp使用extrafile/commit组件;当用户已身份认证时不允许更新姓名、性别、生日

This commit is contained in:
lxy 2025-05-12 15:16:55 +08:00
parent 3a2b1dd845
commit 6a7bb6b41b
17 changed files with 162 additions and 79 deletions

View File

@ -89,6 +89,9 @@ export default OakComponent({
const canSyncPublic = token?.wechatUser?.applicationId === app.id;
const editable = user && user.$$createAt$$ === 1 || user['#oakLegalActions']?.includes('update');
const executable = this.tryExecute();
const commitBtnProps = {
disabled: executable === true,
};
return {
id: user?.id,
name: user?.name,
@ -119,6 +122,7 @@ export default OakComponent({
editable,
executable,
isCreation: this.isCreation(),
commitBtnProps,
};
},
data: {
@ -172,6 +176,16 @@ export default OakComponent({
});
}
},
checkIdState() {
if (this.state.idState === 'verified') {
this.setMessage({
type: 'warning',
content: this.t('notAllowUpdate')
});
return false;
}
return true;
},
async refreshWechatPublicUserInfo() {
this.checkEditable('nickname');
this.setState({
@ -248,21 +262,28 @@ export default OakComponent({
},
editName() {
this.checkEditable('name');
this.setState({
editAttr: 'name',
});
if (this.checkIdState()) {
this.setState({
editAttr: 'name',
});
}
},
editGender() {
this.checkEditable('gender');
this.setState({
editAttr: 'gender',
});
const { idState } = this.state;
if (this.checkIdState()) {
this.setState({
editAttr: 'gender',
});
}
},
editBirth() {
this.checkEditable('birth');
this.setState({
editAttr: 'birth',
});
if (this.checkIdState()) {
this.setState({
editAttr: 'birth',
});
}
},
cancelEdit() {
this.setState({

View File

@ -12,6 +12,7 @@
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-form-item": "@oak-frontend-base/miniprogram_npm/lin-ui/form-item/index",
"oak-extraFile-avatar": "../../../components/extraFile/avatar/index"
"oak-extraFile-avatar": "../../../components/extraFile/avatar/index",
"oak-commit": "../../../components/extraFile/commit/index"
}
}

View File

@ -1,6 +1,6 @@
<view class="col">
<view class="avatar-container">
<button
<!-- <button
class="avatar-btn"
open-type="chooseAvatar"
bind:chooseavatar="onChooseAvatar"
@ -12,7 +12,12 @@
<block wx:else>
<l-avatar icon="user" size="140" icon-size="80" />
</block>
</button>
</button> -->
<oak-extraFile-avatar
oakAutoUnmount="{{true}}"
oakPath="{{oakFullpath}}.extraFile$entity"
entity="user"
/>
</view>
<l-list
title="昵称"
@ -30,7 +35,7 @@
bindconfirm="cancelEdit"
bindblur="cancelEdit"
disabled="{{!editable}}"
/>
/>
</block>
<block wx:else>
<view slot="right-section" class="{{nnDirty ? 'value warning' : 'value'}}">{{nickname || '未设置'}}</view>
@ -41,7 +46,7 @@
<l-list
title="姓名"
bind:lintap="editName"
is-link="{{editAttr !== 'name'}}"
is-link="{{editAttr !== 'name' && idState !== 'verified'}}"
>
<block wx:if="{{editAttr==='name'}}">
<input
@ -52,8 +57,8 @@
bindchange="changeNameMp"
bindconfirm="cancelEdit"
bindblur="cancelEdit"
disabled="{{!editable}}"
/>
disabled="{{!editable || idState === 'verified'}}"
/>
</block>
<block wx:else>
<view slot="right-section" class="{{nameDirty ? 'value warning' : 'value'}}">{{name || '未设置'}}</view>
@ -62,19 +67,21 @@
<l-list
title="性别"
bind:lintap="editGender"
is-link="{{editAttr !== 'gender'}}"
is-link="{{editAttr !== 'gender' && idState !== 'verified'}}"
>
<view slot="right-section" class="{{genderDirty ? 'value warning' : 'value'}}">{{genderStr || '未设置'}}</view>
</l-list>
<l-list
title="生日"
is-link="{{idState !== 'verified'}}"
>
<view slot="right-section" class="{{birthDirty ? 'value warning' : 'value'}}">
<block wx:if="{{editable}}">
<block wx:if="{{editable && idState !== 'verified'}}">
<picker mode="date" end="{{birthEnd}}" value="{{birthText}}" bind:change="changeBirthMp">
{{ birthText || '选择日期'}}
</picker>
</block>
<view wx:else>{{birthText || '未设置'}}</view>
</view>
</l-list>
<l-list title="手机号" bind:lintap="editMobile">
@ -95,11 +102,11 @@
/>
</block>
<block wx:else>
<view slot="right-section" class="value">{{hasPassword ? '******' : '未设置'}}</view>
<view slot="right-section" class="value">{{hasPassword ? '******' : '未设置'}}</view>
</block>
</l-list>
<l-list tag-position="right" is-link="{{false}}" title="用户状态">
<view slot="right-section" class="value">
<l-list tag-position="right" is-link="{{false}}" title="用户状态">
<view slot="right-section" class="value">
<l-tag plain="{{true}}" font-color="{{userStateColor}}" shape="circle">
{{userStateStr || '未设置'}}
</l-tag>
@ -113,19 +120,25 @@
</view>
</l-list>
<view style="flex:1" />
<block wx:if="{{executable === true}}">
<!-- <block wx:if="{{executable === true}}">
<l-button
size="long"
bind:lintap="onConfirm"
>
{{t('common::action.confirm')}}
</l-button>
</block>
</block> -->
<oak-commit
oakPath="{{oakFullpath}}"
entity='user'
buttonProps="{{commitBtnProps}}"
/>
</view>
<l-popup
show="{{editAttr === 'gender' || editAttr === 'mobile'}}"
content-align="bottom"
bind:lintap="cancelEdit"
z-index="{{1000}}"
>
<view class='popup-content'>
<view class='popup-form'>
@ -145,7 +158,7 @@
</l-form-item>
</block>
<block wx:else>
<l-input
<l-input
hide-label="{{true}}"
focus="{{true}}"
value="{{mobileInput || mobile}}"

View File

@ -22,5 +22,6 @@
"secuInfo": "安全信息",
"wechatAccount": "微信帐号",
"bindMobile": "绑定手机号",
"bindWechat": "绑定微信"
"bindWechat": "绑定微信",
"notAllowUpdate": "暂不支持更新"
}

View File

@ -27,6 +27,7 @@ type DataProps = {
userStateColor: string;
idStateStr: string;
idStateColor: string;
idState: EntityDict['user']['Schema']['idState'];
isCreation: boolean;
editable: boolean;
};

View File

@ -7,7 +7,7 @@ import Style from './mobile.module.less';
export default function render(props) {
const { data, methods } = props;
const { t, clean, editMobile, goAuthenticate, refreshWechatPublicUserInfo, editPassword, editNickname, editName, editGender, cancelEdit, update, editBirth, execute, } = methods;
const { oakFullpath, executable, nickname, name, birth, gender, mobile, isCreation, id, canSyncPublic, refreshing, editAttr, genderOptions, oakDirty, nnDirty, birthDirty, nameDirty, genderDirty, userStateColor, userStateStr, idStateColor, idStateStr, editable, } = data;
const { oakFullpath, executable, nickname, name, birth, gender, mobile, isCreation, id, canSyncPublic, refreshing, editAttr, genderOptions, oakDirty, nnDirty, birthDirty, nameDirty, genderDirty, userStateColor, userStateStr, idStateColor, idStateStr, idState, editable, } = data;
return (<div className={Style.container}>
<div className={Style['avatar_container']}>
<OakAvatar oakAutoUnmount={true} oakPath={oakFullpath + '.extraFile$entity'} entity="user" entityId={id} autoUpload={true}/>
@ -24,7 +24,7 @@ export default function render(props) {
{name ? name : t('unset')}
</div>) : (<Input disabled={!editable} placeholder={t('placeholder.name')} autoFocus value={name} onChange={(value) => update({
name: value,
})} onBlur={() => cancelEdit()} onEnterPress={() => cancelEdit()}/>)} onClick={editAttr === 'name' ? undefined : () => editName()}>
})} onBlur={() => cancelEdit()} onEnterPress={() => cancelEdit()}/>)} onClick={editAttr === 'name' ? undefined : () => editName()} clickable={editable && idState !== 'verified'}>
{t('user:attr.name')}
</List.Item>
<List.Item extra={editAttr !== 'gender' ? (<div className={genderDirty ? Style.dirty : undefined}>
@ -40,12 +40,12 @@ export default function render(props) {
{ele.label}
</Radio>))}
</Space>
</Radio.Group>)} onClick={editAttr === 'gender' ? undefined : () => editGender()}>
</Radio.Group>)} onClick={editAttr === 'gender' ? undefined : () => editGender()} clickable={editable && idState !== 'verified'}>
{t('user:attr.gender')}
</List.Item>
<List.Item extra={<div className={birthDirty ? Style.dirty : undefined}>
{birth ? dayjs(birth).format('YYYY-MM-DD') : t('unset')}
</div>} onClick={editAttr === 'birth' ? undefined : () => editBirth()}>
</div>} onClick={editAttr === 'birth' ? undefined : () => editBirth()} clickable={editable && idState !== 'verified'}>
{t('user:attr.birth')}
</List.Item>
{!isCreation && <List.Item extra={mobile ? mobile : t('unset')} onClick={() => {

View File

@ -21,6 +21,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
idStateColor: string;
isCreation: boolean;
editable: boolean;
idState: EntityDict['user']['Schema']['idState'];
}, {
editMobile: () => void;
sendCaptcha: () => void;

View File

@ -10,7 +10,7 @@ import Style from './web.module.less';
export default function Render(props) {
const { data, methods } = props;
const { t, updateMyInfo, editMobile, goAuthenticate, sendCaptcha, unbindingWechat, editPassword, } = methods;
const { nickname, name, birth, gender, mobile, oakExecuting, genderOptions, oakFullpath, oakDirty, wechatUser, editable, userStateColor, userStateStr, idStateColor, idStateStr, isRoot, isCreation, } = data;
const { nickname, name, birth, gender, mobile, oakExecuting, genderOptions, oakFullpath, oakDirty, wechatUser, editable, userStateColor, userStateStr, idStateColor, idStateStr, isRoot, isCreation, idState, } = data;
const [open, setOpen] = useState(false);
const [open2, setOpen2] = useState(false);
return (<div className={Style.container}>
@ -27,7 +27,7 @@ export default function Render(props) {
},
]}>
<>
<Input disabled={!editable} placeholder="" onChange={(e) => methods.update({
<Input disabled={!editable || idState === 'verified'} placeholder="" onChange={(e) => methods.update({
name: e.target.value,
})} value={name}/>
</>
@ -45,14 +45,14 @@ export default function Render(props) {
</Form.Item>
<Form.Item label={t('user:attr.gender')}>
<Space direction="vertical">
<Radio.Group disabled={!editable} value={gender} options={genderOptions} onChange={({ target: { value } }) => {
<Radio.Group disabled={!editable || idState === 'verified'} value={gender} options={genderOptions} onChange={({ target: { value } }) => {
methods.update({ gender: value });
}}/>
</Space>
</Form.Item>
<Form.Item label={t('user:attr.birth')}>
<>
<DatePicker disabled={!editable} format="YYYY-MM-DD" inputReadOnly={true} allowClear={false} value={birth ? dayjs(birth) : undefined} disabledDate={(current) => {
<DatePicker disabled={!editable || idState === 'verified'} format="YYYY-MM-DD" inputReadOnly={true} allowClear={false} value={birth ? dayjs(birth) : undefined} disabledDate={(current) => {
if (dayjs(current).valueOf() >
dayjs().valueOf()) {
return true;
@ -111,7 +111,7 @@ export default function Render(props) {
<Form.Item label={t('user:attr.password')}>
<Space>
<Typography>{'********'}</Typography>
{editable && <Button disabled={!editable} size="small" onClick={() => {
{editable && <Button disabled={!editable} size="small" onClick={() => {
editPassword();
return;
}}>

View File

@ -302,7 +302,8 @@ const i18ns = [
"secuInfo": "安全信息",
"wechatAccount": "微信帐号",
"bindMobile": "绑定手机号",
"bindWechat": "绑定微信"
"bindWechat": "绑定微信",
"notAllowUpdate": "暂不支持更新"
}
},
{

View File

@ -304,7 +304,8 @@ const i18ns = [
"secuInfo": "安全信息",
"wechatAccount": "微信帐号",
"bindMobile": "绑定手机号",
"bindWechat": "绑定微信"
"bindWechat": "绑定微信",
"notAllowUpdate": "暂不支持更新"
}
},
{

View File

@ -12,6 +12,7 @@
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-form-item": "@oak-frontend-base/miniprogram_npm/lin-ui/form-item/index",
"oak-extraFile-avatar": "../../../components/extraFile/avatar/index"
"oak-extraFile-avatar": "../../../components/extraFile/avatar/index",
"oak-commit": "../../../components/extraFile/commit/index"
}
}
}

View File

@ -96,7 +96,9 @@ export default OakComponent({
const canSyncPublic = token?.wechatUser?.applicationId === app.id
const editable = user && user.$$createAt$$ === 1 || user['#oakLegalActions']?.includes('update');
const executable = this.tryExecute();
const commitBtnProps = {
disabled: executable === true,
}
return {
id: user?.id,
name: user?.name,
@ -128,6 +130,7 @@ export default OakComponent({
editable,
executable,
isCreation: this.isCreation(),
commitBtnProps,
};
},
data: {
@ -182,6 +185,16 @@ export default OakComponent({
});
}
},
checkIdState() {
if (this.state.idState === 'verified') {
this.setMessage({
type: 'warning',
content: this.t('notAllowUpdate')
})
return false;
}
return true;
},
async refreshWechatPublicUserInfo() {
this.checkEditable('nickname');
this.setState({
@ -212,7 +225,7 @@ export default OakComponent({
this.navigateTo({
url: changeMobileUrl,
userId: oakId,
});
});
}
else if (process.env.NODE_ENV === 'development') {
console.warn('changeMobileUrl unset');
@ -231,7 +244,7 @@ export default OakComponent({
this.navigateTo({
url: changePasswordUrl,
oakId,
});
});
}
else if (process.env.NODE_ENV === 'development') {
console.warn('changePasswordUrl unset');
@ -243,7 +256,7 @@ export default OakComponent({
this.navigateTo({
url: authenticateUrl,
oakId,
});
});
}
else if (process.env.NODE_ENV === 'development') {
console.warn('authenticateUrl unset');
@ -257,21 +270,28 @@ export default OakComponent({
},
editName() {
this.checkEditable('name');
this.setState({
editAttr: 'name',
});
if (this.checkIdState()) {
this.setState({
editAttr: 'name',
});
}
},
editGender() {
this.checkEditable('gender');
this.setState({
editAttr: 'gender',
});
const { idState } = this.state;
if (this.checkIdState()) {
this.setState({
editAttr: 'gender',
});
}
},
editBirth() {
this.checkEditable('birth');
this.setState({
editAttr: 'birth',
});
if (this.checkIdState()) {
this.setState({
editAttr: 'birth',
});
}
},
cancelEdit() {
this.setState({
@ -298,8 +318,8 @@ export default OakComponent({
birth,
});
},
changePasswordMp(e: WechatMiniprogram.Input) {
changePasswordMp(e: WechatMiniprogram.Input) {
const { value } = e.detail;
this.update({
password: value,
@ -307,19 +327,19 @@ export default OakComponent({
});
},
changeNicknameMp(e: WechatMiniprogram.Input) {
changeNicknameMp(e: WechatMiniprogram.Input) {
const { value } = e.detail;
this.update({
nickname: value,
});
},
changeNameMp(e: WechatMiniprogram.Input) {
changeNameMp(e: WechatMiniprogram.Input) {
const { value } = e.detail;
this.update({
name: value,
});
},
inputMobileMp(e: WechatMiniprogram.Input) {
inputMobileMp(e: WechatMiniprogram.Input) {
const { value } = e.detail;
const mobileInputLegal = !!isMobile(value);
this.setState({
@ -363,10 +383,10 @@ export default OakComponent({
});
}
},
async onChooseAvatar(e: { detail: { avatarUrl: string }}) {
async onChooseAvatar(e: { detail: { avatarUrl: string } }) {
const { avatarUrl } = e.detail;
const { avatar } = this.state;
this.update({
extraFile$entity: ([
{
@ -402,6 +422,6 @@ export default OakComponent({
this.reRender();
const { onConfirm } = this.props;
onConfirm && onConfirm();
},
},
},
});

View File

@ -1,6 +1,6 @@
<view class="col">
<view class="avatar-container">
<button
<!-- <button
class="avatar-btn"
open-type="chooseAvatar"
bind:chooseavatar="onChooseAvatar"
@ -12,7 +12,12 @@
<block wx:else>
<l-avatar icon="user" size="140" icon-size="80" />
</block>
</button>
</button> -->
<oak-extraFile-avatar
oakAutoUnmount="{{true}}"
oakPath="{{oakFullpath}}.extraFile$entity"
entity="user"
/>
</view>
<l-list
title="昵称"
@ -30,7 +35,7 @@
bindconfirm="cancelEdit"
bindblur="cancelEdit"
disabled="{{!editable}}"
/>
/>
</block>
<block wx:else>
<view slot="right-section" class="{{nnDirty ? 'value warning' : 'value'}}">{{nickname || '未设置'}}</view>
@ -41,7 +46,7 @@
<l-list
title="姓名"
bind:lintap="editName"
is-link="{{editAttr !== 'name'}}"
is-link="{{editAttr !== 'name' && idState !== 'verified'}}"
>
<block wx:if="{{editAttr==='name'}}">
<input
@ -52,8 +57,8 @@
bindchange="changeNameMp"
bindconfirm="cancelEdit"
bindblur="cancelEdit"
disabled="{{!editable}}"
/>
disabled="{{!editable || idState === 'verified'}}"
/>
</block>
<block wx:else>
<view slot="right-section" class="{{nameDirty ? 'value warning' : 'value'}}">{{name || '未设置'}}</view>
@ -62,19 +67,21 @@
<l-list
title="性别"
bind:lintap="editGender"
is-link="{{editAttr !== 'gender'}}"
is-link="{{editAttr !== 'gender' && idState !== 'verified'}}"
>
<view slot="right-section" class="{{genderDirty ? 'value warning' : 'value'}}">{{genderStr || '未设置'}}</view>
</l-list>
<l-list
title="生日"
is-link="{{idState !== 'verified'}}"
>
<view slot="right-section" class="{{birthDirty ? 'value warning' : 'value'}}">
<block wx:if="{{editable}}">
<block wx:if="{{editable && idState !== 'verified'}}">
<picker mode="date" end="{{birthEnd}}" value="{{birthText}}" bind:change="changeBirthMp">
{{ birthText || '选择日期'}}
</picker>
</block>
<view wx:else>{{birthText || '未设置'}}</view>
</view>
</l-list>
<l-list title="手机号" bind:lintap="editMobile">
@ -95,11 +102,11 @@
/>
</block>
<block wx:else>
<view slot="right-section" class="value">{{hasPassword ? '******' : '未设置'}}</view>
<view slot="right-section" class="value">{{hasPassword ? '******' : '未设置'}}</view>
</block>
</l-list>
<l-list tag-position="right" is-link="{{false}}" title="用户状态">
<view slot="right-section" class="value">
<l-list tag-position="right" is-link="{{false}}" title="用户状态">
<view slot="right-section" class="value">
<l-tag plain="{{true}}" font-color="{{userStateColor}}" shape="circle">
{{userStateStr || '未设置'}}
</l-tag>
@ -113,19 +120,25 @@
</view>
</l-list>
<view style="flex:1" />
<block wx:if="{{executable === true}}">
<!-- <block wx:if="{{executable === true}}">
<l-button
size="long"
bind:lintap="onConfirm"
>
{{t('common::action.confirm')}}
</l-button>
</block>
</block> -->
<oak-commit
oakPath="{{oakFullpath}}"
entity='user'
buttonProps="{{commitBtnProps}}"
/>
</view>
<l-popup
show="{{editAttr === 'gender' || editAttr === 'mobile'}}"
content-align="bottom"
bind:lintap="cancelEdit"
z-index="{{1000}}"
>
<view class='popup-content'>
<view class='popup-form'>
@ -145,7 +158,7 @@
</l-form-item>
</block>
<block wx:else>
<l-input
<l-input
hide-label="{{true}}"
focus="{{true}}"
value="{{mobileInput || mobile}}"

View File

@ -22,5 +22,6 @@
"secuInfo": "安全信息",
"wechatAccount": "微信帐号",
"bindMobile": "绑定手机号",
"bindWechat": "绑定微信"
"bindWechat": "绑定微信",
"notAllowUpdate": "暂不支持更新"
}

View File

@ -49,6 +49,7 @@ export default function Render(
idStateColor: string;
isCreation: boolean;
editable: boolean;
idState: EntityDict['user']['Schema']['idState'];
},
{
editMobile: () => void;
@ -88,6 +89,7 @@ export default function Render(
idStateStr,
isRoot,
isCreation,
idState,
} = data;
const [open, setOpen] = useState(false);
const [open2, setOpen2] = useState(false);
@ -118,7 +120,7 @@ export default function Render(
>
<>
<Input
disabled={!editable}
disabled={!editable || idState === 'verified'}
placeholder=""
onChange={(e) =>
methods.update({
@ -156,7 +158,7 @@ export default function Render(
>
<Space direction="vertical">
<Radio.Group
disabled={!editable}
disabled={!editable || idState === 'verified'}
value={gender}
options={genderOptions}
onChange={({ target: { value } }) => {
@ -175,7 +177,7 @@ export default function Render(
>
<>
<DatePicker
disabled={!editable}
disabled={!editable || idState === 'verified'}
format="YYYY-MM-DD"
inputReadOnly={true}
allowClear={false}
@ -257,7 +259,7 @@ export default function Render(
<Form.Item label={t('user:attr.password')}>
<Space>
<Typography>{'********'}</Typography>
{editable && <Button
{editable && <Button
disabled={!editable}
size="small"
onClick={() => {

View File

@ -40,6 +40,7 @@ type DataProps = {
userStateColor: string;
idStateStr: string;
idStateColor: string;
idState: EntityDict['user']['Schema']['idState'];
isCreation: boolean;
editable: boolean;
@ -100,6 +101,7 @@ export default function render(
userStateStr,
idStateColor,
idStateStr,
idState,
editable,
} = data;
@ -158,6 +160,7 @@ export default function render(
/>
)}
onClick={editAttr === 'name' ? undefined : () => editName()}
clickable={editable && idState !== 'verified'}
>
{t('user:attr.name')}
</List.Item>
@ -191,6 +194,7 @@ export default function render(
</Radio.Group>
)}
onClick={editAttr === 'gender' ? undefined : () => editGender()}
clickable={editable && idState !== 'verified'}
>
{t('user:attr.gender')}
</List.Item>
@ -201,6 +205,7 @@ export default function render(
</div>
}
onClick={editAttr === 'birth' ? undefined : () => editBirth()}
clickable={editable && idState !== 'verified'}
>
{t('user:attr.birth')}
</List.Item>

View File

@ -304,7 +304,8 @@ const i18ns: I18n[] = [
"secuInfo": "安全信息",
"wechatAccount": "微信帐号",
"bindMobile": "绑定手机号",
"bindWechat": "绑定微信"
"bindWechat": "绑定微信",
"notAllowUpdate": "暂不支持更新"
}
},
{