Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
wz_shi 3 years ago
parent
commit
5448a41f5c
  1. 22
      src/views/components/upload_img3.vue
  2. 231
      src/views/components/upload_img4.vue
  3. 97
      src/views/materialContent/materialList/index.vue

22
src/views/components/upload_img3.vue

@ -1,7 +1,8 @@
<template>
<div class="upload">
<div id="video_container">
<div id="pickfiles">上传视频</div>
<!-- <div id="pickfiles">上传视频</div> -->
<div id="pickfiles"><el-button style="margin-top: 5px" type="primary" @click="initUploader">上传视频</el-button></div>
<div>
<div class="upload_info">
<b>{{ fileSize }}MB | 已上传{{ fileLoaded }} | 上传速度{{ fileSpeed }}/s</b>
@ -21,8 +22,13 @@
<script>
// import { apis, chttp } from '@/libs/interfaces'
import * as qiniu from 'qiniu-js'
// import * as qiniu from 'qiniu-js'
import axios from 'axios'
require('../../../static/dist/qiniu.min')
// import { Uploader } from 'qiniup'
// import { getQiniuToken } from '@/api/material/material'
export default {
name: 'Qiniu',
data() {
return {
fileSize: 0,
@ -71,7 +77,7 @@ export default {
},
initUploader() {
const plupload = window.plupload
const Qiniu = global.Qiniu
const Qiniu = global.qiniu
const _this = this
// domain ->->
const isIphone5 = this.phoneType === '5'
@ -142,9 +148,15 @@ export default {
const params = {
filename: this.filename
}
chttp.get(apis.qiniuToken, { params: params })
// chttp.get(apis.qiniuToken, { params: params })
// .then(res => {
// this.token = res.token
// callback()
// })
//
axios.get('http://192.168.99.84:7000/api/qiniu/uploadTokenCover', { params: params })
.then(res => {
this.token = res.token
this.token = res.data
callback()
})
},

231
src/views/components/upload_img4.vue

@ -0,0 +1,231 @@
<template>
<div class="components_upload">
<!-- <input id="upFile" type="file" name="upFile" @change="changeFile($event)" /> -->
<el-button class="cont_upload_btn" round type="primary">上传</el-button>
<input id="upFile" type="file" name="upFile" @change="changeFile($event)" />
<!-- <img v-if="coverUrl" :src="coverUrl" alt="封面" /> -->
<!-- <el-progress :percentage="filePercent" />
{{ filePercent }} -->
<!-- 上传列表layer -->
<div class="upload_layer">
<!-- width="736px" -->
<el-dialog
title="上传列表"
:close-on-click-modal="false"
:show-close="false"
:visible.sync="uploadListVisible"
height="384px"
>
<!-- :status="percentage === 100 ? undefined : 'success'" -->
<el-table :data="fileData" :header-cell-style="{ color: '#333' }">
<el-table-column align="center" prop="fileNames" label="文件名" />
<el-table-column align="center" prop="formatType" label="类型" />
<el-table-column align="center" prop="fileSize" label="大小" />
<el-table-column align="center" prop="filePercentTxt" label="状态">
<template>
<div class="loadingModal" :style="{ 'height': '100%' }">
<!-- :format="format" -->
<!-- <el-progress
:stroke-width="6"
:percentage="filePercent"
:color="colors"
/> -->
{{ filePercentTxt }}
</div>
</template>
</el-table-column>
<el-table-column align="center" prop="handle" label="操作">
<template slot-scope="scope">
<el-button
type="primary"
round
class="on_off_btn"
@click="end(scope.$index, scope.row)"
>{{ loading_txt }}</el-button>
<el-button
type="info"
round
class="upload_delt"
@click="handleRecord(scope.$index, scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="upload_list_right">
<!-- <el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
multiple
:limit="3"
>
<div class="right_upload">点击上传</div>
</el-upload> -->
<input type="button" name="开始上传" value="开始上传" @click="uploadFile()" />
<div class="upload_return" @click="uploadListVisible=false">返回</div>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import * as qiniu from 'qiniu-js'
import { getQiniuToken } from '@/api/material/material'
export default {
name: 'Qiniu',
data() {
return {
file: null,
token: '',
baseurl: 'qiniu.aiyxlib.com',
fileData: [],
uploadFileUrl: null,
filePercent: 0,
fileNames: '',
formatType: '',
postfix: '',
fileSize: '',
uploadListVisible: false,
loading_txt: '暂停',
colors: '#1e9f4c',
uploadListData: [],
filePercentTxt: '上传中'
}
},
mounted() {
this.getQiniuToken()
},
methods: {
changeFile(e) {
//
this.file = e.target.files[0]
this.formatType = this.file.type.substring(0, this.file.type.indexOf('/'))
console.log('formatType', this.formatType)
this.fileNames = this.file.name
console.log('fileNames', this.fileNames)
this.postfix = this.fileNames.substring(
this.fileNames.lastIndexOf('.') + 1,
this.fileNames.length
)
console.log(this.postfix)
this.fileSize = this.file.size
console.log('fileSize', this.fileSize)
if (this.formatType === 'image') {
const isJPG = this.file.type === 'image/jpeg' || this.file.type === 'image/png' || this.file.type === 'image/bmp' || this.file.type === 'image/gif'
const isLt2M = this.file.size / 1024 / 1024 < 4
if (!isJPG) {
this.$message.error('图片只支持bmp、jpg、png、gif格式的文件')
}
if (!isLt2M) {
this.$message.error('图片大小不能超过 4MB !')
}
}
this.uploadListVisible = true
this.fileData.push({
fileNames: this.fileNames,
formatType: this.formatType,
fileSize: this.fileSize,
filePercentTxt: this.filePercentTxt
})
console.log(this.fileData[0].filePercent)
},
getQiniuToken() {
getQiniuToken().then(res => {
this.token = res.data
})
},
// format(percentage) {
// return percentage === 100 ? '100%' : `${percentage}%`
// },
uploadFile() {
// VUEthis _this this
const _this = this
// token
const token = _this.token
console.log(token)
//
var config = {
useCdnDomain: true
}
//
var putExtra = {
fname: '',
params: {},
mimeType: null
}
//
var observable = qiniu.upload(_this.file, _this.file.name, token, putExtra, { resumingByFileSize: 4 * 1024 * 1024 }, config)
//
var observer = {
//
next(res) {
//
console.log(res)
console.log(res.total.size)
_this.filePercent = parseInt(res.total.percent)
console.log(_this.filePercent)
this.filePercentTxt = '上传中'
if (_this.filePercent == 100) {
// _this.fileData.push(_this.filePercent)
// _this.fileData.forEach((value, index) => {
// value['filePercent'] = parseInt(res.total.percent)
// })
this.filePercentTxt = '上传成功'
console.log('success')
}
console.log(_this.fileData)
// _this.fileData[0].filePercent = parseInt(res.total.percent)
// console.log(_this.fileData[0].filePercent)
// _this.fileData.forEach((value, index) => {
// value['filePercent'] = parseInt(res.total.percent)
// })
},
//
error(err) {
console.log(err)
},
//
complete(res) {
this.filePercentTxt = '上传成功'
console.log(res)
console.log(res.key)
_this.uploadFileUrl = 'http://' + _this.baseurl + '/' + res.key
console.log(_this.uploadFileUrl)
// console.log(_this.fileUrl.push({ name: _this.file.name, url: _this.fileUrl }))
// console.log(_this.fileUrl)
}
}
//
var subscription = observable.subscribe(observer)
// subscription.unsubscribe()
}
}
}
</script>
<style lang="scss" scoped>
.components_upload{
position: relative;
// width: 100%;
}
#upFile{
display: block;
width: 114px;
height: 34px;
padding: 0;
font-size: 14px;
border: none;
opacity: 0;
}
.cont_upload_btn{
position: absolute;
left: 0;
top: 0;
}
</style>

97
src/views/materialContent/materialList/index.vue

@ -2,15 +2,9 @@
<div>
<div class="material_content">
<div class="material_item cont_upload">
<el-button class="cont_upload_btn" round type="primary">上传</el-button>
<!-- <el-upload action="#" list-type="picture-card" :auto-upload="false">
<i slot="default" class="el-icon-plus"></i>
<img src="@/assets/images/t-sc.png" alt />
<div slot="file" slot-scope="{file}">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt />
</div>
</el-upload> -->
<Upload />
<div>
<Upload rel="upload" />
</div>
<el-button class="mkdir_btn" round type="primary" @click="handleMkdir">创建文件夹</el-button>
</div>
<div v-for="item in materialFolders" :key="item.id" class="material_item folder">
@ -74,64 +68,6 @@
</el-dialog>
</div>
<!-- 上传列表layer -->
<div class="upload_layer">
<!-- width="736px" -->
<el-dialog
title="上传列表"
:close-on-click-modal="false"
:show-close="false"
:visible.sync="uploadListVisible"
height="384px"
>
<!-- :status="percentage === 100 ? undefined : 'success'" -->
<el-table :data="materialFolders" :header-cell-style="{ color: '#333' }">
<el-table-column align="center" prop="updateTime" label="文件名" />
<!-- <el-table-column align="center" prop="type" label="类型" />
<el-table-column align="center" prop="size" label="大小" />
<el-table-column align="center" prop="status" label="状态">
<template>
<div v-if="progressLoading" class="loadingModal" :style="{ 'height': '100%' }">
<el-progress
:stroke-width="6"
:percentage="percentage"
:color="colors"
:format="format"
/>
</div>
</template>
</el-table-column>
<el-table-column align="center" prop="handle" label="操作">
<template slot-scope="scope">
<el-button
type="primary"
round
class="on_off_btn"
@click="end(scope.$index, scope.row)"
>{{ loading_txt }}</el-button>
<el-button
type="info"
round
class="upload_delt"
@click="handleRecord(scope.$index, scope.row)"
>删除</el-button>
</template>
</el-table-column> -->
</el-table>
<div class="upload_list_right">
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
multiple
:limit="3"
>
<div class="right_upload">点击上传</div>
</el-upload>
<div class="upload_return" @click="uploadListVisible=false">返回</div>
</div>
</el-dialog>
</div>
<!-- 多选操作 -->
<div v-if="contentIds.length !== 0" class="multi_handle">
<el-button type="button" class="mulit_btn" @click="publishHandle(0)">即时发布</el-button>
@ -182,7 +118,7 @@
<script>
import { getMaterialList } from '@/api/material/material'
import Upload from '../../components/upload_img'
import Upload from '../../components/upload_img4'
export default {
name: 'MaterialList',
components: { Upload },
@ -200,10 +136,10 @@ export default {
return {
materialFolders: [], // list
materialList: [], // list
uploadListVisible: false,
loading_txt: '暂停',
progressLoading: true,
percentage: 0,
// uploadListVisible: false,
// progressLoading: true,
// percentage: 0,
colors: '#1e9f4c',
layerTitle: '创建文件夹',
labelTxt: '文件夹名称',
@ -216,14 +152,7 @@ export default {
name: '',
file: null
},
uploadData: [
{
id: '1',
name: '文件夹1',
type: 'vedio',
size: '3MB'
}
uploadListData: [
],
listData: [
{
@ -431,4 +360,12 @@ export default {
width: 128px;
height: 120px;
}
.components_upload{
position: relative;
}
.cont_upload_btn{
position: absolute;
left: 0;
top: 0;
}
</style>
Loading…
Cancel
Save