index.js 8.3 KB

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