wangdong 6 months ago
parent 18260c8e7b
commit 5acf36216b
  1. 6
      api/upload.js
  2. 4
      pages/squareDynamic/index.vue
  3. 4
      pages/squareDynamic/publish.vue
  4. 1
      utils/request/upload/utils.js

@ -7,11 +7,11 @@ const api = {
// 图片上传 // 图片上传
export const image = (files, checkLogin = true) => { export const image = (files, checkLogin = true) => {
// 文件上传大小, 2M // 文件上传大小, 5M
const maxSize = 1024 * 1024 * 2 const maxSize = 1024 * 1024 * 5
// 执行上传 // 执行上传
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request.urlFileUpload({ name: 'file', files, maxSize, data: { test: 123, checkLogin: Number(checkLogin) } }) request.urlFileUpload({ name: 'file', files, maxSize, data: { filename: files[0].name, test: 123, checkLogin: Number(checkLogin) } })
.then(result => resolve(result.map(item => item.data.fileInfo.file_id), result)) .then(result => resolve(result.map(item => item.data.fileInfo.file_id), result))
.catch(reject) .catch(reject)
}) })

@ -285,9 +285,9 @@
  })   })
  return Promise.all(tasks)   return Promise.all(tasks)
}, },
previewFile() { previewFile(url) {
uni.downloadFile({ uni.downloadFile({
      url: 'https://www.royaum.com.cn/static/test/test.xls',       url,
      success: (res) => {       success: (res) => {
        if (res.statusCode === 200) {         if (res.statusCode === 200) {
this.isPreview = true; this.isPreview = true;

@ -8,10 +8,10 @@
<image :src="item" mode="aspectFill" @click="previewImage(item)"></image> <image :src="item" mode="aspectFill" @click="previewImage(item)"></image>
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteImage(index)"></image> <image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteImage(index)"></image>
</view> </view>
<view class="upload-btn" v-if="imageList.length < 5" @click="addImage"> <view class="upload-btn" v-if="imageList.length < 9" @click="addImage">
<image src="/static/add.png" mode="aspectFill"></image> <image src="/static/add.png" mode="aspectFill"></image>
<text class="tip">添加照片</text> <text class="tip">添加照片</text>
<text class="tip sub-tip">最多5</text> <text class="tip sub-tip">最多9</text>
</view> </view>
</view> </view>
<textarea placeholder="请输入您想发布的内容哦~" placeholder-class="textarea-placeholer" id="" cols="30" rows="10" v-model="content" maxlength="3000"></textarea> <textarea placeholder="请输入您想发布的内容哦~" placeholder-class="textarea-placeholer" id="" cols="30" rows="10" v-model="content" maxlength="3000"></textarea>

@ -272,6 +272,7 @@ export const urlUpload = function(requestInfo, dataFactory) {
if (requestInfo.data) { if (requestInfo.data) {
config.formData = requestInfo.data; config.formData = requestInfo.data;
} }
console.log(config);
const uploadTask = uni.uploadFile(config); const uploadTask = uni.uploadFile(config);
uploadTask.onProgressUpdate(res => { uploadTask.onProgressUpdate(res => {
requestInfo.onProgressUpdate && requestInfo.onProgressUpdate(Object.assign({}, fileData, res)); requestInfo.onProgressUpdate && requestInfo.onProgressUpdate(Object.assign({}, fileData, res));

Loading…
Cancel
Save