index.js 8.3 KB

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