Commit ffdf5c8e authored by liwei's avatar liwei

对接了oss上传的接口

parent e85e4f41
import {request} from '../../util/api' import {request} from '../../util/api'
// banner列表 // 动态列表
export function articleList(query) { export function articleList(query) {
return request({ return request({
url: '/app/open/opmArticle/queryArticleByPagination', url: '/app/open/opmArticle/queryArticleByPagination',
...@@ -9,3 +9,13 @@ export function articleList(query) { ...@@ -9,3 +9,13 @@ export function articleList(query) {
method: 'GET', method: 'GET',
}) })
} }
// 动态列表
export function getOssUrl(id) {
return request({
url: '/common/getOssUrl?businessId=' + id,
method: 'GET',
})
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<textarea style="width: 100%;height: 260rpx;" v-model="form.content" :maxlength="-1" :auto-height="false" <textarea style="width: 100%;height: 260rpx;" v-model="form.content" :maxlength="-1" :auto-height="false"
:showConfirmBar="false" :adjust-position="false" @focus="focusFn" :focus="focus" @blur="blurFn" :showConfirmBar="false" :adjust-position="false" @focus="focusFn" :focus="focus" @blur="blurFn"
border="none" placeholder="分享生活、表达思考、提出困惑..."></textarea> border="none" placeholder="分享生活、表达思考、提出困惑..."></textarea>
<image :src="img"></image>
<view class="upload"> <view class="upload">
<u-upload :fileList="fileList" accept="image" uploadIcon="plus" :capture="['album', 'camera']" <u-upload :fileList="fileList" accept="image" uploadIcon="plus" :capture="['album', 'camera']"
@afterRead="afterRead" @delete="deletePic" width="200rpx" height="200rpx" multiple :maxCount="9" @afterRead="afterRead" @delete="deletePic" width="200rpx" height="200rpx" multiple :maxCount="9"
...@@ -26,13 +27,14 @@ ...@@ -26,13 +27,14 @@
<script> <script>
import ELM from '@/components/elm-toast/index.vue'; import ELM from '@/components/elm-toast/index.vue';
import {uploadPublic} from '../api/article/index' import {getOssUrl, uploadPublic} from '../api/article/index'
export default { export default {
components: { components: {
ELM ELM
}, },
data() { data() {
return { return {
img:'',
form: { form: {
content: '', content: '',
img: [] img: []
...@@ -53,12 +55,16 @@ ...@@ -53,12 +55,16 @@
methods: { methods: {
//发布 //发布
submit() { submit() {
this.form.img = this.fileList.map(item => item.url ) getOssUrl(109).then(res=>{
if (!this.form.content && !this.fileList.length) { this.img = res.data.data.replace(/\\/g, '/')
this.tipMsg = '请输入内容或上传图片后再点击发布' console.log(this.img)
this.$refs.elm.showDialog(); })
return; // this.form.img = this.fileList.map(item => item.url )
} // if (!this.form.content && !this.fileList.length) {
// this.tipMsg = '请输入内容或上传图片后再点击发布'
// this.$refs.elm.showDialog();
// return;
// }
}, },
// 删除图片 // 删除图片
deletePic(event) { deletePic(event) {
...@@ -95,7 +101,8 @@ ...@@ -95,7 +101,8 @@
filePath: file.url, filePath: file.url,
formData: { formData: {
file: file,//你要传的临时文件 file: file,//你要传的临时文件
temp: 'opmArticle' temp: 'opmArticle',
bucket:'cust-91isoft'
}, },
header: { header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"), Authorization: 'Bearer ' + uni.getStorageSync("token"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment