viewPage.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. const getHeight = require("../../../../utils/getRheRemainingHeight");
  2. const _Http = getApp().globalData.http;
  3. const MFT = require("../../../../utils/matchingFeilType");
  4. let dowmCount = null;
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. padBot: {
  11. type: Boolean,
  12. value: true
  13. }
  14. },
  15. options: {
  16. addGlobalClass: true
  17. },
  18. lifetimes: {
  19. ready() {
  20. this.getList();
  21. getHeight.getHeight('.tabs', this).then(res => {
  22. this.setData({
  23. listHeight: res
  24. })
  25. });
  26. }
  27. },
  28. /**
  29. * 组件的初始数据
  30. */
  31. data: {
  32. listHeight: 0, //列表高度
  33. tabActiveTitle: "列表", //列表类型
  34. show: false, //显示底部弹出
  35. fileSelected: {}, //选中文件详情
  36. content: { //请求搜索条件
  37. "pageNumber": 1,
  38. "pageSize": 20,
  39. "parentid": 1,
  40. "pageTotal": 1,
  41. "where": {
  42. "condition": ""
  43. }
  44. },
  45. list: [], //文件列表
  46. inTotal: 0, //总计
  47. sort: [], //排序规则
  48. },
  49. /**
  50. * 组件的方法列表
  51. */
  52. methods: {
  53. /* 是否收藏 */
  54. changeCollect() {
  55. const {
  56. isCollect,
  57. attachmentid,
  58. rowindex
  59. } = this.data.fileSelected;
  60. console.log(isCollect)
  61. _Http.basic({
  62. "classname": "system.attachment.MediaCenter",
  63. "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
  64. "content": {
  65. "collecttype": "营销物料",
  66. "attachmentid": attachmentid
  67. }
  68. }).then(res => {
  69. console.log(res)
  70. if (res.msg != '成功') return wx.showToast({
  71. title: res.msg,
  72. icon: "none"
  73. })
  74. wx.showToast({
  75. title: isCollect == 0 ? '收藏成功' : "已取消收藏",
  76. icon: "none"
  77. })
  78. let list = this.data.list,
  79. index = rowindex - 1;
  80. this.data.tabActiveTitle == '列表' ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1);
  81. this.setData({
  82. list
  83. })
  84. this.closeShow();
  85. })
  86. },
  87. /* 文件下载 */
  88. dowmLoad() {
  89. const that = this;
  90. wx.setClipboardData({
  91. data: this.data.fileSelected.url,
  92. success: function () {
  93. wx.showToast({
  94. title: '复制成功,将链接放置到浏览器中便可下载文件',
  95. icon: "none",
  96. duration: 3000
  97. });
  98. that.closeShow();
  99. }
  100. })
  101. },
  102. /* 获得列表 */
  103. getList(init = false) {
  104. if (init.detail != undefined) init = init.detail;
  105. if (init) this.setData({
  106. ['content.pageNumber']: 1
  107. })
  108. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  109. let content = this.data.content;
  110. if (this.data.sort[0]) content.sort = this.data.sort;
  111. console.log(content)
  112. _Http.basic({
  113. "classname": "saletool.salematerial.salematerial",
  114. "method": (this.data.tabActiveTitle == '列表') ? "selectList" : "selectMyList",
  115. content
  116. }).then(res => {
  117. console.log("营销", res)
  118. this.selectComponent('#ListBox').RefreshToComplete();
  119. if (res.msg != '成功') return wx.showToast({
  120. title: res.data,
  121. icon: "none"
  122. })
  123. this.setData({
  124. list: (res.pageNumber == 1) ? MFT.fileList(res.data) : this.data.list.concat(MFT.fileList(res.data)),
  125. ['content.pageNumber']: res.pageNumber + 1,
  126. ['content.pageTotal']: res.pageTotal,
  127. inTotal: res.total,
  128. sort: res.sort
  129. })
  130. })
  131. },
  132. /* 搜索框输入 */
  133. searchInput({
  134. detail
  135. }) {
  136. clearTimeout(dowmCount);
  137. this.setData({
  138. ['content.where.condition']: detail.trim()
  139. })
  140. dowmCount = setTimeout(() => {
  141. this.getList(true)
  142. }, 1000);
  143. },
  144. /* 清除搜索输入 */
  145. searchClear() {
  146. this.setData({
  147. ['content.where.condition']: ""
  148. })
  149. },
  150. /* tab切换 */
  151. tabsChange({
  152. detail
  153. }) {
  154. this.setData({
  155. tabActiveTitle: detail.title
  156. })
  157. this.getList(true);
  158. },
  159. /* 开关切换 */
  160. changeSwitch({
  161. detail
  162. }) {
  163. this.setData({
  164. sort: detail
  165. })
  166. this.getList(true);
  167. },
  168. /* 修改ID */
  169. changeParentid(id) {
  170. this.setData({
  171. ['content.parentid']: id
  172. })
  173. },
  174. /* 修改选中ID */
  175. changeId({
  176. detail
  177. }) {
  178. console.log(detail)
  179. this.setData({
  180. fileSelected: detail,
  181. show: true
  182. })
  183. },
  184. /* 关闭修改 */
  185. closeShow() {
  186. this.setData({
  187. show: false
  188. })
  189. setTimeout(() => {
  190. this.setData({
  191. fileSelected: {}
  192. })
  193. }, 150)
  194. },
  195. }
  196. })