diff --git a/acdr-ui/.vscode/settings.json b/acdr-ui/.vscode/settings.json
index 21db4690..32c7ef4e 100644
--- a/acdr-ui/.vscode/settings.json
+++ b/acdr-ui/.vscode/settings.json
@@ -61,5 +61,6 @@
".eslintrc.cjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,.stylelintrc.*,.eslintrc-auto-import.json,.editorconfig,.commitlint.cjs",
"vite.config.ts": "tsconfig.*.json,uno.config.ts,tsconfig.json,uni-pages.d.ts",
"manifest.config.ts": "manifest.config.ts,pages.config.ts"
- }
+ },
+ "vue3snippets.enable-compile-vue-file-on-did-save-code": true
}
diff --git a/acdr-ui/src/components/AddressCell.vue b/acdr-ui/src/components/AddressCell.vue
new file mode 100644
index 00000000..bb634b83
--- /dev/null
+++ b/acdr-ui/src/components/AddressCell.vue
@@ -0,0 +1,36 @@
+
+
+
+
+ {{
+ !addressDetail.addressComponent
+ ? '正在加载...'
+ : `${addressDetail.addressComponent.city} ${addressDetail.addressComponent.district}`
+ }}
+
+
+
+
+
+
+
diff --git a/acdr-ui/src/pages.json b/acdr-ui/src/pages.json
index 5cc05c5c..e9bc3333 100644
--- a/acdr-ui/src/pages.json
+++ b/acdr-ui/src/pages.json
@@ -299,10 +299,7 @@
{
"path": "pages/settings/index",
"type": "page",
- "style": {
- "navigationBarTitleText": "设置页面"
- },
- "needLogin": true
+ "style": {}
},
{
"path": "pages/space/index",
diff --git a/acdr-ui/src/pages/index/index.vue b/acdr-ui/src/pages/index/index.vue
index 5445ad12..db0e7c9e 100644
--- a/acdr-ui/src/pages/index/index.vue
+++ b/acdr-ui/src/pages/index/index.vue
@@ -10,6 +10,7 @@
+
{
-// isLoading.value = false
-// }, 2000)
-
-const toExtended = () => {
- // 跳转到extended 页面
- uni.navigateTo({
- url: '/pages/extended/index',
- })
-}
-
// 获取当前页面的宠物信息
const getPetInfo = async () => {
try {
const res = await httpGet('/petInfo/index')
if (res.code === 200) {
petInfo.value = res.data
+ } else {
+ toast(res.message)
}
} catch (error) {
console.log(error)
}
}
+const toExtended = () => {
+ // 跳转到extended 页面
+ uni.navigateTo({
+ url: '/pages/extended/index',
+ })
+}
+
const toPath = (path) => {
uni.navigateTo({
url: path,
@@ -113,7 +112,9 @@ const toPath = (path) => {
}
onLoad(async () => {
+ isLoading.value = true
await getPetInfo()
+ isLoading.value = false
})
diff --git a/acdr-ui/src/pages/settings/index.vue b/acdr-ui/src/pages/settings/index.vue
index 426f8a13..94573a90 100644
--- a/acdr-ui/src/pages/settings/index.vue
+++ b/acdr-ui/src/pages/settings/index.vue
@@ -1,12 +1,3 @@
-
-{
- style: {
- navigationBarTitleText: '设置页面',
- },
- needLogin: true,
-}
-
-
@@ -22,37 +13,64 @@
- 账户设置
-
- 手机号绑定
- 191****0915
+
+ 账户名称
+ {{ sinfo.userName }}
-
+
+ 手机号绑定
+ {{ sinfo.phone }}
+
+
+
实名认证
- 已实名
+ 已实名
+ 未实名
+
+
+
+ 修改用户名
+
+
+
+
+
+
+
+
+
+
-
diff --git a/acdr-ui/src/static/addresscell/location.png b/acdr-ui/src/static/addresscell/location.png
new file mode 100644
index 00000000..29aed107
Binary files /dev/null and b/acdr-ui/src/static/addresscell/location.png differ
diff --git a/acdr/src/main/java/com/yskj/acdr/common/verify/UserNameValidator.java b/acdr/src/main/java/com/yskj/acdr/common/verify/UserNameValidator.java
new file mode 100644
index 00000000..a623b18d
--- /dev/null
+++ b/acdr/src/main/java/com/yskj/acdr/common/verify/UserNameValidator.java
@@ -0,0 +1,62 @@
+package com.yskj.acdr.common.verify;
+
+import cn.hutool.core.util.StrUtil;
+import lombok.Getter;
+import org.springframework.stereotype.Component;
+
+@Getter
+@Component
+public class UserNameValidator {
+
+ private String errorString = "用户名不合法";
+
+ // 非法词语列表
+ private final String[] ILLEGAL_WORDS = {"admin", "root", "illegal"};
+
+ @Override
+ public String toString() {
+ return errorString;
+ }
+
+ public boolean valid(String userName) {
+ // 用户名不能为空
+ if (StrUtil.isBlank(userName)) {
+ errorString = "用户名不能为空";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名长度不能大于6
+ if (userName.length() > 6) {
+ errorString = "用户名长度大于6";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能以特殊字符开头(仅允许字母或数字开头)
+ if (!Character.isLetterOrDigit(userName.charAt(0))) {
+ errorString = "用户名不能以特殊字符开头";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能全是数字
+ if (userName.matches("\\d+")) {
+ errorString = "用户名不能全是数字";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能包含违法词语
+ for (String word : ILLEGAL_WORDS) {
+ if (userName.toLowerCase().contains(word)) {
+ errorString = "用户名包含违法词语: " + word;
+ System.out.println(errorString);
+ return false;
+ }
+ }
+
+ // 所有条件都符合,验证通过
+ return true;
+ }
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java b/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java
new file mode 100644
index 00000000..46236293
--- /dev/null
+++ b/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java
@@ -0,0 +1,79 @@
+package com.yskj.acdr.master.setting.controller;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.StrUtil;
+import com.yskj.acdr.common.cache.GlobalRedisCache;
+import com.yskj.acdr.common.response.GlobalResponse;
+import com.yskj.acdr.common.verify.UserNameValidator;
+import com.yskj.acdr.master.setting.entity.AccountInfo;
+import com.yskj.acdr.master.user.entity.Users;
+import com.yskj.acdr.master.user.service.AuthenticationService;
+import com.yskj.acdr.master.user.service.UsersService;
+import jakarta.annotation.Resource;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("/setting")
+@RestController
+public class SettingController {
+
+ @Resource
+ private UsersService usersService;
+
+ @Resource
+ private AuthenticationService authService;
+
+ @Resource
+ private GlobalRedisCache redisCache;
+
+ @Resource
+ private UserNameValidator userValid;
+
+ /**
+ * 获取账户信息
+ * @return 账户信息类
+ */
+ @GetMapping("/info")
+ public GlobalResponse info() {
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ return GlobalResponse.success(
+ new AccountInfo().setIsAuth(authService.isRealName())
+ .setPhone(users.getPhone())
+ .setUserName(users.getNickname())
+ );
+ }
+
+ /**
+ * 修改手机号
+ */
+ @PostMapping("/updatePhone")
+ @Transactional
+ public GlobalResponse updatePhone(String code,String newPhone) {
+ // 验证验证码
+ String cachedCode = redisCache.get(newPhone);
+ if (cachedCode == null || !cachedCode.equals(code)) {
+ return GlobalResponse.failure("验证码错误或已过期");
+ }
+ // 更新用户手机号
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ users.setPhone(newPhone);
+ return GlobalResponse.success(usersService.updateById(users));
+ }
+
+ /**
+ * 修改用户名称
+ */
+ @PostMapping("/updateUserName")
+ @Transactional
+ public GlobalResponse updateUserName(String userName) {
+ // 这里添加验证信息
+ if (!userValid.valid(userName)) {
+ return GlobalResponse.failure("用户名不合理,%s,请重新输入!".formatted(userValid.getErrorString()));
+ }
+ // 更新用户手机号
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ users.setNickname(userName);
+ return GlobalResponse.success(usersService.updateById(users));
+ }
+
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java b/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java
new file mode 100644
index 00000000..cf6a261a
--- /dev/null
+++ b/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java
@@ -0,0 +1,21 @@
+package com.yskj.acdr.master.setting.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "AccountInfo", description = "账户信息类")
+public class AccountInfo {
+
+ // 手机号信息
+ private String phone;
+
+ // 用户名信息
+ private String userName;
+
+ // 是否实名认证
+ private Boolean isAuth;
+
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java b/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
index 072a62de..32af9ea0 100644
--- a/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
+++ b/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
@@ -17,6 +17,7 @@ import com.yskj.acdr.master.user.service.UsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yskj.acdr.utils.MutualHttpUtil;
import com.yskj.acdr.utils.ProfileUtil;
+import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -56,7 +57,7 @@ public class UsersServiceImpl extends ServiceImpl implements
@Value("${profiles:active}")
private String debug;
- @Autowired
+ @Resource
private GlobalRedisCache redisCache;
@Override