index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. const _Http = getApp().globalData.http;
  2. const MFT = require("../../utils/matchingFeilType");
  3. let parems = {
  4. "classname": "saletool.salematerial.salematerial",
  5. method: "selectList",
  6. content: {
  7. "nocache": true,
  8. "parentid": '',
  9. "pageNumber": 1,
  10. "pageSize": 20,
  11. "where": {
  12. "condition": ""
  13. }
  14. }
  15. }
  16. Page({
  17. data: {},
  18. onLoad(options) {
  19. getApp().globalData.Language.getLanguagePackage(this, '营销物料')
  20. if (options.item) {
  21. let item = JSON.parse(options.item);
  22. parems.content.parentid = item.attachmentid;
  23. wx.setNavigationBarTitle({
  24. title: item.document
  25. });
  26. } else {
  27. parems.content.parentid = wx.getStorageSync('siteP').salematerialfolderid;
  28. }
  29. this.getList(true)
  30. },
  31. /* 获得列表 */
  32. getList(init = false) {
  33. if (init.detail != undefined) init = init.detail;
  34. if (init) parems.content.pageNumber = 1;
  35. if (parems.content.pageNumber > parems.content.pageTotal) return;
  36. parems.content.sort = this.data.sort || [];
  37. _Http.basic(parems).then(res => {
  38. console.log('营销物料', res)
  39. this.selectComponent('#ListBox').RefreshToComplete();
  40. if (res.code != '1') return wx.showToast({
  41. title: res.msg,
  42. icon: "none"
  43. })
  44. parems.content.pageNumber = res.pageNumber + 1;
  45. parems.content.pageTotal = res.pageTotal;
  46. this.setData({
  47. list: (res.pageNumber == 1) ? MFT.fileList(res.data) : this.data.list.concat(MFT.fileList(res.data)),
  48. total: res.total,
  49. sort: res.sort
  50. })
  51. })
  52. },
  53. /* 是否收藏 */
  54. changeCollect() {
  55. const {
  56. isCollect,
  57. attachmentid,
  58. rowindex
  59. } = this.data.fileSelected;
  60. _Http.basic({
  61. "classname": "system.attachment.MediaCenter",
  62. "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
  63. "content": {
  64. "collecttype": "营销物料",
  65. "attachmentid": attachmentid
  66. }
  67. }).then(res => {
  68. if (res.code != '1') return wx.showToast({
  69. title: res.msg,
  70. icon: "none"
  71. })
  72. wx.showToast({
  73. title: isCollect == 0 ? getApp().globalData.Language.getMapText('收藏成功') : getApp().globalData.Language.getMapText('已取消收藏'),
  74. icon: "none"
  75. })
  76. let list = this.data.list,
  77. index = rowindex - 1;
  78. parems.method == "selectList" ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1);
  79. this.setData({
  80. list
  81. })
  82. this.closeShow();
  83. })
  84. },
  85. /* 文件下载 */
  86. dowmLoad() {
  87. const that = this;
  88. wx.setClipboardData({
  89. data: this.data.fileSelected.url,
  90. success: function () {
  91. wx.showToast({
  92. title: getApp().globalData.Language.getMapText('复制成功,将链接放置到浏览器中便可下载文件'),
  93. icon: "none",
  94. duration: 3000
  95. });
  96. that.closeShow();
  97. }
  98. })
  99. },
  100. /* 搜索框输入 */
  101. searchInput({
  102. detail
  103. }) {
  104. parems.content.where.condition = detail;
  105. console.log(detail)
  106. this.getList(true)
  107. },
  108. /* 清除搜索输入 */
  109. searchClear() {
  110. parems.content.where.condition = '';
  111. this.getList(true)
  112. },
  113. /* tab切换 */
  114. tabsChange({
  115. detail
  116. }) {
  117. parems.method = detail.name == '列表' ? "selectList" : "selectMyList";
  118. this.getList(true);
  119. },
  120. /* 开关切换 */
  121. changeSwitch({
  122. detail
  123. }) {
  124. this.setData({
  125. sort: detail
  126. })
  127. this.getList(true);
  128. },
  129. onReady() {
  130. this.selectComponent("#ListBox").setHeight(".tabs", this);
  131. },
  132. /* 修改选中ID */
  133. changeId({
  134. detail
  135. }) {
  136. this.setData({
  137. fileSelected: detail,
  138. show: true
  139. })
  140. },
  141. /* 关闭修改 */
  142. closeShow() {
  143. this.setData({
  144. show: false
  145. })
  146. this.data.fileSelected = {}
  147. },
  148. })