<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>
|
<image v-show="isshipin" class="shipMp4img" :videos="videos" :src="videoSrc" mode="" @click="getVideo"></image>
|
</u-form>
|
<view class="but">
|
<u-button class="custom-style" type="primary" @click="inits"> 我发布</u-button>
|
</view>
|
<u-toast ref="uToast" />
|
<u-tabbar :list="tabs" :mid-button="false"></u-tabbar>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
tabs: [],
|
form: {
|
a: '',
|
b: '',
|
c: '',
|
d: '',
|
e: '',
|
f: '',
|
g: '',
|
h: '',
|
i: '',
|
},
|
fileList: [], // 图片文件
|
multipleImgs: [], // 多张图片
|
videos: "",
|
action: '你的地址',
|
sizeType: ['compressed'],
|
cshow: false,
|
actionSheetList: [{
|
text: '文字类'
|
},
|
{
|
text: '视频类'
|
}
|
],
|
isWenzi: false,
|
isshipin: false,
|
videoSrc: "../../static/images/lssue/selectVideo.png"
|
}
|
},
|
methods: {
|
inits() {
|
var datas = this.form;
|
var that = this;
|
|
if(this.$store.state.UserData.stype != "1"){
|
this.$refs.uToast.show({
|
title: '功能暂未开放',
|
type: 'warning',
|
});
|
return;
|
}
|
|
var content = "";
|
var videoUrl = "";
|
if(datas.c == "文字类"){
|
datas.c = "hyq004"
|
content = datas.g;
|
}else{
|
datas.c = "hyq004"
|
videoUrl = that.videos
|
}
|
|
uni.request({
|
url: this.$store.state.piAPI + '/article/article/submit',
|
method: 'POST',
|
data: {
|
title: datas.a,
|
articleType: datas.c,
|
publish: 0,
|
url:that.fileList[0].url,
|
videoUrl:videoUrl,
|
sourceName:uni.getStorageSync("name"),
|
sourceId:uni.getStorageSync("ids"),
|
content:content,
|
type:"1"
|
},
|
success: (res) => {
|
if (res.data.code == 200) {
|
uni.showToast({
|
title: '上传成功,请等待审核',
|
duration: 1000
|
});
|
}
|
}
|
});
|
},
|
// 读取文件 -- 单个
|
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: that.$store.state.piAPI + '/depl/put-depl',
|
filePath: event.file.path,
|
name: 'file',
|
formData: {
|
user: 'test'
|
},
|
success(res) {
|
let resp = JSON.parse(res.data)
|
console.log(resp + "2323232")
|
if (resp && resp.code === 200) {
|
let obj = {};
|
obj.url = resp.data
|
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() {
|
var that = this;
|
uni.chooseVideo({
|
sourceType: ['album', 'camera'],
|
maxDuration: 60,
|
camera: 'back',
|
success(res) {
|
var tempFilePath = res.tempFilePath;
|
// try {
|
uni.showLoading({
|
title: "上传中...",
|
mask: true
|
})
|
uni.uploadFile({
|
// url: 'https://web.byisf.com/api/depl/put-depl', //仅为示例,非真实的接口地址
|
url: that.$store.state.piAPI + '/depl/put-depl',
|
filePath: tempFilePath,
|
name: 'file',
|
formData: {
|
'user': 'test' // 上传附带参数
|
},
|
success: (data) => {
|
uni.showToast({
|
title: '上传视频成功!',
|
duration: 1000
|
});
|
// // 根据接口具体返回格式 赋值具体对应url
|
// that.videos.push({
|
// id: that.videos.length,
|
// src: JSON.parse(data.data).data
|
// })
|
that.videos = JSON.parse(data.data).data;
|
|
// console.log(JSON.parse(data.data).data)
|
}
|
});
|
|
// } catch (e) {
|
// console.log(e);
|
// wx.showToast({
|
// title: '上传视频失败!',
|
// duration: 2000
|
// });
|
// } finally {
|
// wx.hideLoading();
|
// }
|
}
|
})
|
}
|
},
|
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;
|
// margin-top: 2rem;
|
// }
|
// }
|
|
.custom-style{
|
margin: 30rpx 70rpx 50rpx;
|
border: none;
|
width: 572rpx;
|
height: 86rpx;
|
line-height: 86rpx;
|
box-sizing: border-box;
|
border-radius: 15rpx;
|
background-color: #103289;
|
color: #ffffff;
|
}
|
|
|
.shipMp4img {
|
position: absolute;
|
top: 17.4rem;
|
left: 3.2rem;
|
width: 7rem;
|
height: 7rem;
|
// border: 1px solid #dcdcdc;
|
border-radius: 10px;
|
// cursor: pointer;
|
}
|
|
.shipMp4 {
|
height: 8rem;
|
}
|
</style>
|