index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 => {
  57. return {
  58. name: v.templetname,
  59. index: v.templetid
  60. }
  61. }),
  62. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  63. "content.type": wx.getStorageSync('templetList')[0].templetid,
  64. });
  65. this.getList();
  66. this.getTypeList()
  67. },
  68. /* 获取列表 */
  69. getList(init = false, data) {
  70. if (init.detail != undefined) init = init.detail;
  71. let content = this.data.content;
  72. if (init) content.pageNumber = 1;
  73. if (content.pageNumber > content.pageTotal) return;
  74. if (data) {
  75. content.where.type = data.typeActive
  76. content.where.status = data.statusActive;
  77. content.where.startdate = data.startdate;
  78. content.where.enddate = data.enddate;
  79. }
  80. _Http.basic({
  81. "id": 20221101095102,
  82. content
  83. }).then(res => {
  84. console.log("市场活动", res)
  85. this.selectComponent('#ListBox').RefreshToComplete();
  86. if (res.msg != '成功') return wx.showToast({
  87. title: res.data,
  88. icon: "none"
  89. })
  90. res.data = res.data.map(v => {
  91. v.progress = v.stage / v.totalstage * 100;
  92. return v
  93. })
  94. this.setData({
  95. 'content.pageNumber': res.pageNumber + 1,
  96. 'content.pageTotal': res.pageTotal,
  97. 'content.total': res.total,
  98. 'content.sort': res.sort,
  99. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  100. loading: false,
  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. getareaList() {
  130. _Http.basic({
  131. "classname": "sysmanage.develop.optiontype.optiontype",
  132. "method": "optiontypeselect",
  133. "content": {
  134. "typename": 'dataarea'
  135. }
  136. }).then(res => {
  137. console.log("状态列表", res)
  138. if (res.msg != '成功') return wx.showToast({
  139. title: res.data,
  140. icon: "none"
  141. })
  142. let classActions = res.data.map(item => {
  143. return {
  144. name: item.value,
  145. index: item.remarks
  146. }
  147. })
  148. this.setData({
  149. classActions: classActions
  150. });
  151. console.log(this.data.classActions);
  152. this.setListHeight();
  153. })
  154. },
  155. /* 处理搜索 */
  156. onSearch({
  157. detail
  158. }) {
  159. this.setData({
  160. "content.where.condition": detail
  161. });
  162. this.getList(true);
  163. },
  164. /* 获取列表标签 */
  165. getTags() {
  166. let list = this.data.list,
  167. ownerids = list.map(v => v.sat_campaignid);
  168. _Http.basic({
  169. "id": 20221018102001,
  170. "content": {
  171. nocache: true,
  172. "ownertable": "sat_campaign",
  173. ownerids
  174. }
  175. }).then(res => {
  176. console.log("标签", res)
  177. for (let key in res.data) {
  178. let index = list.findIndex(v => v.sat_campaignid == key);
  179. list[index].tags = res.data[key]
  180. };
  181. this.setData({
  182. list
  183. })
  184. })
  185. },
  186. /* 去添加 */
  187. openType() {
  188. wx.navigateTo({
  189. url: '/packageA/activity/addActivity',
  190. })
  191. },
  192. /* 选择添加报价形式 */
  193. typeSelect({
  194. detail
  195. }) {
  196. wx.navigateTo({
  197. url: detail.name == '项目报价' ? '/packageA/offers/addProjectOffer' : '/packageA/offers/addSetclientOffer',
  198. });
  199. this.typeCancel();
  200. },
  201. onReady() {
  202. this.setListHeight();
  203. },
  204. setListHeight() {
  205. this.selectComponent("#ListBox").setHeight(".total", this);
  206. },
  207. /* 顶部条件导航回调 */
  208. navClick({
  209. detail
  210. }) {
  211. switch (detail.id) {
  212. case '1':
  213. this.setData({
  214. classShow: true
  215. })
  216. break;
  217. case '2':
  218. this.setData({
  219. 'filter.show': true
  220. })
  221. break;
  222. }
  223. },
  224. classClose() {
  225. this.setData({
  226. classShow: false
  227. })
  228. },
  229. classSelect({
  230. detail
  231. }) {
  232. if (this.data.content.type == detail.index) return this.classClose();
  233. this.setData({
  234. "content.type": detail.index,
  235. 'navList[0].label': detail.name
  236. })
  237. this.classClose();
  238. this.getList(true)
  239. },
  240. /* 筛选状态选择 */
  241. selectStatus(e) {
  242. const {
  243. item
  244. } = e.currentTarget.dataset;
  245. this.setData({
  246. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  247. })
  248. },
  249. /* 筛选状态选择 */
  250. typeStatus(e) {
  251. const {
  252. item
  253. } = e.currentTarget.dataset;
  254. this.setData({
  255. "filter.typeActive": this.data.filter.typeActive == item ? "" : item
  256. })
  257. },
  258. /* 处理筛选 */
  259. handleFilter({
  260. detail
  261. }) {
  262. const data = this.data.filter;
  263. switch (detail) {
  264. case 'confirm':
  265. this.setData({
  266. 'filter.show': false
  267. });
  268. this.getList(true, data);
  269. break;
  270. case 'reset':
  271. this.setData({
  272. 'filter.statusActive': "",
  273. 'filter.typeActive': "",
  274. 'filter.startdate': "",
  275. 'filter.enddate': "",
  276. });
  277. this.getList(true, this.data.filter)
  278. break;
  279. case 'close':
  280. this.setData({
  281. 'filter.show': false
  282. });
  283. break;
  284. }
  285. },
  286. onShareAppMessage() {
  287. }
  288. })