index.js 11 KB

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