partDetail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. var app = getApp();
  2. var util = require("../../../../utils/util.js");
  3. let wxparse = require("../../../../wxParse/wxParse.js");
  4. let pageid = "";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. bottomLeft: app.bottomLeft,
  11. appAssetsUrl: app.appAssetsUrl,
  12. appAssetsUrl2: app.appAssetsUrl2,
  13. appAssetsUrl3: app.appAssetsUrl3,
  14. maskShow: false,
  15. options: {},
  16. isyn: false,
  17. vipid: util.getUserId(),
  18. detail: {
  19. tags: [],
  20. appraiseManageVoList: [],
  21. collect: false,
  22. },
  23. workContent: "",
  24. attention: "",
  25. member: {},
  26. time: 5,
  27. timer: null,
  28. isDjs: false,
  29. isShowPop: true,
  30. peopleList: [],
  31. people6: [],
  32. isMore: true,
  33. dotLeft: 0,
  34. vipMsg: "",
  35. isWx: false,
  36. isDev: true, //审核
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. pageid = options.id;
  43. let _this = this;
  44. let user = util.getUser();
  45. this.setData({
  46. options: {
  47. ...options,
  48. type: 1, //类型(1兼职 2活动)
  49. stuId: user ? user.id : "",
  50. },
  51. });
  52. _this.loadData();
  53. _this.addRead();
  54. _this.ready();
  55. _this.env();
  56. },
  57. collect: function () {
  58. let that = this;
  59. if (util.getUserId()) {
  60. app._post_form(
  61. "favorite/addOrCancelFavorite",
  62. "application/json", {
  63. sid: that.data.options.id,
  64. vipid: that.data.options.stuId,
  65. type: 1, //1:兼职 2:活动
  66. },
  67. function (res) {
  68. if (res.code == 0) {
  69. that.setData({
  70. detail: {
  71. ...that.data.detail,
  72. collect: !that.data.detail.collect,
  73. },
  74. });
  75. wx.showToast({
  76. title: that.data.detail.collect ? "收藏成功" : "取消收藏",
  77. icon: "success",
  78. duration: 2000,
  79. });
  80. }
  81. }
  82. );
  83. } else {
  84. wx.showToast({
  85. title: "没有登录,操作失败",
  86. icon: "fail",
  87. duration: 2000,
  88. });
  89. }
  90. },
  91. loadData: function () {
  92. let _this = this;
  93. wx.showLoading({
  94. title: "努力加载中...",
  95. });
  96. app._post_form("work/one", "", _this.data.options, function (res) {
  97. if (res.code === 0) {
  98. _this.setData({
  99. detail: res.data,
  100. });
  101. _this.getUser(res.data.id);
  102. if (res.data.isAppletsRelease == 1) {
  103. // 小程序发布
  104. _this.setData({
  105. isWx: true,
  106. });
  107. } else {
  108. // 后台发布
  109. _this.setData({
  110. isWx: false,
  111. });
  112. wxparse.wxParse(
  113. "workContent",
  114. "html",
  115. res.data.workContent,
  116. _this,
  117. 0
  118. );
  119. wxparse.wxParse("attention", "html", res.data.attention, _this, 0);
  120. }
  121. }
  122. });
  123. },
  124. // 获取参与人员
  125. getUser(id) {
  126. app._get(
  127. `work/participants`, {
  128. workId: id,
  129. },
  130. (res) => {
  131. if (res.code === 0) {
  132. this.setData({
  133. people6: res.list.slice(0, 6),
  134. peopleList: res.list,
  135. });
  136. }
  137. }
  138. );
  139. },
  140. /**
  141. * 生命周期函数--监听页面初次渲染完成
  142. */
  143. onReady: function () {
  144. //获得popup组件
  145. this.popup = this.selectComponent("#popup");
  146. this.popup2 = this.selectComponent("#popup2");
  147. this.popup0 = this.selectComponent("#popup0");
  148. this.popup3 = this.selectComponent("#popup3");
  149. this.popup4 = this.selectComponent("#popup4");
  150. this.popup5 = this.selectComponent("#popup5");
  151. },
  152. addRead() {
  153. app._post_form("read/num", "", {
  154. id: this.data.options.id,
  155. type: 1,
  156. });
  157. },
  158. /**
  159. * 生命周期函数--监听页面显示
  160. */
  161. onShow: function () {
  162. this.PushVipInfo();
  163. let user = util.getUser();
  164. this.setData({
  165. options: {
  166. ...this.data.options,
  167. stuId: user ? user.id : "",
  168. },
  169. });
  170. },
  171. /**
  172. * 生命周期函数--监听页面隐藏
  173. */
  174. onHide: function () {},
  175. /**
  176. * 页面相关事件处理函数--监听用户下拉动作
  177. */
  178. onPullDownRefresh: function () {},
  179. /**
  180. * 页面上拉触底事件的处理函数
  181. */
  182. onReachBottom: function () {},
  183. showShareMenu: function () {
  184. wx.showShareMenu();
  185. },
  186. hideShareMenu() {
  187. wx.hideShareMenu();
  188. },
  189. //查询会员信息
  190. PushVipInfo() {
  191. let _this = this;
  192. let id = util.getUserId();
  193. if (id) {
  194. app._post_form(
  195. "member/apiSelectMeberInfo",
  196. "application/json", {
  197. id
  198. },
  199. function (res) {
  200. if (res.code === 0) {
  201. _this.setData({
  202. member: res.member,
  203. });
  204. }
  205. }
  206. );
  207. }
  208. },
  209. /**
  210. * 用户点击右上角分享
  211. */
  212. onShareAppMessage() {
  213. this.addScore();
  214. return {
  215. title: "兼职详情",
  216. path: `/pages/home/index/partDetail/partDetail?id=${pageid}`,
  217. desc: "欢迎大家踊跃报名",
  218. };
  219. },
  220. //统计积分(每日小程序分享)
  221. addScore: function () {
  222. if (!util.getUserId()) {
  223. return;
  224. }
  225. let _this = this;
  226. wx.showLoading({
  227. title: "努力加载中...",
  228. });
  229. app._post_form(
  230. "scoreStu/share",
  231. "", {
  232. stuId: util.getUserId(),
  233. },
  234. function (res) {
  235. if (res.code === 0) {}
  236. }
  237. );
  238. },
  239. // 预览图片
  240. previewImage(e) {
  241. wx.previewImage({
  242. urls: e.currentTarget.dataset.images,
  243. current: e.currentTarget.dataset.images[e.currentTarget.dataset.index],
  244. });
  245. },
  246. // 判断是否开发huanjing
  247. env() {
  248. let that = this;
  249. app._post_form(
  250. "wgfillinfo/apiSelectwgfillinfo",
  251. "application/json",
  252. null,
  253. function (res) {
  254. if (res.code === 0) {
  255. that.setData({
  256. isDev: res.wgFillInfo.isDev,
  257. });
  258. }
  259. }
  260. );
  261. },
  262. submit() {
  263. let that = this;
  264. //报名满了
  265. if (this.data.detail.statusName != "预定中") {
  266. return;
  267. }
  268. if (util.UserLoginStatus()) {
  269. this.popup3.showPopup();
  270. this.setData({
  271. maskShow: true,
  272. isDjs: true,
  273. timer: setInterval(that.countDown, 1000),
  274. isShowPop: true
  275. })
  276. return
  277. if (
  278. (this.data.detail.isNeedVip && this.data.member.memberState > 0) ||
  279. !this.data.detail.isNeedVip
  280. ) {
  281. // wx.showModal({
  282. // title: '提示',
  283. // content: '您确定要报名该兼职吗',
  284. // success (res) {
  285. // if (res.confirm) {
  286. // that.signUp();
  287. // }
  288. // }
  289. // })
  290. that.popup4.showPopup();
  291. that.setData({
  292. maskShow: true,
  293. });
  294. } else {
  295. if (that.data.isDev) {
  296. wx.showToast({
  297. title: "暂未开始报名,请关注进度!",
  298. icon: "none",
  299. duration: 2000,
  300. });
  301. return;
  302. }
  303. // wx.showToast({
  304. // title: "您还不是会员,报名请联系平台客服处理",
  305. // icon: "none",
  306. // duration: 2000,
  307. // });
  308. that.popup.showPopup();
  309. that.setData({
  310. maskShow: true,
  311. });
  312. }
  313. }
  314. },
  315. showMore() {
  316. this.setData({
  317. isMore: !this.data.isMore,
  318. });
  319. },
  320. // 查看二维码
  321. seeCode() {
  322. if (!this.data.detail.workStuYN) {
  323. wx.showToast({
  324. title: "请报名后查看",
  325. icon: "error",
  326. duration: 2000,
  327. });
  328. return;
  329. }
  330. this.popup0.showPopup();
  331. this.setData({
  332. maskShow: true,
  333. });
  334. // let that = this
  335. // this.popup3.showPopup();
  336. // this.setData({
  337. // maskShow: true,
  338. // isDjs: true,
  339. // timer: setInterval(that.countDown, 1000)
  340. // })
  341. },
  342. //倒计时
  343. countDown() {
  344. var that = this;
  345. if (that.data.time <= 1) {
  346. this.setData({
  347. isDjs: false,
  348. time: 5,
  349. });
  350. clearInterval(that.data.timer);
  351. } else {
  352. --that.data.time;
  353. this.setData({
  354. isDjs: true,
  355. time: that.data.time,
  356. });
  357. }
  358. },
  359. // 我已知晓
  360. know() {
  361. if (this.data.isDjs) return;
  362. this.popup3.hidePopup();
  363. this.loadData();
  364. if (this.data.isShowPop) {
  365. this.setData({
  366. isShowPop: false,
  367. isDjs: false,
  368. maskShow: false,
  369. });
  370. // this.signUp();
  371. this.popup4.showPopup();
  372. }
  373. // if (!this.data.isDjs) {}
  374. },
  375. // 查看地图
  376. goLocal() {
  377. let that = this;
  378. let [latitude, longitude] = [
  379. this.data.detail.coordinate.split(",")[0],
  380. this.data.detail.coordinate.split(",")[1],
  381. ];
  382. console.log(Number(latitude), Number(longitude));
  383. wx.openLocation({
  384. latitude: Number(longitude),
  385. longitude: Number(latitude),
  386. name: that.data.detail.title,
  387. address: that.data.detail.address,
  388. success: function () {
  389. console.log("success");
  390. },
  391. });
  392. },
  393. usePoints() {
  394. this.setData({
  395. isShowPop: false
  396. })
  397. this.popup.hidePopup();
  398. this.signUp();
  399. },
  400. signUp() {
  401. let that = this;
  402. wx.showLoading({
  403. title: "提交中...",
  404. });
  405. app._post_form(
  406. "work/register",
  407. "", {
  408. wid: that.data.options.id,
  409. sid: that.data.options.stuId,
  410. },
  411. function (res) {
  412. if (res.code === 0) {
  413. wx.hideToast();
  414. wx.showToast({
  415. title: "报名成功",
  416. icon: "none",
  417. });
  418. if (that.data.isShowPop) {
  419. that.popup3.hidePopup();
  420. that.setData({
  421. isShowPop: false,
  422. isDjs: true,
  423. maskShow: true,
  424. timer: setInterval(that.countDown, 1000),
  425. })
  426. } else {
  427. that.setData({
  428. isShowPop: false,
  429. isDjs: false,
  430. maskShow: false,
  431. });
  432. }
  433. that.loadData();
  434. setTimeout(() => {
  435. that.popup0.showPopup();
  436. that.setData({
  437. maskShow: true,
  438. });
  439. // wx.redirectTo({
  440. // url: '/pages/my/myTimejob/myTimejob',
  441. // })
  442. }, 1000);
  443. } else if (res.code == 502) {
  444. setTimeout(() => {
  445. that.loadData()
  446. }, 500);
  447. } else if (res.code == 500 && res.msg == "积分不足") {
  448. that.popup5.showPopup();
  449. } else if (res.msg == "请完善学籍认证后进行报名操作") {
  450. wx.hideToast();
  451. that.popup2.showPopup();
  452. }
  453. if (res.code != 0) {
  454. that.setData({
  455. isShowPop: true,
  456. });
  457. }
  458. }
  459. );
  460. },
  461. // 会员必读
  462. ready() {
  463. let _this = this;
  464. app._post_form(
  465. "wgfillinfo/apiSelectwgfillinfo",
  466. "application/json",
  467. null,
  468. function (res) {
  469. if (res.code === 0) {
  470. // _this.setData({
  471. // vipMsg: res.wgFillInfo.vipMessage
  472. // })
  473. wxparse.wxParse(
  474. "vipMsg",
  475. "html",
  476. res.wgFillInfo.vipMessage,
  477. _this,
  478. 0
  479. );
  480. }
  481. }
  482. );
  483. },
  484. //取消事件
  485. _error(e) {
  486. this[e.currentTarget.dataset.name].hidePopup();
  487. this.setData({
  488. maskShow: false,
  489. isDjs: false,
  490. time: 5,
  491. });
  492. clearInterval(this.data.timer);
  493. },
  494. //确认事件
  495. _success(e) {
  496. let that = this;
  497. if (e.currentTarget.dataset.name == "popup0") { } else if (e.currentTarget.dataset.name == "popup4") {
  498. if (that.data.detail.isNeedVip && that.data.member.memberState > 0) {
  499. // that.popup3.showPopup();
  500. // that.setData({
  501. // maskShow: true,
  502. // isDjs: true,
  503. // timer: setInterval(that.countDown, 1000),
  504. // });
  505. this.signUp();
  506. console.log("会员");
  507. } else {
  508. // that.popup3.hidePopup();
  509. that.setData({
  510. isShowPop: false
  511. })
  512. // console.log("非会员", that.data.detail.isNeedVip);
  513. if (that.data.detail.isNeedVip) {
  514. that.popup.showPopup();
  515. } else {
  516. that.signUp();
  517. }
  518. console.log("非会员");
  519. }
  520. } else if (e.currentTarget.dataset.name == "popup2") {
  521. wx.navigateTo({
  522. url: "/pages/my/myStudy/myStudy",
  523. });
  524. } else if (e.currentTarget.dataset.name == "popup5") {
  525. wx.navigateTo({
  526. url: "/pages/checkin/index",
  527. });
  528. } else {
  529. wx.navigateTo({
  530. url: e.currentTarget.dataset.name == "popup" ?
  531. "/pages/myMember/myMember" : "/pages/my/myData/myData",
  532. });
  533. }
  534. this.setData({
  535. maskShow: false,
  536. });
  537. this[e.currentTarget.dataset.name].hidePopup();
  538. },
  539. seeBigCode(e) {
  540. let arr = [this.data.detail.qrCodePicture];
  541. wx.previewImage({
  542. urls: arr, // 需要预览的图片http链接列表
  543. });
  544. },
  545. onUnload: function () {
  546. clearInterval(this.data.timer);
  547. },
  548. });