index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../utils/getRheRemainingHeight");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. navList: [{
  9. label: "排序",
  10. icon: "icon-shengxu",
  11. color: "",
  12. width: "",
  13. id: "sort"
  14. }, {
  15. label: "筛选",
  16. icon: "icon-shaixuan",
  17. color: "",
  18. width: "",
  19. id: "2"
  20. }],
  21. classShow: false,
  22. classActions: [{
  23. name: '全部',
  24. index: 0
  25. }, {
  26. name: '我负责的',
  27. index: 1
  28. },
  29. {
  30. name: '我参与的',
  31. index: 2
  32. },
  33. {
  34. name: "我下属负责的",
  35. index: 3
  36. }, {
  37. name: "我下属参与的",
  38. index: 4
  39. }
  40. ],
  41. content: {
  42. "isAll":0,
  43. "nocache": true,
  44. "version": 1,
  45. "pageNumber": 1,
  46. "pageSize": 20,
  47. "where": {
  48. "condition": "",
  49. "startdate": "",
  50. "enddate": "",
  51. "status": "",
  52. },
  53. "sort": []
  54. },
  55. filter: {
  56. show: false,
  57. type: ['行业峰会', '区域交流会'], //状态项
  58. typeActive: "",
  59. status: ['新建', '发布', '结束'], //状态项
  60. statusActive: "",
  61. startdate: "",
  62. enddate: ""
  63. }
  64. },
  65. onLoad(options) {
  66. this.getList();
  67. this.getTypeList()
  68. },
  69. /* 获取列表 */
  70. getList(init = false, data) {
  71. if (init.detail != undefined) init = init.detail;
  72. let content = this.data.content;
  73. if (init) content.pageNumber = 1;
  74. if (content.pageNumber > content.pageTotal) return;
  75. if (data) {
  76. content.where.type = data.typeActive
  77. content.where.status = data.statusActive;
  78. content.where.startdate = data.startdate;
  79. content.where.enddate = data.enddate;
  80. }
  81. _Http.basic({
  82. "id": 20221101095102,
  83. content
  84. }).then(res => {
  85. console.log("市场活动", res)
  86. this.selectComponent('#ListBox').RefreshToComplete();
  87. if (res.msg != '成功') return wx.showToast({
  88. title: res.data,
  89. icon: "none"
  90. })
  91. res.data = res.data.map(v => {
  92. v.progress = v.stage / v.totalstage * 100;
  93. return v
  94. })
  95. this.setData({
  96. 'content.pageNumber': res.pageNumber + 1,
  97. 'content.pageTotal': res.pageTotal,
  98. 'content.total': res.total,
  99. 'content.sort': res.sort,
  100. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  101. });
  102. this.setListHeight();
  103. this.getTags();
  104. })
  105. },
  106. /* 获取活动类型 */
  107. getTypeList () {
  108. _Http.basic({
  109. "id": 20220901092501,
  110. "content": {
  111. "typename":'campaigntype'
  112. }
  113. }).then(res => {
  114. console.log("活动类型", res)
  115. if (res.msg != '成功') return wx.showToast({
  116. title: res.data,
  117. icon: "none"
  118. })
  119. let type = res.data.map(item => {
  120. return item.value
  121. })
  122. this.setData({
  123. 'filter.type': type
  124. });
  125. this.setListHeight();
  126. })
  127. },
  128. /* 处理搜索 */
  129. onSearch({
  130. detail
  131. }) {
  132. this.setData({
  133. "content.where.condition": detail
  134. });
  135. this.getList(true);
  136. },
  137. /* 获取列表标签 */
  138. getTags() {
  139. let list = this.data.list,
  140. ownerids = list.map(v => v.sat_campaignid);
  141. _Http.basic({
  142. "id": 20221018102001,
  143. "content": {
  144. nocache: true,
  145. "ownertable": "sat_campaign",
  146. ownerids
  147. }
  148. }).then(res => {
  149. console.log("标签", res)
  150. for (let key in res.data) {
  151. let index = list.findIndex(v => v.sat_campaignid == key);
  152. list[index].tags = res.data[key]
  153. };
  154. this.setData({
  155. list
  156. })
  157. })
  158. },
  159. /* 去添加 */
  160. openType() {
  161. wx.navigateTo({
  162. url: '/packageA/activity/addActivity',
  163. })
  164. },
  165. /* 选择添加报价形式 */
  166. typeSelect({
  167. detail
  168. }) {
  169. wx.navigateTo({
  170. url: detail.name == '项目报价' ? '/packageA/offers/addProjectOffer' : '/packageA/offers/addSetclientOffer',
  171. });
  172. this.typeCancel();
  173. },
  174. onReady() {
  175. this.setListHeight();
  176. },
  177. setListHeight() {
  178. getHeight.getHeight('.total', this).then(res => {
  179. if (this.data.listHeight != res)
  180. this.setData({
  181. listHeight: res
  182. })
  183. });
  184. },
  185. /* 顶部条件导航回调 */
  186. navClick({
  187. detail
  188. }) {
  189. switch (detail.id) {
  190. case '1':
  191. this.setData({
  192. classShow: true
  193. })
  194. break;
  195. case '2':
  196. this.setData({
  197. 'filter.show': true
  198. })
  199. break;
  200. }
  201. },
  202. classClose() {
  203. this.setData({
  204. classShow: false
  205. })
  206. },
  207. classSelect({
  208. detail
  209. }) {
  210. if (this.data.content.type == detail.index) return this.classClose();
  211. this.setData({
  212. "content.type": detail.index,
  213. 'navList[0].label': detail.name
  214. })
  215. this.classClose();
  216. this.getList(true)
  217. },
  218. /* 筛选状态选择 */
  219. selectStatus(e) {
  220. const {
  221. item
  222. } = e.currentTarget.dataset;
  223. this.setData({
  224. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  225. })
  226. },
  227. /* 筛选状态选择 */
  228. typeStatus(e) {
  229. const {
  230. item
  231. } = e.currentTarget.dataset;
  232. this.setData({
  233. "filter.typeActive": this.data.filter.typeActive == item ? "" : item
  234. })
  235. },
  236. /* 处理筛选 */
  237. handleFilter({
  238. detail
  239. }) {
  240. const data = this.data.filter;
  241. switch (detail) {
  242. case 'confirm':
  243. this.setData({
  244. 'filter.show': false
  245. });
  246. this.getList(true, data);
  247. break;
  248. case 'reset':
  249. this.setData({
  250. 'filter.statusActive': "",
  251. 'filter.typeActive': "",
  252. 'filter.startdate': "",
  253. 'filter.enddate': "",
  254. });
  255. this.getList(true, this.data.filter)
  256. break;
  257. case 'close':
  258. this.setData({
  259. 'filter.show': false
  260. });
  261. break;
  262. }
  263. },
  264. onShareAppMessage() {
  265. }
  266. })