新增美甲师手机号改为选填并跳过空值哈希索引
自动发布开发环境 Nacos 配置 / publish (push) Successful in 25s

This commit is contained in:
2026-11-07 00:57:23 +08:00
parent 5fae5163ff
commit ae6317903a
4 changed files with 21 additions and 15 deletions
@@ -5,6 +5,7 @@ import com.xiaowang.jayucloud.salon.core.support.privacy.PhoneCrypto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject; import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -67,7 +68,8 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
return; return;
} }
Object value = metaObject.getValue(source); Object value = metaObject.getValue(source);
String hash = value == null ? null : PhoneCrypto.current().index(String.valueOf(value)); String text = value == null ? null : String.valueOf(value).trim();
String hash = !StringUtils.hasText(text) ? null : PhoneCrypto.current().index(text);
metaObject.setValue(target, hash); metaObject.setValue(target, hash);
} }
} }
@@ -384,7 +384,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
if (userDTO == null || !Integer.valueOf(3).equals(userDTO.getType())) throw new IllegalArgumentException("仅支持新增美甲师"); if (userDTO == null || !Integer.valueOf(3).equals(userDTO.getType())) throw new IllegalArgumentException("仅支持新增美甲师");
if (shopId == null || shopId <= 0) throw new IllegalArgumentException("门店不能为空"); if (shopId == null || shopId <= 0) throw new IllegalArgumentException("门店不能为空");
if (!StringUtils.hasText(userDTO.getNickname())) throw new IllegalArgumentException("美甲师姓名不能为空"); if (!StringUtils.hasText(userDTO.getNickname())) throw new IllegalArgumentException("美甲师姓名不能为空");
String phone = validateUserPhone(userDTO.getPhone(), null, true); String phone = validateUserPhone(userDTO.getPhone(), null, false);
UserDO userDO = new UserDO(); UserDO userDO = new UserDO();
userDO.setShopId(shopId); userDO.setShopId(shopId);
userDO.setNickname(userDTO.getNickname().trim()); userDO.setNickname(userDTO.getNickname().trim());
+10 -7
View File
@@ -325,25 +325,28 @@ Page({
} }
return return
} }
if (!nickname || !phone) { if (!nickname) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' }) wx.showToast({ title: '请填写美甲师姓名', icon: 'none' })
return return
} }
if (!/^1[3-9]\d{9}$/.test(phone)) { if (phone && !/^1[3-9]\d{9}$/.test(phone)) {
wx.showToast({ title: '请输入正确手机号', icon: 'none' }) wx.showToast({ title: '请输入正确手机号', icon: 'none' })
return return
} }
this.setData({ creating: true }) this.setData({ creating: true })
try { try {
const result = await employeesApi.createUser({ const payload = {
nickname, nickname,
phone,
contactPhone: phone,
wechatId, wechatId,
color: form.color, color: form.color,
avatar: form.avatar || undefined, avatar: form.avatar || undefined,
type: 3 type: 3
}) }
if (phone) {
payload.phone = phone
payload.contactPhone = phone
}
const result = await employeesApi.createUser(payload)
const id = result && typeof result === 'object' ? (result.id || result.userId) : result const id = result && typeof result === 'object' ? (result.id || result.userId) : result
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' } const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
this.setData({ createdEmployee: employee, applicationApproved: false }) this.setData({ createdEmployee: employee, applicationApproved: false })
@@ -9,11 +9,12 @@
<image wx:else class="avatar-preview" src="/assets/images/default-user-avatar.png" mode="aspectFit"></image> <image wx:else class="avatar-preview" src="/assets/images/default-user-avatar.png" mode="aspectFit"></image>
<view class="avatar-copy"> <view class="avatar-copy">
<text class="avatar-title">美甲师头像</text> <text class="avatar-title">美甲师头像</text>
<text class="avatar-tip">点击选择图片,可稍后补充</text> <text class="avatar-tip">点击选择图片</text>
</view> </view>
<text class="avatar-action">{{avatarUploading ? '上传中' : '更换'}}</text> <!-- <text class="avatar-action">{{avatarUploading ? '上传中' : '更换'}}</text> -->
<button wx:if="{{form.avatarUrl}}" class="avatar-action" catchtap="removeAvatar" style="width: 95rpx; display: block; box-sizing: border-box; left: 58rpx; top: 0rpx; height: 24rpx; position: relative">移除</button>
</view> </view>
<button wx:if="{{form.avatarUrl}}" class="remove-avatar" catchtap="removeAvatar">移除当前头像</button>
<view class="card form-card create-form"> <view class="card form-card create-form">
<view class="field"> <view class="field">
@@ -21,8 +22,8 @@
<input value="{{form.nickname}}" data-field="nickname" bindinput="onInput" placeholder="请输入美甲师姓名" /> <input value="{{form.nickname}}" data-field="nickname" bindinput="onInput" placeholder="请输入美甲师姓名" />
</view> </view>
<view class="field"> <view class="field">
<text class="field-label required">手机号</text> <text class="field-label">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" /> <input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="选填" />
</view> </view>
<view class="field"> <view class="field">
<text class="field-label">微信号</text> <text class="field-label">微信号</text>
@@ -34,7 +35,7 @@
<view class="color-current"> <view class="color-current">
<view class="color-current-chip" style="background: {{form.color}};"></view> <view class="color-current-chip" style="background: {{form.color}};"></view>
<text class="color-current-value">{{form.color}}</text> <text class="color-current-value">{{form.color}}</text>
<view class="color-select-btn" bindtap="openColorSheet">选择颜色<text class="color-select-arrow">›</text></view> <view class="color-select-btn" bindtap="openColorSheet">选择颜色</view>
</view> </view>
</view> </view>
<view class="login-unlinked" bindtap="openUserPicker"> <view class="login-unlinked" bindtap="openUserPicker">