sadjv3_jishi/pages/video/setVideo.vue

299 lines
7.0 KiB
Vue

<template>
<view style="padding-bottom: 100upx; margin-top: 20rpx;">
<view class=" padding bg radius margin">
<view class="padding-top">发布内容</view>
<view class="margin-tb-sm">
<u-input v-model="form.describes" style="border-radius: 20rpx;"
type="textarea" height="200" placeholde="请填写发布内容" maxlengt="200" :clearable="false" />
</view>
<view style="height: 15rpx;"></view>
</view>
<view class=" padding bg radius margin">
<view class="margin-top-sm">上传视频</view>
<view class="flex" style="overflow: hidden;flex-wrap: wrap;">
<view class="margin-top flex margin-right-sm flex-wrap" v-if="videosList">
<view class="flex" style="width: 200rpx;height: 200rpx;margin-right: 5rpx;position: relative;">
<video style="width: 100%;height: 100%;" :src="videosList"></video>
<view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;" @click="headVideoremove">
<u-icon name="close-circle-fill" color="#d81e06" size="50rpx"></u-icon>
</view>
</view>
</view>
</view>
<view class="margin-top" @click="addvideo" v-if="videosList.length<=0">
<view style="width: 200rpx;height: 200rpx;background: #f7f8fa;"
class="flex justify-center align-center">
<view>
<view class="text-center">
<image src="../../static/images/my/avatar.png" style="width: 80rpx;height: 80rpx;">
</image>
</view>
<view class="text-center add-word">添加视频</view>
</view>
</view>
</view>
</view>
<view class=" padding bg radius margin">
<view class="margin-top-sm">视频封面</view>
<view class="flex" style="overflow: hidden;flex-wrap: wrap;">
<view class="margin-top flex margin-right-sm flex-wrap" v-if="form.headImg && form.headImg.length">
<view class="flex" style="width: 200rpx;height: 200rpx;margin-right: 5rpx;position: relative;">
<image :src="form.headImg" style="width: 100%;height: 100%;"></image>
<view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;" @click="headImgremove(index)">
<u-icon name="close-circle-fill" color="#d81e06" size="50rpx"></u-icon>
</view>
</view>
</view>
</view>
<view class="margin-top" @click="addImage(4)" v-if="form.headImg.length<=0">
<view style="width: 200rpx;height: 200rpx;background: #f7f8fa;"
class="flex justify-center align-center">
<view>
<view class="text-center">
<image src="../../static/images/my/avatar.png" style="width: 80rpx;height: 80rpx;">
</image>
</view>
<view class="text-center add-word">添加头像</view>
</view>
</view>
</view>
</view>
<view class="tabbar" style="background: linear-gradient(to right, #019c88, #2dbe93); border-radius: 50rpx;"
@click="submit()">提交发布
</view>
</view>
</template>
<script>
import * as websocketUtils from 'utils/websocketUtils.js';
export default {
data() {
return {
form: {
//头像上传
headImg: '',
},
//头像上传
headImg: [],
videos: [],
videosList:''
}
},
onLoad(e) {
},
methods: {
headImgremove(index) {
this.form.headImg = ''
},
headVideoremove() {
this.videosList = ''
},
submit() {
if (!this.videosList) {
uni.showToast({
title: '请上视频',
icon: 'none',
duration: 1000
})
return;
}
if (!this.form.describes) {
uni.showToast({
title: '请填发布内容',
icon: 'none',
duration: 1000
})
return
}
if (!this.form.headImg) {
uni.showToast({
title: '请上视频封面',
icon: 'none',
duration: 1000
})
return;
}
let data = {
createBy: uni.getStorageSync("userId"),
filePath: this.videosList,
picPath: this.form.headImg,
content: this.form.describes,
}
this.$Request.postJson("/app/shipinquan/add", data).then(res => {
if (res.code == 0) {
uni.showToast({
title: '操作成功!',
icon: 'none'
})
setTimeout(function() {
uni.navigateTo({
url: '/pages/video/index'
})
}, 1000)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
});
},
addvideo(e){
let that = this
uni.chooseVideo({
count: 1,
sourceType: ['album', 'camera'],
success: res => {
that.videos.push(res.tempFilePath);
for (let i = 0; i < that.videos.length; i++) {
that.$queue.showLoading("上传中...");
uni.uploadFile({ // 上传接口
url: websocketUtils.uploadFileUrl(), //真实的接口地址
filePath: that.videos[i],
name: 'file',
success: (uploadFileRes) => {
that.videosList = JSON.parse(uploadFileRes.data).data
console.log("that.videosList",that.videosList)
uni.hideLoading();
}
});
}
}
})
},
addImage(e) {
let that = this
uni.chooseImage({
count: 1,
sourceType: ['album', 'camera'],
success: res => {
for (let i = 0; i < res.tempFilePaths.length; i++) {
that.$queue.showLoading("上传中...");
uni.uploadFile({ // 上传接口
url: websocketUtils.uploadFileUrl(), //真实的接口地址
filePath: res.tempFilePaths[i],
name: 'file',
success: (uploadFileRes) => {
if (e == 1) {
that.form.front = JSON.parse(uploadFileRes.data).data
} else if (e == 2) {
that.form.back = JSON.parse(uploadFileRes.data).data
} else if (e == 4) {
that.form.headImg = JSON.parse(uploadFileRes.data).data
console.log(that.form.headImg)
}
uni.hideLoading();
}
});
}
}
})
},
}
}
</script>
<style>
page {
background-color: #F7F7F7;
}
.bg {
width: 94%;
margin:30rpx auto;
background-color: #FFFFFF;
padding: 20rpx 36rpx;
border-radius: 26rpx;
}
.add-word{
font-size: 26rpx;
color: #afb5c1;
}
.skbox {}
.skleft {
width: 160rpx;
font-size: 28rpx;
}
.u-form-item {
padding: 10rpx !important;
}
.u-form-item--right__content__slot {
flex: 200rpx 1 !important;
}
.footer {
padding-left: 30upx;
font-size: 24upx;
color: #666666;
text-align: center;
display: flex;
margin-bottom: 20rpx;
}
.u-input__input {
color: balck !important;
}
.title_btn {
height: 78upx;
line-height: 78upx;
/* background: #f7f7f7; */
}
.tabbar {
width: 690upx;
height: 86upx;
background: #019c88;
border-radius: 8upx;
margin: 0 auto;
text-align: center;
line-height: 86upx;
color: #FFFFFF;
margin-top: 20rpx;
}
.popup_pay {
width: 100%;
position: relative;
padding-bottom: 45rpx;
/* height: 160px; */
/* #ifndef MP-WEIXIN */
/* height: 130px; */
/* #endif */
}
.pay_btn {
width: 90%;
margin: 0 auto;
text-align: center;
background: #1777FF;
height: 80rpx;
border-radius: 16rpx;
color: #ffffff;
line-height: 80rpx;
}
.hb {
/* #ifdef H5 */
padding-bottom: 180rpx;
/* #endif */
}
.bgCol2 {
color: #557EFD;
}
</style>