fix(user):修复用户信息页面性别选择功能

- 移除了无效的 computed() 调用- 修复了性别选择器的值绑定逻辑
- 确保用户信息正确响应式更新
This commit is contained in:
liguigong
2025-09-29 10:17:01 +08:00
parent 94819cac4e
commit f8a4cbfb51
+34 -35
View File
@@ -1,24 +1,24 @@
<!-- 用户信息 --> <!-- 用户信息 -->
<template> <template>
<s-layout title="用户信息" class="set-userinfo-wrap"> <s-layout class="set-userinfo-wrap" title="用户信息">
<uni-forms <uni-forms
:model="state.model" :model="state.model"
:rules="state.rules" :rules="state.rules"
labelPosition="left"
border border
class="form-box" class="form-box"
labelPosition="left"
> >
<!-- 头像 --> <!-- 头像 -->
<view class="ss-flex ss-row-center ss-col-center ss-p-t-60 ss-p-b-0 bg-white"> <view class="ss-flex ss-row-center ss-col-center ss-p-t-60 ss-p-b-0 bg-white">
<view class="header-box-content"> <view class="header-box-content">
<su-image <su-image
:current="0"
:height="160"
:radius="80"
:src="state.model?.avatar || sheep.$url.static('/static/img/shop/default_avatar.png')"
:width="160"
class="content-img" class="content-img"
isPreview isPreview
:current="0"
:src="state.model?.avatar || sheep.$url.static('/static/img/shop/default_avatar.png')"
:height="160"
:width="160"
:radius="80"
mode="scaleToFill" mode="scaleToFill"
/> />
<view class="avatar-action"> <view class="avatar-action">
@@ -40,25 +40,25 @@
<view class="bg-white ss-p-x-30"> <view class="bg-white ss-p-x-30">
<!-- 昵称 + 性别 --> <!-- 昵称 + 性别 -->
<uni-forms-item name="nickname" label="昵称"> <uni-forms-item label="昵称" name="nickname">
<uni-easyinput <uni-easyinput
v-model="state.model.nickname" v-model="state.model.nickname"
type="nickname"
placeholder="设置昵称"
:inputBorder="false" :inputBorder="false"
:placeholderStyle="placeholderStyle" :placeholderStyle="placeholderStyle"
placeholder="设置昵称"
type="nickname"
/> />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="sex" label="性别"> <uni-forms-item label="性别" name="sex">
<view class="ss-flex ss-col-center ss-h-100"> <view class="ss-flex ss-col-center ss-h-100">
<radio-group @change="onChangeGender" class="ss-flex ss-col-center"> <radio-group class="ss-flex ss-col-center" @change="onChangeGender">
<label class="radio" v-for="item in sexRadioMap" :key="item.value"> <label v-for="item in sexRadioMap" :key="item.value" class="radio">
<view class="ss-flex ss-col-center ss-m-r-32"> <view class="ss-flex ss-col-center ss-m-r-32">
<radio <radio
:checked="parseInt(item.value) === state.model?.sex"
:value="item.value" :value="item.value"
color="var(--ui-BG-Main)" color="var(--ui-BG-Main)"
style="transform: scale(0.8)" style="transform: scale(0.8)"
:checked="parseInt(item.value) === state.model?.sex"
/> />
<view class="gender-name">{{ item.name }}</view> <view class="gender-name">{{ item.name }}</view>
</view> </view>
@@ -67,15 +67,15 @@
</view> </view>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="mobile" label="手机号" @tap="onChangeMobile"> <uni-forms-item label="手机号" name="mobile" @tap="onChangeMobile">
<uni-easyinput <uni-easyinput
v-model="userInfo.mobile" v-model="userInfo.mobile"
placeholder="请绑定手机号"
:inputBorder="false"
disabled
:styles="{ disableColor: '#fff' }"
:placeholderStyle="placeholderStyle"
:clearable="false" :clearable="false"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
:styles="{ disableColor: '#fff' }"
disabled
placeholder="请绑定手机号"
> >
<template v-slot:right> <template v-slot:right>
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
@@ -88,22 +88,22 @@
</uni-easyinput> </uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="password" label="登录密码" @tap="onSetPassword"> <uni-forms-item label="登录密码" name="password" @tap="onSetPassword">
<uni-easyinput <uni-easyinput
v-model="userInfo.password" v-model="userInfo.password"
placeholder="点击修改登录密码" :clearable="false"
:inputBorder="false" :inputBorder="false"
:styles="{ disableColor: '#fff' }" :styles="{ disableColor: '#fff' }"
disabled disabled
placeholder="点击修改登录密码"
placeholderStyle="color:#BBBBBB;font-size:28rpx;line-height:normal" placeholderStyle="color:#BBBBBB;font-size:28rpx;line-height:normal"
:clearable="false"
> >
<template v-slot:right> <template v-slot:right>
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<su-radio <su-radio
class="ss-flex"
v-if="userInfo.verification?.password" v-if="userInfo.verification?.password"
:modelValue="true" :modelValue="true"
class="ss-flex"
/> />
<button v-else class="ss-reset-button ss-flex ss-col-center ss-row-center"> <button v-else class="ss-reset-button ss-flex ss-col-center ss-row-center">
<text class="_icon-forward" style="color: #bbbbbb; font-size: 26rpx" /> <text class="_icon-forward" style="color: #bbbbbb; font-size: 26rpx" />
@@ -117,12 +117,12 @@
<view class="bg-white ss-m-t-14"> <view class="bg-white ss-m-t-14">
<uni-list> <uni-list>
<uni-list-item <uni-list-item
clickable
@tap="sheep.$router.go('/pages/user/address/list')"
title="地址管理"
showArrow
:border="false" :border="false"
class="list-border" class="list-border"
clickable
showArrow
title="地址管理"
@tap="sheep.$router.go('/pages/user/address/list')"
/> />
</uni-list> </uni-list>
</view> </view>
@@ -134,28 +134,28 @@
<view class="account-list ss-flex ss-row-between"> <view class="account-list ss-flex ss-row-between">
<view v-if="'WechatOfficialAccount' === sheep.$platform.name" class="ss-flex ss-col-center"> <view v-if="'WechatOfficialAccount' === sheep.$platform.name" class="ss-flex ss-col-center">
<image <image
class="list-img"
:src="sheep.$url.static('/static/img/shop/platform/WechatOfficialAccount.png')" :src="sheep.$url.static('/static/img/shop/platform/WechatOfficialAccount.png')"
class="list-img"
/> />
<text class="list-name">微信公众号</text> <text class="list-name">微信公众号</text>
</view> </view>
<view v-if="'WechatMiniProgram' === sheep.$platform.name" class="ss-flex ss-col-center"> <view v-if="'WechatMiniProgram' === sheep.$platform.name" class="ss-flex ss-col-center">
<image <image
class="list-img"
:src="sheep.$url.static('/static/img/shop/platform/WechatMiniProgram.png')" :src="sheep.$url.static('/static/img/shop/platform/WechatMiniProgram.png')"
class="list-img"
/> />
<text class="list-name">微信小程序</text> <text class="list-name">微信小程序</text>
</view> </view>
<view v-if="'App' === sheep.$platform.name" class="ss-flex ss-col-center"> <view v-if="'App' === sheep.$platform.name" class="ss-flex ss-col-center">
<image <image
class="list-img"
:src="sheep.$url.static('/static/img/shop/platform/wechat.png')" :src="sheep.$url.static('/static/img/shop/platform/wechat.png')"
class="list-img"
/> />
<text class="list-name">微信开放平台</text> <text class="list-name">微信开放平台</text>
</view> </view>
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<view class="info ss-flex ss-col-center" v-if="state.thirdInfo"> <view v-if="state.thirdInfo" class="info ss-flex ss-col-center">
<image class="avatar ss-m-r-20" :src="sheep.$url.cdn(state.thirdInfo.avatar)" /> <image :src="sheep.$url.cdn(state.thirdInfo.avatar)" class="avatar ss-m-r-20" />
<text class="name">{{ state.thirdInfo.nickname }}</text> <text class="name">{{ state.thirdInfo.nickname }}</text>
</view> </view>
<view class="bind-box ss-m-l-20"> <view class="bind-box ss-m-l-20">
@@ -172,7 +172,7 @@
</view> </view>
</view> </view>
<su-fixed bottom placeholder bg="none"> <su-fixed bg="none" bottom placeholder>
<view class="footer-box ss-p-20"> <view class="footer-box ss-p-20">
<button class="ss-rest-button logout-btn ui-Shadow-Main" @tap="onSubmit">保存</button> <button class="ss-rest-button logout-btn ui-Shadow-Main" @tap="onSubmit">保存</button>
</view> </view>
@@ -211,7 +211,6 @@
]; ];
const userInfo = computed(() => sheep.$store('user').userInfo); const userInfo = computed(() => sheep.$store('user').userInfo);
computed()
// 选择性别 // 选择性别
function onChangeGender(e) { function onChangeGender(e) {
state.model.sex = e.detail.value; state.model.sex = e.detail.value;