index.js 8.1 KB

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