123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- const _Http = getApp().globalData.http;
- const MFT = require("../../utils/FormatTheAttachment");
- let parems = {
- "classname": "saletool.salematerial.salematerial",
- method: "selectList",
- content: {
- "nocache": true,
- "parentid": '',
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- }
- }
- Page({
- data: {},
- onLoad(options) {
- if (options.item) {
- let item = JSON.parse(options.item);
- parems.content.parentid = item.attachmentid;
- wx.setNavigationBarTitle({
- title: item.document
- });
- } else {
- parems.content.parentid = wx.getStorageSync('siteP').salematerialfolderid;
- }
- this.getList(true)
- },
- /* 获得列表 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) parems.content.pageNumber = 1;
- if (parems.content.pageNumber > parems.content.pageTotal) return;
- parems.content.sort = this.data.sort || [];
- _Http.basic(parems).then(res => {
- console.log('营销物料', res)
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- parems.content.pageNumber = res.pageNumber + 1;
- parems.content.pageTotal = res.pageTotal;
- this.setData({
- list: (res.pageNumber == 1) ? MFT.fileList(res.data) : this.data.list.concat(MFT.fileList(res.data)),
- total: res.total,
- sort: res.sort
- })
- })
- },
- /* 是否收藏 */
- changeCollect() {
- const {
- isCollect,
- attachmentid,
- rowindex
- } = this.data.fileSelected;
- _Http.basic({
- "classname": "system.attachment.MediaCenter",
- "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
- "content": {
- "collecttype": "营销物料",
- "attachmentid": attachmentid
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- wx.showToast({
- title: isCollect == 0 ? '收藏成功' : "已取消收藏",
- icon: "none"
- })
- let list = this.data.list,
- index = rowindex - 1;
- parems.method == "selectList" ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1);
- this.setData({
- list
- })
- this.closeShow();
- })
- },
- /* 文件下载 */
- dowmLoad() {
- const that = this;
- wx.setClipboardData({
- data: this.data.fileSelected.url,
- success: function () {
- wx.showToast({
- title: '复制成功,将链接放置到浏览器中便可下载文件',
- icon: "none",
- duration: 3000
- });
- that.closeShow();
- }
- })
- },
- /* 搜索框输入 */
- searchInput({
- detail
- }) {
- parems.content.where.condition = detail;
- console.log(detail)
- this.getList(true)
- },
- /* 清除搜索输入 */
- searchClear() {
- parems.content.where.condition = '';
- this.getList(true)
- },
- /* tab切换 */
- tabsChange({
- detail
- }) {
- parems.method = detail.title == '列表' ? "selectList" : "selectMyList";
- this.getList(true);
- },
- /* 开关切换 */
- changeSwitch({
- detail
- }) {
- this.setData({
- sort: detail
- })
- this.getList(true);
- },
- onReady() {
- this.selectComponent("#ListBox").setHeight(".tabs", this);
- },
- /* 修改选中ID */
- changeId({
- detail
- }) {
- this.setData({
- fileSelected: detail,
- show: true
- })
- },
- /* 关闭修改 */
- closeShow() {
- this.setData({
- show: false
- })
- this.data.fileSelected = {}
- },
- })
|