index.js 7.8 KB

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