index.js 8.3 KB

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