index.js 8.0 KB

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