practicalExperience.js 10 KB

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