index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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:福利岗位
  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. },
  30. onLoad: function(options) {
  31. console.log(options)
  32. this.setData({
  33. hpPositionId: options.hpPositionId,
  34. positionCategory: options.cate || 0,
  35. })
  36. },
  37. onShow: function() {
  38. if (app.globalData.userInfo) {
  39. console.log('有info===', app.globalData)
  40. this.fetchData()
  41. } else if (this.data.canIUse) {
  42. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  43. // 所以此处加入 callback 以防止这种情况
  44. app.userInfoReadyCallback = res => {
  45. console.log('userInfoReadyCallback===', app.globalData)
  46. this.fetchData()
  47. }
  48. } else {
  49. // 在没有 open-type=getUserInfo 版本的兼容处理
  50. wx.getUserInfo({
  51. success: res => {
  52. app.globalData.userInfo = res.userInfo
  53. console.log('兼容处理===', app.globalData)
  54. this.fetchData()
  55. }
  56. })
  57. }
  58. },
  59. onShareAppMessage: function() {
  60. var shareToken = wx.getStorageSync('shareToken')
  61. return {
  62. title: '开心工作入职有奖',
  63. path: `/pages/detail/index?shareToken=${shareToken}&positionCategory=${this.data.positionCategory}&hpPositionId=${this.data.hpPositionId}`,
  64. imageUrl: ''
  65. }
  66. },
  67. //获取岗位详情
  68. fetchData() {
  69. let paramsObj = {
  70. position_category: this.data.positionCategory,
  71. id: this.data.hpPositionId,
  72. user_id: app.globalData.userId,
  73. user_token: app.globalData.userToken
  74. }
  75. Object.assign(paramsObj);
  76. getPositionDetail(paramsObj).then(data => {
  77. console.log(data)
  78. let postitionDetail = {};
  79. switch (this.data.positionCategory) {
  80. case "0":
  81. postitionDetail = data.data.hpFulltimePosition
  82. break;
  83. case "1":
  84. postitionDetail = data.data.hpParttimePosition
  85. break;
  86. case "2":
  87. postitionDetail = data.data.hpRewardPosition
  88. break;
  89. case "3":
  90. postitionDetail = data.data.hpGoodmoneyPosition
  91. break;
  92. case "4":
  93. postitionDetail = data.data.hpGroupPosition
  94. break;
  95. case "5":
  96. postitionDetail = data.data.hpWelfarePosition
  97. break;
  98. }
  99. // let isOpen;
  100. // if (this.data.positionCategory != 4) {
  101. // isOpen = Date.parse(new Date()) < Date.parse(postitionDetail.endTime);
  102. // } else {
  103. // isOpen = Date.parse(new Date()) < postitionDetail.groupEndTime;
  104. // }
  105. this.setData({
  106. postitionDetail: postitionDetail,
  107. // isOpen: isOpen,
  108. isApply: data.data.isApply
  109. })
  110. //富文本转义
  111. var detailArray = [];
  112. if (postitionDetail.hpWelfarePositionDetailList != null && postitionDetail.hpWelfarePositionDetailList.length > 0) {
  113. for (var i = 0; i < postitionDetail.hpWelfarePositionDetailList.length; i++) {
  114. var ss = WxParse.wxParse('positionDetail', 'html', postitionDetail.hpWelfarePositionDetailList[i].positionDetail, this);
  115. detailArray.push(ss);
  116. }
  117. this.setData({
  118. detailArray: detailArray
  119. })
  120. }
  121. //富文本转义
  122. if (postitionDetail.applyCondition) {
  123. WxParse.wxParse('applyCondition', 'html', postitionDetail.applyCondition, this);
  124. }
  125. })
  126. },
  127. //获取拼团列表
  128. fetchPtList() {
  129. // if (!this.data.isOpen) {
  130. // showToast('拼团已结束')
  131. // return false
  132. // }
  133. groupList(this.data.hpPositionId).then(data => {
  134. console.log(data)
  135. this.setData({
  136. isShowList: true,
  137. ptList: data.list.map(item => {
  138. item.leftTime = new Date().getTime() + item.leftTime * 1000
  139. item.leaderName = decodeURIComponent(item.leaderName)
  140. return item
  141. })
  142. })
  143. })
  144. },
  145. //申请工作
  146. applyJob(e) {
  147. var self = this;
  148. wx.showModal({
  149. title: '提示',
  150. content: '确定提交申请吗?',
  151. success: function(res) {
  152. if (res.confirm) {
  153. let {
  154. formId
  155. } = e.detail;
  156. let paramsObj = {
  157. positionCategory: self.data.positionCategory,
  158. positionId: self.data.hpPositionId,
  159. user_id: app.globalData.userId,
  160. user_token: app.globalData.userToken
  161. }
  162. Object.assign(paramsObj);
  163. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionId=' + self.data.hpPositionId + "&positionCategory=" + self.data.positionCategory)
  164. positionApply(paramsObj).then(data => {
  165. showToast('申请职位成功', 'success')
  166. wx.navigateBack();
  167. })
  168. } else if (res.cancel) {
  169. }
  170. }
  171. })
  172. },
  173. //申请开团
  174. applyPt(e) {
  175. wx.showModal({
  176. title: '提示',
  177. content: '确定提交申请吗?',
  178. success: function(res) {
  179. if (res.confirm) {
  180. let {
  181. formId
  182. } = e.detail;
  183. let paramsObj = {
  184. positionCategory: this.data.positionCategory,
  185. positionId: this.data.hpPositionId,
  186. user_id: app.globalData.userId,
  187. user_token: app.globalData.userToken
  188. }
  189. Object.assign(paramsObj);
  190. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionId=' + this.data.hpPositionId + "&positionCategory=" + this.data.positionCategory)
  191. groupApply(paramsObj).then(data => {
  192. // var hpPositionGroupId = data.data.hpPositionGroupId
  193. console.log("ff22", data);
  194. wx.navigateTo({
  195. url: '../result/index?positionCategory=' + this.data.positionCategory + '&status=1&hpPositionGroupId=' + this.data.hpPositionId,
  196. })
  197. })
  198. } else if (res.cancel) {
  199. }
  200. }
  201. })
  202. },
  203. //参与拼团
  204. joinTuan(e) {
  205. let {
  206. formId
  207. } = e.detail
  208. let {
  209. groupid
  210. } = e.currentTarget.dataset;
  211. let paramsObj = {
  212. positionCategory: this.data.positionCategory,
  213. positionId: this.data.hpPositionId,
  214. user_id: app.globalData.userId,
  215. user_token: app.globalData.userToken,
  216. groupId: e.currentTarget.dataset.groupid
  217. }
  218. Object.assign(paramsObj);
  219. wx.setStorageSync('resumeUrl', '/pages/user-info/user-info?hpPositionGroupId=' + groupid + "&formId=" + formId)
  220. groupApply(paramsObj).then(data => {
  221. wx.navigateTo({
  222. url: '../pt-detail/index?hpPositionGroupId=' + groupid,
  223. })
  224. })
  225. },
  226. //查看拼团
  227. catPt() {
  228. wx.navigateTo({
  229. url: '../pt-detail/index?hpPositionGroupId=' + this.data.hpPositionGroupId,
  230. })
  231. },
  232. //隐藏拼团列表模态框
  233. hideModal() {
  234. this.setData({
  235. isShowList: false
  236. })
  237. },
  238. //拨打手机号
  239. phoneCall() {
  240. if (this.data.postitionDetail.contactPhone) {
  241. wx.makePhoneCall({
  242. phoneNumber: this.data.postitionDetail.contactPhone,
  243. success: function(data) {
  244. console.log(data)
  245. },
  246. fail: function(data) {
  247. console.log(data)
  248. }
  249. })
  250. } else {
  251. showToast('暂无手机号')
  252. }
  253. },
  254. //查看线路
  255. toRoadsLine() {
  256. wx.navigateTo({
  257. url: '../roadsLine/index',
  258. })
  259. },
  260. //倒计时回调
  261. myLinsterner() {
  262. this.fetchPtList()
  263. },
  264. // 获取公司规模描述
  265. getComScale(lower, high) {
  266. if (!lower || lower == 0) {
  267. return high + '人以下'
  268. }
  269. if (!high || high == 0) {
  270. return lower + '人以上'
  271. }
  272. return lower + '-' + high + '人'
  273. },
  274. //获取位置
  275. getNodePos() {
  276. var query = wx.createSelectorQuery()
  277. query.select('#base').boundingClientRect()
  278. query.select('#require').boundingClientRect()
  279. query.select('#otherWelfare').boundingClientRect()
  280. query.select('#jieshao').boundingClientRect()
  281. var that = this;
  282. query.exec(function(res) {
  283. console.log(res)
  284. that.setData({
  285. basePos: res[0].top - 40,
  286. requirePos: res[1].top - 40,
  287. otherWelfarePos: res[2].top - 40,
  288. jieshaoPos: res[3].top - 40
  289. })
  290. })
  291. },
  292. //距离页面滚动
  293. scrollTop(e) {
  294. let top = e.currentTarget.dataset.top
  295. wx.pageScrollTo({
  296. scrollTop: top,
  297. duration: 0
  298. })
  299. },
  300. // tomap() {
  301. // var that = this
  302. // wx.showLoading({ title: 'loading', mask: true });
  303. // //获得当前位置坐标
  304. // $.map.getRegeo({
  305. // success(data) {
  306. // wx.hideLoading();
  307. // var data = data[0], cityd = data.regeocodeData.addressComponent.province;
  308. // let POIlongitude = that.data.comLocation.split(",")[0]
  309. // let POIlatitude = that.data.comLocation.split(",")[1]
  310. // let obj = {
  311. // POIlocation: that.data.comLocation,
  312. // POIlongitude: POIlongitude,
  313. // POIlatitude: POIlatitude,
  314. // address: '',
  315. // city: that.data.cityName,
  316. // cityd: cityd,
  317. // fromhistory: "0",
  318. // latitude: data.latitude,
  319. // longitude: data.longitude,
  320. // name: that.data.addrDetail,
  321. // saddress: data.name,
  322. // sname: "我的位置",
  323. // }
  324. // let params = ''
  325. // for (let key in obj) {
  326. // params += key + "=" + obj[key] + "&"
  327. // }
  328. // wx.navigateTo({
  329. // url: '../gdmap/index?' + params,
  330. // })
  331. // },
  332. // fail(data){
  333. // wx.hideLoading();
  334. // that.setData({
  335. // authMask:true
  336. // })
  337. // }
  338. // });
  339. // },
  340. hideAuth() {
  341. this.setData({
  342. authMask: false
  343. })
  344. },
  345. submitInfo(e) {
  346. console.log('form发生了submit事件,事件数据为:', e)
  347. },
  348. toPt() {
  349. wx.navigateTo({
  350. url: '../document/pt'
  351. })
  352. },
  353. toFanxian() {
  354. wx.navigateTo({
  355. url: '../document/fanxian'
  356. })
  357. },
  358. imageLoad() {
  359. var that = this
  360. var query = wx.createSelectorQuery()
  361. query.select('.wel_top').boundingClientRect()
  362. query.exec(function(res) {
  363. console.log(res)
  364. that.setData({
  365. swiperH: res[0].height
  366. })
  367. })
  368. },
  369. onError(err) {
  370. app.aldstat.sendEvent('报错', {
  371. 'err': err
  372. });
  373. },
  374. })