refactor: 优化反馈和布局
This commit is contained in:
1 parent
07e9ce725c
commit
030e19084f
15 files changed
+417
-775
No files matched your search
+2
-1
@@ -7,7 +7,8 @@ VITE_APP_PORT = 4096
|
|||||||
VITE_APP_BASE_API = '/dev-api'
|
VITE_APP_BASE_API = '/dev-api'
|
||||||
|
|
||||||
# API 服务器的 URL
|
# API 服务器的 URL
|
||||||
VITE_APP_API_URL = http://localhost:8989
|
#VITE_APP_API_URL = http://localhost:8989
|
||||||
|
VITE_APP_API_URL = https://api.youlai.tech
|
||||||
|
|
||||||
# WebSocket 服务器的 URL,不配置默认关闭 WebSocket
|
# WebSocket 服务器的 URL,不配置默认关闭 WebSocket
|
||||||
#VITE_APP_WS_ENDPOINT= ws://localhost:4096/ws
|
#VITE_APP_WS_ENDPOINT= ws://localhost:4096/ws
|
||||||
Vendored
+3
-3
@@ -8,8 +8,6 @@ export {}
|
|||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
CuDateQuery: typeof import('./src/components/cu-date-query/index.vue')['default']
|
CuDateQuery: typeof import('./src/components/cu-date-query/index.vue')['default']
|
||||||
CuDict: typeof import('./src/components/cu-dict/index.vue')['default']
|
|
||||||
CuDictLabel: typeof import('./src/components/cu-dict-label/index.vue')['default']
|
|
||||||
CuPicker: typeof import('./src/components/cu-picker/index.vue')['default']
|
CuPicker: typeof import('./src/components/cu-picker/index.vue')['default']
|
||||||
Loading1: typeof import('./src/components/qiun-loading/loading1.vue')['default']
|
Loading1: typeof import('./src/components/qiun-loading/loading1.vue')['default']
|
||||||
Loading2: typeof import('./src/components/qiun-loading/loading2.vue')['default']
|
Loading2: typeof import('./src/components/qiun-loading/loading2.vue')['default']
|
||||||
@@ -27,6 +25,7 @@ declare module 'vue' {
|
|||||||
WdCollapseItem: typeof import('wot-design-uni/components/wd-collapse-item/wd-collapse-item.vue')['default']
|
WdCollapseItem: typeof import('wot-design-uni/components/wd-collapse-item/wd-collapse-item.vue')['default']
|
||||||
WdConfigProvider: typeof import('wot-design-uni/components/wd-config-provider/wd-config-provider.vue')['default']
|
WdConfigProvider: typeof import('wot-design-uni/components/wd-config-provider/wd-config-provider.vue')['default']
|
||||||
WdForm: typeof import('wot-design-uni/components/wd-form/wd-form.vue')['default']
|
WdForm: typeof import('wot-design-uni/components/wd-form/wd-form.vue')['default']
|
||||||
|
WdFormItem: typeof import('wot-design-uni/components/wd-form-item/wd-form-item.vue')['default']
|
||||||
WdGrid: typeof import('wot-design-uni/components/wd-grid/wd-grid.vue')['default']
|
WdGrid: typeof import('wot-design-uni/components/wd-grid/wd-grid.vue')['default']
|
||||||
WdGridItem: typeof import('wot-design-uni/components/wd-grid-item/wd-grid-item.vue')['default']
|
WdGridItem: typeof import('wot-design-uni/components/wd-grid-item/wd-grid-item.vue')['default']
|
||||||
WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
|
WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
|
||||||
@@ -42,14 +41,15 @@ declare module 'vue' {
|
|||||||
WdProgress: typeof import('wot-design-uni/components/wd-progress/wd-progress.vue')['default']
|
WdProgress: typeof import('wot-design-uni/components/wd-progress/wd-progress.vue')['default']
|
||||||
WdRadio: typeof import('wot-design-uni/components/wd-radio/wd-radio.vue')['default']
|
WdRadio: typeof import('wot-design-uni/components/wd-radio/wd-radio.vue')['default']
|
||||||
WdRadioGroup: typeof import('wot-design-uni/components/wd-radio-group/wd-radio-group.vue')['default']
|
WdRadioGroup: typeof import('wot-design-uni/components/wd-radio-group/wd-radio-group.vue')['default']
|
||||||
|
WdStatusTip: typeof import('wot-design-uni/components/wd-status-tip/wd-status-tip.vue')['default']
|
||||||
WdSwiper: typeof import('wot-design-uni/components/wd-swiper/wd-swiper.vue')['default']
|
WdSwiper: typeof import('wot-design-uni/components/wd-swiper/wd-swiper.vue')['default']
|
||||||
WdSwitch: typeof import('wot-design-uni/components/wd-switch/wd-switch.vue')['default']
|
WdSwitch: typeof import('wot-design-uni/components/wd-switch/wd-switch.vue')['default']
|
||||||
WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default']
|
WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default']
|
||||||
WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default']
|
WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default']
|
||||||
WdTag: typeof import('wot-design-uni/components/wd-tag/wd-tag.vue')['default']
|
WdTag: typeof import('wot-design-uni/components/wd-tag/wd-tag.vue')['default']
|
||||||
|
WdText: typeof import('wot-design-uni/components/wd-text/wd-text.vue')['default']
|
||||||
WdTextarea: typeof import('wot-design-uni/components/wd-textarea/wd-textarea.vue')['default']
|
WdTextarea: typeof import('wot-design-uni/components/wd-textarea/wd-textarea.vue')['default']
|
||||||
WdToast: typeof import('wot-design-uni/components/wd-toast/wd-toast.vue')['default']
|
WdToast: typeof import('wot-design-uni/components/wd-toast/wd-toast.vue')['default']
|
||||||
WdUpload: typeof import('wot-design-uni/components/wd-upload/wd-upload.vue')['default']
|
WdUpload: typeof import('wot-design-uni/components/wd-upload/wd-upload.vue')['default']
|
||||||
WechatProfile: typeof import('./src/components/business/WechatProfile.vue')['default']
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="wechat-profile">
|
|
||||||
<!-- 头像选择 -->
|
|
||||||
<view class="avatar-section">
|
|
||||||
<view class="section-title">头像</view>
|
|
||||||
<button class="avatar-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
|
||||||
<image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill" />
|
|
||||||
<view v-else class="avatar-placeholder">
|
|
||||||
<wd-icon name="camera" size="40" color="#999" />
|
|
||||||
<text class="placeholder-text">选择头像</text>
|
|
||||||
</view>
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 昵称输入 -->
|
|
||||||
<view class="nickname-section">
|
|
||||||
<view class="section-title">昵称</view>
|
|
||||||
<input
|
|
||||||
v-model="nickname"
|
|
||||||
type="nickname"
|
|
||||||
class="nickname-input"
|
|
||||||
placeholder="请输入昵称"
|
|
||||||
:maxlength="20"
|
|
||||||
@blur="onNicknameChange"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 性别选择 -->
|
|
||||||
<view class="gender-section">
|
|
||||||
<view class="section-title">性别</view>
|
|
||||||
<wd-radio-group v-model="gender" shape="button" class="gender-group">
|
|
||||||
<wd-radio :value="1" class="gender-radio">男</wd-radio>
|
|
||||||
<wd-radio :value="2" class="gender-radio">女</wd-radio>
|
|
||||||
</wd-radio-group>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, watch } from "vue";
|
|
||||||
import FileAPI, { type FileInfo } from "@/api/file";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信小程序头像昵称组件
|
|
||||||
*
|
|
||||||
* @description 用于微信小程序环境下的头像、昵称和性别选择
|
|
||||||
* @component WechatProfile
|
|
||||||
* @example
|
|
||||||
* <WechatProfile v-model="profileData" @change="onProfileChange" />
|
|
||||||
*/
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: "WechatProfile",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Props
|
|
||||||
interface ProfileData {
|
|
||||||
avatar?: string;
|
|
||||||
nickname?: string;
|
|
||||||
gender?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
modelValue?: ProfileData;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
modelValue: () => ({
|
|
||||||
avatar: "",
|
|
||||||
nickname: "",
|
|
||||||
gender: 1,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Emits
|
|
||||||
const emit = defineEmits<{
|
|
||||||
"update:modelValue": [value: ProfileData];
|
|
||||||
change: [value: ProfileData];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
// 响应式数据
|
|
||||||
const avatar = ref(props.modelValue?.avatar || "");
|
|
||||||
const nickname = ref(props.modelValue?.nickname || "");
|
|
||||||
const gender = ref(props.modelValue?.gender || 1);
|
|
||||||
|
|
||||||
// 监听props变化
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
avatar.value = newValue.avatar || "";
|
|
||||||
nickname.value = newValue.nickname || "";
|
|
||||||
gender.value = newValue.gender || 1;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true, deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听数据变化并发出事件
|
|
||||||
const emitChange = () => {
|
|
||||||
const value = {
|
|
||||||
avatar: avatar.value,
|
|
||||||
nickname: nickname.value,
|
|
||||||
gender: gender.value,
|
|
||||||
};
|
|
||||||
emit("update:modelValue", value);
|
|
||||||
emit("change", value);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 头像选择处理
|
|
||||||
const onChooseAvatar = async (e: any) => {
|
|
||||||
try {
|
|
||||||
const { avatarUrl } = e.detail;
|
|
||||||
|
|
||||||
// 上传头像到服务器
|
|
||||||
uni.showLoading({ title: "上传中..." });
|
|
||||||
|
|
||||||
const fileInfo: FileInfo = await FileAPI.upload(avatarUrl);
|
|
||||||
avatar.value = fileInfo.url;
|
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
uni.showToast({ title: "头像上传成功", icon: "success" });
|
|
||||||
|
|
||||||
emitChange();
|
|
||||||
} catch (error) {
|
|
||||||
uni.hideLoading();
|
|
||||||
console.error("头像上传失败:", error);
|
|
||||||
uni.showToast({ title: "头像上传失败", icon: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 昵称变化处理
|
|
||||||
const onNicknameChange = () => {
|
|
||||||
emitChange();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 监听性别变化
|
|
||||||
watch(gender, () => {
|
|
||||||
emitChange();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.wechat-profile {
|
|
||||||
padding: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--wot-color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-section {
|
|
||||||
margin-bottom: 40rpx;
|
|
||||||
|
|
||||||
.avatar-button {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 160rpx;
|
|
||||||
height: 160rpx;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0 auto;
|
|
||||||
overflow: hidden;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
border-radius: 50%;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-placeholder {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: var(--wot-color-bg-light);
|
|
||||||
border: 2rpx dashed var(--wot-color-border);
|
|
||||||
border-radius: 50%;
|
|
||||||
|
|
||||||
.placeholder-text {
|
|
||||||
margin-top: 10rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: var(--wot-color-text-secondary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.nickname-section {
|
|
||||||
margin-bottom: 40rpx;
|
|
||||||
|
|
||||||
.nickname-input {
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 100%;
|
|
||||||
height: 80rpx;
|
|
||||||
padding: 0 20rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
background: var(--wot-color-bg-light);
|
|
||||||
border: 1rpx solid var(--wot-color-border);
|
|
||||||
border-radius: 12rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.gender-section {
|
|
||||||
.gender-group {
|
|
||||||
display: flex;
|
|
||||||
gap: 20rpx;
|
|
||||||
|
|
||||||
.gender-radio {
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
:deep(.wd-radio) {
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* 业务组件导出索引
|
|
||||||
*/
|
|
||||||
import WechatProfile from "./WechatProfile.vue";
|
|
||||||
|
|
||||||
export { WechatProfile };
|
|
||||||
|
|
||||||
// 用于批量注册组件
|
|
||||||
export default {
|
|
||||||
WechatProfile,
|
|
||||||
};
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<template>
|
|
||||||
<template v-if="tagType">
|
|
||||||
<wd-tag :type="tagType as any" :round="round">{{ label }}</wd-tag>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<view>{{ label }}</view>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useDictStore } from "@/store/modules/dict";
|
|
||||||
const dictStore = useDictStore();
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
code: String,
|
|
||||||
modelValue: [String, Number],
|
|
||||||
round: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const label = ref("");
|
|
||||||
const tagType = ref<string | undefined>();
|
|
||||||
|
|
||||||
const getLabelAndTagByValue = async (dictCode: string, value: any) => {
|
|
||||||
// 按需加载字典数据
|
|
||||||
await dictStore.loadDictItems(dictCode);
|
|
||||||
|
|
||||||
// 从缓存中获取字典数据
|
|
||||||
const dictItems = dictStore.getDictItems(dictCode);
|
|
||||||
|
|
||||||
// 查找对应的字典项
|
|
||||||
const dictItem = dictItems.find((item) => item.value == value);
|
|
||||||
|
|
||||||
return {
|
|
||||||
label: dictItem?.label || "",
|
|
||||||
tagType: dictItem?.tagType,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// 监听字典数据变化,确保WebSocket更新时刷新标签
|
|
||||||
watch(
|
|
||||||
() => props.code && dictStore.getDictItems(props.code),
|
|
||||||
async () => {
|
|
||||||
if (props.code) {
|
|
||||||
await fetchLabelAndTag();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听 props 的变化,获取并更新 label 和 tag
|
|
||||||
const fetchLabelAndTag = async () => {
|
|
||||||
if (!props.code || props.modelValue === undefined) return;
|
|
||||||
|
|
||||||
const result = await getLabelAndTagByValue(props.code, props.modelValue);
|
|
||||||
label.value = result.label;
|
|
||||||
tagType.value = result.tagType;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 首次挂载时获取字典数据
|
|
||||||
onMounted(fetchLabelAndTag);
|
|
||||||
|
|
||||||
// 当 modelValue 发生变化时重新获取
|
|
||||||
watch(() => props.modelValue, fetchLabelAndTag);
|
|
||||||
</script>
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
<template>
|
|
||||||
<wd-picker
|
|
||||||
v-if="type === 'select' || type === 'radio'"
|
|
||||||
v-model="selectedValue"
|
|
||||||
:columns="options"
|
|
||||||
:label="label"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
clearable
|
|
||||||
:rules="rules"
|
|
||||||
@confirm="handleChange"
|
|
||||||
/>
|
|
||||||
<wd-select-picker
|
|
||||||
v-else-if="type === 'checkbox'"
|
|
||||||
v-model="selectedValue"
|
|
||||||
:columns="options"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
clearable
|
|
||||||
:label="label"
|
|
||||||
:rules="rules"
|
|
||||||
@confirm="handleChange"
|
|
||||||
/>
|
|
||||||
<wd-input
|
|
||||||
v-else
|
|
||||||
v-model="selectedValue"
|
|
||||||
:label="label"
|
|
||||||
clearable
|
|
||||||
:placeholder="placeholder"
|
|
||||||
:rules="rules"
|
|
||||||
@input="handleChange"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useDictStore } from "@/store/modules/dict";
|
|
||||||
|
|
||||||
const dictStore = useDictStore();
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
code: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number, Array],
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: "select",
|
|
||||||
validator: (value: string) => ["select", "radio", "checkbox"].includes(value),
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: "请选择",
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
type: Array as PropType<any[]>,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue"]);
|
|
||||||
|
|
||||||
const options = ref<Array<{ label: string; value: string | number }>>([]);
|
|
||||||
|
|
||||||
const selectedValue = ref<any>(
|
|
||||||
typeof props.modelValue === "string" || typeof props.modelValue === "number"
|
|
||||||
? props.modelValue
|
|
||||||
: Array.isArray(props.modelValue)
|
|
||||||
? props.modelValue
|
|
||||||
: undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听 modelValue 变化
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(newValue) => {
|
|
||||||
if (props.type === "checkbox") {
|
|
||||||
selectedValue.value = Array.isArray(newValue) ? newValue : [];
|
|
||||||
} else {
|
|
||||||
selectedValue.value = newValue?.toString() || "";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听 options 变化并重新匹配 selectedValue
|
|
||||||
watch(
|
|
||||||
() => options.value,
|
|
||||||
(newOptions) => {
|
|
||||||
// options 加载后,确保 selectedValue 可以正确匹配到 options
|
|
||||||
if (newOptions.length > 0 && selectedValue.value !== undefined) {
|
|
||||||
const matchedOption = newOptions.find((option) => option.value === selectedValue.value);
|
|
||||||
if (!matchedOption && props.type !== "checkbox") {
|
|
||||||
// 如果找不到匹配项,清空选中
|
|
||||||
selectedValue.value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听 selectedValue 的变化并触发 update:modelValue
|
|
||||||
function handleChange(val: any) {
|
|
||||||
emit("update:modelValue", val.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取字典数据
|
|
||||||
onMounted(async () => {
|
|
||||||
if (!props.code) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 按需加载字典数据
|
|
||||||
await dictStore.loadDictItems(props.code);
|
|
||||||
options.value = dictStore.getDictItems(props.code).map((item) => ({
|
|
||||||
label: item.label,
|
|
||||||
value: item.value,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// 监听字典数据变化,确保WebSocket更新时刷新选项
|
|
||||||
watch(
|
|
||||||
() => dictStore.getDictItems(props.code),
|
|
||||||
(newItems) => {
|
|
||||||
if (newItems.length > 0) {
|
|
||||||
options.value = newItems.map((item) => ({
|
|
||||||
label: item.label,
|
|
||||||
value: item.value,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
+18
-1
@@ -2,6 +2,21 @@
|
|||||||
import { useTheme } from "@/composables/useTheme";
|
import { useTheme } from "@/composables/useTheme";
|
||||||
|
|
||||||
const { theme, themeVars } = useTheme();
|
const { theme, themeVars } = useTheme();
|
||||||
|
|
||||||
|
// 状态栏高度
|
||||||
|
const statusBarHeight = ref(0);
|
||||||
|
|
||||||
|
// 获取状态栏高度
|
||||||
|
onMounted(() => {
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
statusBarHeight.value = res.statusBarHeight || 20;
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
statusBarHeight.value = 20;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -21,7 +36,9 @@ export default {
|
|||||||
custom-style="background-color: #f5f5f5;min-height: 100vh"
|
custom-style="background-color: #f5f5f5;min-height: 100vh"
|
||||||
:class="{ 'wot-theme-dark': theme === 'dark' }"
|
:class="{ 'wot-theme-dark': theme === 'dark' }"
|
||||||
>
|
>
|
||||||
<slot />
|
<view class="box-border w-full min-h-screen" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||||
|
<slot />
|
||||||
|
</view>
|
||||||
<wd-notify />
|
<wd-notify />
|
||||||
<wd-toast />
|
<wd-toast />
|
||||||
<wd-message-box />
|
<wd-message-box />
|
||||||
|
|||||||
+99
-150
@@ -1,152 +1,10 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: weisheng
|
* @Author: Ray.Hao
|
||||||
* @Date: 2024-11-01 12:31:47
|
* @Date: 2025-05-01 12:31:47
|
||||||
* @LastEditTime: 2024-11-14 19:02:06
|
* @LastEditTime: 2025-05-01 12:31:47
|
||||||
* @LastEditors: weisheng
|
* @LastEditors: Ray.Hao
|
||||||
* @Description:
|
* @Description: Tabbar 布局组件
|
||||||
* @FilePath: \wot-demo\src\layouts\tabbar.vue
|
|
||||||
* 记得注释
|
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, computed, onMounted, nextTick, onUnmounted } from "vue";
|
|
||||||
import { onShow } from "@dcloudio/uni-app";
|
|
||||||
import { useTheme } from "@/composables/useTheme";
|
|
||||||
|
|
||||||
// 定义 TabbarItem 接口
|
|
||||||
interface TabbarItem {
|
|
||||||
name: string;
|
|
||||||
value: number | null;
|
|
||||||
active: boolean;
|
|
||||||
title: string;
|
|
||||||
icon: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据 pages.json 配置的 tabbar 项目
|
|
||||||
const tabbarItems = ref<TabbarItem[]>([
|
|
||||||
{ name: "index", value: null, active: true, title: "首页", icon: "home" },
|
|
||||||
{ name: "mine", value: null, active: false, title: "我的", icon: "user" },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const { theme, themeVars } = useTheme();
|
|
||||||
|
|
||||||
// 计算属性
|
|
||||||
const tabbarList = computed(() => tabbarItems.value);
|
|
||||||
|
|
||||||
const activeTabbar = computed(() => {
|
|
||||||
const item = tabbarItems.value.find((item) => item.active);
|
|
||||||
return item || tabbarItems.value[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
// 方法
|
|
||||||
const getTabbarItemValue = (name: string) => {
|
|
||||||
const item = tabbarItems.value.find((item) => item.name === name);
|
|
||||||
return item && item.value ? item.value : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const setTabbarItemActive = (name: string) => {
|
|
||||||
console.log(`设置 tabbar 激活状态: ${name}`);
|
|
||||||
tabbarItems.value.forEach((item) => {
|
|
||||||
if (item.name === name) {
|
|
||||||
item.active = true;
|
|
||||||
} else {
|
|
||||||
item.active = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 根据当前路由更新 tabbar 激活状态
|
|
||||||
const updateTabbarByRoute = () => {
|
|
||||||
const pages = getCurrentPages();
|
|
||||||
if (pages.length > 0) {
|
|
||||||
const currentPage = pages[pages.length - 1];
|
|
||||||
const route = currentPage.route;
|
|
||||||
|
|
||||||
console.log("=== Tabbar 路由更新 ===");
|
|
||||||
console.log("当前路由:", route);
|
|
||||||
console.log("当前激活的 tabbar:", activeTabbar.value.name);
|
|
||||||
|
|
||||||
// 根据当前路由设置活跃的 tabbar
|
|
||||||
if (route === "pages/index/index") {
|
|
||||||
console.log("设置首页为激活状态");
|
|
||||||
setTabbarItemActive("index");
|
|
||||||
} else if (route === "pages/mine/index") {
|
|
||||||
console.log("设置我的页面为激活状态");
|
|
||||||
setTabbarItemActive("mine");
|
|
||||||
} else {
|
|
||||||
console.log("非 tabbar 页面,保持当前状态");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("更新后激活的 tabbar:", activeTabbar.value.name);
|
|
||||||
console.log("=== 更新完成 ===");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function handleTabbarChange({ value }: { value: string }) {
|
|
||||||
console.log(`用户点击 tabbar: ${value}`);
|
|
||||||
|
|
||||||
// 立即设置激活状态
|
|
||||||
tabbarItems.value.forEach((item) => {
|
|
||||||
item.active = item.name === value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 导航到对应页面
|
|
||||||
if (value === "index") {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: "/pages/index/index",
|
|
||||||
});
|
|
||||||
} else if (value === "mine") {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: "/pages/mine/index",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听页面栈变化
|
|
||||||
const currentRoute = ref("");
|
|
||||||
|
|
||||||
const updateCurrentRoute = () => {
|
|
||||||
const pages = getCurrentPages();
|
|
||||||
if (pages.length > 0) {
|
|
||||||
const currentPage = pages[pages.length - 1];
|
|
||||||
const newRoute = currentPage.route || "";
|
|
||||||
|
|
||||||
if (newRoute !== currentRoute.value) {
|
|
||||||
currentRoute.value = newRoute;
|
|
||||||
console.log("页面路由发生变化:", newRoute);
|
|
||||||
updateTabbarByRoute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
nextTick(() => {
|
|
||||||
updateTabbarByRoute();
|
|
||||||
updateCurrentRoute();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 监听页面发出的 tabbar 更新事件
|
|
||||||
uni.$on("updateTabbar", (tabName: string) => {
|
|
||||||
console.log("收到 tabbar 更新事件:", tabName);
|
|
||||||
setTabbarItemActive(tabName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 页面显示时更新 tabbar 状态
|
|
||||||
onShow(() => {
|
|
||||||
nextTick(() => {
|
|
||||||
updateCurrentRoute();
|
|
||||||
});
|
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
uni.hideTabBar();
|
|
||||||
// #endif
|
|
||||||
});
|
|
||||||
|
|
||||||
// 组件卸载时移除事件监听
|
|
||||||
onUnmounted(() => {
|
|
||||||
uni.$off("updateTabbar");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -165,7 +23,9 @@ export default {
|
|||||||
custom-style="min-height: 100vh"
|
custom-style="min-height: 100vh"
|
||||||
:class="{ 'wot-theme-dark': theme === 'dark' }"
|
:class="{ 'wot-theme-dark': theme === 'dark' }"
|
||||||
>
|
>
|
||||||
<slot />
|
<view class="box-border w-full min-h-screen" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||||
|
<slot />
|
||||||
|
</view>
|
||||||
<wd-tabbar
|
<wd-tabbar
|
||||||
:model-value="activeTabbar.name"
|
:model-value="activeTabbar.name"
|
||||||
placeholder
|
placeholder
|
||||||
@@ -178,7 +38,7 @@ export default {
|
|||||||
v-for="(item, index) in tabbarList"
|
v-for="(item, index) in tabbarList"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="item.name"
|
:name="item.name"
|
||||||
:value="getTabbarItemValue(item.name)"
|
:value="item.value"
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
:icon="item.icon"
|
:icon="item.icon"
|
||||||
/>
|
/>
|
||||||
@@ -189,4 +49,93 @@ export default {
|
|||||||
</wd-config-provider>
|
</wd-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<script setup lang="ts">
|
||||||
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
|
import { useTheme } from "@/composables/useTheme";
|
||||||
|
|
||||||
|
// 定义 TabbarItem 接口
|
||||||
|
interface TabbarItem {
|
||||||
|
name: string;
|
||||||
|
value: number | null;
|
||||||
|
active: boolean;
|
||||||
|
title: string;
|
||||||
|
icon: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { theme, themeVars } = useTheme();
|
||||||
|
|
||||||
|
// 状态栏高度
|
||||||
|
const statusBarHeight = ref(0);
|
||||||
|
|
||||||
|
// tabbar 配置
|
||||||
|
const tabbarItems = ref<TabbarItem[]>([
|
||||||
|
{ name: "index", value: null, active: true, title: "首页", icon: "home" },
|
||||||
|
{ name: "mine", value: null, active: false, title: "我的", icon: "user" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 计算属性
|
||||||
|
const tabbarList = computed(() => tabbarItems.value);
|
||||||
|
const activeTabbar = computed(
|
||||||
|
() => tabbarItems.value.find((item) => item.active) || tabbarItems.value[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新 tabbar 状态
|
||||||
|
const updateTabbarState = () => {
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
if (!pages.length) return;
|
||||||
|
|
||||||
|
const route = pages[pages.length - 1].route;
|
||||||
|
|
||||||
|
if (route === "pages/index/index") {
|
||||||
|
setTabbarActive("index");
|
||||||
|
} else if (route === "pages/mine/index") {
|
||||||
|
setTabbarActive("mine");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 设置激活状态
|
||||||
|
const setTabbarActive = (name: string) => {
|
||||||
|
tabbarItems.value.forEach((item) => {
|
||||||
|
item.active = item.name === name;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理点击事件
|
||||||
|
const handleTabbarChange = ({ value }: { value: string }) => {
|
||||||
|
setTabbarActive(value);
|
||||||
|
|
||||||
|
const url = value === "index" ? "/pages/index/index" : "/pages/mine/index";
|
||||||
|
uni.reLaunch({ url });
|
||||||
|
};
|
||||||
|
|
||||||
|
// 生命周期
|
||||||
|
onMounted(() => {
|
||||||
|
// 获取状态栏高度(改为异步方法)
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
statusBarHeight.value = res.statusBarHeight || 20;
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
statusBarHeight.value = 20;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 初始化状态
|
||||||
|
nextTick(updateTabbarState);
|
||||||
|
|
||||||
|
// 监听事件
|
||||||
|
uni.$on("updateTabbar", setTabbarActive);
|
||||||
|
});
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
nextTick(updateTabbarState);
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
uni.hideTabBar();
|
||||||
|
// #endif
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
uni.$off("updateTabbar");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
+6
-1
@@ -17,6 +17,11 @@
|
|||||||
"style": {},
|
"style": {},
|
||||||
"layout": "tabbar"
|
"layout": "tabbar"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/work/index",
|
||||||
|
"type": "page",
|
||||||
|
"style": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/about/index",
|
"path": "pages/mine/about/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
@@ -93,4 +98,4 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subPackages": []
|
"subPackages": []
|
||||||
}
|
}
|
||||||
@@ -147,25 +147,25 @@ const navList = reactive([
|
|||||||
{
|
{
|
||||||
icon: "/static/icons/user.png",
|
icon: "/static/icons/user.png",
|
||||||
title: "用户管理",
|
title: "用户管理",
|
||||||
url: "/pages/work/user/index",
|
url: "/pages/work/index",
|
||||||
prem: "sys:user:query",
|
prem: "sys:user:query",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: "/static/icons/role.png",
|
icon: "/static/icons/role.png",
|
||||||
title: "角色管理",
|
title: "角色管理",
|
||||||
url: "/pages/work/role/index",
|
url: "/pages/work/index",
|
||||||
prem: "sys:role:query",
|
prem: "sys:role:query",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: "/static/icons/notice.png",
|
icon: "/static/icons/notice.png",
|
||||||
title: "通知公告",
|
title: "通知公告",
|
||||||
url: "/pages/work/notice/index",
|
url: "/pages/work/index",
|
||||||
prem: "sys:notice:query",
|
prem: "sys:notice:query",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: "/static/icons/setting.png",
|
icon: "/static/icons/setting.png",
|
||||||
title: "系统配置",
|
title: "系统配置",
|
||||||
url: "/pages/work/config/index",
|
url: "/pages/work/index",
|
||||||
prem: "sys:config:query",
|
prem: "sys:config:query",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -265,6 +265,4 @@ onShow(() => {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style setup lang="scss">
|
<style setup lang="scss"></style>
|
||||||
/* 已全部使用UnoCSS替代,不需要额外的样式 */
|
|
||||||
</style>
|
|
||||||
+125
-130
@@ -1,67 +1,62 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="feedback-container">
|
<view class="app-container">
|
||||||
<!-- 问题类型选择 -->
|
<wd-navbar title="意见反馈" left-arrow @click-left="handleBack" />
|
||||||
<wd-cell-group title="问题类型" border>
|
|
||||||
<view class="radio-group">
|
|
||||||
<label v-for="item in feedbackTypes" :key="item.value" class="radio-item">
|
|
||||||
<text class="radio-text">{{ item.label }}</text>
|
|
||||||
<radio
|
|
||||||
:value="item.value"
|
|
||||||
:checked="feedbackType === item.value"
|
|
||||||
color="#0083ff"
|
|
||||||
class="radio-button"
|
|
||||||
style="transform: scale(0.8)"
|
|
||||||
@click="handleRadioChange(item.value)"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</view>
|
|
||||||
</wd-cell-group>
|
|
||||||
|
|
||||||
<!-- 问题描述 -->
|
123
|
||||||
<wd-cell-group title="问题描述" border>
|
<wd-text size="small">选填,最多上传3张图片</wd-text>
|
||||||
<wd-textarea
|
<wd-form ref="formRef" :model="formData" :rules="rules">
|
||||||
v-model="description"
|
<!-- 问题类型选择 -->
|
||||||
placeholder="请详细描述您遇到的问题或建议..."
|
<wd-form-item label="问题类型" prop="feedbackType">
|
||||||
:maxlength="500"
|
<wd-radio-group v-model="formData.feedbackType" inline>
|
||||||
show-count
|
<wd-radio v-for="item in feedbackTypes" :key="item.value" :value="item.value">
|
||||||
:rows="5"
|
{{ item.label }}
|
||||||
/>
|
</wd-radio>
|
||||||
</wd-cell-group>
|
</wd-radio-group>
|
||||||
|
</wd-form-item>
|
||||||
|
|
||||||
<!-- 图片上传 -->
|
<!-- 问题描述 -->
|
||||||
<wd-cell-group title="相关截图(选填)" border>
|
<wd-form-item label="问题描述" prop="description">
|
||||||
<view class="upload-box">
|
<wd-textarea
|
||||||
|
v-model="formData.description"
|
||||||
|
placeholder="请详细描述您遇到的问题或建议..."
|
||||||
|
:maxlength="120"
|
||||||
|
show-word-limit
|
||||||
|
/>
|
||||||
|
</wd-form-item>
|
||||||
|
|
||||||
|
<!-- 图片上传 -->
|
||||||
|
<wd-form-item label="相关截图" prop="fileList">
|
||||||
<wd-upload
|
<wd-upload
|
||||||
v-model="fileList"
|
v-model="formData.fileList"
|
||||||
:max-count="3"
|
:max-count="3"
|
||||||
:before-read="beforeRead"
|
:before-read="beforeRead"
|
||||||
@delete="handleDelete"
|
@delete="handleDelete"
|
||||||
/>
|
/>
|
||||||
|
</wd-form-item>
|
||||||
|
|
||||||
|
<!-- 联系方式 -->
|
||||||
|
<wd-form-item label="联系方式" prop="contact">
|
||||||
|
<wd-input v-model="formData.contact" placeholder="请输入您的手机号或邮箱" clearable />
|
||||||
|
<wd-text size="small">选填,便于我们与您联系</wd-text>
|
||||||
|
</wd-form-item>
|
||||||
|
|
||||||
|
<!-- 提交按钮 -->
|
||||||
|
<view class="submit-btn">
|
||||||
|
<wd-button type="primary" block :loading="submitting" @click="handleSubmit">
|
||||||
|
提交反馈
|
||||||
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</wd-cell-group>
|
</wd-form>
|
||||||
|
|
||||||
<!-- 联系方式 -->
|
|
||||||
<wd-cell-group title="联系方式(选填)" border>
|
|
||||||
<wd-input v-model="contact" placeholder="请输入您的手机号或邮箱" clearable />
|
|
||||||
</wd-cell-group>
|
|
||||||
|
|
||||||
<!-- 提交按钮 -->
|
|
||||||
<view class="submit-btn">
|
|
||||||
<wd-button type="primary" block :loading="submitting" @click="handleSubmit">
|
|
||||||
提交反馈
|
|
||||||
</wd-button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<wd-toast />
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
|
||||||
import { useToast } from "wot-design-uni";
|
|
||||||
import { checkLogin } from "@/utils/auth";
|
import { checkLogin } from "@/utils/auth";
|
||||||
|
import { useToast } from "wot-design-uni";
|
||||||
|
import { FormRules } from "wot-design-uni/components/wd-form/types";
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
// 检查登录状态
|
// 检查登录状态
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
@@ -76,14 +71,50 @@ const feedbackTypes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const feedbackType = ref("bug");
|
const formData = reactive({
|
||||||
const description = ref("");
|
feedbackType: "bug",
|
||||||
const fileList = ref<any[]>([]);
|
description: "",
|
||||||
const contact = ref("");
|
fileList: [] as Array<Record<string, any>>,
|
||||||
|
contact: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const rules: FormRules = {
|
||||||
|
description: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "请描述您遇到的问题",
|
||||||
|
validator: (value) => {
|
||||||
|
if (value && value.trim()) {
|
||||||
|
return Promise.resolve();
|
||||||
|
} else {
|
||||||
|
return Promise.reject("请描述您遇到的问题");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
contact: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
validator: (value) => {
|
||||||
|
if (!value) return Promise.resolve(); // 非必填
|
||||||
|
const emailReg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
|
||||||
|
const phoneReg = /^1[3456789]\d{9}$/;
|
||||||
|
return emailReg.test(value) || phoneReg.test(value)
|
||||||
|
? Promise.resolve()
|
||||||
|
: Promise.reject("请输入正确的手机号或邮箱");
|
||||||
|
},
|
||||||
|
message: "请输入正确的手机号或邮箱",
|
||||||
|
trigger: "blur",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交状态
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
|
|
||||||
// 图片上传前的校验
|
// 图片上传前的校验
|
||||||
const beforeRead = (file: any) => {
|
const beforeRead = (file: Record<string, any>) => {
|
||||||
// 验证文件类型
|
// 验证文件类型
|
||||||
const validTypes = ["image/jpeg", "image/png", "image/gif"];
|
const validTypes = ["image/jpeg", "image/png", "image/gif"];
|
||||||
if (!validTypes.includes(file.type)) {
|
if (!validTypes.includes(file.type)) {
|
||||||
@@ -99,95 +130,59 @@ const beforeRead = (file: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 删除图片
|
// 删除图片
|
||||||
const handleDelete = (detail: any) => {
|
const handleDelete = (detail: { index: number }) => {
|
||||||
const index = detail.index;
|
const index = detail.index;
|
||||||
fileList.value.splice(index, 1);
|
formData.fileList.splice(index, 1);
|
||||||
};
|
|
||||||
|
|
||||||
// 处理单选框变化
|
|
||||||
const handleRadioChange = (value: string) => {
|
|
||||||
feedbackType.value = value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 提交反馈
|
// 提交反馈
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!description.value.trim()) {
|
|
||||||
toast.error("请描述您遇到的问题");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
submitting.value = true;
|
|
||||||
try {
|
try {
|
||||||
// TODO: 调用提交反馈的接口
|
const { valid } = await formRef.value.validate();
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1500)); // 模拟提交
|
|
||||||
toast.success("提交成功");
|
|
||||||
// 重置表单
|
|
||||||
description.value = "";
|
|
||||||
fileList.value = [];
|
|
||||||
contact.value = "";
|
|
||||||
|
|
||||||
// 延迟返回上一页
|
if (valid) {
|
||||||
setTimeout(() => {
|
submitting.value = true;
|
||||||
uni.navigateBack();
|
try {
|
||||||
}, 1500);
|
// TODO: 调用提交反馈的接口
|
||||||
} catch {
|
await new Promise((resolve) => setTimeout(resolve, 1500)); // 模拟提交
|
||||||
toast.error("提交失败,请重试");
|
toast.success("提交成功");
|
||||||
} finally {
|
|
||||||
submitting.value = false;
|
// 重置表单
|
||||||
|
formRef.value.reset();
|
||||||
|
formData.feedbackType = "bug";
|
||||||
|
formData.description = "";
|
||||||
|
formData.fileList = [];
|
||||||
|
formData.contact = "";
|
||||||
|
|
||||||
|
// 延迟返回上一页
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 1500);
|
||||||
|
} catch (_error) {
|
||||||
|
toast.error("提交失败,请重试");
|
||||||
|
} finally {
|
||||||
|
submitting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_error) {
|
||||||
|
// 表单验证失败
|
||||||
|
console.log("表单验证失败");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 返回
|
||||||
|
const handleBack = () => {
|
||||||
|
uni.navigateBack();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.feedback-container {
|
:deep(.wd-form-item) {
|
||||||
min-height: 100vh;
|
margin-bottom: 12rpx;
|
||||||
padding: 20rpx 0;
|
}
|
||||||
background-color: #f5f5f5;
|
|
||||||
|
|
||||||
:deep(.wd-cell-group__title) {
|
.submit-btn {
|
||||||
padding: 20rpx 30rpx 10rpx;
|
margin: 40rpx 30rpx;
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-group {
|
|
||||||
padding: 4rpx 0;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 10rpx 30rpx;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-text {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-box {
|
|
||||||
padding: 20rpx 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
margin: 40rpx 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-textarea) {
|
|
||||||
padding: 20rpx 30rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-button {
|
|
||||||
margin-right: -8rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -15,7 +15,47 @@
|
|||||||
<!-- #ifdef MP-WEIXIN -->
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
<view class="form-section">
|
<view class="form-section">
|
||||||
<view class="section-title">基本信息</view>
|
<view class="section-title">基本信息</view>
|
||||||
<WechatProfile v-model="wechatProfileData" @change="onWechatProfileChange" />
|
|
||||||
|
<!-- 内联WechatProfile组件的内容 -->
|
||||||
|
<view class="wechat-profile">
|
||||||
|
<!-- 头像选择 -->
|
||||||
|
<view class="avatar-section">
|
||||||
|
<view class="section-title">头像</view>
|
||||||
|
<button class="avatar-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
||||||
|
<image
|
||||||
|
v-if="profileForm.avatar"
|
||||||
|
:src="profileForm.avatar"
|
||||||
|
class="avatar-image"
|
||||||
|
mode="aspectFill"
|
||||||
|
/>
|
||||||
|
<view v-else class="avatar-placeholder">
|
||||||
|
<wd-icon name="camera" size="40" color="#999" />
|
||||||
|
<text class="placeholder-text">选择头像</text>
|
||||||
|
</view>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 昵称输入 -->
|
||||||
|
<view class="nickname-section">
|
||||||
|
<view class="section-title">昵称</view>
|
||||||
|
<input
|
||||||
|
v-model="profileForm.nickname"
|
||||||
|
type="nickname"
|
||||||
|
class="nickname-input"
|
||||||
|
placeholder="请输入昵称"
|
||||||
|
:maxlength="20"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 性别选择 -->
|
||||||
|
<view class="gender-section">
|
||||||
|
<view class="section-title">性别</view>
|
||||||
|
<wd-radio-group v-model="profileForm.gender" shape="button" class="gender-group">
|
||||||
|
<wd-radio :value="1" class="gender-radio">男</wd-radio>
|
||||||
|
<wd-radio :value="2" class="gender-radio">女</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
|
|
||||||
@@ -120,7 +160,6 @@ import { useToast } from "wot-design-uni";
|
|||||||
import { useUserStore } from "@/store/modules/user.store";
|
import { useUserStore } from "@/store/modules/user.store";
|
||||||
import UserAPI, { type UserProfileForm } from "@/api/user";
|
import UserAPI, { type UserProfileForm } from "@/api/user";
|
||||||
import FileAPI, { type FileInfo } from "@/api/file";
|
import FileAPI, { type FileInfo } from "@/api/file";
|
||||||
import WechatProfile from "@/components/business/WechatProfile.vue";
|
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -136,13 +175,6 @@ const profileForm = reactive<UserProfileForm & { mobile?: string }>({
|
|||||||
mobile: "",
|
mobile: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 微信头像昵称数据
|
|
||||||
const wechatProfileData = ref({
|
|
||||||
avatar: "",
|
|
||||||
nickname: "",
|
|
||||||
gender: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules = {
|
const rules = {
|
||||||
nickname: [
|
nickname: [
|
||||||
@@ -179,6 +211,26 @@ onLoad((options: any) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 微信小程序头像选择处理
|
||||||
|
const onChooseAvatar = async (e: any) => {
|
||||||
|
try {
|
||||||
|
const { avatarUrl } = e.detail;
|
||||||
|
|
||||||
|
// 上传头像到服务器
|
||||||
|
uni.showLoading({ title: "上传中..." });
|
||||||
|
|
||||||
|
const fileInfo: FileInfo = await FileAPI.upload(avatarUrl);
|
||||||
|
profileForm.avatar = fileInfo.url;
|
||||||
|
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: "头像上传成功", icon: "success" });
|
||||||
|
} catch (error) {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error("头像上传失败:", error);
|
||||||
|
uni.showToast({ title: "头像上传失败", icon: "error" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 选择头像
|
// 选择头像
|
||||||
const chooseAvatar = () => {
|
const chooseAvatar = () => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
@@ -331,13 +383,6 @@ const handleSkip = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 微信头像昵称变化处理
|
|
||||||
const onWechatProfileChange = (data: { avatar?: string; nickname?: string; gender?: number }) => {
|
|
||||||
profileForm.avatar = data.avatar || "";
|
|
||||||
profileForm.nickname = data.nickname || "";
|
|
||||||
profileForm.gender = data.gender || 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
@@ -510,4 +555,86 @@ function handleBack() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 内联WechatProfile组件的样式 */
|
||||||
|
.wechat-profile {
|
||||||
|
padding: 20rpx;
|
||||||
|
|
||||||
|
.avatar-section {
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
|
||||||
|
.avatar-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 160rpx;
|
||||||
|
height: 160rpx;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--wot-color-bg-light);
|
||||||
|
border: 2rpx dashed var(--wot-color-border);
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
.placeholder-text {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: var(--wot-color-text-secondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.nickname-section {
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
|
||||||
|
.nickname-input {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
background: var(--wot-color-bg-light);
|
||||||
|
border: 1rpx solid var(--wot-color-border);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.gender-section {
|
||||||
|
.gender-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 20rpx;
|
||||||
|
|
||||||
|
.gender-radio {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
:deep(.wd-radio) {
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<view class="app-container">
|
||||||
|
<wd-navbar title="设置" left-arrow @click-left="handleBack" />
|
||||||
|
|
||||||
|
<wd-status-tip type="search" tip="建设中..." />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const handleBack = () => {
|
||||||
|
uni.navigateBack();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss"></style>
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
export interface Todo {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
description?: string;
|
|
||||||
completed: boolean;
|
|
||||||
deadline?: string;
|
|
||||||
priority?: "low" | "medium" | "high";
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TodoState {
|
|
||||||
todos: Todo[];
|
|
||||||
loading: boolean;
|
|
||||||
error: string | null;
|
|
||||||
}
|
|
||||||
Vendored
+1
@@ -7,6 +7,7 @@ interface NavigateToOptions {
|
|||||||
url: "/pages/index/index" |
|
url: "/pages/index/index" |
|
||||||
"/pages/login/index" |
|
"/pages/login/index" |
|
||||||
"/pages/mine/index" |
|
"/pages/mine/index" |
|
||||||
|
"/pages/work/index" |
|
||||||
"/pages/mine/about/index" |
|
"/pages/mine/about/index" |
|
||||||
"/pages/mine/faq/index" |
|
"/pages/mine/faq/index" |
|
||||||
"/pages/mine/feedback/index" |
|
"/pages/mine/feedback/index" |
|
||||||
|
|||||||
Reference in new issue
Block a user