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> </view>
<uv-radio-group v-model="form.topId"> <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="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" <view class="item"
v-for="(item, index) in upTopList" v-for="(item, index) in upTopList"
:key="index"> :key="index">
@ -147,8 +148,18 @@
代表作 代表作
</view> </view>
<view class="upload"> <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> @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> </view>
</view> </view>
@ -212,6 +223,7 @@
], ],
fileListImage: [],// fileListImage: [],//
upTopList: [], upTopList: [],
inputs : [],
}; };
}, },
computed : { computed : {
@ -240,6 +252,7 @@
// //
deleteImage(e) { deleteImage(e) {
this.fileList.splice(e.index, 1) this.fileList.splice(e.index, 1)
this.inputs.splice(e.index, 1)
}, },
// //
afterRead(e) { afterRead(e) {
@ -249,6 +262,9 @@
self.fileList.push({ self.fileList.push({
url url
}) })
self.inputs.push({
title : '',
})
}) })
}) })
}, },
@ -272,8 +288,11 @@
let data = { let data = {
...this.form, ...this.form,
isCard: 'N', 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', 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, { if (this.$utils.verificationAll(this.form, {
name: '请输入演员名称', name: '请输入演员名称',
photographerContent: '请输入演员介绍', photographerContent: '请输入演员介绍',
@ -427,6 +456,15 @@
.upload { .upload {
padding-left: 20rpx; 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 存储桶中的目标文件夹 * @param folder 存储桶中的目标文件夹
*/ */
export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) { export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
uni.showLoading({
title: '上传中...'
})
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (folder && folder?.length > 0) { if (folder && folder?.length > 0) {
if (folder[0] == "/") folder = folder.slice(1, folder.length) if (folder[0] == "/") folder = folder.slice(1, folder.length)
@ -63,6 +66,7 @@ export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
signature: OSSConfig.signature, signature: OSSConfig.signature,
}, },
success(res) { success(res) {
uni.hideLoading()
if (res.errMsg.includes("uploadFile:ok")) { if (res.errMsg.includes("uploadFile:ok")) {
resolve(ossConfig.aliOss.url + key) resolve(ossConfig.aliOss.url + key)
} else { } else {
@ -71,6 +75,7 @@ export function ossUpload(filePath, key = storeKey(), folder = storeFolder()) {
}, },
fail(err) { fail(err) {
reject(err) reject(err)
uni.hideLoading()
} }
} }
uni.uploadFile(config) uni.uploadFile(config)


+ 35
- 14
utils/utils.js View File

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


Loading…
Cancel
Save