viewPage.js 5.5 KB

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