|
@@ -84,15 +84,46 @@ const rules = {
|
|
|
spaceExtent: [{ required: true, message: '请填写空间面积' }],
|
|
|
circleDesc: [{ required: true, message: '请填写案例描述' }],
|
|
|
}
|
|
|
+const useImg = ref(true)
|
|
|
+const useVideo = ref(true)
|
|
|
const formData = ref({})
|
|
|
const formInited = ref(false)
|
|
|
const tagName = ref('')
|
|
|
const tagIds = ref([])
|
|
|
const imgList = ref([])
|
|
|
const publishing = ref(false)
|
|
|
+const handleImgFail = ({error, file}) =>{
|
|
|
+ // imgList.value = fileList
|
|
|
+ fileList.value.splice(0,1)
|
|
|
+}
|
|
|
+const delImg = () =>{
|
|
|
+ console.log('del')
|
|
|
+ fileList.value.splice(0,1)
|
|
|
+}
|
|
|
const handleChange = ({ fileList: files }) => {
|
|
|
+ // fileList.value = files
|
|
|
+ console.log(files)
|
|
|
+ let arr = [];
|
|
|
+ for(let i in files){
|
|
|
+ if(files[i].status==="success"){
|
|
|
+ arr.push(JSON.parse(files[i].response).data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ imgList.value = arr
|
|
|
+ if(files.length > 0){
|
|
|
+ useVideo.value = false
|
|
|
+ }else{
|
|
|
+ useVideo.value = true
|
|
|
+ }
|
|
|
+}
|
|
|
+const handleVideoChange = ({ fileList: files }) => {
|
|
|
fileList.value = files
|
|
|
- console.log(fileList.value)
|
|
|
+ if(files.length > 0){
|
|
|
+ useImg.value = false
|
|
|
+ }else{
|
|
|
+ useImg.value = true
|
|
|
+ }
|
|
|
+ // console.log(imgList.value)
|
|
|
}
|
|
|
const uploadImg = async (img) =>{
|
|
|
return new Promise((resolve)=>{
|
|
@@ -101,7 +132,7 @@ const uploadImg = async (img) =>{
|
|
|
filePath: img,
|
|
|
name:img,
|
|
|
success: (res) => {
|
|
|
- console.log(res)
|
|
|
+ // console.log(res)
|
|
|
resolve(res)
|
|
|
}
|
|
|
})
|
|
@@ -128,17 +159,25 @@ const handleSubmit = async () => {
|
|
|
// }
|
|
|
// console.log(imgUrl)
|
|
|
// return false
|
|
|
- if (!fileList.value.length) {
|
|
|
- toast(messages.moment.imageNotExist)
|
|
|
- return false
|
|
|
+ if(useImg.value){
|
|
|
+ if (!imgList.value.length) {
|
|
|
+ toast(messages.moment.imageNotExist)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (!fileList.value.length) {
|
|
|
+ toast(messages.moment.imageNotExist)
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
publishing.value = true
|
|
|
const { code, msg, duration } = await requestToast(
|
|
|
() =>
|
|
|
createCircle({
|
|
|
stylistId: userInfo.value.userId,
|
|
|
stylistName: userInfo.value.nickname,
|
|
|
- bannerUrls: fileList.value.map(({ response }) => JSON.parse(response).data),
|
|
|
+ bannerUrls: useImg.value?imgList.value:fileList.value.map(({ response }) => JSON.parse(response).data),
|
|
|
tagName: tagName.value,
|
|
|
headUrl: userInfo.value.avatar,
|
|
|
circleDesc: content.value,
|
|
@@ -224,16 +263,34 @@ onLoad(async (query: { circleType: '1' | '2' }) => {
|
|
|
custom-class="my-5"
|
|
|
></SectionHeading>
|
|
|
</div>
|
|
|
- <!-- <dragImg v-model="imgList" :number="String(circleType) === '2' ? 30 : 9"></dragImg> -->
|
|
|
- <wd-upload
|
|
|
- :file-list="fileList"
|
|
|
- image-mode="aspectFill"
|
|
|
- accept="media"
|
|
|
- :action="action"
|
|
|
- :multiple="true"
|
|
|
- :limit="String(circleType) === '2' ? 30 : 9"
|
|
|
- @change="handleChange"
|
|
|
- ></wd-upload>
|
|
|
+ <div class="flex">
|
|
|
+ <div class="mr-[20rpx]" v-if="useImg">
|
|
|
+ <wd-upload
|
|
|
+ :file-list="fileList"
|
|
|
+ customPreviewClass="display"
|
|
|
+ image-mode="aspectFill"
|
|
|
+ accept="image"
|
|
|
+ :action="action"
|
|
|
+ :multiple="true"
|
|
|
+ :limit="String(circleType) === '2' ? 30 : 9"
|
|
|
+ @change="handleChange"
|
|
|
+ @fail="handleImgFail"
|
|
|
+ ></wd-upload>
|
|
|
+ <div class="text-[24rpx] text-black/60 text-center">上传图片</div>
|
|
|
+ </div>
|
|
|
+ <div v-if="useVideo && String(circleType) === '1'">
|
|
|
+ <wd-upload
|
|
|
+ :file-list="fileList"
|
|
|
+ image-mode="aspectFill"
|
|
|
+ accept="video"
|
|
|
+ :action="action"
|
|
|
+ :limit="1"
|
|
|
+ @change="handleVideoChange"
|
|
|
+ ></wd-upload>
|
|
|
+ <div class="text-[24rpx] text-black/60 text-center">上传视频</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <dragImg v-if="imgList.length > 0" v-model="imgList" @del="delImg" :number="String(circleType) === '2' ? 30 : 9"></dragImg>
|
|
|
<SectionHeading
|
|
|
title="标签"
|
|
|
custom-class="my-6"
|
|
@@ -260,7 +317,7 @@ onLoad(async (query: { circleType: '1' | '2' }) => {
|
|
|
</SectionHeading>
|
|
|
<div class="flex-1"></div>
|
|
|
<BottomAppBar fixed safe-area-inset-bottom placeholder>
|
|
|
- <div class="w-full">
|
|
|
+ <div class="w-full relative z-9">
|
|
|
<wd-button type="primary" :round="false" block :loading="publishing" @click="handleSubmit">
|
|
|
发布
|
|
|
</wd-button>
|
|
@@ -268,3 +325,8 @@ onLoad(async (query: { circleType: '1' | '2' }) => {
|
|
|
</BottomAppBar>
|
|
|
</div>
|
|
|
</template>
|
|
|
+<style>
|
|
|
+ .display{
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+</style>
|