index.js 6.0 KB

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