index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. import {
  2. getBanner,
  3. getIndexList
  4. } from '../../services/index.js'
  5. import {
  6. imgServerUrl
  7. } from '../../config/config.js'
  8. Page({
  9. data: {
  10. //banner图
  11. imgList: [],
  12. activity: [{
  13. src: imgServerUrl + "/images/happyjob/quanzhi.png",
  14. text: "全职工作"
  15. },
  16. {
  17. src: imgServerUrl + "/images/happyjob/jianzhi.png",
  18. text: "兼职工作"
  19. },
  20. {
  21. src: imgServerUrl + "/images/happyjob/fanxian.png",
  22. text: "入职奖励"
  23. },
  24. {
  25. src: imgServerUrl + "/images/happyjob/jipin.png",
  26. text: "高薪急聘"
  27. }
  28. ],
  29. activity_two: [{
  30. src: imgServerUrl + "/images/happyjob/fuli.png"
  31. },
  32. {
  33. src: imgServerUrl + "/images/happyjob/quanmin.png"
  34. }
  35. ],
  36. cityCode: '',
  37. keyWord: '',
  38. pageNo: 1, //当前分页
  39. isScroll: true, //是否可以滚动
  40. filter: -1, //岗位类型
  41. userInfo: {},
  42. hasUserInfo: false,
  43. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  44. list: [],
  45. showNoMore: "没有更多信息...", //显示已无更多
  46. broadcastList: [],
  47. imgServerUrl: imgServerUrl,
  48. hasLocation1: true,
  49. disclaimer: false, //是否展示防欺诈弹窗 默认不弹出
  50. },
  51. onLoad: function () {
  52. // 如果传进来的值是 '1' 则展示防欺诈弹窗
  53. if (!wx.getStorageSync('disclaimer')) {
  54. wx.hideTabBar({
  55. success: () => {
  56. this.setData({
  57. disclaimer: true
  58. })
  59. }
  60. })
  61. }
  62. },
  63. reload() {
  64. this.onPullDownRefresh();
  65. },
  66. start() {
  67. this.fetchBanner();
  68. this.fetchList();
  69. },
  70. onShow: function () {
  71. this.setData({
  72. cityName: wx.getStorageSync('city') || '无锡',
  73. cityCode: wx.getStorageSync('cityCode') || '320200',
  74. pageNo: 1, //当前分页
  75. isScroll: true, //是否可以滚动
  76. filter: -1, //岗位类型
  77. list: [],
  78. }, _ => {
  79. this.start();
  80. })
  81. },
  82. //下拉刷新
  83. onPullDownRefresh: function () {
  84. this.setData({
  85. pageNo: 1, //当前分页
  86. isScroll: true, //是否可以滚动
  87. filter: -1, //岗位类型
  88. list: [],
  89. }, _ => {
  90. this.start();
  91. })
  92. },
  93. //上拉加载
  94. onReachBottom: function () {
  95. var pageNo = this.data.pageNo + 1;
  96. this.setData({
  97. pageNo
  98. })
  99. this.fetchList();
  100. },
  101. onShareAppMessage: function () {
  102. },
  103. // 获取banner图
  104. fetchBanner() {
  105. let paramsObj = {
  106. application: 0
  107. }
  108. Object.assign(paramsObj);
  109. getBanner(paramsObj).then(data => {
  110. this.setData({
  111. imgList: data.data.bannerList,
  112. broadcastList: data.data.broadcastList
  113. })
  114. })
  115. },
  116. //获取热门列表数据
  117. fetchList() {
  118. if (!this.data.isScroll) {
  119. return false
  120. }
  121. let paramsObj = {
  122. cityCode: this.data.cityCode,
  123. pageNo: this.data.pageNo
  124. }
  125. getIndexList(Object.assign(paramsObj)).then(data => {
  126. var pageNo = data.data.pageNo;
  127. let setData = {};
  128. // 是否可以滚动加载数据
  129. if (data.data.isLast) {
  130. setData.isScroll = false
  131. }
  132. if (data.data.hotPosition.length != 0) {
  133. setData.list = this.data.list.concat(data.data.hotPosition)
  134. setData.pageNo = pageNo;
  135. } else {
  136. setData.list = this.data.list;
  137. }
  138. this.setData({
  139. offline: false,
  140. ...setData
  141. })
  142. }).catch(() => {
  143. this.setData({
  144. offline: true
  145. })
  146. })
  147. },
  148. //改变列表
  149. changeList(e) {
  150. const {
  151. index
  152. } = e.currentTarget.dataset
  153. this.workType(index)
  154. if (index === 1) {
  155. wx.aldPushSubscribeMessage({
  156. eventId: '5ea271177739104342928e99'
  157. });
  158. }
  159. },
  160. //判断当前工作类型
  161. workType(index) {
  162. switch (index) {
  163. case 0:
  164. wx.navigateTo({
  165. url: '../fulltime/index',
  166. })
  167. break;
  168. case 1:
  169. wx.navigateTo({
  170. url: '../parttime/index',
  171. })
  172. break;
  173. case 2:
  174. wx.navigateTo({
  175. url: '../reward/index',
  176. })
  177. break;
  178. case 3:
  179. wx.navigateTo({
  180. url: '../jipin/index',
  181. })
  182. break;
  183. }
  184. },
  185. changeList2(e) {
  186. const {
  187. index
  188. } = e.currentTarget.dataset
  189. this.workType2(index)
  190. },
  191. workType2(index) {
  192. switch (index) {
  193. case 0:
  194. wx.navigateTo({
  195. url: '../fuli/index',
  196. })
  197. break;
  198. case 1:
  199. wx.navigateTo({
  200. url: '../agent/index',
  201. })
  202. break;
  203. }
  204. },
  205. //去详情页
  206. toDetail(e) {
  207. const {
  208. id,
  209. cate
  210. } = e.detail;
  211. wx.navigateTo({
  212. url: '../detail/index?hpPositionId=' + id + "&cate=" + cate
  213. })
  214. },
  215. //轮播图跳转详情页
  216. toDetail_slide(e) {
  217. var id = e.currentTarget.dataset.id;
  218. var url = e.currentTarget.dataset.url;
  219. var arr;
  220. if (id) {
  221. arr = id.split(",");
  222. var positionId = arr[1];
  223. var cate = arr[0];
  224. wx.navigateTo({
  225. url: '../detail/index?hpPositionId=' + positionId + "&cate=" + cate,
  226. })
  227. } else if (url) {
  228. wx.navigateTo({
  229. url: '../web-view/web-view?url=' + url,
  230. })
  231. }
  232. },
  233. // 去搜索页
  234. toSearch() {
  235. wx.navigateTo({
  236. url: '../search/index',
  237. })
  238. },
  239. // 去城市选择页
  240. toCity() {
  241. wx.navigateTo({
  242. url: '../city/index',
  243. })
  244. },
  245. // 知晓规则
  246. knowDisclaimer() {
  247. this.setData({
  248. disclaimer: false
  249. })
  250. wx.showTabBar({
  251. success: _ => {
  252. wx.setStorageSync('disclaimer', true)
  253. }
  254. })
  255. }
  256. })