practicalExperience.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. const app = getApp();
  2. var util = require("../../utils/util.js")
  3. Page({
  4. data: {
  5. appAssetsUrl: app.appAssetsUrl,
  6. appAssetsUrl2: app.appAssetsUrl2,
  7. nodata: util.nodata(),
  8. nameList: [{ itemname: '全部' }],
  9. nameListEle: [],
  10. nameIndex: 0,
  11. navScrollWidth: 0,
  12. showFilterBox: false,
  13. filterList: [{
  14. name: '兼职特点',
  15. list: []
  16. }, {
  17. name: '性别要求',
  18. list: []
  19. }, {
  20. name: '兼职状态',
  21. list: []
  22. }, {
  23. name: '结算方式',
  24. list: []
  25. }],
  26. params: {
  27. pageNum: 1,
  28. pageSize: 10,
  29. city: '',
  30. area: '',
  31. category: '', //兼职分类(不传查所有 01周末兼职 02日常兼职)
  32. type: '', //兼职特点
  33. sexlimit: '', //性别要求
  34. status: '', //兼职状态
  35. cashMethod: '' //结算方式
  36. },
  37. total: {
  38. currPage: 0,
  39. totalPage: 0
  40. },
  41. noMore: false,
  42. listData: [],
  43. statusBarHeight: 0,
  44. titleHeight: 0,
  45. conTop: 0,
  46. timeListIndex: 0,
  47. statusListIndex: 0,
  48. timeList: [{
  49. code: 'createTime',
  50. name: '发布时间',
  51. order: 'desc'
  52. }, {
  53. code: 'workdateStart',
  54. name: '兼职开始时间',
  55. order: 'desc'
  56. }],
  57. statusList: [],
  58. statusBarHeight: 0,
  59. staHeight: 0,
  60. shaiHeight: 0
  61. },
  62. onShow() {
  63. // let index = getApp().params.pePageToIndex;
  64. // let nameIndex = this.data.nameIndex;
  65. // console.log(nameIndex,'nameIndex')
  66. // this.setData({
  67. // nameIndex:index || 0
  68. // })
  69. // this.setData({
  70. // nameIndex:''
  71. // })
  72. // if(this.data.nameList.length==1){
  73. // this.getNameList(index?index:0)
  74. // }else{
  75. // this.scroll(index?index:0)
  76. // }
  77. },
  78. onLoad() {
  79. // this.getFilterList();
  80. this.height()
  81. this.getJobList()
  82. let index = getApp().params.pePageToIndex;
  83. let nameIndex = this.data.nameIndex;
  84. console.log(nameIndex, 'nameIndex')
  85. this.setData({
  86. nameIndex: ''
  87. })
  88. if (this.data.nameList.length == 1) {
  89. this.getNameList(0)
  90. } else {
  91. this.scroll(0)
  92. }
  93. this.loadList(true);
  94. },
  95. //选择时间排序
  96. timePickerChange(e) {
  97. let timeListIndex = e.detail.value;
  98. this.setData({
  99. timeListIndex,
  100. })
  101. console.log(timeListIndex)
  102. this.loadList(true)
  103. },
  104. getJobList() {
  105. let that = this;
  106. app._get('bizcatelog/apiSelectBizcatelog/workStatus', '',
  107. function(res) {
  108. if (res.code == 0) {
  109. console.log(res)
  110. that.setData({
  111. statusList: [{ itemname: '兼职状态', itemcode: '' }, ...res.dictList]
  112. })
  113. }
  114. })
  115. },
  116. //选择报名状态
  117. statusPickerChange(e) {
  118. let statusListIndex = e.detail.value;
  119. this.setData({
  120. statusListIndex,
  121. ['params.status']: this.data.statusList[statusListIndex].itemcode
  122. })
  123. this.loadList(true)
  124. },
  125. // 自定义高度处理
  126. height() {
  127. let that = this
  128. const {
  129. platform,
  130. statusBarHeight
  131. } = wx.getSystemInfoSync()
  132. let height = statusBarHeight + 4 //ios 24px
  133. let mH = statusBarHeight + 4
  134. if (platform.toLowerCase() == "android") {
  135. height += 4 //android 28px
  136. mH += 4
  137. }
  138. height = height + 38
  139. // 胶囊高度 32px 下边框6px height 状态栏高度
  140. // 胶囊高度 32px 下边框6px height 状态栏高度
  141. const ButtonBounding = wx.getMenuButtonBoundingClientRect()
  142. wx.getSystemInfo({
  143. success: res => {
  144. let navHeight = ButtonBounding.height + res.statusBarHeight + (ButtonBounding.top -
  145. res.statusBarHeight) * 2
  146. that.setData({
  147. statusBarHeight: ButtonBounding.height + res.statusBarHeight + (
  148. ButtonBounding.top - res.statusBarHeight) * 2 + 'px',
  149. titleHeight: (height - res.statusBarHeight) + 'px',
  150. conTop: 50 + 'px',
  151. shaiHeight: (navHeight + 48) + 'px',
  152. staHeight: res.statusBarHeight,
  153. })
  154. }
  155. })
  156. },
  157. onReachBottom: function() {
  158. this.loadList();
  159. },
  160. toPartDetail(e) {
  161. wx.navigateTo({
  162. url: `/pages/home/index/partDetail/partDetail?id=${e.currentTarget.dataset.id}`
  163. })
  164. },
  165. nameHandler(e) {
  166. let nameIndex = e.currentTarget.dataset.index;
  167. getApp().params.pePageToIndex = nameIndex;
  168. this.setData({
  169. nameIndex
  170. })
  171. this.scroll(nameIndex);
  172. this.loadList(true);
  173. },
  174. showFilter(e) {
  175. this.setData({
  176. showFilterBox: !this.data.showFilterBox
  177. })
  178. },
  179. clickMask() {
  180. this.setData({
  181. showFilterBox: false
  182. })
  183. },
  184. setChecked(e) {
  185. let index = e.currentTarget.dataset.index;
  186. let index2 = e.currentTarget.dataset.index2;
  187. let filterList = this.data.filterList;
  188. for (let i in filterList) {
  189. let list = filterList[i].list;
  190. for (let m in list) {
  191. if (i == index) {
  192. if (m == index2) {
  193. list[m].checked = !list[m].checked
  194. } else {
  195. //兼职特点可以多选
  196. if (i == 0) {
  197. continue;
  198. }
  199. list[m].checked = false
  200. }
  201. }
  202. }
  203. }
  204. this.setData({
  205. filterList
  206. })
  207. },
  208. loadList(isRefresh) {
  209. let that = this;
  210. if (!isRefresh && this.data.noMore) {
  211. wx.showToast({
  212. title: '没有更多了~',
  213. icon: 'none'
  214. })
  215. return false;
  216. }
  217. let nowCity = wx.getStorageSync("CHOOSECITY");
  218. this.setData({
  219. listData: isRefresh ? [] : this.data.listData,
  220. noMore: isRefresh ? false : this.data.noMore,
  221. params: {
  222. ...this.data.params,
  223. pageNum: isRefresh ? 1 : this.data.params.pageNum + 1,
  224. category: this.data.nameIndex == 0 ? '' : `0${this.data.nameIndex}`,
  225. city: nowCity.cityId,
  226. area: nowCity.areaId,
  227. isHome: 0,
  228. sidx: that.data.timeList[that.data.timeListIndex].code,
  229. order: 'desc'
  230. // timeListIndex
  231. }
  232. })
  233. wx.showLoading({
  234. title: '努力加载中...',
  235. })
  236. app._post_form('home/label', '', this.data.params,
  237. function(res) {
  238. if (res.code == 0) {
  239. if (res.page.list.length > 0 && that.data.listData.length > 0 && res.page.list[0].id ==
  240. that.data.listData[0].id) {
  241. return;
  242. }
  243. res.page.list.map(v => {
  244. v.workdateStart = v.workdateStart.replace(/-/g, '.')
  245. v.workdateEnd = v.workdateEnd.replace(/-/g, '.')
  246. })
  247. // let listData = that.data.listData;
  248. // listData.push(...res.page.list);
  249. that.setData({
  250. listData: []
  251. })
  252. setTimeout(() => {
  253. const dataList = res.page.list || []
  254. const page = {
  255. currPage: res.page.currPage,
  256. totalPage: res.page.totalPage,
  257. }
  258. that.setData({
  259. listData: dataList,
  260. total: page,
  261. noMore: res.page.totalPage == res.page.currPage
  262. })
  263. },0)
  264. // that.setData({
  265. // listData,
  266. // currPage: res.page.currPage,
  267. // totalPage: res.page.totalPage,
  268. // total: {
  269. // currPage: res.page.currPage,
  270. // totalPage: res.page.totalPage,
  271. // },
  272. // noMore: res.page.totalPage == res.page.currPage
  273. // })
  274. }
  275. },
  276. function(res) {
  277. wx.hideLoading()
  278. })
  279. },
  280. getNameList(index) {
  281. let that = this;
  282. app._post_form('home/navigation', '', null,
  283. function(res) {
  284. if (res.code == 0) {
  285. that.setData({
  286. nameList: [{ itemname: '全部' }, ...res.data]
  287. })
  288. wx.nextTick(() => {
  289. let query = wx.createSelectorQuery();
  290. query.selectAll('.nameitem').boundingClientRect().exec(function(res) {
  291. let nameListEle = [];
  292. for (let i in res[0]) {
  293. nameListEle.push(res[0][i].width * 1);
  294. }
  295. that.setData({
  296. nameListEle
  297. })
  298. })
  299. setTimeout(() => {
  300. that.scroll(index)
  301. }, 500)
  302. })
  303. }
  304. })
  305. },
  306. scroll(index) {
  307. let that = this;
  308. let leftNum = 0;
  309. if (index > 0) {
  310. for (let i in that.data.nameListEle) {
  311. if (i < index) {
  312. leftNum += that.data.nameListEle[i];
  313. leftNum += (20 / 750 * wx.getSystemInfoSync().windowWidth)
  314. }
  315. }
  316. }
  317. that.setData({
  318. navScrollWidth: leftNum
  319. })
  320. },
  321. getFilterList() {
  322. let that = this;
  323. app._post_form('home/filter', '', null,
  324. function(res) {
  325. if (res.code == 0) {
  326. let filterList = that.data.filterList;
  327. //兼职特点
  328. filterList[0].list = [{
  329. itemname: '全部',
  330. itemcode: '',
  331. checked: false
  332. }];
  333. for (let i in res.data.typeList) {
  334. filterList[0].list.push({
  335. itemname: res.data.typeList[i].itemname,
  336. itemcode: res.data.typeList[i].itemcode,
  337. checked: false
  338. })
  339. }
  340. //性别要求
  341. filterList[1].list = [{
  342. itemname: '全部',
  343. itemcode: '',
  344. checked: false
  345. }];
  346. for (let i in res.data.sexList) {
  347. filterList[1].list.push({
  348. itemname: res.data.sexList[i].itemname,
  349. itemcode: res.data.sexList[i].itemcode,
  350. checked: false
  351. })
  352. }
  353. //兼职状态
  354. filterList[2].list = [{
  355. itemname: '全部',
  356. itemcode: '',
  357. checked: false
  358. }];
  359. for (let i in res.data.statusList) {
  360. filterList[2].list.push({
  361. itemname: res.data.statusList[i].itemname,
  362. itemcode: res.data.statusList[i].itemcode,
  363. checked: false
  364. })
  365. }
  366. //结算方式
  367. filterList[3].list = [{
  368. itemname: '全部',
  369. itemcode: '',
  370. checked: false
  371. }];
  372. for (let i in res.data.cashMethodList) {
  373. filterList[3].list.push({
  374. itemname: res.data.cashMethodList[i].itemname,
  375. itemcode: res.data.cashMethodList[i].itemcode,
  376. checked: false
  377. })
  378. }
  379. that.setData({
  380. filterList
  381. })
  382. }
  383. })
  384. },
  385. clearFilterBox() {
  386. let filterList = this.data.filterList;
  387. for (let i in filterList) {
  388. let list = filterList[i].list;
  389. for (let m in list) {
  390. list[m].checked = false;
  391. }
  392. }
  393. this.setData({
  394. filterList
  395. })
  396. },
  397. filter() {
  398. this.setData({
  399. showFilterBox: false
  400. })
  401. let filterList = this.data.filterList;
  402. let params = this.data.params;
  403. let type = [];
  404. let sexlimit = '';
  405. let status = '';
  406. let cashMethod = '';
  407. for (let i in filterList) {
  408. let list = filterList[i].list;
  409. for (let m in list) {
  410. if (list[m].checked && i == 0) {
  411. type.push(list[m].itemcode);
  412. }
  413. if (list[m].checked && i == 1) {
  414. sexlimit = list[m].itemcode;
  415. }
  416. if (list[m].checked && i == 2) {
  417. status = list[m].itemcode;
  418. }
  419. if (list[m].checked && i == 3) {
  420. cashMethod = list[m].itemcode;
  421. }
  422. }
  423. }
  424. this.setData({
  425. params: {
  426. ...this.data.params,
  427. type: type.length > 0 ? type.join(',') : '',
  428. sexlimit: sexlimit,
  429. status: status,
  430. cashMethod: cashMethod
  431. }
  432. })
  433. this.loadList(true);
  434. },
  435. onReachBottom: function() {
  436. // this.loadList();
  437. },
  438. onPreviousPage() {
  439. let num = this.data.params.pageNum
  440. if (num <= 1) return;
  441. num -= 2;
  442. this.setData({
  443. params: {
  444. ...this.data.params,
  445. pageNum: num
  446. },
  447. noMore: false
  448. });
  449. this.loadList();
  450. },
  451. onNextPage() {
  452. this.loadList();
  453. },
  454. onPullDownRefresh: function() {
  455. let nameIndex = this.data.nameIndex;
  456. this.getNameList(nameIndex ? nameIndex : 0)
  457. this.loadList(true);
  458. // this.getFilterList();
  459. this.getJobList()
  460. // 处理完成后,终止下拉刷新
  461. wx.stopPullDownRefresh();
  462. },
  463. onShareAppMessage: function() {
  464. }
  465. })