index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. {
  10. itemname: "全部",
  11. },
  12. ],
  13. nameListEle: [],
  14. nameIndex: 0,
  15. navScrollWidth: 0,
  16. showFilterBox: false,
  17. filterList: [
  18. {
  19. name: "兼职特点",
  20. list: [],
  21. },
  22. {
  23. name: "性别要求",
  24. list: [],
  25. },
  26. {
  27. name: "兼职状态",
  28. list: [],
  29. },
  30. {
  31. name: "结算方式",
  32. list: [],
  33. },
  34. ],
  35. params: {
  36. page: 1,
  37. limit: 10,
  38. city: "",
  39. goodLabelsId: "",
  40. // area:'',
  41. // category:'',//兼职分类(不传查所有 01周末兼职 02日常兼职)
  42. // type:'',//兼职特点
  43. // sexlimit:'',//性别要求
  44. // status:'',//兼职状态
  45. // cashMethod:''//结算方式
  46. },
  47. total: {
  48. currPage: 0,
  49. totalPage: 0,
  50. },
  51. noMore: false,
  52. listData: [],
  53. statusBarHeight: 0,
  54. staHeight: 0,
  55. },
  56. onShow() {
  57. // let index = getApp().params.pePageToIndex;
  58. // let nameIndex = this.data.nameIndex;
  59. // this.setData({
  60. // nameIndex: index || 0
  61. // })
  62. // this.setData({
  63. // nameIndex: "",
  64. // });
  65. // if (this.data.nameList.length == 1) {
  66. // this.getNameList(index ? index : 0)
  67. // } else {
  68. // this.scroll(index ? index : 0)
  69. // }
  70. // if (this.data.nameList.length == 1) {
  71. // this.getNameList(0);
  72. // } else {
  73. // this.scroll(0);
  74. // }
  75. },
  76. onLoad() {
  77. this.height();
  78. let index = getApp().params.pePageToIndex;
  79. let nameIndex = this.data.nameIndex;
  80. this.setData({
  81. nameIndex: "",
  82. });
  83. if (this.data.nameList.length == 1) {
  84. this.getNameList(0);
  85. } else {
  86. this.scroll(0);
  87. }
  88. this.loadList(true);
  89. },
  90. onReachBottom: function () {
  91. this.loadList();
  92. },
  93. // 自定义高度处理
  94. height() {
  95. let that = this;
  96. const { platform, statusBarHeight } = wx.getSystemInfoSync();
  97. let height = statusBarHeight + 4; //ios 24px
  98. let mH = statusBarHeight + 4;
  99. if (platform.toLowerCase() == "android") {
  100. height += 4; //android 28px
  101. mH += 4;
  102. }
  103. height = height + 38;
  104. // 胶囊高度 32px 下边框6px height 状态栏高度
  105. const ButtonBounding = wx.getMenuButtonBoundingClientRect();
  106. wx.getSystemInfo({
  107. success: (res) => {
  108. let navHeight =
  109. ButtonBounding.height +
  110. res.statusBarHeight +
  111. (ButtonBounding.top - res.statusBarHeight) * 2;
  112. that.setData({
  113. statusBarHeight:
  114. ButtonBounding.height +
  115. res.statusBarHeight +
  116. (ButtonBounding.top - res.statusBarHeight) * 2 +
  117. "px",
  118. conTop: 50 + 48 + "px",
  119. shaiHeight: navHeight + 48 + "px",
  120. staHeight: res.statusBarHeight,
  121. });
  122. },
  123. });
  124. },
  125. toPartDetail(e) {
  126. wx.navigateTo({
  127. url: `/expert/detail/detail?id=${e.currentTarget.dataset.id}`,
  128. });
  129. },
  130. nameHandler(e) {
  131. console.log(e);
  132. let nameIndex = e.currentTarget.dataset.index;
  133. let goodLabelsId =
  134. e.currentTarget.dataset && e.currentTarget.dataset.guid
  135. ? e.currentTarget.dataset.guid
  136. : "";
  137. getApp().params.pePageToIndex = nameIndex;
  138. this.setData({
  139. nameIndex,
  140. params: {
  141. ...this.data.params,
  142. goodLabelsId,
  143. },
  144. });
  145. this.scroll(nameIndex);
  146. this.loadList(true);
  147. },
  148. showFilter(e) {
  149. this.setData({
  150. showFilterBox: !this.data.showFilterBox,
  151. });
  152. },
  153. clickMask() {
  154. this.setData({
  155. showFilterBox: false,
  156. });
  157. },
  158. setChecked(e) {
  159. let index = e.currentTarget.dataset.index;
  160. let index2 = e.currentTarget.dataset.index2;
  161. let filterList = this.data.filterList;
  162. for (let i in filterList) {
  163. let list = filterList[i].list;
  164. for (let m in list) {
  165. if (i == index) {
  166. if (m == index2) {
  167. list[m].checked = !list[m].checked;
  168. } else {
  169. //兼职特点可以多选
  170. if (i == 0) {
  171. continue;
  172. }
  173. list[m].checked = false;
  174. }
  175. }
  176. }
  177. }
  178. this.setData({
  179. filterList,
  180. });
  181. },
  182. loadList(isRefresh) {
  183. let that = this;
  184. if (!isRefresh && this.data.noMore) {
  185. wx.showToast({
  186. title: "没有更多了~",
  187. icon: "none",
  188. });
  189. return false;
  190. }
  191. let nowCity = wx.getStorageSync("CHOOSECITY");
  192. this.setData({
  193. listData: isRefresh ? [] : this.data.listData,
  194. noMore: isRefresh ? false : this.data.noMore,
  195. params: {
  196. ...this.data.params,
  197. page: isRefresh ? 1 : this.data.params.page + 1,
  198. // category: this.data.nameIndex == 0 ? '' : `0${this.data.nameIndex}`,
  199. // city: nowCity.cityId,
  200. city: "",
  201. // area: nowCity.areaId
  202. },
  203. });
  204. wx.showLoading({
  205. title: "努力加载中...",
  206. });
  207. // app._post_form('home/label', '', this.data.params,
  208. app._get(
  209. "expert/greatGodGangPage",
  210. this.data.params,
  211. function (res) {
  212. if (res.code == 0) {
  213. if (
  214. res.page.list.length > 0 &&
  215. that.data.listData.length > 0 &&
  216. res.page.list[0].id == that.data.listData[0].id
  217. ) {
  218. return;
  219. }
  220. let listData = that.data.listData;
  221. listData.push(...res.page.list);
  222. that.setData({
  223. listData,
  224. currPage: res.page.currPage,
  225. totalPage: res.page.totalPage,
  226. noMore: res.page.totalPage == res.page.currPage,
  227. });
  228. }
  229. },
  230. function (res) {
  231. wx.hideLoading();
  232. },
  233. function () {
  234. wx.hideLoading();
  235. }
  236. );
  237. },
  238. getNameList(index) {
  239. let that = this;
  240. // app._post_form('home/navigation', '', null,
  241. app._post_form("bizlibrary/infoList/maven_label", "", null, function (res) {
  242. if (res.code == 0) {
  243. that.setData({
  244. nameList: [
  245. {
  246. itemname: "全部",
  247. },
  248. ...res.dictList,
  249. ],
  250. });
  251. wx.nextTick(() => {
  252. let query = wx.createSelectorQuery();
  253. query
  254. .selectAll(".nameitem")
  255. .boundingClientRect()
  256. .exec(function (res) {
  257. let nameListEle = [];
  258. for (let i in res[0]) {
  259. nameListEle.push(res[0][i].width * 1);
  260. }
  261. that.setData({
  262. nameListEle,
  263. });
  264. });
  265. setTimeout(() => {
  266. that.scroll(index);
  267. }, 500);
  268. });
  269. }
  270. });
  271. },
  272. scroll(index) {
  273. let that = this;
  274. let leftNum = 0;
  275. if (index > 0) {
  276. for (let i in that.data.nameListEle) {
  277. if (i < index) {
  278. leftNum += that.data.nameListEle[i];
  279. leftNum += (20 / 750) * wx.getSystemInfoSync().windowWidth;
  280. }
  281. }
  282. }
  283. that.setData({
  284. navScrollWidth: leftNum,
  285. });
  286. },
  287. clearFilterBox() {
  288. let filterList = this.data.filterList;
  289. for (let i in filterList) {
  290. let list = filterList[i].list;
  291. for (let m in list) {
  292. list[m].checked = false;
  293. }
  294. }
  295. this.setData({
  296. filterList,
  297. });
  298. },
  299. filter() {
  300. this.setData({
  301. showFilterBox: false,
  302. });
  303. let filterList = this.data.filterList;
  304. let params = this.data.params;
  305. let type = [];
  306. let sexlimit = "";
  307. let status = "";
  308. let cashMethod = "";
  309. for (let i in filterList) {
  310. let list = filterList[i].list;
  311. for (let m in list) {
  312. if (list[m].checked && i == 0) {
  313. type.push(list[m].itemcode);
  314. }
  315. if (list[m].checked && i == 1) {
  316. sexlimit = list[m].itemcode;
  317. }
  318. if (list[m].checked && i == 2) {
  319. status = list[m].itemcode;
  320. }
  321. if (list[m].checked && i == 3) {
  322. cashMethod = list[m].itemcode;
  323. }
  324. }
  325. }
  326. this.setData({
  327. params: {
  328. ...this.data.params,
  329. type: type.length > 0 ? type.join(",") : "",
  330. sexlimit: sexlimit,
  331. status: status,
  332. cashMethod: cashMethod,
  333. },
  334. });
  335. this.loadList(true);
  336. },
  337. onReachBottom: function () {
  338. this.loadList();
  339. },
  340. onPullDownRefresh: function () {
  341. let nameIndex = this.data.nameIndex;
  342. this.getNameList(nameIndex ? nameIndex : 0);
  343. this.loadList(true);
  344. // 处理完成后,终止下拉刷新
  345. wx.stopPullDownRefresh();
  346. },
  347. onShareAppMessage: function () {},
  348. });