practicalExperience.js 11 KB

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