import { icommunity } from '../../../api/api.js'; const app = getApp() Page({ data: { article: { fileType: 2 }, imgUrl: app.globalData.imgUrl, }, clickUpload() { let {article} = this.data if (!article.articleTitle) { return wx.showToast({ icon: 'loading', title: '请输入标题' }) } if (!article.filePath) { return wx.showToast({ icon: 'loading', title: '请添加视频' }) } if (!article.coverImage) { return wx.showToast({ icon: 'loading', title: '请添加预览图' }) } console.log(article); icommunity.loadPubArticle({reqdata:article}, r => { wx.showToast({ mask: true, title: '提交成功', success() { setTimeout(wx.navigateBack, 1800) } }) }) }, inputTitle(e) { this.setData({ ['article.articleTitle']: e.detail.value }) }, inputContent(e) { this.setData({ ['article.articleContent']: e.detail.value }) }, clickVideo(e) { if (e.currentTarget.dataset.t == 'poster') { this.setData({ poster: false }) } else { this.setData({ ['article.video']: false }) } }, clickAddimg() { wx.chooseImage({ count: 1, success: r => { icommunity.uploadPics(r.tempFilePaths[0], r => { wx.showToast({ title: '添加成功' }) console.log(r); this.setData({ ['article.coverImage']: r.url }) }) }, }) }, clickAddvideo() { wx.chooseVideo({ compressed: false, success: v => { icommunity.uploadVideos(v.tempFilePath, r => { console.log(r); this.setData({ ['article.filePath']: r.url, // ['article.video.poster']: { // url: v.thumbTempFilePath // } },()=>{ console.log(this.data.article); }) // if (v.thumbTempFilePath) { // icommunity.uploadPics(v.thumbTempFilePath, r => { // console.log(r); // this.setData({ // ['article.video.poster']: r // }) // }) // } wx.showToast({ title: '添加成功' }) }) } }) }, onLoad(args) {}, })