activityinfo.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. // pages/experience/activityinfo/activityinfo.js
  2. var app = getApp();
  3. var util = require("../../../utils/util.js")
  4. let cityList = [];
  5. Page({
  6. data: {
  7. current: 'tab1',
  8. hidden: true,
  9. list: [],
  10. allcity: [],
  11. value: [],
  12. cityIndex: [0, 0],
  13. array: [{ itemcode: '', itemname: '全部' }],
  14. scrollTop: 0,
  15. scrollHeight: 0,
  16. totalCount: 0,
  17. loadingmore: false,
  18. partTrue: true,
  19. activityTrue: false,
  20. produindex: 0,
  21. produindexone: 0,
  22. totalPage: 0,
  23. nodata: util.nodata(),
  24. arraylist: [{ id: '', name: '全部排序' }, { id: '1', name: '最近三天' }, { id: '2', name: '最近七天' }, { id: '3', name: '最近一个月' }],
  25. arraystatus: [{ id: '', name: '全部' }, { id: '1', name: '报名中' }, { id: '2', name: '预告' }, { id: '3', name: '已结束' }],
  26. parm: {
  27. page: 1,
  28. limit: "10",
  29. city: "",
  30. time: "",
  31. status: "",
  32. },
  33. parmtwo: {
  34. page: 1,
  35. limit: '10',
  36. city: null,
  37. category: null,
  38. name: null,
  39. },
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. cityExperience: function () {
  45. wx.switchTab({
  46. url: '../../../pages/experience/index/index', //注意switchTab只能跳转到带有tab的页面,不能跳转到不带tab的页面
  47. })
  48. },
  49. onLoad: function (options) {
  50. wx.setNavigationBarTitle({ title: '实践体验' })
  51. let citystorage = wx.getStorageSync("CHOOSECITY")
  52. this.data.parmtwo.city = citystorage.cityId
  53. let _this = this;
  54. wx.getSystemInfo({
  55. success: function (res) {
  56. _this.setData({
  57. scrollHeight: res.windowHeight
  58. });
  59. }
  60. });
  61. _this.loadmsg();
  62. _this.loadpartime();
  63. },
  64. bindMultiPickerColumnChange: function (e) {
  65. console.log(e)
  66. console.log(cityList)
  67. let _this = this;
  68. if (e.detail.column === 0) {
  69. let c = [];
  70. for (let i = 0; i < cityList[e.detail.column + 1].length; i++) {
  71. let id = cityList[e.detail.column][e.detail.value].code + ""
  72. let oneId = cityList[e.detail.column + 1][i].pid + ""
  73. if (id === oneId) {
  74. c.push(cityList[e.detail.column + 1][i]);
  75. }
  76. }
  77. _this.data.allcity[e.detail.column + 1] = c;
  78. }
  79. _this.data.cityIndex[e.detail.column] = e.detail.value
  80. _this.setData({
  81. allcity: _this.data.allcity,
  82. cityIndex: _this.data.cityIndex
  83. })
  84. },
  85. bindMultiPickerChange: function (e) {
  86. let _this = this;
  87. if (_this.data.allcity[1].length) {
  88. _this.data.parm.city = _this.data.allcity[1][e.detail.value[1]].code + "";
  89. } else {
  90. _this.data.parm.city = null;
  91. }
  92. _this.data.value = [];
  93. _this.loadActivity();
  94. },
  95. // 单列 价格
  96. bindPickerChange: function (e) {
  97. console.log(e)
  98. this.setData({
  99. index: e.detail.value
  100. })
  101. this.data.value = [];
  102. this.setData({
  103. produindex: parseInt(e.detail.value),
  104. })
  105. if (this.data.arraylist[parseInt(e.detail.value)].id) {
  106. this.data.parm.time = this.data.arraylist[parseInt(e.detail.value)].id
  107. } else {
  108. this.data.parm.time = null;
  109. }
  110. this.loadActivity();
  111. },
  112. // 分类
  113. bindPickerChanger: function (e) {
  114. console.log(e)
  115. this.setData({
  116. index: e.detail.value
  117. })
  118. this.data.value = [];
  119. this.setData({
  120. produindexone: parseInt(e.detail.value),
  121. })
  122. if (this.data.arraylist[parseInt(e.detail.value)].id) {
  123. this.data.parm.status = this.data.arraylist[parseInt(e.detail.value)].id
  124. } else {
  125. this.data.parm.status = null;
  126. }
  127. this.loadActivity();
  128. },
  129. loadmsg: function () {
  130. let _this = this;
  131. app._post_form('bizcatelog/apiSelectBizcatelog/cityEnjoyCategory', '', null, function (res) {
  132. // console.log(res)
  133. if (res.code === 0) {
  134. let gender = res.dictList
  135. _this.setData({
  136. activitylist: gender
  137. })
  138. _this.loadCity()
  139. _this.loadData()
  140. }
  141. })
  142. },
  143. loadpartime: function () {
  144. let _this = this;
  145. app._post_form('bizcatelog/apiSelectBizcatelog/workCategory', '', null, function (res) {
  146. console.log(res)
  147. if (res.code === 0) {
  148. let gender = res.dictList
  149. _this.setData({
  150. partlist: gender
  151. })
  152. }
  153. })
  154. },
  155. loadActivity: function () {
  156. wx.showLoading({
  157. title: '努力加载中...',
  158. })
  159. let _this = this;
  160. _this.data.parm.page = _this.data.parm.page + "";
  161. app._post_form('act/list', "application/json", JSON.stringify(_this.data.parm), function (res) {
  162. console.log(res)
  163. // if (res.code === 0) {
  164. // _this.setData({
  165. // listActivity: res.data.list,
  166. // totalPage: res.data.totalPage
  167. // });
  168. // _this.data.totalPage = res.data.totalPage;
  169. // }
  170. if (res.code === 0) {
  171. _this.data.totalPage = res.data.totalPage;
  172. let d = _this.data.value;
  173. if (res.data.list.length) {
  174. d.push(...res.data.list);
  175. } else {
  176. d = [];
  177. }
  178. _this.setData({
  179. listActivity: d,
  180. totalPage: res.data.totalPage,
  181. totalCount: res.data.totalCount,
  182. currPage: res.data.currPage
  183. })
  184. wx.hideLoading();
  185. }
  186. })
  187. },
  188. // tab 切换
  189. tabs: function (e) {
  190. let _this = this
  191. _this.data.value = [];
  192. _this.data.parm.page = 1;
  193. _this.data.parmtwo.page = 1;
  194. _this.data.totalCount = 0;
  195. _this.data.totalPage = 0;
  196. let type = e.currentTarget.dataset.type
  197. _this.data.value = [];
  198. if (type === 0) {
  199. _this.setData({
  200. partTrue: true,
  201. activityTrue: false
  202. })
  203. _this.loadData()
  204. } else {
  205. _this.setData({
  206. partTrue: false,
  207. activityTrue: true
  208. })
  209. _this.loadActivity()
  210. }
  211. // if (e) {
  212. //
  213. // _this.data.parm.SPRODUCTTYPE = type
  214. // _this.loadData();
  215. // }
  216. },
  217. bindDownLoad: function () {
  218. // if (this.data.parm.page < this.data.totalPage) {
  219. // // this.loadNext()
  220. // this.loadData();
  221. // } else {
  222. // this.setData({
  223. // loadingmore: true
  224. // })
  225. // }
  226. },
  227. activeDetail: function (e) {
  228. // console.log(e.currentTarget.dataset.id)
  229. if (e.currentTarget.dataset.id) {
  230. wx.navigateTo({
  231. url: '/pages/home/index/activityDetail/activityDetail?id=' + e.currentTarget.dataset.id,
  232. })
  233. }
  234. },
  235. // tab
  236. handleChange({ detail }) {
  237. let _this = this
  238. _this.data.value = [];
  239. _this.data.parmtwo.page = 1;
  240. _this.data.totalCount = 0;
  241. _this.data.totalPage = 0;
  242. this.setData({
  243. current: detail.key
  244. });
  245. if (detail.key == "tab1") {
  246. this.data.parmtwo.category = null
  247. } else {
  248. this.data.parmtwo.category = detail.key
  249. }
  250. this.loadData()
  251. },
  252. handleChangeScroll({ detail }) {
  253. this.setData({
  254. current_scroll: detail.key
  255. });
  256. },
  257. scroll: function (event) {
  258. //该方法绑定了页面滚动时的事件,我这里记录了当前的position.y的值,为了请求数据之后把页面定位到这里来。
  259. let _this = this;
  260. _this.setData({
  261. scrollTop: event.detail.scrollTop
  262. });
  263. },
  264. seeDetails: function (e) {
  265. // console.log(e.currentTarget.dataset.id)
  266. if (e.currentTarget.dataset.id) {
  267. wx.navigateTo({
  268. url: '/pages/home/index/partDetail/partDetail?id=' + e.currentTarget.dataset.id,
  269. })
  270. }
  271. },
  272. // 兼职
  273. loadData: function () {
  274. wx.showLoading({
  275. title: '努力加载中...',
  276. })
  277. let _this = this;
  278. _this.data.parmtwo.page = _this.data.parmtwo.page + "";
  279. app._post_form('work/list', "application/json", JSON.stringify(_this.data.parmtwo),
  280. function (res) {
  281. for (let i = 0; i < res.data.list.length; i++) {
  282. res.data.list[i].workdateStart = util.changeTime(res.data.list[i].workdateStart)
  283. res.data.list[i].workdateEnd = util.changeTime(res.data.list[i].workdateEnd)
  284. }
  285. if (res.code === 0) {
  286. _this.data.totalPage = res.data.totalPage;
  287. let d = _this.data.value;
  288. if (res.data.list.length) {
  289. d.push(...res.data.list);
  290. } else {
  291. d = [];
  292. }
  293. _this.setData({
  294. listitem: d,
  295. totalPage: res.data.totalPage,
  296. totalCount: res.data.totalCount,
  297. currPage: res.data.currPage
  298. })
  299. wx.hideLoading();
  300. }
  301. }
  302. )
  303. },
  304. loadCity() {
  305. let _this = this;
  306. app._post_form('act/area', '', null, function (res) {
  307. console.log(res)
  308. if (res.code === 0) {
  309. let prov = [];
  310. let city = [];
  311. let citycode = '';
  312. for (let i = 0; i < res.data.length; i++) {
  313. let provCode = res.data[i].province.code;
  314. prov.push(res.data[i].province);
  315. for (let j = 0; j < res.data[i].area.length; j++) {
  316. res.data[i].area[j].pid = provCode;
  317. city.push(res.data[i].area[j]);
  318. citycode = res.data[0].area[0].code;
  319. }
  320. }
  321. if (citycode) {
  322. _this.data.parm.city = citycode
  323. }
  324. _this.data.allcity.push(prov)
  325. _this.data.allcity.push(city)
  326. cityList.push(prov)
  327. cityList.push(city)
  328. // _this.loadActivity();
  329. /* console.log(cityList)
  330. _this.setData({
  331. allcity: _this.data.allcity
  332. })*/
  333. let e = {};
  334. e["detail"] = {
  335. column: 0,
  336. value: 0
  337. }
  338. _this.bindMultiPickerColumnChange(e)
  339. }
  340. })
  341. },
  342. /**
  343. * 生命周期函数--监听页面初次渲染完成
  344. */
  345. onReady: function () {
  346. },
  347. /**
  348. * 生命周期函数--监听页面显示
  349. */
  350. onShow: function () {
  351. },
  352. /**
  353. * 生命周期函数--监听页面隐藏
  354. */
  355. onHide: function () {
  356. },
  357. /**
  358. * 生命周期函数--监听页面卸载
  359. */
  360. onUnload: function () {
  361. },
  362. /**
  363. * 页面相关事件处理函数--监听用户下拉动作
  364. */
  365. onPullDownRefresh: function () {
  366. },
  367. /**
  368. * 页面上拉触底事件的处理函数
  369. */
  370. onReachBottom: function () {
  371. if (this.data.parmtwo.page < this.data.totalPage) {
  372. this.data.parmtwo.page++;
  373. this.loadData();
  374. }
  375. else if (this.data.parm.page < this.data.totalPage) {
  376. this.data.parm.page++;
  377. this.loadData();
  378. }
  379. },
  380. /**
  381. * 用户点击右上角分享
  382. */
  383. onShareAppMessage: function () {
  384. }
  385. })