index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. import {
  2. getPositionDetail,
  3. positionApply,
  4. groupApply,
  5. groupList,
  6. saveFavoritePosition
  7. } from '../../services/index.js'
  8. import {
  9. imgServerUrl
  10. } from '../../config/config.js'
  11. import {
  12. showToast
  13. } from '../../utils/tips.js'
  14. const WxParse = require('../../plugins/wxParse/wxParse.js');
  15. // var $ = require('../../libs/gdconf.js');
  16. const app = getApp();
  17. Page({
  18. data: {
  19. imgServerUrl: imgServerUrl,
  20. hpPositionId: 0,
  21. positionCategory: 0, //0:全职 1:兼职 2:入职奖励 3:高薪急聘 4:拼团岗位 5:福利岗位 8:自发布全职 9:自发布兼职
  22. isShowList: false,
  23. clearTimer: false,
  24. comScale: '',
  25. comType: '',
  26. myFormat: ['天', '时', '分', '秒'],
  27. authMask: false,
  28. detailArray: [],
  29. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  30. detailIndex: 0, //详情指引
  31. isApply: false,
  32. storeAction: [],
  33. showJoinPt: false, //显示加入拼工
  34. showAllPt: false, //显示所有拼工
  35. allPtList: [],
  36. leftTime: 0,
  37. isEnd: 0, //岗位是否已结束0:未结束;1:结束
  38. myGroupId: '', //我的拼团id
  39. groupId: '', //拼团id
  40. inviteUser_id: '', //拼团邀请人
  41. isFarovite: false, //是否收藏
  42. maxReward: 0, //入职最高奖励
  43. minReward: 0, //入职最低奖励
  44. },
  45. onLoad: function(options) {
  46. console.log(options)
  47. this.setData({
  48. hpPositionId: options.hpPositionId,
  49. positionCategory: options.cate || 0,
  50. })
  51. },
  52. onShow: function() {
  53. this.fetchData();
  54. this.fetchPtList();
  55. },
  56. onShareAppMessage: function() {
  57. var shareToken = wx.getStorageSync('shareToken')
  58. var hpuser = wx.getStorageSync('hpuser');
  59. return {
  60. title: '开心工作入职有奖',
  61. path: '/pages/detail/index?cate=' + this.data.positionCategory + '&hpPositionId=' + this.data.hpPositionId,
  62. imageUrl: ''
  63. }
  64. },
  65. //获取岗位详情
  66. fetchData() {
  67. let paramsObj = {
  68. position_category: this.data.positionCategory,
  69. id: this.data.hpPositionId,
  70. }
  71. Object.assign(paramsObj);
  72. getPositionDetail(paramsObj).then(data => {
  73. console.log(data)
  74. let postitionDetail = {};
  75. let groupLessList = {};
  76. var leftTime = 0;
  77. var myGroupId = '';
  78. switch (this.data.positionCategory) {
  79. case "0":
  80. postitionDetail = data.data.hpFulltimePosition
  81. break;
  82. case "1":
  83. postitionDetail = data.data.hpParttimePosition
  84. break;
  85. case "2":
  86. postitionDetail = data.data.hpRewardPosition
  87. break;
  88. case "3":
  89. postitionDetail = data.data.hpGoodmoneyPosition
  90. break;
  91. case "4":
  92. postitionDetail = data.data.hpGroupPosition;
  93. leftTime = data.data.hpGroupPosition.groupEndTime;
  94. groupLessList = data.data.groupLessList;
  95. myGroupId = data.data.myGroupId;
  96. var maxReward;
  97. var minReward;
  98. var femaleReward = data.data.hpGroupPosition.femaleReward;
  99. var maleReward = data.data.hpGroupPosition.maleReward;
  100. var fiveGroupCashback = data.data.hpGroupPosition.fiveGroupCashback;
  101. var threeGroupCashback = data.data.hpGroupPosition.threeGroupCashback;
  102. var hasReward = data.data.hpGroupPosition.hasReward;
  103. if (hasReward == 1) {
  104. if (maleReward >= femaleReward) {
  105. maxReward = fiveGroupCashback + maleReward;
  106. minReward = femaleReward;
  107. } else {
  108. maxReward = fiveGroupCashback + femaleReward;
  109. minReward = maleReward;
  110. }
  111. } else {
  112. maxReward = fiveGroupCashback;
  113. minReward = 0;
  114. }
  115. this.setData({
  116. maxReward: maxReward,
  117. minReward: minReward
  118. })
  119. break;
  120. case "5":
  121. postitionDetail = data.data.hpWelfarePosition
  122. break;
  123. case "8":
  124. postitionDetail = data.data.hpFulltimePosition
  125. break;
  126. case "9":
  127. postitionDetail = data.data.hpParttimePosition
  128. break;
  129. }
  130. if (data.data.isEnd == 1) {
  131. this.setData({
  132. isEnd: data.data.isEnd
  133. })
  134. console.log("该岗位已结束")
  135. } else {
  136. console.log("该岗位未结束")
  137. }
  138. this.setData({
  139. postitionDetail: postitionDetail,
  140. isApply: data.data.isApply,
  141. leftTime: leftTime,
  142. storeAction: groupLessList,
  143. myGroupId: myGroupId,
  144. isFarovite: data.data.isFarovite
  145. })
  146. //富文本转义
  147. var detailArray = [];
  148. if (postitionDetail.hpWelfarePositionDetailList != null && postitionDetail.hpWelfarePositionDetailList.length > 0) {
  149. for (var i = 0; i < postitionDetail.hpWelfarePositionDetailList.length; i++) {
  150. var ss = WxParse.wxParse('positionDetail', 'html', postitionDetail.hpWelfarePositionDetailList[i].positionDetail, this);
  151. detailArray.push(ss);
  152. }
  153. this.setData({
  154. detailArray: detailArray
  155. })
  156. }
  157. //富文本转义
  158. if (postitionDetail.applyCondition) {
  159. WxParse.wxParse('applyCondition', 'html', postitionDetail.applyCondition, this);
  160. }
  161. this.getNodePos();
  162. })
  163. },
  164. //获取所有拼工列表
  165. fetchPtList() {
  166. if (this.data.isEnd == 1) {
  167. showToast('拼团已结束')
  168. return false
  169. }
  170. let paramsObj = {
  171. positionCategory: this.data.positionCategory,
  172. positionId: this.data.hpPositionId,
  173. user_id: app.globalData.userId,
  174. user_token: app.globalData.userToken
  175. }
  176. Object.assign(paramsObj);
  177. groupList(paramsObj).then(data => {
  178. console.log("allpt", data)
  179. this.setData({
  180. allPtList: data.data.groupList
  181. })
  182. })
  183. },
  184. //申请工作
  185. applyJob(e) {
  186. var self = this;
  187. wx.showModal({
  188. title: '提示',
  189. content: '确定提交申请吗?',
  190. success: function(res) {
  191. if (res.confirm) {
  192. let {
  193. formId
  194. } = e.detail;
  195. let paramsObj = {
  196. positionCategory: self.data.positionCategory,
  197. positionId: self.data.hpPositionId,
  198. user_id: app.globalData.userId,
  199. user_token: app.globalData.userToken
  200. }
  201. Object.assign(paramsObj);
  202. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionId=' + self.data.hpPositionId + "&positionCategory=" + self.data.positionCategory)
  203. positionApply(paramsObj).then(data => {
  204. showToast('申请职位成功', 'success')
  205. setTimeout(function() {
  206. wx.navigateBack();
  207. }, 2000)
  208. })
  209. } else if (res.cancel) {
  210. }
  211. }
  212. })
  213. },
  214. //申请开团
  215. applyPt(e) {
  216. var self = this;
  217. wx.showModal({
  218. title: '提示',
  219. content: '确定提交开团申请吗?',
  220. success: function(res) {
  221. if (res.confirm) {
  222. let {
  223. formId
  224. } = e.detail;
  225. let paramsObj = {
  226. // groupId: self.data.groupId,
  227. // inviteUser_id: self.data.inviteUser_id,
  228. positionCategory: self.data.positionCategory,
  229. positionId: self.data.hpPositionId,
  230. user_id: app.globalData.userId,
  231. user_token: app.globalData.userToken
  232. }
  233. Object.assign(paramsObj);
  234. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionId=' + self.data.hpPositionId + "&positionCategory=" + self.data.positionCategory)
  235. groupApply(paramsObj).then(data => {
  236. var hpPositionGroupId = data.data.hpApplyPosition.groupId
  237. console.log("ff22", data);
  238. showToast("开团成功");
  239. wx.navigateTo({
  240. url: '../pt-detail/index?gd=' + hpPositionGroupId + '&pc' + self.data.positionCategory + '&pd=' + self.data.hpPositionId,
  241. })
  242. })
  243. } else if (res.cancel) {
  244. }
  245. }
  246. })
  247. },
  248. //我的拼团
  249. myApply() {
  250. var self = this;
  251. wx.navigateTo({
  252. url: '../pt-detail/index?gd=' + self.data.myGroupId + '&pc=' + self.data.positionCategory + '&pd=' + self.data.hpPositionId,
  253. })
  254. },
  255. //拨打手机号
  256. phoneCall() {
  257. if (this.data.postitionDetail.contactPhone) {
  258. wx.makePhoneCall({
  259. phoneNumber: this.data.postitionDetail.contactPhone,
  260. success: function(data) {
  261. console.log(data)
  262. },
  263. fail: function(data) {
  264. console.log(data)
  265. }
  266. })
  267. } else {
  268. showToast('暂无手机号')
  269. }
  270. },
  271. //查看线路
  272. toRoadsLine() {
  273. wx.navigateTo({
  274. url: '../roadsLine/index',
  275. })
  276. },
  277. // 获取公司规模描述
  278. getComScale(lower, high) {
  279. if (!lower || lower == 0) {
  280. return high + '人以下'
  281. }
  282. if (!high || high == 0) {
  283. return lower + '人以上'
  284. }
  285. return lower + '-' + high + '人'
  286. },
  287. //获取位置
  288. getNodePos() {
  289. if (this.data.positionCategory != 5) {
  290. var query = wx.createSelectorQuery()
  291. query.select('#base').boundingClientRect()
  292. query.select('#require').boundingClientRect()
  293. query.select('#otherWelfare').boundingClientRect()
  294. query.select('#jieshao').boundingClientRect()
  295. var that = this;
  296. query.exec(function(res) {
  297. console.log(res)
  298. that.setData({
  299. basePos: res[0].top - 40,
  300. requirePos: res[1].top - 40,
  301. otherWelfarePos: res[2].top - 40,
  302. jieshaoPos: res[3].top - 40
  303. })
  304. })
  305. }
  306. },
  307. //距离页面滚动
  308. goDeatil: function(e) {
  309. var index = e.currentTarget.dataset.index;
  310. this.setData({
  311. detailIndex: index
  312. })
  313. let top = e.currentTarget.dataset.top
  314. wx.pageScrollTo({
  315. scrollTop: top,
  316. duration: 0
  317. })
  318. },
  319. // 加入拼工
  320. joinPt(e) {
  321. var index = e.currentTarget.dataset.index;
  322. console.log("joinptindex", index)
  323. this.setData({
  324. showAllPt: false,
  325. showJoinPt: true,
  326. joinPtList: this.data.storeAction[index]
  327. })
  328. console.log("DFD", this.data.joinPtList)
  329. },
  330. // 加入拼工(所有拼工)
  331. joinPt_1(e) {
  332. var index = e.currentTarget.dataset.index;
  333. console.log("joinptindex", index)
  334. this.setData({
  335. showAllPt: false,
  336. showJoinPt: true,
  337. joinPtList: this.data.allPtList[index]
  338. })
  339. },
  340. hideJoinPt() {
  341. this.setData({
  342. showJoinPt: false
  343. })
  344. },
  345. cancelPt() {
  346. this.setData({
  347. showJoinPt: false
  348. })
  349. },
  350. //加入拼工,进入拼工详情
  351. confirmPt(e) {
  352. var self = this;
  353. var groupId = e.currentTarget.dataset.groupid;
  354. self.setData({
  355. showJoinPt: false
  356. })
  357. wx.navigateTo({
  358. url: '../pt-detail/index?gd=' + groupId + '&pc=' + self.data.positionCategory + '&pd=' + self.data.hpPositionId,
  359. })
  360. },
  361. // 所有拼工
  362. allPt(e) {
  363. this.setData({
  364. showAllPt: true
  365. })
  366. },
  367. hideAllPt() {
  368. this.setData({
  369. showAllPt: false
  370. })
  371. },
  372. hideAuth() {
  373. this.setData({
  374. authMask: false
  375. })
  376. },
  377. submitInfo(e) {
  378. console.log('form发生了submit事件,事件数据为:', e)
  379. },
  380. toPt() {
  381. wx.navigateTo({
  382. url: '../document/pt'
  383. })
  384. },
  385. toFanxian() {
  386. wx.navigateTo({
  387. url: '../document/fanxian'
  388. })
  389. },
  390. imageLoad() {
  391. var that = this
  392. var query = wx.createSelectorQuery()
  393. query.select('.wel_top').boundingClientRect()
  394. query.exec(function(res) {
  395. console.log(res)
  396. that.setData({
  397. swiperH: res[0].height
  398. })
  399. })
  400. },
  401. onError(err) {
  402. app.aldstat.sendEvent('报错', {
  403. 'err': err
  404. });
  405. },
  406. //跳转工作地址列表
  407. toaddressdetail() {
  408. wx.setStorageSync("addressList", this.data.postitionDetail.hpPositionAddressList);
  409. wx.navigateTo({
  410. url: '../address/index',
  411. })
  412. },
  413. //收藏岗位
  414. favourate() {
  415. var self = this;
  416. var isFavorite = self.data.isFarovite ? 0 : 1;
  417. let paramsObj = {
  418. positionCategory: self.data.positionCategory,
  419. positionId: self.data.hpPositionId,
  420. user_id: app.globalData.userId,
  421. user_token: app.globalData.userToken,
  422. isFavorite: isFavorite
  423. }
  424. Object.assign(paramsObj);
  425. saveFavoritePosition(paramsObj).then(data => {
  426. console.log("sssccc", data.data.isFavorite);
  427. if (data.data.isFavorite) {
  428. showToast('收藏成功');
  429. } else {
  430. showToast('取消收藏');
  431. }
  432. self.setData({
  433. isFarovite: data.data.isFavorite
  434. })
  435. })
  436. },
  437. })