Browse Source

上传代码

master
前端-胡立永 10 months ago
parent
commit
04edf736d2
3 changed files with 94 additions and 30 deletions
  1. +54
    -16
      pages/publish/actorRelease.vue
  2. +5
    -0
      utils/oss-upload/oss/index.js
  3. +35
    -14
      utils/utils.js

+ 54
- 16
pages/publish/actorRelease.vue View File

@ -110,20 +110,21 @@
</view>
<uv-radio-group v-model="form.topId">
<view class="item">
<view class="left">
不需要置顶
</view>
<view class="right">
<uv-radio
size="35rpx"
icon-size="35rpx"
:name="0">
</uv-radio>
</view>
</view>
<view class="list">
<view class="item">
<view class="left">
不需要置顶
</view>
<view class="right">
<uv-radio
size="35rpx"
icon-size="35rpx"
:name="0">
</uv-radio>
</view>
</view>
<view class="item"
v-for="(item, index) in upTopList"
:key="index">
@ -147,8 +148,18 @@
代表作
</view>
<view class="upload">
<uv-upload :fileList="fileList" :maxCount="5" multiple accept="video" width="150rpx" height="150rpx"
<view class="">
</view>
<uv-upload :fileList="fileList" :maxCount="1" multiple accept="video" width="150rpx" height="150rpx"
@delete="deleteImage" @afterRead="afterRead" :previewFullImage="true"></uv-upload>
<view class="input"
v-for="(item, index) in inputs">
<input type="text" v-model="item.title"
:placeholder="`请输入第${index + 1}个代表作的名称`"/>
</view>
</view>
</view>
</view>
@ -212,6 +223,7 @@
],
fileListImage: [],//
upTopList: [],
inputs : [],
};
},
computed : {
@ -240,6 +252,7 @@
//
deleteImage(e) {
this.fileList.splice(e.index, 1)
this.inputs.splice(e.index, 1)
},
//
afterRead(e) {
@ -249,6 +262,9 @@
self.fileList.push({
url
})
self.inputs.push({
title : '',
})
})
})
},
@ -272,8 +288,11 @@
let data = {
...this.form,
isCard: 'N',
isImage : this.fileList.map((item) => item.url).join(","),
image : this.fileListImage.map((item) => item.url).join(","),
isImage : this.fileList.map((item) => item.url).join(","),//
image : this.fileListImage.map((item) => item.url).join(","),//
//
titles : this.inputs.map((item) => item.title).join(","),//
isTop : this.form.topId ? 'Y' : 'N',
}
@ -325,6 +344,16 @@
})
}
for(let i = 0; i < this.inputs.length; i++){
if(!this.inputs[i].title){
return uni.showToast({
title: `请输入第${i + 1}个代表作的名称`,
icon : 'none'
})
}
}
if (this.$utils.verificationAll(this.form, {
name: '请输入演员名称',
photographerContent: '请输入演员介绍',
@ -427,6 +456,15 @@
.upload {
padding-left: 20rpx;
.input{
margin: 20rpx auto;
border: 1px solid #00000022;
padding: 20rpx;
border-radius: 15rpx;
input{
}
}
}
}
}


+ 5
- 0
utils/oss-upload/oss/index.js View File

@ -43,6 +43,9 @@ function storeFolder() {
* @param folder 存储桶中的目标文件夹
*/
export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
uni.showLoading({
title: '上传中...'
})
return new Promise((resolve, reject) => {
if (folder && folder?.length > 0) {
if (folder[0] == "/") folder = folder.slice(1, folder.length)
@ -63,6 +66,7 @@ export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
signature: OSSConfig.signature,
},
success(res) {
uni.hideLoading()
if (res.errMsg.includes("uploadFile:ok")) {
resolve(ossConfig.aliOss.url + key)
} else {
@ -71,6 +75,7 @@ export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
},
fail(err) {
reject(err)
uni.hideLoading()
}
}
uni.uploadFile(config)


+ 35
- 14
utils/utils.js View File

@ -36,33 +36,54 @@ function generateLightRandomColor() {
function verificationAll(data, msg){
let Msgs = {
default : msg || '表单数据未填写'
}
if(typeof msg == 'object'){
Msgs = {
default : '表单数据未填写',
...msg,
}
if (!msg){
return false
}
if (!data){
uni.showToast({
title: Msgs.default,
title: '表单数据未填写',
icon: "none"
})
return true
}
for (let key in data) {
if (!data[key] && Msgs[key]) {
for (let key in msg) {
if (!data[key]) {
uni.showToast({
title: Msgs[key],
title: msg[key],
icon: "none"
})
return true
}
}
// let Msgs = {
// default : msg || '表单数据未填写'
// }
// if(typeof msg == 'object'){
// Msgs = {
// default : '表单数据未填写',
// ...msg,
// }
// }
// if (!data){
// uni.showToast({
// title: Msgs.default,
// icon: "none"
// })
// return true
// }
// for (let key in data) {
// if (!data[key] && Msgs[key]) {
// uni.showToast({
// title: Msgs[key],
// icon: "none"
// })
// return true
// }
// }
return false
}


Loading…
Cancel
Save