<template>
|
<view class="issue">
|
<u-form :model="form" ref="uForm">
|
<u-form-item label="标题">
|
<u-input v-model="form.a" />
|
</u-form-item>
|
<u-form-item label="封面">
|
<u-upload ref="uUpload" :file-list="fileList" :action="action" accept="image"
|
:max-size="2 * 1024 * 1024" @oversize="oversize" :sizeType="sizeType" :show-progress="false"
|
:auto-upload="false" max-count="1" width="150" height="150" @on-choose-complete="afterRead">
|
</u-upload>
|
</u-form-item>
|
<u-form-item label="来源">
|
<u-input v-model="form.b" />
|
</u-form-item>
|
<u-form-item label="类型">
|
<u-input v-model="form.c" type="select" @click="cshow = true" />
|
<u-action-sheet :list="actionSheetList" v-model="cshow" @click="actionSheetCallback"></u-action-sheet>
|
</u-form-item>
|
<u-form-item label="时间">
|
<u-input v-model="form.d" />
|
</u-form-item>
|
<u-form-item label="状态">
|
<u-input v-model="form.e" />
|
</u-form-item>
|
<!-- <u-form-item label="评论">
|
<u-input v-model="form.f" />
|
</u-form-item> -->
|
<u-form-item label="内容" v-show="isWenzi">
|
<u-input v-model="form.g" type="textarea" />
|
</u-form-item>
|
<u-form-item label="标题" v-show="isshipin">
|
<u-input v-model="form.h" />
|
</u-form-item>
|
<u-form-item label="视频" v-show="isshipin" class="shipMp4">
|
<!-- <u-input v-model="form.i" /> -->
|
</u-form-item>
|
<img v-show="isshipin" class="shipMp4img" :src="videoSrc" mode="" @click="getVideo"></img>
|
</u-form>
|
<view class="but">
|
<u-button class="custom-style" type="primary" @click="inits"> 我发布</u-button>
|
</view>
|
<u-tabbar :list="tabs" :mid-button="true"></u-tabbar>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
tabs: [],
|
form: {
|
a: '',
|
b: '',
|
c: '',
|
d: '',
|
e: '',
|
f: '',
|
g: '',
|
h: '',
|
i: '',
|
},
|
fileList: [], // 图片文件
|
multipleImgs: [], // 多张图片
|
action: '你的地址',
|
sizeType: ['compressed'],
|
cshow: false,
|
actionSheetList: [{
|
text: '文字类'
|
},
|
{
|
text: '视频类'
|
}
|
],
|
isWenzi: false,
|
isshipin: false,
|
videoSrc: "../../static/images/lssue/selectVideo.png"
|
}
|
},
|
methods: {
|
inits() {
|
for (let k in this.form) {
|
console.log(this.form[k])
|
}
|
console.log(this.fileList)
|
},
|
// 读取文件 -- 单个
|
afterRead() {
|
this.multipleUpload(this.$refs.uUpload.lists, 0)
|
},
|
// 多张图片上传
|
multipleUpload(event, type) {
|
let that = this;
|
let num = 9;
|
event.map(item => {
|
if (num === event.length) {
|
uni.showToast({
|
title: '最多上传9张图片',
|
icon: 'none'
|
})
|
return
|
}
|
num += 1
|
if (item.file) {
|
that.uploadDo(item, type)
|
}
|
})
|
},
|
// 执行上传
|
uploadDo(event, type) {
|
let that = this;
|
uni.uploadFile({
|
url: "请求地址",
|
filePath: event.file.path,
|
name: 'uploadFile',
|
formData: {
|
user: 'test'
|
},
|
success(res) {
|
console.log(res)
|
// let resp = JSON.parse(res.data)
|
// if (resp && resp.state === 200) {
|
// let obj = {};
|
// obj.url = that.requestUrl.api.fileUrl + resp.data.path
|
// obj.name = '图' + that.avatar.length + 1
|
// that.fileList = []
|
// that.fileList.push(obj)
|
// that.$refs.uUpload.clear()
|
// }
|
}
|
});
|
},
|
actionSheetCallback(index) {
|
this.form.c = this.actionSheetList[index].text;
|
if (this.form.c == "视频类") {
|
//
|
this.isWenzi = false;
|
this.isshipin = true;
|
} else {
|
//
|
this.isWenzi = true;
|
this.isshipin = false;
|
}
|
},
|
getVideo() {
|
// console.log("get")
|
// 上传视频
|
uni.chooseVideo({
|
maxDuration: 60,
|
count: 1,
|
// camera: this.cameraList[this.cameraIndex].value,
|
sourceType: ['album'],
|
success: res => {
|
console.log(res);
|
this.videoSrc = res.tempFilePath;
|
// console.log(this.res_url2)
|
|
// var that2 = this;
|
// uni.uploadFile({
|
// // 需要上传的地址
|
// url: '需要上传的地址',
|
// // filePath 需要上传的文件
|
// filePath: that2.res_url2,
|
// name: 'file',
|
// success(res1) {
|
// console.log(res1)
|
// // 显示上传信息
|
// console.log(JSON.parse(res1.data))
|
// let a = JSON.parse(res1.data);
|
// if (res1.errMsg == 'uploadFile:ok') {
|
// uni.showToast({
|
// title: '视频上传成功'
|
// })
|
// }
|
// console.log(a.data.url);
|
// that2.url2 = a.data.url;
|
// console.log(that2.url2);
|
// },
|
// fail(res) {
|
// console.log(res)
|
// }
|
// });
|
}
|
});
|
}
|
},
|
created() {
|
this.tabs = this.$store.state.tabbar;
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
page {
|
width: 100%;
|
box-sizing: border-box;
|
}
|
|
.issue {
|
margin: 0 8px;
|
box-sizing: border-box;
|
}
|
|
.but {
|
width: 30%;
|
margin: 0 auto;
|
|
.custom-style {
|
background-image: linear-gradient(to right, #08EFF6, #0693FD);
|
border-radius: 20px;
|
}
|
}
|
|
.shipMp4img {
|
position: absolute;
|
top: 27.6rem;
|
left: 3.2rem;
|
width: 7rem;
|
height: 7rem;
|
// border: 1px solid #dcdcdc;
|
border-radius: 10px;
|
// cursor: pointer;
|
}
|
|
.shipMp4 {
|
height: 8rem;
|
}
|
</style>
|