fix:相册文件上传修改
This commit is contained in:
1 parent
2d4e7db772
commit
18fdcafd39
5 files changed
+36
-27
No files matched your search
+9
-1
@@ -26,7 +26,9 @@
|
||||
"Payment" : {},
|
||||
"Share" : {},
|
||||
"VideoPlayer" : {},
|
||||
"OAuth" : {}
|
||||
"OAuth" : {},
|
||||
"Camera" : {},
|
||||
"Geolocation" : {}
|
||||
},
|
||||
"distribute" : {
|
||||
"android" : {
|
||||
@@ -111,6 +113,12 @@
|
||||
"appid" : "wxae7a0c156da9383b",
|
||||
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
|
||||
}
|
||||
},
|
||||
"maps" : {},
|
||||
"geolocation" : {
|
||||
"system" : {
|
||||
"__platform__" : [ "ios", "android" ]
|
||||
}
|
||||
}
|
||||
},
|
||||
"orientation" : [ "portrait-primary" ],
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
export interface AlbumData {
|
||||
resourceType: 'IMAGE' | 'VIDEO';
|
||||
address: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
</view>
|
||||
<view class="px-4">
|
||||
<wd-upload
|
||||
class=""
|
||||
v-model:file-list="imageFileList"
|
||||
image-mode="aspectFill"
|
||||
:upload-method="customUpload"
|
||||
@@ -31,7 +30,6 @@
|
||||
</view>
|
||||
<view class="px-4">
|
||||
<wd-upload
|
||||
class=""
|
||||
v-model:file-list="videoFileList"
|
||||
image-mode="aspectFill"
|
||||
:upload-method="customUpload"
|
||||
@@ -46,13 +44,6 @@
|
||||
<wd-message-box />
|
||||
<wd-toast />
|
||||
</wd-config-provider>
|
||||
|
||||
<view
|
||||
class="mt-40rpx w-1/3 mx-auto rounded-full bg-color-theme-dark text-base text-center py-2 active:bg-color-theme"
|
||||
@click="save"
|
||||
>
|
||||
保 存
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -64,12 +55,11 @@
|
||||
} from '@/uni_modules/wot-design-uni/components/wd-upload/types';
|
||||
// @ts-ignore
|
||||
import FileApi from '@/sheep/api/infra/file';
|
||||
import RecentApi from '@/sheep/api/member/recent';
|
||||
import { useMessage, useToast } from '@/uni_modules/wot-design-uni';
|
||||
|
||||
const messageBox = useMessage();
|
||||
const toast = useToast();
|
||||
const { ablumList, getUserAlbum } = useAblum();
|
||||
const { ablumList } = useAblum();
|
||||
|
||||
const imageFileList = ref<UploadFile[]>([]);
|
||||
const videoFileList = ref<UploadFile[]>([]);
|
||||
@@ -77,8 +67,12 @@
|
||||
watch(
|
||||
() => ablumList.value,
|
||||
(val) => {
|
||||
imageFileList.value = val.map((item) => ({ url: item.address }));
|
||||
// videoFileList.value = val.map((item) => ({ url: item.address }));
|
||||
imageFileList.value = val
|
||||
.filter((item) => item.resourceType === '1')
|
||||
.map((item) => ({ url: item.address, id: item.id }));
|
||||
videoFileList.value = val
|
||||
.filter((item) => item.resourceType === 'VIDEO')
|
||||
.map((item) => ({ url: item.address, id: item.id }));
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -93,6 +87,8 @@
|
||||
|
||||
// 移除确认
|
||||
const beforeRemove = ({ file, fileList, resolve }: any) => {
|
||||
console.log(file, fileList, resolve);
|
||||
|
||||
messageBox
|
||||
.confirm({
|
||||
msg: '是否移除',
|
||||
@@ -105,6 +101,7 @@
|
||||
.catch(() => {
|
||||
// toast.show('取消删除操作');
|
||||
});
|
||||
resolve(true);
|
||||
};
|
||||
|
||||
const images = computed(() => {
|
||||
@@ -113,10 +110,4 @@
|
||||
const videos = computed(() => {
|
||||
return imageFileList.value.map((item) => ({ address: item.url, resourceType: 'VIDEO' }));
|
||||
});
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
await RecentApi.saveUserAlbum([...images.value, ...videos.value]);
|
||||
getUserAlbum();
|
||||
};
|
||||
</script>
|
||||
@@ -7,7 +7,7 @@ export default function useAblum() {
|
||||
|
||||
// 获取用户相册
|
||||
const getUserAlbum = async () => {
|
||||
const { data = null } = await RecentApi.getUserAlbum({ pageNo: 1, pageSize: 10 });
|
||||
const { data = null } = await RecentApi.getUserAlbum({ pageNo: 1, pageSize: 20 });
|
||||
ablumList.value = data.list ?? [];
|
||||
};
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@
|
||||
<wd-textarea v-model="userinfo.description" :maxlength="50" clearable show-word-limit />
|
||||
</wd-cell-group>
|
||||
|
||||
<view class="mx-5 my-3 flex justify-between">
|
||||
<!-- <view class="mx-5 my-3 flex justify-between">
|
||||
<text>个人相册</text>
|
||||
<text>{{ userinfo.photo?.length || 0 }}/9</text>
|
||||
</view>
|
||||
<view class="px-4">
|
||||
<s-uploader v-model:url="userinfo.photo" fileMediatype="image" limit="9" mode="grid" />
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="h-100"></view>
|
||||
</scroll-view>
|
||||
</wd-config-provider>
|
||||
@@ -112,7 +112,7 @@
|
||||
})).reverse();
|
||||
// 体重选择器选项
|
||||
const columnsWeight = Array.from({ length: 80 }, (_, i) => ({
|
||||
text: i + 20 + 'kg',
|
||||
label: i + 20 + 'kg',
|
||||
value: i + 20,
|
||||
}));
|
||||
// 职业选择器选项
|
||||
@@ -125,6 +125,15 @@
|
||||
{ text: '投资人', value: '投资人' },
|
||||
{ text: '学生', value: '学生' },
|
||||
{ text: '其他', value: '其他' },
|
||||
{ text: '老师', value: '老师' },
|
||||
{ text: '白领', value: '白领' },
|
||||
{ text: '模特', value: '模特' },
|
||||
{ text: '主播', value: '主播' },
|
||||
{ text: '幼师', value: '幼师' },
|
||||
{ text: 'coser', value: 'coser' },
|
||||
{ text: '空乘', value: '空乘' },
|
||||
{ text: '公关', value: '公关' },
|
||||
{ text: '护士', value: '护士' },
|
||||
];
|
||||
</script>
|
||||
|
||||
@@ -133,15 +142,15 @@
|
||||
import { reactive } from 'vue';
|
||||
// @ts-ignore
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
import SUploader from '@/sheep/components/s-uploader/s-uploader.vue';
|
||||
// @ts-ignore
|
||||
import sheep from '@/sheep';
|
||||
import SUploader from '@/sheep/components/s-uploader/s-uploader.vue';
|
||||
|
||||
onLoad(async () => {
|
||||
// 获取用户信息
|
||||
const { data } = await UserApi.getUserInfo();
|
||||
Object.assign(userinfo, data, {
|
||||
photo: data.photo?.map((item: { address: string }) => item.address),
|
||||
// photo: data.photo?.map((item: { address: string }) => item.address),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -161,7 +170,7 @@
|
||||
const saveUserInfo = async () => {
|
||||
const params = {
|
||||
...userinfo,
|
||||
photo: userinfo.photo?.map((url: string) => ({ resourceType: 'IMAGE', address: url })) || [],
|
||||
// photo: userinfo.photo?.map((url: string) => ({ resourceType: 'IMAGE', address: url })) || [],
|
||||
};
|
||||
await UserApi.updateUser(params);
|
||||
sheep.$store('user').getInfo();
|
||||
|
||||
Reference in new issue
Block a user