partDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. },
  151. addRead() {
  152. app._post_form("read/num", "", {
  153. id: this.data.options.id,
  154. type: 1,
  155. });
  156. },
  157. /**
  158. * 生命周期函数--监听页面显示
  159. */
  160. onShow: function () {
  161. this.PushVipInfo();
  162. let user = util.getUser();
  163. this.setData({
  164. options: {
  165. ...this.data.options,
  166. stuId: user ? user.id : "",
  167. },
  168. });
  169. },
  170. /**
  171. * 生命周期函数--监听页面隐藏
  172. */
  173. onHide: function () {},
  174. /**
  175. * 页面相关事件处理函数--监听用户下拉动作
  176. */
  177. onPullDownRefresh: function () {},
  178. /**
  179. * 页面上拉触底事件的处理函数
  180. */
  181. onReachBottom: function () {},
  182. showShareMenu: function () {
  183. wx.showShareMenu();
  184. },
  185. hideShareMenu() {
  186. wx.hideShareMenu();
  187. },
  188. //查询会员信息
  189. PushVipInfo() {
  190. let _this = this;
  191. let id = util.getUserId();
  192. if (id) {
  193. app._post_form(
  194. "member/apiSelectMeberInfo",
  195. "application/json", {
  196. id
  197. },
  198. function (res) {
  199. if (res.code === 0) {
  200. _this.setData({
  201. member: res.member,
  202. });
  203. }
  204. }
  205. );
  206. }
  207. },
  208. /**
  209. * 用户点击右上角分享
  210. */
  211. onShareAppMessage() {
  212. this.addScore();
  213. return {
  214. title: "兼职详情",
  215. path: `/pages/home/index/partDetail/partDetail?id=${pageid}`,
  216. desc: "欢迎大家踊跃报名",
  217. };
  218. },
  219. //统计积分(每日小程序分享)
  220. addScore: function () {
  221. if (!util.getUserId()) {
  222. return;
  223. }
  224. let _this = this;
  225. wx.showLoading({
  226. title: "努力加载中...",
  227. });
  228. app._post_form(
  229. "scoreStu/share",
  230. "", {
  231. stuId: util.getUserId(),
  232. },
  233. function (res) {
  234. if (res.code === 0) {}
  235. }
  236. );
  237. },
  238. // 预览图片
  239. previewImage(e) {
  240. wx.previewImage({
  241. urls: e.currentTarget.dataset.images,
  242. current: e.currentTarget.dataset.images[e.currentTarget.dataset.index],
  243. });
  244. },
  245. // 判断是否开发huanjing
  246. env() {
  247. let that = this;
  248. app._post_form(
  249. "wgfillinfo/apiSelectwgfillinfo",
  250. "application/json",
  251. null,
  252. function (res) {
  253. if (res.code === 0) {
  254. that.setData({
  255. isDev: res.wgFillInfo.isDev,
  256. });
  257. }
  258. }
  259. );
  260. },
  261. submit() {
  262. let that = this;
  263. //报名满了
  264. if (this.data.detail.statusName != "预定中") {
  265. return;
  266. }
  267. if (util.UserLoginStatus()) {
  268. if (
  269. (this.data.detail.isNeedVip && this.data.member.memberState > 0) ||
  270. !this.data.detail.isNeedVip
  271. ) {
  272. // wx.showModal({
  273. // title: '提示',
  274. // content: '您确定要报名该兼职吗',
  275. // success (res) {
  276. // if (res.confirm) {
  277. // that.signUp();
  278. // }
  279. // }
  280. // })
  281. that.popup4.showPopup();
  282. that.setData({
  283. maskShow: true,
  284. });
  285. } else {
  286. if (that.data.isDev) {
  287. wx.showToast({
  288. title: "暂未开始报名,请关注进度!",
  289. icon: "none",
  290. duration: 2000,
  291. });
  292. return;
  293. }
  294. wx.showToast({
  295. title: "您还不是会员,报名请联系平台客服处理",
  296. icon: "none",
  297. duration: 2000,
  298. });
  299. // this.popup.showPopup();
  300. // this.setData({
  301. // maskShow: true,
  302. // });
  303. }
  304. }
  305. },
  306. showMore() {
  307. this.setData({
  308. isMore: !this.data.isMore,
  309. });
  310. },
  311. // 查看二维码
  312. seeCode() {
  313. if (!this.data.detail.workStuYN) {
  314. wx.showToast({
  315. title: "请报名后查看",
  316. icon: "error",
  317. duration: 2000,
  318. });
  319. return;
  320. }
  321. this.popup0.showPopup();
  322. this.setData({
  323. maskShow: true,
  324. });
  325. // let that = this
  326. // this.popup3.showPopup();
  327. // this.setData({
  328. // maskShow: true,
  329. // isDjs: true,
  330. // timer: setInterval(that.countDown, 1000)
  331. // })
  332. },
  333. //倒计时
  334. countDown() {
  335. var that = this;
  336. if (that.data.time <= 0) {
  337. this.setData({
  338. isDjs: false,
  339. time: 5,
  340. });
  341. clearInterval(that.data.timer);
  342. } else {
  343. --that.data.time;
  344. this.setData({
  345. isDjs: true,
  346. time: that.data.time,
  347. });
  348. }
  349. },
  350. // 我已知晓
  351. know() {
  352. this.popup3.hidePopup();
  353. this.loadData();
  354. if (this.data.isShowPop) {
  355. this.setData({
  356. isShowPop: false,
  357. isDjs: false,
  358. maskShow: false,
  359. });
  360. this.signUp();
  361. }
  362. // if (!this.data.isDjs) {}
  363. },
  364. // 查看地图
  365. goLocal() {
  366. let that = this;
  367. let [latitude, longitude] = [
  368. this.data.detail.coordinate.split(",")[0],
  369. this.data.detail.coordinate.split(",")[1],
  370. ];
  371. console.log(Number(latitude), Number(longitude));
  372. wx.openLocation({
  373. latitude: Number(longitude),
  374. longitude: Number(latitude),
  375. name: that.data.detail.title,
  376. address: that.data.detail.address,
  377. success: function () {
  378. console.log("success");
  379. },
  380. });
  381. },
  382. signUp() {
  383. let that = this;
  384. wx.showLoading({
  385. title: "提交中...",
  386. });
  387. app._post_form(
  388. "work/register",
  389. "", {
  390. wid: that.data.options.id,
  391. sid: that.data.options.stuId,
  392. },
  393. function (res) {
  394. if (res.code === 0) {
  395. wx.hideToast();
  396. wx.showToast({
  397. title: "报名成功",
  398. icon: "none",
  399. });
  400. if (that.data.isShowPop) {
  401. that.popup3.hidePopup();
  402. that.setData({
  403. isShowPop: false,
  404. isDjs: true,
  405. maskShow: true,
  406. timer: setInterval(that.countDown, 1000),
  407. })
  408. } else {
  409. that.setData({
  410. isShowPop: false,
  411. isDjs: false,
  412. maskShow: false,
  413. });
  414. }
  415. that.loadData();
  416. setTimeout(() => {
  417. that.popup0.showPopup();
  418. that.setData({
  419. maskShow: true,
  420. });
  421. // wx.redirectTo({
  422. // url: '/pages/my/myTimejob/myTimejob',
  423. // })
  424. }, 1000);
  425. } else if (res.code == 502) {
  426. setTimeout(() => {
  427. that.loadData()
  428. }, 500);
  429. } else if (res.msg == "请完善学籍认证后进行报名操作") {
  430. wx.hideToast();
  431. that.popup2.showPopup();
  432. }
  433. }
  434. );
  435. },
  436. // 会员必读
  437. ready() {
  438. let _this = this;
  439. app._post_form(
  440. "wgfillinfo/apiSelectwgfillinfo",
  441. "application/json",
  442. null,
  443. function (res) {
  444. if (res.code === 0) {
  445. // _this.setData({
  446. // vipMsg: res.wgFillInfo.vipMessage
  447. // })
  448. wxparse.wxParse(
  449. "vipMsg",
  450. "html",
  451. res.wgFillInfo.vipMessage,
  452. _this,
  453. 0
  454. );
  455. }
  456. }
  457. );
  458. },
  459. //取消事件
  460. _error(e) {
  461. this[e.currentTarget.dataset.name].hidePopup();
  462. this.setData({
  463. maskShow: false,
  464. isDjs: false,
  465. time: 5,
  466. });
  467. clearInterval(this.data.timer);
  468. },
  469. //确认事件
  470. _success(e) {
  471. let that = this;
  472. if (e.currentTarget.dataset.name == "popup0") {} else if (e.currentTarget.dataset.name == "popup4") {
  473. if (that.data.detail.isNeedVip && that.data.member.memberState > 0) {
  474. that.popup3.showPopup();
  475. that.setData({
  476. maskShow: true,
  477. isDjs: true,
  478. timer: setInterval(that.countDown, 1000),
  479. });
  480. console.log("会员");
  481. } else {
  482. // that.popup3.hidePopup();
  483. // that.setData({
  484. // isDjs: false,
  485. // maskShow: false,
  486. // time: 5
  487. // })
  488. that.signUp();
  489. console.log("非会员");
  490. }
  491. } else if (e.currentTarget.dataset.name == "popup2") {
  492. wx.navigateTo({
  493. url: "/pages/my/myStudy/myStudy",
  494. });
  495. } else {
  496. wx.navigateTo({
  497. url: e.currentTarget.dataset.name == "popup" ?
  498. "/pages/myMember/myMember" : "/pages/my/myData/myData",
  499. });
  500. }
  501. this.setData({
  502. maskShow: false,
  503. });
  504. this[e.currentTarget.dataset.name].hidePopup();
  505. },
  506. seeBigCode(e) {
  507. let arr = [this.data.detail.qrCodePicture];
  508. wx.previewImage({
  509. urls: arr, // 需要预览的图片http链接列表
  510. });
  511. },
  512. onUnload: function () {
  513. clearInterval(this.data.timer);
  514. },
  515. });