123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- // component/fileBottomPop/fileBottomPop.ts
- import { TimeUtil } from '../../utils/TimeUtil'
- import { httpUtil } from '../../utils/restful'
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- pageHeight: 0,
- pageWidth: 0,
- windowType: -1,
- hideModal: true,
- itemData: null,
- fileName: '',
- uploadTime: '',
- expireTime: '',
- iconUrl: ''
- },
- lifetimes: {
- attached: function () {
- // 在组件实例被从页面节点树添加时执行
- this.setData({
- pageHeight: wx.getSystemInfoSync().windowHeight,
- pageWidth: wx.getSystemInfoSync().windowWidth
- })
- },
- detached: function () {
- // 在组件实例被从页面节点树移除时执行
- },
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 显示遮罩层 windowType==是文件夹 windowType==1是文件
- showModal: function (showItem: any, windowType: any) {
- var that = this;
- let icon = ''
- if (showItem.type == 0) {
- //图片
- icon = '../../image/document/document_img.png'
- } else if (showItem.type == 1) {
- //不知道是不是视频
- icon = '../../image/document/document_video.png'
- } else {
- icon = '../../image/teacher/file_icon.png'
- }
- that.setData({
- hideModal: false,
- itemData: showItem,
- fileName: showItem.title,
- uploadTime: TimeUtil.dateFormat(parseInt(showItem.uploadTime), "yyyy-MM-dd HH:mm"),
- expireTime: TimeUtil.dateFormat(parseInt(showItem.expireTime), "yyyy-MM-dd HH:mm"),
- iconUrl: icon,
- windowType: windowType
- })
- },
- // 隐藏遮罩层
- hideModal: function () {
- var that = this;
- that.setData({
- hideModal: true
- })
- },
- none: function () {
- return true;
- },
- renameFile: function () {
- let rename = '';
- let that = this;
- wx.showModal({
- title: '重命名',
- editable: true,
- success: function (res) {
- if (res.confirm) {
- rename = res.content
- console.log('点击确认回调:', res.content)
- let puturl = ''
- console.log("重命名方法")
- if (that.data.windowType == 0) {
- //文件夹重命名
- puturl = httpUtil.interfaces.createLess
- } else if (that.data.windowType == 1) {
- puturl = httpUtil.interfaces.getDocumentFile
- //文件重命名
- }
- let params = {
- id: that.data.itemData.id,
- lessId: that.data.itemData.lessId,
- title: rename
- }
- httpUtil.wxPut(puturl, params).then((res:any) => {
- that.setData({
- fileName: res.data.data.title
- })
- that.triggerEvent("fileDel")
- }).catch((res) => {
- console.log("重命名失败:", res)
- })
- } else {
- console.log('点击取消回调')
- }
- }
- })
- },
- downloadFile: function () {
- console.log("下载方法")
- if (this.data.windowType == 0) {
- //文件夹下载
- } else if (this.data.windowType == 1) {
- //文件下载
- httpUtil.wxDownLoadFile(this.data.itemData.url, function (res: any) {
- console.log("下载没??===", res.progress)
- })
- }
- },
- deleteFile: function () {
- if (this.data.windowType == 0) {
- //删除文件夹
- console.log("删除文件夹")
- let params = {
- id: this.data.itemData.id
- }
- httpUtil.wxDel(httpUtil.interfaces.createLess, params).then((res) => {
- this.delVoer()
- }).catch((res) => {
- console.log("删除失败:", res)
- })
- } else if (this.data.windowType == 1) {
- console.log("删除单独文件")
- let params = {
- id: this.data.itemData.id,
- lessonId: this.data.itemData.lessonId
- }
- httpUtil.wxDel(httpUtil.interfaces.getDocumentFile, params).then((res) => {
- this.delVoer()
- }).catch((res) => {
- console.log("删除失败:", res)
- })
- }
- },
- delVoer() {
- this.hideModal()
- this.triggerEvent("fileDel")
- }
- }
- })
|