123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // pages/document/document.ts
- import { httpUtil } from "../../utils/restful"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- lessId: '',
- itemList: null,
- showItemIndex: 0,
- downloadAll: false,
- pageTitle: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let bool = false;
- if (options.downLoadAll) {
- bool = true
- }
- this.setData({
- lessId: options.lessId,
- downloadAll: bool,
- pageTitle: options.pageTitle
- })
- wx.setNavigationBarTitle({
- title: options.pageTitle?.toString()
- })
- this.getDocumentAll();
- console.log("this.data.itemList:", this.data.itemList)
- },
- showActionWindow: function (evnet: any) {
- console.log("event:", evnet.detail.item)
- this.setData({
- showItemIndex: evnet.detail.itemIndex
- })
- this.selectComponent("#popupwindow").showModal(evnet.detail.item, 1)
- },
- fileDel: function () {
- //文件删除了就重新请求刷新一下
- this.getDocumentAll();
- },
- getDocumentAll() {
- //根据ID查询文件库下所有文件
- let params = {
- lessId: this.data.lessId,
- userId: httpUtil.httpData.userId,
- pageNo: 1,
- pageSize: 100000,
- }
- httpUtil.wxGet(httpUtil.interfaces.getDocumentFile, params).then((res: any) => {
- console.log("获取所有文件成功:", res)
- this.setData({
- itemList: res.data.data.list
- })
- if (this.data.downloadAll) {
- //下载全部
- console.log("this.data.downloadAll:", this.data.downloadAll)
- this.data.itemList.forEach((item: { type: any; }, index: string) => {
- this.selectComponent('#documentItem' + index).downLoadItem(1, item.type);
- });
- }
- }).catch((res) => {
- console.log("获取所有文件失败:", res)
- })
- },
- downLoading: function (progress: any) {
- this.selectComponent("#documentItem" + this.data.showItemIndex).setDownLoadProgress(progress)
- },
- downLoadComplete: function (data: any) {
- this.selectComponent("#documentItem" + this.data.showItemIndex).downLoadComplete(data)
- },
- downLoadError: function (data: any) {
- this.selectComponent("#documentItem" + this.data.showItemIndex).downLoadError(data)
- }
- })
|